Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CWB_Plugin_SNR.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 "watplot.hh"
17 #include <vector>
18 
19 void
21 //!NOISE_MDC_SIMULATION
22 // Plugin used in simulation mode to compute and save the mdc SNR (terminate after the read noise/mdc stage)
23 
24  cout << endl;
25  cout << "-----> CWB_Plugin_SNR.C" << endl;
26  cout << "ifo " << ifo.Data() << endl;
27  cout << "type " << type << endl;
28  cout << endl;
29 
30  // set sim in simulation mode = 2
31  if(type==CWB_PLUGIN_CONFIG) {
32  cfg->simulation = 2;
33  cfg->nfactor = 1;
34  cfg->factors[0] = 1;
35  }
36 
37  if(type==CWB_PLUGIN_OREADDATA) {
38 
39  if(cfg->simulation!=2) {
40  cout << "CWB_Plugin_SNR.C - Error : this pluging is implemented only in simulation mode = 2" << endl;
41  gSystem->Exit(1);
42  }
43 
44  // create output root file to store snr infos
45  char snrFile[1024];
46  sprintf(snrFile,"%s/snr_%s_%d.root",cfg->output_dir,cfg->data_label,NET->nRun);
47  TFile* froot = new TFile(snrFile, "RECREATE");
48  if(froot==NULL) {
49  cout << "CWB_Plugin_SNR.C - Error opening root file : " << snrFile << endl;
50  gSystem->Exit(1);
51  }
52  froot->cd();
53 
54  // create mdc tree
55  int nIFO = NET->ifoListSize(); // number of detectors
56  injection mdc(nIFO);
57  TTree* mdc_tree = mdc.setTree();
58  // add iSNR branch to mdc_tree
59  char ciSNR[16]; sprintf(ciSNR,"iSNR[%1d]/F",nIFO);
60  float* iSNR = new float[nIFO];
61  mdc_tree->Branch("iSNR", iSNR, ciSNR);
62 
63  NET->setVeto(cfg->gap); // select mdc
64  // in pipeline is done in the coherence stage
65 
66  int N = NET->mdc__ID.size(); // number of injectios
67 
68  std::vector<size_t> mdc__ID = NET->mdc__ID; // save a copy mdc__ID
69 
70  NET->mdc__ID.resize(1); // resize to 1 to save single event
71  for (int k=0;k<N;k++) { // loop over mdc
72  int ID = mdc__ID[k];
73  NET->mdc__ID[0] = ID;
74  for(int i=0; i<nIFO; i++) {
75  detector* pD = NET->getifo(i);
76  iSNR[i] = pD->ISNR.data[ID]; // fill mdc with iSNR
77  //cout << k << " SNR " << iSNR[i] << endl;
78  }
79  mdc.output(mdc_tree,NET,1); // fill tree with mdc parameters
80  }
81 
82  NET->mdc__ID = mdc__ID; // restore mdc__ID
83 
84  mdc_tree->Write(); // save tree
85  froot->Close();
86 
87  delete iSNR;
88 
89  gSystem->Exit(0); // terminate job
90 
91  }
92 
93  return;
94 }
95 
detector * getifo(size_t n)
param: detector index
Definition: network.hh:418
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
TString("c")
void output(TTree *, network *, double, bool=true)
Definition: injection.cc:573
size_t nRun
Definition: network.hh:554
int ID
Definition: TestMDC.C:70
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
TString mdc[4]
TTree * setTree()
Definition: injection.cc:201
std::vector< size_t > mdc__ID
Definition: network.hh:597
i drho i
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *NET, WSeries< double > *x, TString ifo, int type)
COHERENCE.
#define N
char ifo[NIFO_MAX][8]
size_t ifoListSize()
Definition: network.hh:413
#define nIFO
jfile
Definition: cwb_job_obj.C:25
double setVeto(double=5.)
param: time window around injections
Definition: network.cc:3456
int simulation
Definition: config.hh:181
char output_dir[1024]
Definition: config.hh:300
network NET
Definition: cwb_dump_inj.C:12
std::vector< double > iSNR[NIFO_MAX]
int k
int nfactor
Definition: config.hh:183
TFile * froot
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
char data_label[1024]
Definition: config.hh:314
wavearray< double > ISNR
Definition: detector.hh:354
detector ** pD