Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_Coherence.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 #include "TComplex.h"
32 #include "TMath.h"
33 #include "mdc.hh"
34 #include <vector>
35 
36 //!COHERENCE
37 
38 void
40 
41 // This plugin implements the built-in coherence stage (only 2G), user can provide its own coherence stage implementation
42 
43  cout << endl;
44  cout << "-----> plugins/CWB_Plugin_Coherence.C" << endl;
45  cout << "ifo " << ifo.Data() << endl;
46  cout << "type " << type << endl;
47  cout << endl;
48 
49  if(type==CWB_PLUGIN_CONFIG) {
50  cfg->cohPlugin=true; // disable built-in coherence stage
51  }
52 
53  if(type==CWB_PLUGIN_ICOHERENCE) {
54 
55  cout << "type==CWB_PLUGIN_ICOHERENCE" << endl;
56 
57  // import ifactor
58  int gIFACTOR=-1; IMPORT(int,gIFACTOR)
59  cout << "-----> CWB_Plugin_Sim4.C -> " << " gIFACTOR : " << gIFACTOR << endl;
60 
61  int rateANA=cfg->inRate>>cfg->levelR;
62  int nIFO = net->ifoListSize();
63  detector* pD[NIFO_MAX]; // pointers to detectors
64  for(int n=0;n<nIFO;n++) pD[n] = net->getifo(n);
65  double mTau=net->getDelay(const_cast<char*>("MAX")); // maximum time delay
66 
67  int upN = rateANA/1024; if(upN<1) upN=1; // calculate upsample factor
68  int nRES = net->wdmListSize(); // number of resolution levels
69 
70  double Eo;
71  netcluster* pwc;
72 
73  for(int i=0; i<nRES; i++) { // loop over TF resolutions
74  // print level infos
75  int level=cfg->l_high-i;
76  int layers = level>0 ? 1<<level : 0;
77  int rate = rateANA>>level;
78  cout << "level : " << level << "\t rate(hz) : " << rate
79  << "\t layers : " << layers << "\t df(hz) : " << rateANA/2./double(1<<level)
80  << "\t dt(ms) : " << 1000./rate << endl;
81 
82  // produce TF maps with max over the sky energy
83  for(int n=0; n<nIFO; n++) {
84  WDM<double>* pwdm = net->wdmList[i];
85  wavearray<double>* hot = net->getifo(n)->getHoT();
86  net->getifo(n)->getTFmap()->maxEnergy(*hot,*pwdm,mTau,upN);
87  //if(singleDetector) {
88  // *(net->getifo(1)->getTFmap()) = *(net->getifo(0)->getTFmap());
89  // break;
90  //}
91  // restore the frequency boundaries changed by the maxEnergy call
92  net->getifo(n)->getTFmap()->setlow(cfg->fLow);
93  net->getifo(n)->getTFmap()->sethigh(cfg->fHigh);
94  }
95 
96  Eo = net->THRESHOLD(cfg->bpp); // threshold on pixel energy
97  cout<<"thresholds in units of noise variance: Eo="<<Eo<<" Emax="<<Eo*2<<endl;
98 
99  double TL = net->setVeto(cfg->iwindow);
100  cout<<"live time in zero lag: "<<TL<<endl; // set veto array
101  if(TL <= 0.) {cout<<"livetime is zero : exit"<<endl;exit(1);} // exit if live time is zero
102 
103  // select pixels
104  if(cfg->simulation) {cout<<"ifactor|clusters|pixels ";cout.flush();}
105  else {cout<<"lag|clusters|pixels "; cout.flush();}
106  int csize_tot=0;int psize_tot=0;
107  for(int j=0; j<(int)net->nLag; j++) {
108 
109  net->getNetworkPixels(j,Eo,Eo*2);
110  net->cluster(1,1);
111  pwc = net->getwc(j);
112 
113  // store cluster into temporary job file
114  int cycle = cfg->simulation ? gIFACTOR : Long_t(pwc->shift);
115  pwc->write(jfile,"coherence","clusters",0,cycle);
116  pwc->write(jfile,"coherence","clusters",-1,cycle);
117  cout<<cycle<<"|"<<pwc->csize()<<"|"<<pwc->size()<<" ";cout.flush();
118  csize_tot+=pwc->csize(); psize_tot+=pwc->size();
119 
120  pwc->clear();
121  }
122  }
123  }
124 
125  return;
126 }
void sethigh(double f)
Definition: wseries.hh:132
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
CWB::config * cfg
double iwindow
Definition: config.hh:200
size_t write(const char *file, int app=0)
Definition: netcluster.cc:3008
size_t nLag
Definition: network.hh:573
long getNetworkPixels(int LAG, double Eo, double DD=1., TH1F *hist=NULL)
Definition: network.cc:78
int n
Definition: cwb_net.C:28
TString("c")
bool cohPlugin
Definition: config.hh:367
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 fLow
Definition: config.hh:140
netcluster * pwc
Definition: cwb_job_obj.C:38
void setlow(double f)
Definition: wseries.hh:125
int layers
int j
Definition: cwb_net.C:28
i drho i
size_t cluster(int kt, int kf)
param: time gap in pixels return: number of reconstructed clusters
Definition: network.hh:321
size_t wdmListSize()
Definition: network.hh:446
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
size_t ifoListSize()
Definition: network.hh:431
#define nIFO
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
jfile
Definition: cwb_job_obj.C:43
double setVeto(double=5.)
param: time window around injections
Definition: network.cc:3487
double shift
Definition: netcluster.hh:382
int simulation
Definition: config.hh:199
int l_high
Definition: config.hh:156
wavearray< double > hot[2]
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:69
double maxEnergy(wavearray< DataType_t > &ts, Wavelet &w, double=0, int=1, int=0, TH1F *=NULL)
Definition: wseries.cc:504
i() int(T_cor *100))
wavearray< double > * getHoT()
param: no parameters
Definition: detector.hh:175
const int NIFO_MAX
Definition: wat.hh:22
double getDelay(const char *c="")
Definition: network.cc:2818
std::vector< WDM< double > * > wdmList
Definition: network.hh:617
double THRESHOLD(double bpp)
param: selected fraction of LTF pixels assuming Gaussian noise
Definition: network.cc:2615
size_t rateANA
Definition: test_config1.C:21
size_t size()
Definition: netcluster.hh:147
double fHigh
Definition: config.hh:141
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:179
size_t csize()
Definition: netcluster.hh:151
int gIFACTOR
double mTau
netcluster * getwc(size_t n)
param: delay index
Definition: network.hh:439
const int nRES
Definition: revMonster.cc:7
double bpp
Definition: config.hh:133
size_t inRate
Definition: config.hh:132
int levelR
Definition: config.hh:152
detector ** pD
exit(0)
void clear()
Definition: netcluster.hh:427