Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_2G_DataConditioning.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 "regression.hh"
28 #include "TString.h"
29 #include "TObjArray.h"
30 #include "TObjString.h"
31 #include "TRandom.h"
32 #include "Toolbox.hh"
33 
34 void
36 //!DATA_CONDITIONING
37 // Plugin which implement the 2G data conditioning with regression
38 
39  cout << endl;
40  cout << "-----> CWB_Plugin_2G_DataConditioning.C" << endl;
41  cout << "ifo " << ifo.Data() << endl;
42  cout << "type " << type << endl;
43  cout << endl;
44 
45  if(type==CWB_PLUGIN_CONFIG) {
46  cfg->dcPlugin=true; // disable built-in dc
47  }
48 
49  if(type==CWB_PLUGIN_DATA) {
50 /*
51  CWB::Toolbox TB;
52  char file[1024];
53  sprintf(file,"%s/sensitivity_%s_%d_%s_job%lu.txt",cfg->dump_dir,ifo.Data(),int(x->start()),cfg->data_label,net->nRun);
54  //sprintf(file,"%s/sensitivity_%s_%d_%s_job%lu.txt",".",ifo.Data(),int(x->start()),"prova",net->nRun);
55  cout << endl << "Dump Sensitivity : " << file << endl << endl;
56  TB.makeSpectrum(file, *x, 8, cfg->segEdge);
57 
58  int nIFO=net->ifoListSize();
59  if(TString(ifo).CompareTo(net->ifoName[nIFO-1])==0) gSystem->Exit(0); // last ifo
60 */
61  }
62 
63  if(type==CWB_PLUGIN_REGRESSION) { // 2G like Data Conditioning
64 
65  if(TString(cfg->analysis)=="1G") {
66  cout << "CWB_Plugin_2G_DataConditioning.C : Error - this plugin works only with 2G" << endl;
67  gSystem->Exit(1);
68  }
69 
70  // get ifo id
71  int id=-1;
72  for(int n=0;n<cfg->nIFO;n++) if(ifo==net->ifoName[n]) {id=n;break;}
73  if(id<0) {cout << "Plugin : Error - bad ifo id" << endl; gSystem->Exit(1);}
74 
75  detector* pD = net->getifo(id);
76  WSeries<double>* pTF = pD->getTFmap();
77 
78  size_t rateANA=cfg->inRate>>cfg->levelR;
79 
80  WDM<double> WDMlpr(int(rateANA/4),int(rateANA/4),6,10);
81 
83  pTF = pD->getTFmap();
84  pTF->Forward(*hot,WDMlpr);
85  regression rr(*pTF,"target",1.,cfg->fHigh);
86  rr.add(*hot,"target");
87  rr.setFilter(8);
88  rr.setMatrix(net->Edge,0.95);
89  rr.solve(0.,4,'h');
90  rr.apply(0.35);
91  *hot = rr.getClean();
92  pTF->Forward(*hot,WDMlpr);
93  pTF->setlow(cfg->fLow);
94  pTF->sethigh(cfg->fHigh);
95  pD->white(cfg->whiteWindow,0,cfg->segEdge,cfg->whiteStride); // calculate noise rms
96  pTF->white(pD->nRMS,1); // whiten WSeries
97  pD->bandPass(16.,0.); // high pass filtering at 16Hz
98  pTF->Inverse();
99  *hot = *pTF; // conditioned TS
100  }
101 
102  if(type==CWB_PLUGIN_WHITE) {
103 
105  int level=-1;
106  if(TString(cfg->analysis)=="1G") {
107  level=x->getLevel();
108  x->Inverse(-1);
109  }
110  // dump spectrum
111  char file[1024];
112  sprintf(file,"%s/sensitivity_white_%s_%d_%s_job%lu.txt",cfg->dump_dir,ifo.Data(),int(x->start()),cfg->data_label,net->nRun);
113  cout << endl << "Dump Sensitivity : " << file << endl << endl;
114  TB.makeSpectrum(file, *x, 8, cfg->segEdge);
115  int nIFO=net->ifoListSize();
116  if(TString(ifo).CompareTo(net->ifoName[nIFO-1])==0) gSystem->Exit(0); // last ifo
117  if(TString(cfg->analysis)=="1G") x->Forward(level);
118 
119  }
120 
121  return;
122 }
std::vector< char * > ifoName
Definition: network.hh:609
void sethigh(double f)
Definition: wseries.hh:132
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
CWB::config * cfg
char analysis[8]
Definition: config.hh:117
void white(double dT=0, int wtype=1, double offset=0., double stride=0.)
what it does: see algorithm description in wseries.hh
Definition: detector.hh:258
void setMatrix(double edge=0., double f=1.)
Definition: regression.cc:425
int n
Definition: cwb_net.C:28
TString("c")
size_t nRun
Definition: network.hh:572
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
double whiteWindow
Definition: config.hh:189
double fLow
Definition: config.hh:140
CWB::Toolbox TB
bool dcPlugin
Definition: config.hh:366
void setlow(double f)
Definition: wseries.hh:125
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
Definition: regression.cc:91
virtual void start(double s)
Definition: wavearray.hh:137
char ifo[NIFO_MAX][8]
double Edge
Definition: network.hh:578
network ** net
NOISE_MDC_SIMULATION.
size_t ifoListSize()
Definition: network.hh:431
double segEdge
Definition: config.hh:164
#define nIFO
int getLevel()
Definition: wseries.hh:109
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
jfile
Definition: cwb_job_obj.C:43
wavearray< double > hot[2]
WSeries< double > nRMS
Definition: detector.hh:358
i() int(T_cor *100))
void apply(double threshold=0., char c='a')
Definition: regression.cc:709
WSeries< double > pTF[nRES]
Definition: revMonster.cc:8
void solve(double th, int nE=0, char c='s')
Definition: regression.cc:610
size_t setFilter(size_t)
Definition: regression.cc:276
void bandPass(double f1, double f2, double a=0.)
Definition: detector.hh:283
wavearray< double > getClean()
Definition: regression.hh:135
size_t rateANA
Definition: test_config1.C:21
double whiteStride
Definition: config.hh:190
double fHigh
Definition: config.hh:141
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:179
char dump_dir[1024]
Definition: config.hh:328
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:246
static void makeSpectrum(wavearray< double > &psd, wavearray< double > x, double chuncklen=8, double scratchlen=0, bool oneside=true)
Definition: Toolbox.cc:5489
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
int nIFO
Definition: config.hh:120
char data_label[1024]
Definition: config.hh:332
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:291
size_t inRate
Definition: config.hh:132
int levelR
Definition: config.hh:152
detector ** pD
virtual WSeries< double > white(double, int, double=0., double=0.)
what it does: each wavelet layer is devided into k intervals.
Definition: wseries.cc:1146