Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CWB_Plugin_MDC_OTF.C
Go to the documentation of this file.
1 //!NOISE_MDC_SIMULATION
2 // Plugin to injected MDC 'on the fly'
3 
4 #define XIFO 4
5 
6 #pragma GCC system_header
7 
8 #include "cwb.hh"
9 #include "config.hh"
10 #include "network.hh"
11 #include "wavearray.hh"
12 #include "TString.h"
13 #include "TObjArray.h"
14 #include "TObjString.h"
15 #include "TRandom.h"
16 #include "TComplex.h"
17 #include "TMath.h"
18 #include "mdc.hh"
19 #include <vector>
20 
21 //#define DUMP_LOG // uncomment to enable dump log
22 
23 void
25 
26  if(type==CWB_PLUGIN_CONFIG) {
27  cfg->mdcPlugin=true; // disable read mdc from frames
28  }
29 
30  if(type==CWB_PLUGIN_MDC) {
31 
32  cout << "Execute CWB_Plugin_MDC_OTF.C : Inject On The Fly MDC ..." << endl;
33 
34  // ---------------------------------
35  // Declare mdc class
36  // On The Fly MDC Injections
37  // ---------------------------------
38 
39  CWB::mdc MDC(net);
41 
42  int gIFACTOR=-1; IMPORT(int,gIFACTOR)
43  int xstart = (int)x->start();
44  int xstop = (int)x->stop();
47  CWB_PLUGIN_EXPORT(xstart)
48  CWB_PLUGIN_EXPORT(xstop)
49  CWB_PLUGIN_EXPORT(gIFACTOR)
50 
51  // ---------------------------------
52  // read plugin config
53  // CWB_Plugin_MDC_OTF_Config.C
54  // ---------------------------------
55 
56 #ifndef _USE_ROOT6
57  char cmd[128];
58  // export gIFOID to the config plugin
59  int gIFOID=0; for(int n=0;n<cfg->nIFO;n++) if(ifo==net->getifo(n)->Name) {gIFOID=n;break;}
60  sprintf(cmd,"int gIFOID = %d;",gIFOID);
61  gROOT->ProcessLine(cmd);
62  // export network object to the config plugin
63  sprintf(cmd,"network* net = (network*)%p;",net);
64  gROOT->ProcessLine(cmd);
65  // export config object to the config plugin
66  sprintf(cmd,"CWB::config* cfg = (CWB::config*)%p;",cfg);
67  gROOT->ProcessLine(cmd);
68  // export job start time to the config plugin
69  sprintf(cmd,"int xstart = %d;",(int)x->start());
70  gROOT->ProcessLine(cmd);
71  // export job stop time to the config plugin
72  sprintf(cmd,"int xstop = %d;",(int)x->stop());
73  gROOT->ProcessLine(cmd);
74 #endif
75  int error=0;
76  // execute config plugin
77  cfg->configPlugin.Exec(NULL,&error);
78  if(error) {
79  cout << "Error executing macro : " << cfg->configPlugin.GetTitle() << endl;
80  cfg->configPlugin.Print();
81  gSystem->Exit(1);
82  }
83 #ifndef _USE_ROOT6
84  // import mdc object initialized in the config plugin
85  IMPORT(CWB::mdc,MDC)
86 #endif
87  // print list waveforms declared in the config plugin
88  MDC.Print();
89 
90  // ---------------------------------
91  // get mdc data
92  // fill x array with MDC injections
93  // ---------------------------------
94 
95  MDC.Get(*x,ifo);
96 
97  // ---------------------------------
98  // set mdc list in the network class
99  // ---------------------------------
100 
101  if(ifo.CompareTo(net->ifoName[0])==0) {
102  net->mdcList.clear();
103  net->mdcType.clear();
104  net->mdcTime.clear();
105  net->mdcList=MDC.mdcList;
106  net->mdcType=MDC.mdcType;
107  net->mdcTime=MDC.mdcTime;
108  }
109 
110  // ---------------------------------
111  // write MDC log file
112  // if enabled (uncomment #define DUMP_LOG) then the txt log file is created under the output dir
113  // the cwb_merge collect all log job files on a single file under the merge directory
114  // ---------------------------------
115 
116 #ifdef DUMP_LOG
117  char logFile[512];
118  int runID = net->nRun;
119  int Tb=x->start()+cfg->segEdge;
120  int dT=x->size()/x->rate()-2*cfg->segEdge;
121  sprintf(logFile,"%s/log_%d_%d_%s_job%d.txt",cfg->output_dir,int(Tb),int(dT),cfg->data_label,runID);
122  cout << "Dump : " << logFile << endl;
123  if(ifo==cfg->ifo[0]) MDC.DumpLog(logFile);
124 #endif
125 
126  // ---------------------------------
127  // print MDC injections list
128  // ---------------------------------
129 
130  cout.precision(14);
131  if(ifo.CompareTo(net->ifoName[0])==0) {
132  for(int k=0;k<(int)net->mdcList.size();k++) cout << k << " mdcList " << MDC.mdcList[k] << endl;
133  for(int k=0;k<(int)net->mdcTime.size();k++) cout << k << " mdcTime " << MDC.mdcTime[k] << endl;
134  for(int k=0;k<(int)net->mdcType.size();k++) cout << k << " mdcType " << MDC.mdcType[k] << endl;
135  }
136  }
137 
138  return;
139 }
std::vector< char * > ifoName
Definition: network.hh:591
detector * getifo(size_t n)
param: detector index
Definition: network.hh:418
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
virtual size_t size() const
Definition: wavearray.hh:127
TMacro configPlugin
Definition: config.hh:344
char cmd[1024]
TString Get(wavearray< double > &x, TString ifo)
Definition: mdc.cc:1502
bool mdcPlugin
Definition: config.hh:347
std::vector< std::string > mdcList
Definition: mdc.hh:357
virtual void rate(double r)
Definition: wavearray.hh:123
char logFile[1024]
Definition: cwb_merge_log.C:13
int n
Definition: cwb_net.C:10
TString("c")
std::vector< std::string > mdcType
Definition: mdc.hh:358
size_t nRun
Definition: network.hh:554
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
std::vector< std::string > mdcType
Definition: network.hh:595
CWB::mdc * MDC
virtual void start(double s)
Definition: wavearray.hh:119
std::vector< double > mdcTime
Definition: network.hh:596
void Print(int level=0)
Definition: mdc.cc:2707
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
double segEdge
Definition: config.hh:146
jfile
Definition: cwb_job_obj.C:25
#define CWB_PLUGIN_EXPORT(VAR)
Definition: CWB_Plugin.h:18
Definition: mdc.hh:216
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:51
i() int(T_cor *100))
char output_dir[1024]
Definition: config.hh:300
std::vector< std::string > mdcList
Definition: network.hh:594
int gIFACTOR
int k
double Tb
char Name[16]
Definition: detector.hh:309
virtual void stop(double s)
Definition: wavearray.hh:121
char ifo[NIFO_MAX][8]
Definition: config.hh:106
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
int nIFO
Definition: config.hh:102
void DumpLog(TString fName, TString label="", bool append=false)
Definition: mdc.cc:5039
double dT
Definition: testWDM_5.C:12
std::vector< double > mdcTime
Definition: mdc.hh:360
char data_label[1024]
Definition: config.hh:314