Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_MDC_OTF.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 //!NOISE_MDC_SIMULATION
20 // Plugin to injected MDC 'on the fly'
21 
22 #define XIFO 4
23 
24 #pragma GCC system_header
25 
26 #include "cwb.hh"
27 #include "config.hh"
28 #include "network.hh"
29 #include "wavearray.hh"
30 #include "TString.h"
31 #include "TObjArray.h"
32 #include "TObjString.h"
33 #include "TRandom.h"
34 #include "TComplex.h"
35 #include "TMath.h"
36 #include "mdc.hh"
37 #include <vector>
38 
39 //#define DUMP_LOG // uncomment to enable dump log
40 
41 void
43 
44  if(type==CWB_PLUGIN_CONFIG) {
45  cfg->mdcPlugin=true; // disable read mdc from frames
46  }
47 
48  if(type==CWB_PLUGIN_MDC) {
49 
50  cout << "Execute CWB_Plugin_MDC_OTF.C : Inject On The Fly MDC ..." << endl;
51 
52  // ---------------------------------
53  // Declare mdc class
54  // On The Fly MDC Injections
55  // ---------------------------------
56 
57  CWB::mdc MDC(net);
59 
60  // export global variables to the config plugin
61  int gIFACTOR=-1; IMPORT(int,gIFACTOR)
62  int xstart = (int)x->start();
63  int xstop = (int)x->stop();
66  CWB_PLUGIN_EXPORT(xstart)
67  CWB_PLUGIN_EXPORT(xstop)
68  CWB_PLUGIN_EXPORT(gIFACTOR)
69  int gIFOID=0; for(int n=0;n<cfg->nIFO;n++) if(ifo==net->getifo(n)->Name) {gIFOID=n;break;}
70  CWB_PLUGIN_EXPORT(gIFOID)
71 
72  // ---------------------------------
73  // read plugin config
74  // CWB_Plugin_MDC_OTF_Config.C
75  // ---------------------------------
76 
77  int error=0;
78  // execute config plugin
79  cfg->configPlugin.Exec(NULL,&error);
80  if(error) {
81  cout << "Error executing macro : " << cfg->configPlugin.GetTitle() << endl;
82  cfg->configPlugin.Print();
83  gSystem->Exit(1);
84  }
85  // print list waveforms declared in the config plugin
86  MDC.Print();
87 
88  // ---------------------------------
89  // get mdc data
90  // fill x array with MDC injections
91  // ---------------------------------
92 
93  MDC.Get(*x,ifo);
94 
95  // ---------------------------------
96  // set mdc list in the network class
97  // ---------------------------------
98 
99  if(ifo.CompareTo(net->ifoName[0])==0) {
100  net->mdcList.clear();
101  net->mdcType.clear();
102  net->mdcTime.clear();
103  net->mdcList=MDC.mdcList;
104  net->mdcType=MDC.mdcType;
105  net->mdcTime=MDC.mdcTime;
106  }
107 
108  // ---------------------------------
109  // write MDC log file
110  // if enabled (uncomment #define DUMP_LOG) then the txt log file is created under the output dir
111  // the cwb_merge collect all log job files on a single file under the merge directory
112  // ---------------------------------
113 
114 #ifdef DUMP_LOG
115  char logFile[512];
116  int runID = net->nRun;
117  int Tb=x->start()+cfg->segEdge;
118  int dT=x->size()/x->rate()-2*cfg->segEdge;
119  sprintf(logFile,"%s/log_%d_%d_%s_job%d.txt",cfg->output_dir,int(Tb),int(dT),cfg->data_label,runID);
120  cout << "Dump : " << logFile << endl;
121  if(ifo==cfg->ifo[0]) MDC.DumpLog(logFile);
122 #endif
123 
124  // ---------------------------------
125  // print MDC injections list
126  // ---------------------------------
127 
128  cout.precision(14);
129  if(ifo.CompareTo(net->ifoName[0])==0) {
130  for(int k=0;k<(int)net->mdcList.size();k++) cout << k << " mdcList " << MDC.mdcList[k] << endl;
131  for(int k=0;k<(int)net->mdcTime.size();k++) cout << k << " mdcTime " << MDC.mdcTime[k] << endl;
132  for(int k=0;k<(int)net->mdcType.size();k++) cout << k << " mdcType " << MDC.mdcType[k] << endl;
133  }
134  }
135 
136  return;
137 }
std::vector< char * > ifoName
Definition: network.hh:609
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
CWB::config * cfg
TMacro configPlugin
Definition: config.hh:362
TString Get(wavearray< double > &x, TString ifo)
Definition: mdc.cc:1529
bool mdcPlugin
Definition: config.hh:365
std::vector< std::string > mdcList
Definition: mdc.hh:389
virtual void rate(double r)
Definition: wavearray.hh:141
char logFile[1024]
Definition: cwb_merge_log.C:31
int error
Definition: cwb_compile.C:43
int n
Definition: cwb_net.C:28
TString("c")
std::vector< std::string > mdcType
Definition: mdc.hh:390
size_t nRun
Definition: network.hh:572
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<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ 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:613
CWB::mdc * MDC
virtual void start(double s)
Definition: wavearray.hh:137
std::vector< double > mdcTime
Definition: network.hh:614
void Print(int level=0)
Definition: mdc.cc:2736
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
double segEdge
Definition: config.hh:164
virtual size_t size() const
Definition: wavearray.hh:145
jfile
Definition: cwb_job_obj.C:43
#define CWB_PLUGIN_EXPORT(VAR)
Definition: CWB_Plugin.h:18
Definition: mdc.hh:248
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:69
i() int(T_cor *100))
char output_dir[1024]
Definition: config.hh:318
std::vector< std::string > mdcList
Definition: network.hh:612
int k
int * xstart
double Tb
char Name[16]
Definition: detector.hh:327
virtual void stop(double s)
Definition: wavearray.hh:139
char ifo[NIFO_MAX][8]
Definition: config.hh:124
int gIFACTOR
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:120
void DumpLog(TString fName, TString label="", bool append=false)
Definition: mdc.cc:5068
double dT
Definition: testWDM_5.C:12
std::vector< double > mdcTime
Definition: mdc.hh:392
char data_label[1024]
Definition: config.hh:332