Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_HEN_SIM.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' MDC & to set SkyMaskCC 'on the fly'
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_HEN_SIM_Config.C
59  // ---------------------------------
60 
61  char cmd[128];
62  sprintf(cmd,"network* net = (network*)%p;",net);
63  gROOT->ProcessLine(cmd);
64  sprintf(cmd,"CWB::config* cfg = (CWB::config*)%p;",cfg);
65  gROOT->ProcessLine(cmd);
66  sprintf(cmd,"int xstart = %d;",(int)x->start());
67  gROOT->ProcessLine(cmd);
68  sprintf(cmd,"int xstop = %d;",(int)x->stop());
69  gROOT->ProcessLine(cmd);
70  int error=0;
71  cfg->configPlugin.Exec(NULL,&error);
72  if(error) {
73  cout << "Error executing macro : " << cfg->configPlugin.GetTitle() << endl;
74  cfg->configPlugin.Print();
75  gSystem->Exit(1);
76  }
77  IMPORT(CWB::mdc,MDC)
78  MDC.Print();
79 
80  // ---------------------------------
81  // get mdc data
82  // fill x array with MDC injections
83  // ---------------------------------
84 
85  MDC.Get(*x,ifo);
86 
87  // ---------------------------------
88  // set mdc list in the network class
89  // ---------------------------------
90 
91  if(ifo.CompareTo(net->ifoName[0])==0) {
92  net->mdcList.clear();
93  net->mdcType.clear();
94  net->mdcTime.clear();
95  net->mdcList=MDC.mdcList;
96  net->mdcType=MDC.mdcType;
97  net->mdcTime=MDC.mdcTime;
98  }
99 
100  // ---------------------------------
101  // write MDC log file
102  // ---------------------------------
103 
104  char logFile[512];
105  int runID = net->nRun;
106  int Tb=x->start()+cfg->segEdge;
107  int dT=x->size()/x->rate()-2*cfg->segEdge;
108  sprintf(logFile,"%s/log_%d_%d_%s_job%d.txt",cfg->output_dir,int(Tb),int(dT),cfg->data_label,runID);
109  cout << "Dump : " << logFile << endl;
110  if(ifo==cfg->ifo[0]) MDC.DumpLog(logFile);
111 
112  // ---------------------------------
113  // print MDC injections list
114  // ---------------------------------
115 
116  cout.precision(14);
117  for(int k=0;k<(int)net->mdcList.size();k++) cout << k << " mdcList " << MDC.mdcList[k] << endl;
118  for(int k=0;k<(int)net->mdcTime.size();k++) cout << k << " mdcTime " << MDC.mdcTime[k] << endl;
119  for(int k=0;k<(int)net->mdcType.size();k++) cout << k << " mdcType " << MDC.mdcType[k] << endl;
120  }
121 
122  return;
123 }
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
int error
Definition: cwb_compile.C:43
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 CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
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
double Tb
virtual void stop(double s)
Definition: wavearray.hh:139
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