Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_TestClassMDC.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' Burst MDC
41 
42  cout << endl;
43  cout << "-----> plugins/CWB_Plugin_TestClassMDC.C" << endl;
44  cout << "ifo " << ifo.Data() << endl;
45  cout << "type " << type << endl;
46  cout << endl;
47 
48 
49  if(type==CWB_PLUGIN_CONFIG) {
50  cfg->dataPlugin=true; // disable read data from frames
51  cfg->mdcPlugin=true; // disable read mdc from frames
52  }
53 
54  if(type==CWB_PLUGIN_DATA) {
55 
57 
58  int seed;
59  if(ifo.CompareTo("L1")==0) seed=1000;
60  if(ifo.CompareTo("H1")==0) seed=2000;
61  if(ifo.CompareTo("V1")==0) seed=3000;
62  if(ifo.CompareTo("J1")==0) seed=4000;
63  if(ifo.CompareTo("A2")==0) seed=5000;
64  if(ifo.CompareTo("Y2")==0) seed=6000;
65  if(ifo.CompareTo("Y3")==0) seed=7000;
66 
67  TString fName;
68  if(ifo.CompareTo("L1")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
69  if(ifo.CompareTo("H1")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
70  if(ifo.CompareTo("V1")==0) fName="plugins/strains/advVIRGO_sensitivity_12May09_8khz_one_side.txt";
71  if(ifo.CompareTo("J1")==0) fName="plugins/strains/LCGT_sensitivity_8khz_one_side.txt";
72  if(ifo.CompareTo("A2")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
73  if(ifo.CompareTo("Y2")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
74  if(ifo.CompareTo("Y3")==0) fName="plugins/strains/advLIGO_NSNS_Opt_8khz_one_side.txt";
75 
76  int size=x->size();
77  double start=x->start();
78  TB.getSimNoise(*x, fName, seed, net->nRun);
79  x->resize(size);
80  x->start(start);
81 /*
82  // dump spectrum
83  char file[1024];
84  sprintf(file,"%s/sensitivity_%s_%d_%s_job%lu.txt",cfg->dump_dir,ifo.Data(),int(x->start()),cfg->data_label,net->nRun);
85  cout << endl << "Dump Sensitivity : " << file << endl << endl;
86  TB.makeSpectrum(file, *x, 8, cfg->segEdge);
87  if(TString(ifo).CompareTo("V1")==0) gSystem->Exit(0);
88 */
89  }
90 
91  if(type==CWB_PLUGIN_MDC) {
92 
93  char cmd[128];
94  sprintf(cmd,"network* net = (network*)%p;",net);
95  gROOT->ProcessLine(cmd);
96 
97  CWB::mdc MDC(net);
98 
99  // ---------------------------------
100  // read plugin config
101  // ---------------------------------
102 
103  cfg->configPlugin.Exec();
104 
105  // ---------------------------------
106  // set list of mdc waveforms
107  // ---------------------------------
108 
109  IMPORT(CWB::mdc,MDC)
110  MDC.Print();
111 
112  // ---------------------------------
113  // get mdc data
114  // ---------------------------------
115 
116  MDC.Get(*x,ifo);
117 
118  // ---------------------------------
119  // set mdc list in the network class
120  // ---------------------------------
121 
122  if(ifo.CompareTo(net->ifoName[0])==0) {
123  net->mdcList.clear();
124  net->mdcType.clear();
125  net->mdcTime.clear();
126  net->mdcList=MDC.mdcList;
127  net->mdcType=MDC.mdcType;
128  net->mdcTime=MDC.mdcTime;
129  }
130 
131  cout.precision(14);
132  for(int k=0;k<(int)net->mdcList.size();k++) cout << k << " mdcList " << MDC.mdcList[k] << endl;
133  for(int k=0;k<(int)net->mdcTime.size();k++) cout << k << " mdcTime " << MDC.mdcTime[k] << endl;
134  for(int k=0;k<(int)net->mdcType.size();k++) cout << k << " mdcType " << MDC.mdcType[k] << endl;
135  }
136 
137  if(type==CWB_PLUGIN_WHITE) {
138 /*
139  CWB::Toolbox TB;
140  int level=x->getLevel();
141  x->Inverse(-1);
142  // dump spectrum
143  char file[1024];
144  sprintf(file,"%s/sensitivity_white_%s_%d_%s_job%lu.txt",cfg->dump_dir,ifo.Data(),int(x->start()),cfg->data_label,net->nRun);
145  cout << endl << "Dump Sensitivity : " << file << endl << endl;
146  TB.makeSpectrum(file, *x, 8, cfg->segEdge);
147  if(TString(ifo).CompareTo("V1")==0) gSystem->Exit(0);
148  x->Forward(level);
149 */
150  }
151 
152  return;
153 }
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
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
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.
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
#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)
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
std::vector< double > mdcTime
Definition: mdc.hh:392
char fName[256]