Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CWB_Plugin_SplittedMDC.C
Go to the documentation of this file.
1 #define XIFO 4
2 
3 #pragma GCC system_header
4 
5 #include "cwb.hh"
6 #include "config.hh"
7 #include "network.hh"
8 #include "wavearray.hh"
9 #include "TString.h"
10 #include "TObjArray.h"
11 #include "TObjString.h"
12 #include "TRandom.h"
13 #include "TComplex.h"
14 #include "TMath.h"
15 #include "mdc.hh"
16 #include <vector>
17 
18 
19 void
21 //!NOISE_MDC_SIMULATION
22 // Plugin to generate simulated gaussian noise and injected 'on the fly' splitted MDC
23 // The standard procedure inject signals only within the run
24 // This plugin allows to test injected signals splitted into two consecutive runs
25 // if simulation==0 the MDC are multiplied by factors[0] and added to the noise
26 // WARNING!!! this plugin can not be used in snr mode (simulation=2)
27 // because the events are splitted into two subevents
28 // and the subevents are differently normalized by the snr mode procedure
29 
30  cout << endl;
31  cout << "-----> CWB_Plugin_SplittedMDC.C" << endl;
32  cout << "ifo " << ifo.Data() << endl;
33  cout << "type " << type << endl;
34  cout << endl;
35 
36  if(type==CWB_PLUGIN_CONFIG) {
37  cfg->dataPlugin=true; // disable read data from frames
38  cfg->mdcPlugin=true; // disable read mdc from frames
39  }
40 
41  if(type==CWB_PLUGIN_DATA) {
42 
44 
45  int seed;
46  if(ifo.CompareTo("L1")==0) seed=1000;
47  if(ifo.CompareTo("H1")==0) seed=2000;
48  if(ifo.CompareTo("V1")==0) seed=3000;
49  if(ifo.CompareTo("J1")==0) seed=4000;
50  if(ifo.CompareTo("A2")==0) seed=5000;
51  if(ifo.CompareTo("Y2")==0) seed=6000;
52  if(ifo.CompareTo("Y3")==0) seed=7000;
53 
54  TString fName;
55  if(ifo.CompareTo("L1")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
56  if(ifo.CompareTo("H1")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
57  if(ifo.CompareTo("V1")==0) fName="plugins/strains/advVIRGO_sensitivity_12May09_8khz_one_side.txt";
58  if(ifo.CompareTo("J1")==0) fName="plugins/strains/LCGT_sensitivity_8khz_one_side.txt";
59  if(ifo.CompareTo("A2")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
60  if(ifo.CompareTo("Y2")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
61  if(ifo.CompareTo("Y3")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
62 
63  int size=x->size();
64  double start=x->start();
65  TB.getSimNoise(*x, fName, seed, net->nRun);
66  x->resize(size);
67  x->start(start);
68  }
69 
70  // if simulation==0 the MDC are multiplied by factors[0] and added to the noise
71  if((type==CWB_PLUGIN_MDC)||((cfg->simulation==0)&&(type==CWB_PLUGIN_DATA))) {
72 
73  if(cfg->simulation==2) {
74  cout << "CWB_Plugin_SplittedMDC.C : Error - "
75  << "Injections on the Edge are not allowed in snr mode (simulation=2)" << endl;
76  gSystem->Exit(1);
77  }
78 
79  char cmd[128];
80  cout.precision(14);
81  sprintf(cmd,"network* net = (network*)%p;",net);
82  gROOT->ProcessLine(cmd);
83  sprintf(cmd,"CWB::config* cfg = (CWB::config*)%p;",cfg);
84  gROOT->ProcessLine(cmd);
85 
86  CWB::mdc MDC(net);
87 
88  // ---------------------------------
89  // read plugin config
90  // ---------------------------------
91 
92  cfg->configPlugin.Exec();
93 
94  // ---------------------------------
95  // set list of mdc waveforms
96  // ---------------------------------
97 
98  IMPORT(CWB::mdc,MDC)
99  MDC.Print();
100 
101  // ---------------------------------
102  // clear mdc list in the network class
103  // ---------------------------------
104 
105  if(cfg->simulation) {
106  if(ifo.CompareTo(net->ifoName[0])==0) {
107  net->mdcList.clear();
108  net->mdcType.clear();
109  net->mdcTime.clear();
110  }
111  }
112 
113  // --------------------------------------------------------------------------------------
114  // get mdc data
115  // --------------------------------------------------------------------------------------
116  //
117  // xxxx segEdge xxxx
118  //
119  // <--------segLen=2*tshift------->
120  //
121  // xxxx---------------||---------------xxxx left shifted
122  // xxxx---------------||---------------xxxx current segment
123  // xxxx---------------||---------------xxxx right shifted
124  //
125 
126  wavearray<double> y(x->size());
127  y.rate(x->rate());
128  y.start(x->start());
129  double tshift = (x->size()/x->rate()-2*cfg->segEdge)/2.;
130  int nedge = int(cfg->segEdge*x->rate());
131 
132  // get buffer half left shifted
133  y.start(x->start()-tshift);
134  MDC.Get(y,ifo);
135 
136  if(cfg->simulation==0) {
137  for(int i=0;i<x->size()/2;i++) x->data[i]+=cfg->factors[0]*y[i+x->size()/2-nedge];
138  } else {
139  for(int i=0;i<x->size()/2;i++) x->data[i]=y[i+x->size()/2-nedge];
140  if(ifo.CompareTo(net->ifoName[0])==0) {
141  for(int k=0;k<(int)MDC.mdcList.size();k++) {
142  net->mdcList.push_back(MDC.mdcList[k]);
143  net->mdcType.push_back(MDC.mdcType[k]);
144  net->mdcTime.push_back(MDC.mdcTime[k]);
145  }
146  }
147  }
148 
149  // get buffer half right shifted
150  y.start(x->start()+tshift);
151  MDC.Get(y,ifo);
152 
153  if(cfg->simulation==0) {
154  for(int i=0;i<x->size()/2;i++) x->data[i+x->size()/2]+=cfg->factors[0]*y[i+nedge];
155  } else {
156  for(int i=0;i<x->size()/2;i++) x->data[i+x->size()/2]=y[i+nedge];
157  if(ifo.CompareTo(net->ifoName[0])==0) {
158  for(int k=0;k<(int)MDC.mdcList.size();k++) {
159  // if event is not duplicated it is added to the network mdc list
160  bool duplicated=false;
161  for(int m=0;m<(int)net->mdcList.size();m++) if(MDC.mdcTime[k]==net->mdcTime[m]) duplicated=true;
162  if(!duplicated) {
163  net->mdcList.push_back(MDC.mdcList[k]);
164  net->mdcType.push_back(MDC.mdcType[k]);
165  net->mdcTime.push_back(MDC.mdcTime[k]);
166  }
167  }
168  }
169  }
170 
171  if(cfg->simulation) {
172  for(int k=0;k<(int)net->mdcList.size();k++) {
173  cout << k << " mdcList " << net->mdcList[k] << endl;
174  cout << k << " mdcTime " << net->mdcTime[k] << endl;
175  cout << k << " mdcType " << net->mdcType[k] << endl;
176  }
177  }
178  }
179 
180  return;
181 }
std::vector< char * > ifoName
Definition: network.hh:591
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
virtual void resize(unsigned int)
Definition: wseries.cc:883
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
bool dataPlugin
Definition: config.hh:346
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
Long_t size
int m
Definition: cwb_net.C:10
virtual void start(double s)
Definition: wavearray.hh:119
i drho i
std::vector< double > mdcTime
Definition: network.hh:596
CWB::Toolbox TB
Definition: ComputeSNR.C:5
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
static void getSimNoise(wavearray< double > &u, TString fName, int seed, int run)
Definition: Toolbox.cc:4809
Definition: mdc.hh:216
int simulation
Definition: config.hh:181
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:51
i() int(T_cor *100))
std::vector< std::string > mdcList
Definition: network.hh:594
int k
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
DataType_t * data
Definition: wavearray.hh:301
double factors[FACTORS_MAX]
Definition: config.hh:184
std::vector< double > mdcTime
Definition: mdc.hh:360
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.