Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CWB_Plugin_PhaseMisCal.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 "mdc.hh"
7 #include "config.hh"
8 #include "network.hh"
9 #include "wavearray.hh"
10 #include "gwavearray.hh"
11 #include "TString.h"
12 #include "TObjArray.h"
13 #include "TObjString.h"
14 #include "TRandom.h"
15 #include "TComplex.h"
16 
17 #define L1_PHS_CAL_ERR 10. // 10 degrees in phase uncertainty
18 #define H1_PHS_CAL_ERR 10. // 10 degrees in phase uncertainty
19 #define V1_PHS_CAL_ERR 10. // 10 degrees in phase uncertainty
20 
21 //#define SAVE_PLOT // plot data in ROOT format before/after mis-calibration
22 
23 void
25 //!MISCALIBRATION
26 // Plugin to mis-calibrate in phase the MDC
27 
28 // This macro implements the the test of the cWB offline analysis
29 // robustness versus the official calibration systematics in phase.
30 
32 
33  cout << endl;
34  cout << "-----> CWB_Plugin_PhaseMisCal.C" << endl;
35  cout << "ifo " << ifo.Data() << endl;
36  cout << "type " << type << endl;
37  cout << endl;
38 
39  if(type==CWB_PLUGIN_MDC) { // mdc
40  cout << "APPLY PHASE MIS-CALIBRATION !!!" << endl;
41 #ifdef SAVE_PLOT
43  gx.Draw(GWAT_TIME); // draw signal before cfactor (BLACK)
44 #endif
45  for (int nmdc=0; nmdc<(int)net->mdcListSize(); nmdc++) {
46  TString mdcstring(net->getmdcList(nmdc));
47  TObjArray* token = mdcstring.Tokenize(' ');
48  TObjString* iname = (TObjString*)token->At(11);
49  TString wavename = iname->GetString();
50  TObjString* itime = (TObjString*)token->At(10);
51  TString wavetime = itime->GetString();
52  double mdctime = wavetime.Atof();
53  if (mdctime<x->start()||mdctime>x->start()+x->size()/x->rate()) continue;
54  //cout << mdcstring.Data() << endl;
55  //printf(" Time : %s %f %f %f", wavetime.Data(), mdctime, x->start(), x->start()+x->size()/x->rate());
56  //cout << "String: " << wavename.Data() << " time : " << wavetime.Data() << " " <<mdctime;
57  int starti = (mdctime - x->start()-cfg->iwindow/2.)*x->rate();
58  int stopi = (mdctime - x->start()+cfg->iwindow/2.)*x->rate();
59  if (starti<0) starti=0;
60  if (stopi>(int)x->size()) stopi=x->size();
61 
62  double pShift = 0;
63  if(ifo=="L1") pShift = L1_PHS_CAL_ERR;
64  if(ifo=="H1") pShift = H1_PHS_CAL_ERR;
65  if(ifo=="V1") pShift = V1_PHS_CAL_ERR;
66  pShift *= (2*gRandom->Integer(2)-1.); // +/- pShift
67 
68  //cout << " starti " << starti << " stopi " << stopi << " pShift : " << pShift << endl;
69  int size = TMath::Nint(cfg->iwindow+0.5)*x->rate();
70  wavearray<double> X(size);X=0;
71  for (int jj=starti; jj<stopi; jj++) X[jj-starti] = x->data[jj];
72  //cout << "Apply phase shift : " << pShift << " degrees" << endl;
73  CWB::mdc::PhaseShift(X,pShift);
74  for (int jj=starti; jj<stopi; jj++) x->data[jj] = X[jj-starti];
75  }
76 #ifdef SAVE_PLOT
77  gx.Draw(x,GWAT_TIME,"SAME",kRed); // draw signal after cfactor (RED)
78  TString gfile="CWB_Plugin_PhaseMisCal_Plot_MDC_"+ifo+".root";
79  watplot* plot = gx.GetWATPLOT(); // get pointer to watplot object
80  (*plot) >> gfile;
81  cout << "CWB_Plugin_PhaseMisCal.C : created plot file name : " << gfile << endl;
82 #endif
83  }
84 
85  return;
86 }
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
double iwindow
Definition: config.hh:182
virtual size_t size() const
Definition: wavearray.hh:127
virtual void rate(double r)
Definition: wavearray.hh:123
#define H1_PHS_CAL_ERR
TString("c")
static void PhaseShift(wavearray< double > &x, double pShift=0.)
Definition: mdc.cc:2926
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
string getmdcList(size_t n)
Definition: network.hh:400
Long_t size
virtual void start(double s)
Definition: wavearray.hh:119
size_t mdcListSize()
Definition: network.hh:390
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
#define V1_PHS_CAL_ERR
int nmdc
Definition: cbc_plots.C:791
x plot
jfile
Definition: cwb_job_obj.C:25
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:70
DataType_t * data
Definition: wavearray.hh:301
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:71