Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_fCuts.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 "Toolbox.hh"
32 
33 //!DATA_CONDITIONING
34 
35 // Implements the 2G frequency cuts in pixel selection stage
36 
37 inline bool CheckRange(int i, double df, double flow, double fhigh)
38  {
39  double iflow=i*df-df/2.;
40  double ifhigh=(i+1)*df-df/2.;
41  if((iflow>=flow)&&(iflow<fhigh)) return true;
42  if((ifhigh>flow)&&(ifhigh<=fhigh)) return true;
43  return false;
44  }
45 
46 // fcut structure used to define the frequency cuts
47 #define _FCUT_MAX 100
48 
50 
51 struct fcut {
52  char ifo[32];
53  float flow;
54  float fhigh;
55  char levels[1024];
56 };
57 
58 
59 void
61 
62  cout << endl;
63  cout << "-----> CWB_Plugin_fCuts.C" << endl;
64  cout << "ifo " << ifo.Data() << endl;
65  cout << "type " << type << endl;
66  cout << endl;
67 
68  if(type==CWB_PLUGIN_XCOHERENCE) {
69 
70  // WSeries contains energy (it is stored in the 0 phase amplitudes)
71 
72  // frequency cuts declaration
73  fcut FCUT[_FCUT_MAX];
74 
75  // export to CINT
76  char cmd[128];
77  sprintf(cmd,"fcut* FCUT = (fcut*)%p;",FCUT);
78  gROOT->ProcessLine(cmd);
79 
80  // read plugin config
81  cfg->configPlugin.Exec();
82  // import resolution level
83  int nFCUT=-1; IMPORT(int,nFCUT)
84  // transform level list { 2, 6, 8} to {,2,6,8,}
85  for(int i=0;i<nFCUT;i++) {
86  TString Levels = FCUT[i].levels;
87  Levels = ","+Levels+",";
88  Levels.ReplaceAll(" ","");
89  strcpy(FCUT[i].levels,Levels.Data());
90  }
91 
92  // import resolution level
93  size_t gILEVEL=-1; IMPORT(size_t,gILEVEL)
94  char slevel[256];sprintf(slevel,",%d,",gILEVEL);
95 
96  int nIFO = net->ifoListSize();
97  detector* pD[NIFO_MAX]; // pointers to detectors
98  for(int n=0;n<nIFO;n++) pD[n] = net->getifo(n);
99 
100  for(int n=0; n<nIFO; n++) { // produce TF maps with max over the sky energy
101 
102  WSeries<double>* WS = pD[n]->getTFmap();
103  ifo = net->ifoName[n];
104 
105  if(WS->pWavelet->m_WaveType!=WDMT) {
106  cout << "CWB_Plugin_fCuts.C - Error : works only for WDMT wavelet types" << endl;
107  gSystem->Exit(1);
108  }
109 
110 
111  int layers = WS->maxLayer()+1; // numbers of frequency bins (first & last bins have df/2)
112  int slices = WS->sizeZero(); // number of time bins
113 
114  float df = WS->resolution(); // frequency bin resolution (hz)
115  float dt = 1./(2*df); // time bin resolution (sec)
116 
117  int rate = int(1./dt);
118 
119  if(n==0) cout << "layers : " << layers << "\t slices : " << slices << "\t rate : " << rate
120  << "\t dt : " << dt << "\t df : " << df << endl;
121 
122  for(int i=0;i<slices;i++) {
123  for(int j=0;j<layers;j++) {
124  for(int k=0;k<nFCUT;k++) {
125  if(FCUT[k].ifo==ifo && TString(FCUT[k].levels).Contains(slevel)) {
126  if(CheckRange(j,df,FCUT[k].flow,FCUT[k].fhigh)) {
127  WS->putSample(0,i,j); // set to 0 the energy
128  }
129  }
130  }
131  }
132  }
133  }
134  }
135  return;
136 }
std::vector< char * > ifoName
Definition: network.hh:609
detector * getifo(size_t n)
param: detector index
Definition: network.hh:436
CWB::config * cfg
int slices
TMacro configPlugin
Definition: config.hh:362
int n
Definition: cwb_net.C:28
TString("c")
int FCUT_MAX
void putSample(DataType_t a, int n, double m)
Definition: wseries.hh:195
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
int layers
void CWB_Plugin(TFile *jfile, CWB::config *cfg, network *net, WSeries< double > *x, TString ifo, int type)
COHERENCE.
int j
Definition: cwb_net.C:28
i drho i
bool CheckRange(int i, double df, double flow, double fhigh)
DATA_CONDITIONING.
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
size_t ifoListSize()
Definition: network.hh:431
#define nIFO
jfile
Definition: cwb_job_obj.C:43
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:69
i() int(T_cor *100))
const int NIFO_MAX
Definition: wat.hh:22
double fhigh
Definition: Wavelet.hh:49
int k
double dt
#define _FCUT_MAX
double flow
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:179
double resolution(int=0)
Definition: wseries.hh:155
char cmd[1024]
strcpy(RunLabel, RUN_LABEL)
double df
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
enum WAVETYPE m_WaveType
Definition: Wavelet.hh:106
WaveDWT< DataType_t > * pWavelet
Definition: wseries.hh:456
size_t sizeZero()
Definition: wseries.hh:144
int maxLayer()
Definition: wseries.hh:139
detector ** pD