Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_TShiftMisCal.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 
32 void
34 //!MISCALIBRATION
35 // Plugin to mis-calibrate in time the injeted MDC
36 
38 
39  cout << endl;
40  cout << "-----> CWB_Plugin_TShiftMisCal.C" << endl;
41  cout << "ifo " << ifo.Data() << endl;
42  cout << "type " << type << endl;
43  cout << endl;
44 
45  if(type==CWB_PLUGIN_MDC) { // mdc
46 
47  // TEST PHASE CALIBRATION ERRORS //GV
48 
49  // upconvertion 16kHz -> 64kHz
50 
51  x->FFTW(1);
52  x->resize(4*x->size());
53  x->rate(4*x->rate());
54  x->FFTW(-1);
55 
56  y.resize(x->size());y.rate(x->rate());y.start(x->start());y=0; // temporary array
57  for (int nmdc=0; nmdc<(int)net->mdcListSize(); nmdc++) {
58  TString mdcstring(net->getmdcList(nmdc));
59  TObjArray* token = mdcstring.Tokenize(' ');
60  TObjString* iname = (TObjString*)token->At(11);
61  TString wavename = iname->GetString();
62  TObjString* itime = (TObjString*)token->At(10);
63  TString wavetime = itime->GetString();
64  double mdctime = wavetime.Atof();
65  if (mdctime<(int)x->start()||mdctime>x->start()+x->size()/x->rate()) continue;
66  //cout << mdcstring.Data() << endl;
67  //printf(" Time : %s %f %f %f", wavetime.Data(), mdctime, x->start(), x->start()+x->size()/x->rate());
68  //cout << "String: " << wavename.Data() << " time : " << wavetime.Data() << " " <<mdctime<< endl;
69  int cshift = 2*int(gRandom->Integer(3)-1);
70 
71  int starti = (mdctime - x->start()-1.)*x->rate();
72  int stopi = (mdctime - x->start()+1.)*x->rate();
73  if(cshift>0) {
74  if (starti<cshift) starti=cshift;
75  if (stopi>(int)x->size()-cshift) stopi=x->size()-cshift;
76  } else {
77  if (starti<0) starti=0;
78  if (stopi>(int)x->size()+cshift) stopi=x->size()+cshift;
79  }
80 
81  cout << " Start: " << starti << " Stop : " << stopi << " cshift : " << cshift << endl;
82  for (int jj=starti; jj<stopi; jj++) {
83  y.data[jj] = x->data[jj-cshift];
84  }
85  //for (int jj=starti; jj<stopi; jj++) {
86  // if(x->data[jj]!=0) cout << jj << " " << cshift << " " << x->data[jj] << " " << y.data[jj] << endl;
87  //}
88  }
89  (*x)=y;y.resize(0);
90 
91  // downconvertion 64kHz -> 16kHz
92  x->FFTW(1);
93  x->resize(x->size()/4);
94  x->rate(x->rate()/4);
95  x->FFTW(-1);
96  }
97 
98  return;
99 }
CWB::config * cfg
virtual void resize(unsigned int)
Definition: wseries.cc:901
virtual void rate(double r)
Definition: wavearray.hh:141
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
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
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
jfile
Definition: cwb_job_obj.C:43
i() int(T_cor *100))
TObjArray * token
virtual void FFTW(int=1)
Definition: wavearray.cc:896
DataType_t * data
Definition: wavearray.hh:319
double * itime
wavearray< double > y
Definition: Test10.C:31