Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_SplittedMDC.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 generate simulated gaussian noise and injected 'on the fly' splitted MDC
41 // The standard procedure inject signals only within the run
42 // This plugin allows to test injected signals splitted into two consecutive runs
43 // if simulation==0 the MDC are multiplied by factors[0] and added to the noise
44 // WARNING!!! this plugin can not be used in snr mode (simulation=2)
45 // because the events are splitted into two subevents
46 // and the subevents are differently normalized by the snr mode procedure
47 
48  cout << endl;
49  cout << "-----> CWB_Plugin_SplittedMDC.C" << endl;
50  cout << "ifo " << ifo.Data() << endl;
51  cout << "type " << type << endl;
52  cout << endl;
53 
54  if(type==CWB_PLUGIN_CONFIG) {
55  cfg->dataPlugin=true; // disable read data from frames
56  cfg->mdcPlugin=true; // disable read mdc from frames
57  }
58 
59  if(type==CWB_PLUGIN_DATA) {
60 
62 
63  int seed;
64  if(ifo.CompareTo("L1")==0) seed=1000;
65  if(ifo.CompareTo("H1")==0) seed=2000;
66  if(ifo.CompareTo("V1")==0) seed=3000;
67  if(ifo.CompareTo("J1")==0) seed=4000;
68  if(ifo.CompareTo("A2")==0) seed=5000;
69  if(ifo.CompareTo("Y2")==0) seed=6000;
70  if(ifo.CompareTo("Y3")==0) seed=7000;
71 
72  TString fName;
73  if(ifo.CompareTo("L1")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
74  if(ifo.CompareTo("H1")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
75  if(ifo.CompareTo("V1")==0) fName="plugins/strains/advVIRGO_sensitivity_12May09_8khz_one_side.txt";
76  if(ifo.CompareTo("J1")==0) fName="plugins/strains/LCGT_sensitivity_8khz_one_side.txt";
77  if(ifo.CompareTo("A2")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
78  if(ifo.CompareTo("Y2")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
79  if(ifo.CompareTo("Y3")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
80 
81  int size=x->size();
82  double start=x->start();
83  TB.getSimNoise(*x, fName, seed, net->nRun);
84  x->resize(size);
85  x->start(start);
86  }
87 
88  // if simulation==0 the MDC are multiplied by factors[0] and added to the noise
89  if((type==CWB_PLUGIN_MDC)||((cfg->simulation==0)&&(type==CWB_PLUGIN_DATA))) {
90 
91  if(cfg->simulation==2) {
92  cout << "CWB_Plugin_SplittedMDC.C : Error - "
93  << "Injections on the Edge are not allowed in snr mode (simulation=2)" << endl;
94  gSystem->Exit(1);
95  }
96 
97  char cmd[128];
98  cout.precision(14);
99  sprintf(cmd,"network* net = (network*)%p;",net);
100  gROOT->ProcessLine(cmd);
101  sprintf(cmd,"CWB::config* cfg = (CWB::config*)%p;",cfg);
102  gROOT->ProcessLine(cmd);
103 
104  CWB::mdc MDC(net);
105 
106  // ---------------------------------
107  // read plugin config
108  // ---------------------------------
109 
110  cfg->configPlugin.Exec();
111 
112  // ---------------------------------
113  // set list of mdc waveforms
114  // ---------------------------------
115 
116  IMPORT(CWB::mdc,MDC)
117  MDC.Print();
118 
119  // ---------------------------------
120  // clear mdc list in the network class
121  // ---------------------------------
122 
123  if(cfg->simulation) {
124  if(ifo.CompareTo(net->ifoName[0])==0) {
125  net->mdcList.clear();
126  net->mdcType.clear();
127  net->mdcTime.clear();
128  }
129  }
130 
131  // --------------------------------------------------------------------------------------
132  // get mdc data
133  // --------------------------------------------------------------------------------------
134  //
135  // xxxx segEdge xxxx
136  //
137  // <--------segLen=2*tshift------->
138  //
139  // xxxx---------------||---------------xxxx left shifted
140  // xxxx---------------||---------------xxxx current segment
141  // xxxx---------------||---------------xxxx right shifted
142  //
143 
144  wavearray<double> y(x->size());
145  y.rate(x->rate());
146  y.start(x->start());
147  double tshift = (x->size()/x->rate()-2*cfg->segEdge)/2.;
148  int nedge = int(cfg->segEdge*x->rate());
149 
150  // get buffer half left shifted
151  y.start(x->start()-tshift);
152  MDC.Get(y,ifo);
153 
154  if(cfg->simulation==0) {
155  for(int i=0;i<x->size()/2;i++) x->data[i]+=cfg->factors[0]*y[i+x->size()/2-nedge];
156  } else {
157  for(int i=0;i<x->size()/2;i++) x->data[i]=y[i+x->size()/2-nedge];
158  if(ifo.CompareTo(net->ifoName[0])==0) {
159  for(int k=0;k<(int)MDC.mdcList.size();k++) {
160  net->mdcList.push_back(MDC.mdcList[k]);
161  net->mdcType.push_back(MDC.mdcType[k]);
162  net->mdcTime.push_back(MDC.mdcTime[k]);
163  }
164  }
165  }
166 
167  // get buffer half right shifted
168  y.start(x->start()+tshift);
169  MDC.Get(y,ifo);
170 
171  if(cfg->simulation==0) {
172  for(int i=0;i<x->size()/2;i++) x->data[i+x->size()/2]+=cfg->factors[0]*y[i+nedge];
173  } else {
174  for(int i=0;i<x->size()/2;i++) x->data[i+x->size()/2]=y[i+nedge];
175  if(ifo.CompareTo(net->ifoName[0])==0) {
176  for(int k=0;k<(int)MDC.mdcList.size();k++) {
177  // if event is not duplicated it is added to the network mdc list
178  bool duplicated=false;
179  for(int m=0;m<(int)net->mdcList.size();m++) if(MDC.mdcTime[k]==net->mdcTime[m]) duplicated=true;
180  if(!duplicated) {
181  net->mdcList.push_back(MDC.mdcList[k]);
182  net->mdcType.push_back(MDC.mdcType[k]);
183  net->mdcTime.push_back(MDC.mdcTime[k]);
184  }
185  }
186  }
187  }
188 
189  if(cfg->simulation) {
190  for(int k=0;k<(int)net->mdcList.size();k++) {
191  cout << k << " mdcList " << net->mdcList[k] << endl;
192  cout << k << " mdcTime " << net->mdcTime[k] << endl;
193  cout << k << " mdcType " << net->mdcType[k] << endl;
194  }
195  }
196  }
197 
198  return;
199 }
std::vector< char * > ifoName
Definition: network.hh:609
CWB::config * cfg
virtual void resize(unsigned int)
Definition: wseries.cc:901
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
bool dataPlugin
Definition: config.hh:364
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
CWB::Toolbox TB
std::vector< std::string > mdcType
Definition: network.hh:613
CWB::mdc * MDC
Long_t size
int m
Definition: cwb_net.C:28
virtual void start(double s)
Definition: wavearray.hh:137
i drho i
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
static void getSimNoise(wavearray< double > &u, TString fName, int seed, int run)
Definition: Toolbox.cc:5593
Definition: mdc.hh:248
int simulation
Definition: config.hh:199
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:69
i() int(T_cor *100))
std::vector< std::string > mdcList
Definition: network.hh:612
int k
char cmd[1024]
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
DataType_t * data
Definition: wavearray.hh:319
double factors[FACTORS_MAX]
Definition: config.hh:202
std::vector< double > mdcTime
Definition: mdc.hh:392
char fName[256]
wavearray< double > y
Definition: Test10.C:31
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.