Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_PhaseMisCal.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 "mdc.hh"
25 #include "config.hh"
26 #include "network.hh"
27 #include "wavearray.hh"
28 #include "gwavearray.hh"
29 #include "TString.h"
30 #include "TObjArray.h"
31 #include "TObjString.h"
32 #include "TRandom.h"
33 #include "TComplex.h"
34 
35 #define L1_PHS_CAL_ERR 10. // 10 degrees in phase uncertainty
36 #define H1_PHS_CAL_ERR 10. // 10 degrees in phase uncertainty
37 #define V1_PHS_CAL_ERR 10. // 10 degrees in phase uncertainty
38 
39 //#define SAVE_PLOT // plot data in ROOT format before/after mis-calibration
40 
41 void
43 //!MISCALIBRATION
44 // Plugin to mis-calibrate in phase the MDC
45 
46 // This macro implements the the test of the cWB offline analysis
47 // robustness versus the official calibration systematics in phase.
48 
50 
51  cout << endl;
52  cout << "-----> CWB_Plugin_PhaseMisCal.C" << endl;
53  cout << "ifo " << ifo.Data() << endl;
54  cout << "type " << type << endl;
55  cout << endl;
56 
57  if(type==CWB_PLUGIN_MDC) { // mdc
58  cout << "APPLY PHASE MIS-CALIBRATION !!!" << endl;
59 #ifdef SAVE_PLOT
61  gx.Draw(GWAT_TIME); // draw signal before cfactor (BLACK)
62 #endif
63  for (int nmdc=0; nmdc<(int)net->mdcListSize(); nmdc++) {
64  TString mdcstring(net->getmdcList(nmdc));
65  TObjArray* token = mdcstring.Tokenize(' ');
66  TObjString* iname = (TObjString*)token->At(11);
67  TString wavename = iname->GetString();
68  TObjString* itime = (TObjString*)token->At(10);
69  TString wavetime = itime->GetString();
70  double mdctime = wavetime.Atof();
71  if (mdctime<x->start()||mdctime>x->start()+x->size()/x->rate()) continue;
72  //cout << mdcstring.Data() << endl;
73  //printf(" Time : %s %f %f %f", wavetime.Data(), mdctime, x->start(), x->start()+x->size()/x->rate());
74  //cout << "String: " << wavename.Data() << " time : " << wavetime.Data() << " " <<mdctime;
75  int starti = (mdctime - x->start()-cfg->iwindow/2.)*x->rate();
76  int stopi = (mdctime - x->start()+cfg->iwindow/2.)*x->rate();
77  if (starti<0) starti=0;
78  if (stopi>(int)x->size()) stopi=x->size();
79 
80  double pShift = 0;
81  if(ifo=="L1") pShift = L1_PHS_CAL_ERR;
82  if(ifo=="H1") pShift = H1_PHS_CAL_ERR;
83  if(ifo=="V1") pShift = V1_PHS_CAL_ERR;
84  pShift *= (2*gRandom->Integer(2)-1.); // +/- pShift
85 
86  //cout << " starti " << starti << " stopi " << stopi << " pShift : " << pShift << endl;
87  int size = TMath::Nint(cfg->iwindow+0.5)*x->rate();
88  wavearray<double> X(size);X=0;
89  for (int jj=starti; jj<stopi; jj++) X[jj-starti] = x->data[jj];
90  //cout << "Apply phase shift : " << pShift << " degrees" << endl;
91  CWB::mdc::PhaseShift(X,pShift);
92  for (int jj=starti; jj<stopi; jj++) x->data[jj] = X[jj-starti];
93  }
94 #ifdef SAVE_PLOT
95  gx.Draw(x,GWAT_TIME,"SAME",kRed); // draw signal after cfactor (RED)
96  TString gfile="CWB_Plugin_PhaseMisCal_Plot_MDC_"+ifo+".root";
97  watplot* plot = gx.GetWATPLOT(); // get pointer to watplot object
98  (*plot) >> gfile;
99  cout << "CWB_Plugin_PhaseMisCal.C : created plot file name : " << gfile << endl;
100 #endif
101  }
102 
103  return;
104 }
CWB::config * cfg
double iwindow
Definition: config.hh:200
virtual void rate(double r)
Definition: wavearray.hh:141
#define H1_PHS_CAL_ERR
TString("c")
static void PhaseShift(wavearray< double > &x, double pShift=0.)
Definition: mdc.cc:2955
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
Long_t size
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.
#define V1_PHS_CAL_ERR
virtual size_t size() const
Definition: wavearray.hh:145
x plot
jfile
Definition: cwb_job_obj.C:43
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
i() int(T_cor *100))
gwavearray< double > * gx
TObjArray * token
TString gfile
watplot * GetWATPLOT()
Definition: gwavearray.hh:88
DataType_t * data
Definition: wavearray.hh:319
double * itime
#define L1_PHS_CAL_ERR
wavearray< double > y
Definition: Test10.C:31
void Draw(GWAT_DRAW type=GWAT_TIME, TString options="ALP", Color_t color=kBlack)
Definition: gwavearray.cc:89