Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_AmplitudeMisCal.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 "gwavearray.hh"
28 #include "TString.h"
29 #include "TObjArray.h"
30 #include "TObjString.h"
31 #include "TRandom.h"
32 
33 #define L1_AMP_CAL_ERR_SIGMA 0.2 // 20% amplitude uncertainty
34 #define H1_AMP_CAL_ERR_SIGMA 0.2 // 20% amplitude uncertainty
35 #define V1_AMP_CAL_ERR_SIGMA 0.1 // 10% amplitude uncertainty
36 
37 //#define SAVE_PLOT // plot data in ROOT format before/after mis-calibration
38 
39 void
41 //!MISCALIBRATION
42 // Plugin to mis-calibrate in amplitude the MDC
43 
44 // The jittering procedure depends on the model describing the calibration uncertainties distribution.
45 // For each detector, jittering values are extracted, via MonteCarlo, from a gaussian distribution,
46 // centered on 1 and with standard deviation equal to the interferometer nominal uncertainty
47 // (i.e., 20% for LIGO observatories, 10% for Virgo).
48 // Such values are then used to rescale the MDC waveforms amplitude before the injection in the detectors data.
49 
50 // The waveforms are injected in the detectors data after having been jittered, with different
51 // values for the three detectors. Since cWB performs a coherent search, a fraction of events
52 // is therefore rejected by the algorithm. How large such fraction is, depends on how extreme
53 // the considered jittering models are. It is expected to get larger for increasing possible jittering values.
54 // Given that part of the jittered injected signals is rejected by the algorithm, the detection efficiency
55 // curves are expected to get lower. Such variations in the detection efficiency induce changes
56 // of the 90% confidence upper limit on the total event rate. i
57 
58  cout << endl;
59  cout << "-----> CWB_Plugin_AmplitudeMisCal.C" << endl;
60  cout << "ifo " << ifo.Data() << endl;
61  cout << "type " << type << endl;
62  cout << endl;
63 
64  if(type==CWB_PLUGIN_MDC) { // mdc
65  cout << "APPLY AMPLITUDE MIS-CALIBRATION !!!" << endl;
66 #ifdef SAVE_PLOT
68  gx.Draw(GWAT_TIME); // draw signal before cfactor (BLACK)
69 #endif
70  for (int nmdc=0; nmdc<(int)net->mdcListSize(); nmdc++) {
71  TString mdcstring(net->getmdcList(nmdc));
72  TObjArray* token = mdcstring.Tokenize(' ');
73  TObjString* iname = (TObjString*)token->At(11);
74  TString wavename = iname->GetString();
75  TObjString* itime = (TObjString*)token->At(10);
76  TString wavetime = itime->GetString();
77  double mdctime = wavetime.Atof();
78  if (mdctime<x->start()||mdctime>x->start()+x->size()/x->rate()) continue;
79  //cout << mdcstring.Data() << endl;
80  //printf(" Time : %s %f %f %f", wavetime.Data(), mdctime, x->start(), x->start()+x->size()/x->rate());
81  //cout << "String: " << wavename.Data() << " time : " << wavetime.Data() << " " <<mdctime;
82  int starti = (mdctime - x->start()-cfg->iwindow/2.)*x->rate();
83  int stopi = (mdctime - x->start()+cfg->iwindow/2.)*x->rate();
84  if (starti<0) starti=0;
85  if (stopi>(int)x->size()) stopi=x->size();
86  double cfactor = 0;
87  if(ifo=="L1") cfactor = gRandom->Gaus(1,L1_AMP_CAL_ERR_SIGMA);
88  if(ifo=="H1") cfactor = gRandom->Gaus(1,H1_AMP_CAL_ERR_SIGMA);
89  if(ifo=="V1") cfactor = gRandom->Gaus(1,V1_AMP_CAL_ERR_SIGMA);
90  //cout << " starti " << starti << " stopi " << stopi << " cfactor : " << cfactor << endl;
91  //cout << "Apply amplitude factor : " << cfactor << endl;
92  for (int jj=starti; jj<stopi; jj++) {
93  //if(x->data[jj]!=0) cout << jj << " " << cfactor << " " << x->data[jj] << endl;
94  x->data[jj] *= cfactor;
95  }
96  }
97 #ifdef SAVE_PLOT
98  gx.Draw(x,GWAT_TIME,"SAME",kRed); // draw signal after cfactor (RED)
99  TString gfile="CWB_Plugin_AmplitudeMisCal_Plot_MDC_"+ifo+".root";
100  watplot* plot = gx.GetWATPLOT(); // get pointer to watplot object
101  (*plot) >> gfile;
102  cout << "CWB_Plugin_AmplitudeMisCal.C : created plot file name : " << gfile << endl;
103 #endif
104  }
105 
106  return;
107 }
CWB::config * cfg
double iwindow
Definition: config.hh:200
virtual void rate(double r)
Definition: wavearray.hh:141
#define L1_AMP_CAL_ERR_SIGMA
TString("c")
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
string getmdcList(size_t n)
Definition: network.hh:418
virtual void start(double s)
Definition: wavearray.hh:137
int nmdc
size_t mdcListSize()
Definition: network.hh:408
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
virtual size_t size() const
Definition: wavearray.hh:145
x plot
jfile
Definition: cwb_job_obj.C:43
i() int(T_cor *100))
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
gwavearray< double > * gx
#define V1_AMP_CAL_ERR_SIGMA
TObjArray * token
TString gfile
watplot * GetWATPLOT()
Definition: gwavearray.hh:88
DataType_t * data
Definition: wavearray.hh:319
double * itime
#define H1_AMP_CAL_ERR_SIGMA
void Draw(GWAT_DRAW type=GWAT_TIME, TString options="ALP", Color_t color=kBlack)
Definition: gwavearray.cc:89