Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_InjectCBC.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 #define XIFO 4
20 
21 #pragma GCC system_header
22 
23 #include "cwb.hh"
24 #include "config.hh"
25 #include "network.hh"
26 #include "wavearray.hh"
27 #include "TString.h"
28 #include "TObjArray.h"
29 #include "TObjString.h"
30 #include "TRandom.h"
31 #include "TComplex.h"
32 #include "TMath.h"
33 #include "mdc.hh"
34 #include <vector>
35 
36 
37 void
39 //!NOISE_MDC_SIMULATION
40 // Plugin to injected 'on the fly' CBC MDC
41 
42 
43  if(type==CWB_PLUGIN_CONFIG) {
44  cfg->mdcPlugin=true; // disable read mdc from frames
45  }
46 
47  if(type==CWB_PLUGIN_MDC) {
48 
49  // ---------------------------------
50  // Declare mdc class
51  // On The Fly MDC Injections
52  // ---------------------------------
53 
54  CWB::mdc MDC(net);
55 
56  // ---------------------------------
57  // read plugin config
58  // CWB_Plugin_InjectCBC_Config.C
59  // ---------------------------------
60 
61  char cmd[128]; sprintf(cmd,"network* net = (network*)%p;",net);
62  gROOT->ProcessLine(cmd);
63  sprintf(cmd,"CWB::config* cfg = (CWB::config*)%p;",cfg);
64  gROOT->ProcessLine(cmd);
65  cfg->configPlugin.Exec();
66  IMPORT(CWB::mdc,MDC)
67  MDC.Print();
68 
69  // ---------------------------------
70  // get mdc data
71  // fill x array with MDC injections
72  // ---------------------------------
73 
74  MDC.Get(*x,ifo);
75 
76  // ---------------------------------
77  // set mdc list in the network class
78  // ---------------------------------
79 
80  if(ifo.CompareTo(net->ifoName[0])==0) {
81  net->mdcList.clear();
82  net->mdcType.clear();
83  net->mdcTime.clear();
84  net->mdcList=MDC.mdcList;
85  net->mdcType=MDC.mdcType;
86  net->mdcTime=MDC.mdcTime;
87  }
88 
89  // ---------------------------------
90  // write MDC log file
91  // ---------------------------------
92 
93  char logFile[512];
94  int runID = net->nRun;
95  int Tb=x->start()+cfg->segEdge;
96  int dT=x->size()/x->rate()-2*cfg->segEdge;
97  sprintf(logFile,"%s/log_%d_%d_%s_job%d.txt",cfg->output_dir,int(Tb),int(dT),cfg->data_label,runID);
98  cout << "Dump : " << logFile << endl;
99  if(ifo==cfg->ifo[0]) MDC.DumpLog(logFile);
100 
101  // ---------------------------------
102  // print MDC injections list
103  // ---------------------------------
104 
105  cout.precision(14);
106  for(int k=0;k<(int)net->mdcList.size();k++) cout << k << " mdcList " << MDC.mdcList[k] << endl;
107  for(int k=0;k<(int)net->mdcTime.size();k++) cout << k << " mdcTime " << MDC.mdcTime[k] << endl;
108  for(int k=0;k<(int)net->mdcType.size();k++) cout << k << " mdcType " << MDC.mdcType[k] << endl;
109  }
110 
111  return;
112 }
std::vector< char * > ifoName
Definition: network.hh:609
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
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
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
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
double Tb
char ifo[NIFO_MAX][8]
Definition: config.hh:124
char cmd[1024]
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
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