Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb2G.cc
Go to the documentation of this file.
1 #include "cwb2G.hh"
2 #include "TKey.h"
3 #include "regression.hh"
4 #include "watplot.hh"
5 #include "sseries.hh"
6 #include "gwavearray.hh"
7 #include <iomanip>
8 
9 // minimun skymap resolution used for subNetCut
10 #define MIN_SKYRES_HEALPIX 4
11 #define MIN_SKYRES_ANGLE 3
12 
13 // regression parameters
14 #define REGRESSION_FILTER_LENGTH 8
15 #define REGRESSION_MATRIX_FRACTION 0.95
16 #define REGRESSION_SOLVE_EIGEN_THR 0.
17 #define REGRESSION_SOLVE_EIGEN_NUM 10
18 #define REGRESSION_SOLVE_REGULATOR 'h'
19 #define REGRESSION_APPLY_THR 0.8
20 
21 // select function parameter
22 #define SELECT_SUBRHO 5.0
23 #define SELECT_SUBNET 0.1
24 
25 // WDM default parameters
26 #define WDM_BETAORDER 6 // beta function order for Meyer
27 #define WDM_PRECISION 10 // wavelet precision
28 
29 #define EXIT(ERR) gSystem->Exit(ERR) // better exit handling for ROOT stuff
30 
31 ClassImp(cwb2G)
32 
33 cwb2G::~cwb2G() {
34 //
35 // Destructor
36 //
37 
38  for(int i=0; i<NRES_MAX; i++) {
39  if(pwdm[i]!=NULL) delete pwdm[i];
40  }
41 }
42 
43 void cwb2G::Init() {
44 //
45 // - Initialize the WDM<double> tranforms for each resolution level used in the analysis
46 // - Load the xTalk Catalog (network::setMRAcatalog) used for the Multi Resolution Analysis
47 //
48 
49  // export this (cwb2G) object (can be used by plugins)
50  char cmd[256];
51  sprintf(cmd,"gCWB2G = (void*)%p;",this); EXPORT(void*,gCWB2G,cmd);
52 
53  // check & set analysis stage
54  if(TString(cfg.analysis)!="2G")
55  {cout << "cwb2G::Init - Error : analysis must be 2G" << endl;EXIT(1);}
56  if(istage!=CWB_STAGE_FULL && iname=="")
57  {cout << "cwb2G::Init - Error : if initial stage!=CWB_STAGE_FULL "
58  << "then input file name must be a job file " << endl;EXIT(1);}
59 
60  nRES = cfg.l_high-cfg.l_low+1; // number of frequency resolution levels
61 
62  for(int i=0; i<NIFO_MAX; i++) hot[i]=NULL;
63  for(int i=0; i<NRES_MAX; i++) pwdm[i]=NULL;
64 
65  // loading MRA catalog
66  char MRAcatalog[1024];
67  sprintf(MRAcatalog,"%s/%s",cfg.filter_dir,cfg.wdmXTalk);
68  cout << "cwb2G::Init - Loading catalog of WDM cross-talk coefficients ... " << endl;
69  cout << MRAcatalog << endl;
70  TB.checkFile(MRAcatalog);
71  NET.setMRAcatalog(MRAcatalog);
72 
73  int BetaOrder = WDM_BETAORDER; // beta function order for Meyer
74  int precision = WDM_PRECISION; // wavelet precision
75  if(NET.wdmMRA.tag!=0) { // new catalog format : read BetaOrder,precision from catalog
76  BetaOrder=NET.wdmMRA.BetaOrder;
77  precision=NET.wdmMRA.precision;
78  }
79  // print catalog infos
80  char info[256];
81  sprintf(info,"-Tag:%d-BetaOrder:%d-precision:%d",NET.wdmMRA.tag,BetaOrder,precision);
82  PrintAnalysisInfo(CWB_STAGE_INIT,"cwb2G::Init",info,true,false);
83 
84  //cout << "cwb2G::Init - Create WDM ... " << endl;
85  for(int level=cfg.l_high; level>=cfg.l_low; level--) {
86  int layers = level>0 ? 1<<level : 0;
87  pwdm[cfg.l_high-level] = new WDM<double>(layers,layers,BetaOrder,precision);
88  // check if filter lenght is less than cwb scratch length
89  double wdmFLen = double(pwdm[cfg.l_high-level]->m_H)/rateANA; // sec
90  if(wdmFLen > cfg.segEdge+0.001) {
91  cout << endl;
92  cout << "cwb2G::Init : Error - filter length must be <= segEdge !!!" << endl;
93  cout << "filter length : " << wdmFLen << " sec" << endl;
94  cout << "cwb scratch : " << cfg.segEdge << " sec" << endl;
95  EXIT(1);
96  } else {
97  cout << "Filter length = " << wdmFLen << " (sec)" << endl;
98  }
99  // check if the length for time delay amplitudes is less than cwb scratch length
100  // the factor 1.5 is used to avoid to use pixels on the border which could be distorted
101  double rate = rateANA>>level;
102  if(cfg.segEdge<int(1.5*(cfg.TDSize/rate)+0.5)) {
103  cout << endl;
104  cout << "cwb2G::Init : Error - segEdge must be > "
105  << "1.5x the length for time delay amplitudes!!!" << endl;
106  cout << "TD length : " << cfg.TDSize/rate << " sec" << endl;
107  cout << "segEdge : " << cfg.segEdge << " sec" << endl;
108  cout << "Select segEdge > " << int(1.5*(cfg.TDSize/rate)+0.5) << endl << endl;
109  EXIT(1);
110  }
111  // add WDM to network
112  NET.add(pwdm[cfg.l_high-level]); // network vector must be filled starting from max resolution level
113  }
114 
115  // check if analysis layers are contained in the MRAcatalog
116  // level : is the decomposition level
117  // layes : are the number of layers along the frequency axis rateANA/(rateANA>>level)
118  int check_layers=0;
119  for(int level=cfg.l_high; level>=cfg.l_low; level--) {
120  int layers = level>0 ? 1<<level : 0;
121  for(int j=0;j<NET.wdmMRA.nRes;j++) if(layers==NET.wdmMRA.layers[j]) check_layers++;
122  }
123 
124  if(check_layers!=nRES) {
125  cout << "cwb2G::Init - Error : analysis layers do not match the MRA catalog" << endl;
126  cout << endl << "analysis layers : " << endl;
127  for(int level=cfg.l_high; level>=cfg.l_low; level--) {
128  int layers = level>0 ? 1<<level : 0;
129  cout << "level : " << level << " layers : " << layers << endl;
130  }
131  cout << endl << "MRA catalog layers : " << endl;
132  for(int i=0;i<NET.wdmMRA.nRes;i++)
133  cout << "layers : " << NET.wdmMRA.layers[i] << endl;
134  EXIT(1);
135  }
136  else {
137  cout << endl;
138  for(int level=cfg.l_high; level>=cfg.l_low; level--) {
139  int layers = level>0 ? 1<<level : 0;
140  int rate = rateANA>>level;
141  cout << "level : " << level << "\t rate(hz) : " << rate << "\t layers : " << layers
142  << "\t df(hz) : " << rateANA/2./double(1<<level)
143  << "\t dt(ms) : " << 1000./rate << endl;
144  }
145  cout << endl;
146  }
147 
148  // Check if lagStep compatible with WDM parity
149  // This condition is necessary to avoid mixing between odd
150  // and even pixels when circular buffer is used for lag shift
151  // The MRAcatalog distinguish odd and even pixels
152  int rate_min = rateANA>>cfg.l_high;
153  double dt_max = 1./rate_min;
154  if(fmod(rate_min,1.)) {
155  cout << "cwb2G::Init - Error : rate min=" << rate_min << "(Hz) is not integer" << endl << endl;
156  EXIT(1);
157  }
158  if(int(cfg.lagStep*rate_min+0.001)&1) {
159  cout << "cwb2G::Init - Error : lagStep=" << cfg.lagStep << "(sec)"
160  << " is not a multple of 2*max_time_resolution=" << 2*dt_max << "(sec)" << endl << endl;
161  EXIT(1);
162  }
163  if(int(cfg.segEdge*rate_min+0.001)&1) {
164  cout << "cwb2G::Init - Error : segEdge=" << cfg.segEdge << "(sec)"
165  << " is not a multple of 2*max_time_resolution=" << 2*dt_max << "(sec)" << endl << endl;
166  EXIT(1);
167  }
168  if(int(cfg.segMLS*rate_min+0.001)&1) {
169  cout << "cwb2G::Init - Error : segMLS=" << cfg.segMLS << "(sec)"
170  << " is not a multple of 2*max_time_resolution=" << 2*dt_max << "(sec)" << endl << endl;
171  EXIT(1);
172  }
173 
174  // time-delay filter rate
175  if(cfg.fResample>0) { // RESAMPLING
177  } else {
179  }
180 
181  return;
182 }
183 
184 double cwb2G::ReadData(double mdcShift, int ifactor) {
185 //
186 // Read Noise & MDC data from frame file or "On The Fly" from plugin
187 //
188 // Loop over detectors
189 // - Read noise from frames or "On The Fly" from plugin
190 // - Resampling data
191 // - Read injections from frames or "On The Fly" from plugin (config::simulation>0)
192 // - Resampling data
193 // - if(simulation==2) MDC are rescaled (detector::setsnr) with a fixed
194 // network SNR according to the config::factors
195 // - Store noise & MDC to job file
196 //
197 
198  // if 2G analysis istage>=CWB_STAGE_STRAIN then skip read data
199  if(istage>=CWB_STAGE_STRAIN) return 0.;
200 
201  PrintStageInfo(CWB_STAGE_STRAIN,"cwb2G::ReadData");
202 
203  // data are loaded from root file
204  if((istage!=CWB_STAGE_INIT)&&(iname!="")) return cwb::ReadData(iname);
205 
206  Meyer<double> B(1024); // set wavelet for resampling
207  wavearray<double> x,z,w; // temporary time series
208  std::vector<wavearray<double> > y; // temporary time series for snr mode
209  y.resize(nIFO);
210  WSeries<double> wM; // mdc WSeries
212 
213  int layers_high = 1<<cfg.l_high;
214  WDM<double> WDMwhite(layers_high,layers_high,6,10); // set whitening WDM
215 
216  // check if wdm filter lenght is less than cwb scratch
217  double wdmFLen = double(WDMwhite.m_H)/rateANA; // sec
218  if(wdmFLen > cfg.segEdge+0.001) {
219  cout << endl;
220  cout << "cwb2G::ReadData : Error - filter scratch must be <= cwb scratch!!!" << endl;
221  cout << "filter length : " << wdmFLen << " sec" << endl;
222  cout << "cwb scratch : " << cfg.segEdge << " sec" << endl;
223  EXIT(1);
224  } else {
225  cout << "WDM filter length for regression = " << wdmFLen << " (sec)" << endl;
226  }
227 
228  int xsize=0.;
229  double xrate=0.;
230  double xstart=0.;
231 
232  // data are loaded from frame files
233  jfile = new TFile(jname,"UPDATE");
234  if(jfile==NULL||!jfile->IsOpen())
235  {cout << "cwb2G::ReadData - Error opening root file : " << jname << endl;EXIT(1);}
236  TDirectory* cdstrain = (TDirectory*)jfile->Get("strain");
237  if(cdstrain==NULL) cdstrain = jfile->mkdir("strain");
238 
239  for(int i=0; i<nIFO; i++) {
240 
241  if(cfg.simulation==4) { // sim4 -> read ifo strain from job file
242  px = (wavearray<double>*)jfile->Get(TString("strain/")+ifo[i]);
243  }
244  if((cfg.simulation==4)&&(px!=NULL)) { // sim4 -> use strain from job file
245  x = *px; delete px;
246  } else {
247  if(cfg.dataPlugin) { // data are provided by the user plugin
248  x.rate(cfg.inRate); x.start(FRF[i].start); x.resize(int(x.rate()*(FRF[i].stop-FRF[i].start)));
249  } else { // data are read from frame
251  }
253  if(TMath::IsNaN(x.mean()))
254  {cout << "cwb2G::ReadData - Error : found NaN in strain data !!!" << endl;EXIT(1);}
255 
256  if(x.rate()!=cfg.inRate)
257  {cout << "cwb2G::ReadData - input rate from frame " << x.rate()
258  << " do not match the one defined in config : " << cfg.inRate << endl;EXIT(1);}
259 
260  x.start(x.start()+cfg.dataShift[i]); // dataShift
261  x.start(x.start()-cfg.segLen*(segID[i]-segID[0])); // SLAG
263  if(cfg.dcCal[i]>0.) x*=cfg.dcCal[i]; // DC correction
264  if(cfg.fResample>0) x.Resample(cfg.fResample); // RESAMPLING
265  x.Resample(x.rate()/(1<<cfg.levelR)); // resampling
266  x*=sqrt(1<<cfg.levelR); // rescaling
267 
268  if(cfg.simulation==2) w = x; // snr mode - save strain
269 
270  // save ifo data to temporary job file
271  cdstrain->cd();gwavearray<double> gx(x);gx.Write(ifo[i],TObject::kOverwrite);
272  }
273 
274  if(i==0) {xrate=x.rate();xstart=x.start();xsize=x.size();}
275 
276  fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(),x.size()/x.rate(),x.rate());
277  if(i>0 && xstart != x.start()) {
278  cout << "cwb2G::ReadData - Error : ifo noise data not synchronized" << endl;
279  cout << ifo[i] << " " << x.start() << " != " << ifo[0] << " " << xstart << endl;
280  EXIT(1);
281  }
282  if(i>0 && xrate != x.rate()) {
283  cout << "cwb2G::ReadData - Error : ifo noise data have different rates" << endl;
284  cout << ifo[i] << " " << x.rate() << " != " << ifo[0] << " " << xrate << endl;
285  EXIT(1);
286  }
287 
288  if(cfg.simulation) {
289  TDirectory* cdmdc = (TDirectory*)jfile->Get("mdc");
290  if(cdmdc==NULL) cdmdc = jfile->mkdir("mdc");
291 
292  if(cfg.mdcPlugin) { // mdc are provided by the user plugin
293  x.rate(cfg.inRate); x.start(FRF[i+nIFO].start);
294  x.resize(int(x.rate()*(FRF[i+nIFO].stop-FRF[i+nIFO].start)));
295  } else { // mdc are read from frame
296  fr[nIFO].readFrames(FRF[i+nIFO],cfg.channelNamesMDC[i],x);
297  if(x.rate()!=cfg.inRate)
298  {cout << "cwb2G::ReadData - input rate from frame " << x.rate()
299  << " do not match the one defined in config : " << cfg.inRate << endl;EXIT(1);}
300  }
302  if(TMath::IsNaN(x.mean()))
303  {cout << "cwb2G::ReadData - Error : found NaN in MDC data !!!" << endl;EXIT(1);}
304 
305  x.start(x.start()+mdcShift);
306  if(cfg.fResample>0) x.Resample(cfg.fResample); // RESAMPLING
307  y[i] = x; // save inj for snr mode
308  x.Resample(x.rate()/(1<<cfg.levelR)); // resampling
309  x*=sqrt(1<<cfg.levelR); // rescaling
310 
311  if(cfg.simulation==2) { // snr mode
312 
313  // calculate noise rms
314  pTF[i] = pD[i]->getTFmap();
315  pTF[i]->Forward(w,WDMwhite);
316  pTF[i]->setlow(cfg.fLow);
317  pTF[i]->sethigh(cfg.fHigh);
319 
320  // compute snr
321  wM.Forward(x,WDMwhite);
322  wM.setlow(cfg.fLow);
323  wM.sethigh(cfg.fHigh);
324  // zero f<fLow to avoid whitening issues when psd noise is not well defined for f<fLow
325  int layers = wM.maxLayer();
326  for(int j=0;j<layers;j++) if(wM.frequency(j)<cfg.fLow) {
327  double layer = j+0.01; // -epsilon select 0 layer for 90 phase
328  wM.getLayer(z, layer);z=0;wM.putLayer(z, layer); // 0 phase
329  wM.getLayer(z,-layer);z=0;wM.putLayer(z,-layer); // 90 phase
330  }
331 
332  // compute mdc snr
333  pD[i]->setsim(wM,NET.getmdcTime(),cfg.iwindow/2.,cfg.segEdge,false);
334  }
335  else { // save mdc data to temporary job file
336  cdmdc->cd();gwavearray<double> gx(x);gx.Write(ifo[i],TObject::kOverwrite);
337  }
338 
339  fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(),x.size()/x.rate(),x.rate());
340  if(xstart != x.start()) {
341  cout << "cwb2G::ReadData - Error : mdc/noise data with different start time" << endl;
342  printf("start time : noise = %10.6f - mdc = %10.6f\n",xstart,x.start());
343  EXIT(1);
344  }
345  if(xrate != x.rate()) {
346  cout << "cwb2G::ReadData - Error : mdc/noise data with different rate" << endl;
347  printf("rate : noise = %10.6f - mdc = %10.6f\n",xrate,x.rate());
348  EXIT(1);
349  }
350  if(xsize != x.size()) {
351  cout << "cwb2G::ReadData - Error : mdc/noise data with different buffer size" << endl;
352  printf("buffer size : noise = %d - mdc = %lu\n",xsize,x.size());
353  EXIT(1);
354  }
355  }
356  if(singleDetector) break;
357  }
358 
359  // for snr mode the factors parameters set to be the mdc snr
360  if(cfg.simulation==2) {
361  TDirectory* cdmdc = (TDirectory*)jfile->Get("mdc");
362  if(cdmdc==NULL) cdmdc = jfile->mkdir("mdc");
363 
364  // compute rescale factor -> snr=1
365  std::vector<double> mdcFactor;
366  for (int k=0;k<(int)pD[0]->ISNR.size();k++) {
367  double snr=0;
368  if(singleDetector) {
369  for(int i=0; i<nIFO; i++) snr+=pD[0]->ISNR.data[k];
370  } else {
371  for(int i=0; i<nIFO; i++) snr+=pD[i]->ISNR.data[k];
372  }
373  snr=sqrt(snr);
374  if(snr>0) mdcFactor.push_back(1./snr); else mdcFactor.push_back(0.);
375  }
376 
377  size_t K = mdcFactor.size();
378  for(int k=0; k<(int)K; k++) {
379  if(mdcFactor[k]) cout << k << " mdcFactor : " << mdcFactor[k] << endl;
380  }
381 
382  // rescale mdc snr to 1
383  for(int i=0; i<nIFO; i++) {
384  pD[i]->setsnr(y[i],NET.getmdcTime(),&mdcFactor,cfg.iwindow/2.,cfg.segEdge);
386 
387  wM.Forward(y[i],B,cfg.levelR);
388  wM.getLayer(y[i],0);
389  cdmdc->cd();gwavearray<double> gyi(y[i]);gyi.Write(ifo[i],TObject::kOverwrite);
390 
391  // rescaled saved injected waveforms
392  for(int k=0; k<(int)pD[i]->IWFP.size(); k++) {
393  wavearray<double>* pwf = pD[i]->IWFP[k];
394  int iwfid = pD[i]->IWFID[k];
395  for(int j=0;j<(int)pwf->size();j++) pwf->data[j]*=mdcFactor[iwfid];
396  }
397  for(int k=0; k<(int)K; k++) {
398  pD[i]->HRSS[k]*=mdcFactor[k];
399  pD[i]->ISNR[k]*=mdcFactor[k];
400  }
401 
402  if(singleDetector) break;
403  }
404  // rescale amplitudes stored in the mdcList
405  for(int k=0; k<(int)K; k++) {
406  int ilog[5] = {1,3,12,13,14};
407  for(int l=0;l<5;l++) {
408  double mfactor = l<2 ? mdcFactor[k] : mdcFactor[k]*mdcFactor[k];
409  TString slog = TB.GetMDCLog(NET.mdcList[k], ilog[l]);
410  NET.mdcList[k]=TB.SetMDCLog(NET.mdcList[k], ilog[l], mfactor*slog.Atof());
411  }
412  }
413  }
414 
415  // mdc data are copied to detectors HoT to be accessible by the user plugin
416  for(int i=0; i<nIFO; i++) pD[i]->HoT = y[i];
418  // clean mdc from detectors HoT
419  for(int i=0; i<nIFO; i++) {pD[i]->HoT.resize(0);y[i].resize(0);}
420 
421  jfile->Close();
422 
423  x.resize(0);
424  z.resize(0);
425  w.resize(0);
426  wM.resize(0);
427 
428  return x.rate();
429 }
430 
431 void
433 //
434 // Apply regression to remove lines & whiten data
435 //
436 // Loop over detectors
437 // - read ifo strain from job file
438 // - read MDC data from temporary job file (config::simulation>0)
439 // - if(config::simulation==1) MDC are rescaled according to the config::factors
440 // - Add MDC to noise
441 // - Apply regression to remove lines
442 // - Use detector::white to estimate noise (detector::nRMS)
443 // - Use the estimated noise to whiten data (WSeries<double>::white)
444 // - Store injected waveforms (SaveWaveforms)
445 // - Store whitened data (detector::HoT) to job file (jfile)
446 // - Store estimated noise to job file (detector::nRMS)
447 //
448 
449  // data are loaded from root file
451  return DataConditioning(iname, ifactor);
452  // if 2G analysis istage==CWB_STAGE_SUPERCLUSTER then skip data conditioning
453  if(istage==CWB_STAGE_SUPERCLUSTER) return;
454 
455  PrintStageInfo(CWB_STAGE_CSTRAIN,"cwb2G::DataConditioning");
456 
457  char info[256];
462  TDirectory* cdrms=NULL;
463  TDirectory* cdcstrain=NULL;
464  double factor=cfg.factors[ifactor];
465 
466  int layers_high = 1<<cfg.l_high;
467  WDM<double> WDMwhite(layers_high,layers_high,6,10); // set whitening WDM
468  int layers = rateANA/8;
469  WDM<double> WDMlpr(layers,layers,6,10); // set LPE filter WDM
470 
471  // check if whitening WDM filter lenght is less than cwb scratch
472  double wdmFLen = double(WDMwhite.m_H)/rateANA; // sec
473  if(wdmFLen > cfg.segEdge+0.001) {
474  cout << endl;
475  cout << "cwb2G::DataConditioning : Error - filter scratch must be <= cwb scratch!!!" << endl;
476  cout << "filter length : " << wdmFLen << " sec" << endl;
477  cout << "cwb scratch : " << cfg.segEdge << " sec" << endl;
478  EXIT(1);
479  } else {
480  cout << "WDM filter max length = " << wdmFLen << " (sec)" << endl;
481  }
482 
483  // open input job file
484  TFile* ifile = ((istage==CWB_STAGE_STRAIN)&&(iname!="")) ? new TFile(iname) : NULL;
485  // open temporary job file
486  jfile = new TFile(jname, "UPDATE");
487  if(jfile==NULL||!jfile->IsOpen())
488  {cout << "cwb2G::DataConditioning - Error : file " << jname << " not found" << endl;EXIT(1);}
489 
490  // create cstrain,rms root dirs
492  TDirectory* dcstrain = (TDirectory*)jfile->Get("cstrain");
493  if(dcstrain==NULL) dcstrain=jfile->mkdir("cstrain");
494  char cdcstrain_name[32];sprintf(cdcstrain_name,"cstrain-f%d",ifactor);
495  cdcstrain=dcstrain->mkdir(cdcstrain_name);
496 
497  TDirectory* drms = (TDirectory*)jfile->Get("rms");
498  if(drms==NULL) drms=jfile->mkdir("rms");
499  char cdrms_name[32];sprintf(cdrms_name,"rms-f%d",ifactor);
500  cdrms=drms->mkdir(cdrms_name);
501  }
502 
503  for(int i=0; i<nIFO; i++) {
504  // read ifo strain from temporary job file
505  if(ifile!=NULL) px = (wavearray<double>*)ifile->Get(TString("strain/")+ifo[i]);
506  else px = (wavearray<double>*)jfile->Get(TString("strain/")+ifo[i]);
507  if(TMath::IsNaN(px->mean()))
508  {cout << "cwb2G::DataConditioning - Error : found NaN in strain data !!!" << endl;EXIT(1);}
509  hot[i] = pD[i]->getHoT();
510  *hot[i] = *px; delete px;
511 
512  if(cfg.simulation) {
513  // read mdc data from temporary job file
514  if(ifile!=NULL) px = (wavearray<double>*)ifile->Get(TString("mdc/")+ifo[i]);
515  else px = (wavearray<double>*)jfile->Get(TString("mdc/")+ifo[i]);
516  if(TMath::IsNaN(px->mean()))
517  {cout << "cwb2G::DataConditioning - Error : found NaN in MDC data !!!" << endl;EXIT(1);}
518 
519  if(cfg.simulation==3) { // time shift : factor is the shift time
520  int nshift = int(factor*px->rate()); // number of shifted samples
521  wavearray<double> pX = *px;(*px)=0; // temporary array
522  int jstart = nshift<0 ? -nshift : 0;
523  int jstop = nshift<0 ? px->size() : px->size()-nshift;
524  for(int j=jstart;j<jstop;j++) px->data[j+nshift] = pX.data[j];
525 
526  double tshift=nshift/px->rate(); // time shift (sec)
527  // take into account of the previous applied time shift
528  tshift = ifactor==0 ? tshift : tshift-int(cfg.factors[ifactor-1]*px->rate())/px->rate();
529 
530  // tshift saved injected waveforms
531  for(int k=0; k<(int)pD[i]->IWFP.size(); k++) {
532  wavearray<double>* pwf = pD[i]->IWFP[k];
533  pwf->start(pwf->start()+tshift);
534  }
535  // tshift saved central times
536  for(int k=0; k<(int)pD[i]->TIME.size(); k++) pD[i]->TIME[k]+=tshift;
537 
538  // shift times stored in the NET.mdcList & NET.mdcTime
539  if(i==0) {
540  vector<TString> ifos(nIFO);
541  for(int n=0;n<nIFO;n++) ifos[n]=ifo[n];
542  TB.shiftBurstMDCLog(NET.mdcList, ifos, tshift);
543  for(int k=0;k<(int)NET.mdcTime.size();k++) NET.mdcTime[k]+=tshift;
544  }
545  xM = *px; // copy MDC to temporary wavearray
546  } else if(cfg.simulation==4) {
547  xM = *px; // copy MDC to temporary wavearray
548  } else {
549  xM = *px; // copy MDC to temporary wavearray
550  (*px)*=factor;
551  }
552  hot[i]->add(*px);
553  delete px;
554  }
555 
556  if(bplugin)
558 
559  // 2G Data Conditioning & Whitening
560 
561  if(!cfg.dcPlugin) { // built in data conditioning
562  pTF[i] = pD[i]->getTFmap();
563 
564  // regression
565  pTF[i]->Forward(*hot[i],WDMlpr);
566  regression rr(*pTF[i],const_cast<char*>("target"),1.,cfg.fHigh);
567  rr.add(*hot[i],const_cast<char*>("target"));
572  *hot[i] = rr.getClean();
573 
574  // whitening
575  pTF[i]->Forward(*hot[i],WDMwhite);
576  pTF[i]->setlow(cfg.fLow);
577  pTF[i]->sethigh(cfg.fHigh);
578  pD[i]->white(cfg.whiteWindow,0,cfg.segEdge,cfg.whiteStride); // calculate noise rms
579  pD[i]->nRMS.bandpass(16.,0.,1); // high pass filtering at 16Hz
580  pTF[i]->white(pD[i]->nRMS,1); // whiten 0 phase WSeries
581  pTF[i]->white(pD[i]->nRMS,-1); // whiten 90 phase WSeries
582  if(cfg.simulation) { // estimated whitened MDC parms
583  wM.Forward(xM,WDMwhite);
584  wM.setlow(cfg.fLow);
585  wM.sethigh(cfg.fHigh);
586  // zero f<fLow to avoid whitening issues when psd noise is not well defined for f<fLow
587  int layers = wM.maxLayer();
588  for(int j=0;j<layers;j++) if(wM.frequency(j)<cfg.fLow) {
589  double layer = j+0.01; // -epsilon select 0 layer for 90 phase
590  wM.getLayer(x, layer);x=0;wM.putLayer(x, layer); // 0 phase
591  wM.getLayer(x,-layer);x=0;wM.putLayer(x,-layer); // 90 phase
592  }
593  // compute mdc snr and save whiten waveforms
594  pD[i]->setsim(wM,NET.getmdcTime(),cfg.iwindow/2.,cfg.segEdge,true);
595  }
596  WSeries<double> wtmp = *pTF[i];
597  pTF[i]->Inverse();
598  wtmp.Inverse(-2);
599  *hot[i] = *pTF[i];
600  *hot[i] += wtmp;
601  *hot[i] *= 0.5;
602  // add infos to history
603  sprintf(info,"-IFO:%d-RMS:%g",i,hot[i]->rms());
604  PrintAnalysisInfo(CWB_STAGE_CSTRAIN,"cwb2G::DataConditioning",info,false);
605  } else { // data conditioning is provided by the user plugin
606  char cmd[128];
607  // export to CINT variables
608  sprintf(cmd,"gRATEANA = %lu;",rateANA); EXPORT(size_t,gRATEANA,cmd);
609  sprintf(cmd,"gMDC = %p;",&xM); EXPORT(void*,gMDC,cmd);
610  if(bplugin)
612  }
613 
614  if(bplugin)
616 
618  SaveWaveforms(jfile, pD[i], ifactor); // write inj waveforms to output job file
619  }
620 
621  if(jobfOptions&CWB_JOBF_SAVE_CSTRAIN) {
622  cdcstrain->cd();gwavearray<double> ghi(*hot[i]);ghi.Write(ifo[i]);
623  cdrms->cd();pD[i]->nRMS.Write(ifo[i]);
624  }
625 
626  cout<<"After "<<ifo[i]<<" data conditioning"<<endl;
627  gSystem->Exec("/bin/date"); GetProcInfo();
628 
629  if(singleDetector) {
630  *pD[1]=*pD[0];
631  // copy detector data not implemented in the copy operator
632  pD[1]->HRSS = pD[0]->HRSS;
633  pD[1]->ISNR = pD[0]->ISNR;
634  pD[1]->FREQ = pD[0]->FREQ;
635  pD[1]->BAND = pD[0]->BAND;
636  pD[1]->TIME = pD[0]->TIME;
637  pD[1]->TDUR = pD[0]->TDUR;
638  pD[1]->IWFID = pD[0]->IWFID;
639  pD[1]->IWFP = pD[0]->IWFP;
640  pD[1]->RWFID = pD[0]->RWFID;
641  pD[1]->RWFP = pD[0]->RWFP;
642  break;
643  }
644  }
645  if(ifile!=NULL) ifile->Close();
646  jfile->Close();
647 
648  xM.resize(0); wM.resize(0); x.resize(0);
649 
650  // strains and mdc data are removed if not set in the jobfOptions (only for the last factor)
651  int ioffset = (cfg.simulation==4) ? int(cfg.factors[0]) : 0; // ifactor offset
652  if(ifactor==ioffset+cfg.nfactor-1) { // the last factor
653  vector<TString> delObjList;
654  if(!(jobfOptions&CWB_JOBF_SAVE_STRAIN)) delObjList.push_back("strain");
655  if(cfg.simulation && !(jobfOptions&CWB_JOBF_SAVE_MDC)) delObjList.push_back("mdc");
656  FileGarbageCollector(jname,"",delObjList);
657  }
658 
659  return;
660 }
661 
662 void
664 //
665 // Read Conditioned Data from Job File (from the previous processed stage)
666 //
667 // Loop over detectors
668 // - Read conditioned data
669 //
670 
671  PrintStageInfo(CWB_STAGE_CSTRAIN,"cwb2G::DataConditioning from file");
672 
673  char cdrms_name[32];sprintf(cdrms_name,"rms-f%d",ifactor);
674  char cdcstrain_name[32];sprintf(cdcstrain_name,"cstrain-f%d",ifactor);
675 
676  // data are loaded from input root file
677  TFile* ifile = new TFile(fName);
678  if(ifile==NULL)
679  {cout << "cwb2G::DataConditioning - Error opening root file : " << fName << endl;EXIT(1);}
680  // open temporary job file
681  jfile = new TFile(jname,"UPDATE");
682  if(jfile==NULL||!jfile->IsOpen())
683  {cout << "cwb::DataConditioning - Error opening root file : " << jname << endl;EXIT(1);}
684 
685  // open job name
686  TDirectory* jcdrms = NULL;
687  TDirectory* jcdcstrain = NULL;
689  TDirectory* dcstrain = (TDirectory*)jfile->Get("cstrain");
690  if(dcstrain==NULL) dcstrain=jfile->mkdir("cstrain");
691  jcdcstrain=dcstrain->mkdir(cdcstrain_name);
692 
693  TDirectory* drms = (TDirectory*)jfile->Get("rms");
694  if(drms==NULL) drms=jfile->mkdir("rms");
695  jcdrms=drms->mkdir(cdrms_name);
696  }
697 
698  WSeries<double>* pws=NULL;
699  for(int i=0; i<nIFO; i++) {
700  pTF[i] = pD[i]->getTFmap();
701  pTF[i]->setlow(cfg.fLow);
702  pTF[i]->sethigh(cfg.fHigh);
703  pTF[i]->w_mode=1;
704 
706  LoadWaveforms(ifile, pD[i], ifactor); // read inj waveforms from input job file
707  SaveWaveforms(jfile, pD[i], ifactor); // write inj waveforms to output job file
708  }
709 
710  // restore ctrain
711  ifile->cd();
712  pws = (WSeries<double>*)ifile->Get(TString("cstrain/")+cdcstrain_name+"/"+pD[i]->Name);
713  if(pws==NULL)
714  {cout << "cwb2G::DataConditioning - Error : cstrain not present, job terminated!!!" << endl;EXIT(1);}
715  if(jobfOptions&CWB_JOBF_SAVE_CSTRAIN)
716  {jfile->cd();jcdcstrain->cd();pws->Write(ifo[i]);}
717  hot[i] = pD[i]->getHoT();
718  *hot[i]=*pws;
719  *pTF[i]=*hot[i];
720  delete pws;
721 
722  // restore strain rms
723  ifile->cd();
724  pws = (WSeries<double>*)ifile->Get(TString("rms/")+cdrms_name+"/"+pD[i]->Name);
725  if(pws==NULL)
726  {cout << "cwb2G::DataConditioning - Error : strain rms not present, job terminated!!!" << endl;EXIT(1);}
727  if(jobfOptions&CWB_JOBF_SAVE_CSTRAIN)
728  {jfile->cd();jcdcstrain->cd();jcdrms->cd();pws->Write(ifo[i]);}
729  pD[i]->nRMS=*pws;;
730  delete pws;
731 
732  if(singleDetector) {
733  *pD[1]=*pD[0];
734  // copy detector data not implemented in the copy operator
735  pD[1]->HRSS = pD[0]->HRSS;
736  pD[1]->ISNR = pD[0]->ISNR;
737  pD[1]->FREQ = pD[0]->FREQ;
738  pD[1]->BAND = pD[0]->BAND;
739  pD[1]->TIME = pD[0]->TIME;
740  pD[1]->TDUR = pD[0]->TDUR;
741  pD[1]->IWFID = pD[0]->IWFID;
742  pD[1]->IWFP = pD[0]->IWFP;
743  pD[1]->RWFID = pD[0]->RWFID;
744  pD[1]->RWFP = pD[0]->RWFP;
745  break;
746  }
747  }
748 
749  if(jfile!=NULL) jfile->Close();
750  ifile->Close();
751  return;
752 }
753 
754 void
756 //
757 // Select the significant pixels
758 //
759 // Loop over resolution levels (nRES)
760 // - Loop over detectors (cwb::nIFO)
761 // - Compute the maximum energy of TF pixels (WSeries<double>::maxEnergy)
762 // - Set pixel energy selection threshold (network::THRESHOLD)
763 // - Loop over time lags (network::nLag)
764 // - Select the significant pixels (network::getNetworkPixels)
765 // - Single resolution clustering (network::cluster)
766 // - Store selected pixels to job file (netcluster::write)
767 //
768 
769  // if 2G analysis istage>=CWB_STAGE_COHERENCE then skip coherence
770  if(istage>=CWB_STAGE_COHERENCE) return;
771 
772  PrintStageInfo(CWB_STAGE_COHERENCE,"cwb2G::Coherence");
773 
774  char info[256];
775  double Eo;
776  netcluster* pwc;
777  netcluster wc;
778 
779  // used to build sparse map
780  SSeries<double> SS;
781  std::vector<SSeries<double> > vSS;
782  for(int n=0; n<nIFO; n++) vSS.push_back(SS);
784 
785  // open temporary job file
786  jfile = new TFile(jname,"UPDATE");
787  if(jfile==NULL||!jfile->IsOpen())
788  {cout << "cwb2G::Coherence - Error : file " << jname << " not found" << endl;EXIT(1);}
789 
790  // create sparse directories in the job root file to store sparse TF maps
791  TDirectory* sdir = (TDirectory*)jfile->Get("csparse");
792  if(sdir==NULL) sdir = jfile->mkdir("csparse");
793 
794  if(bplugin) {
795  char sfactor[8];sprintf(sfactor,"%d",ifactor);
796  CWB_Plugin(jfile,&cfg,&NET,NULL,sfactor,CWB_PLUGIN_ICOHERENCE);
797  }
798 
799  if(!cfg.cohPlugin) { // built in coherence stage
800  TStopwatch watchCoh; // coherence benchmark
801  int upN = rateANA/1024; if(upN<1) upN=1; // calculate upsample factor
802 
803  for(int i=0; i<nRES; i++) { // loop over TF resolutions
804  watchCoh.Start();
805  // print level infos
806  int level=cfg.l_high-i;
807  int layers = level>0 ? 1<<level : 0;
808  int rate = rateANA>>level;
809  cout << "level : " << level << "\t rate(hz) : " << rate
810  << "\t layers : " << layers << "\t df(hz) : " << rateANA/2./double(1<<level)
811  << "\t dt(ms) : " << 1000./rate << endl;
812 
813  // produce TF maps with max over the sky energy
814  double alp=0;
815  for(int n=0; n<nIFO; n++) {
816  alp+=NET.getifo(n)->getTFmap()->maxEnergy(*hot[n],*pwdm[i],mTau,upN,NET.pattern);
817  // restore the frequency boundaries changed by the maxEnergy call
818  NET.getifo(n)->getTFmap()->setlow(cfg.fLow);
820  if(singleDetector) {
821  *(NET.getifo(1)->getTFmap()) = *(NET.getifo(0)->getTFmap());
822  break;
823  }
824  }
825 
826  if(bplugin) { // call user plugin
827  char cmd[128];
828  // export resolution level to CINT
829  sprintf(cmd,"gILEVEL = %lu;",level); EXPORT(size_t,gILEVEL,cmd);
831  }
832 
833  // threshold on pixel energy
834  alp /= nIFO;
835  if(NET.pattern!=0) {
836  Eo = NET.THRESHOLD(cfg.bpp,alp);
837  } else {
838  Eo = NET.THRESHOLD(cfg.bpp);
839  }
840  cout.precision(5);
841  cout<<"thresholds in units of noise variance: Eo="<<Eo<<" Emax="<<Eo*2<<endl;
842  // add infos to history
843  sprintf(info,"-RES:%d-THR:%g",i,Eo);
844  PrintAnalysisInfo(CWB_STAGE_COHERENCE,"cwb2G::Coherence",info,false);
845 
846  double TL = NET.setVeto(cfg.iwindow);
847  cout<<"live time in zero lag: "<<TL<<endl; // set veto array
848  if(TL <= 0.) {froot->Close();EXIT(1);} // exit if live time is zero
849 
850  if(bplugin) { // call user plugin
851  char cmd[128];
852  // export resolution level to CINT
853  sprintf(cmd,"gILEVEL = %lu;",level); EXPORT(size_t,gILEVEL,cmd);
855  }
856 
857 
858  // init sparse table (used in supercluster stage : set the TD filter size)
859  pwdm[i]->setTDFilter(cfg.TDSize, 1);
860  for(int n=0; n<nIFO; n++) {
861  WS[n].Forward(*hot[n],*pwdm[i]);
862  vSS[n].SetMap(&WS[n]);
863  vSS[n].SetHalo(mTau);
864  if(singleDetector) {
865  WS[1]=WS[0];
866  vSS[1].SetMap(&WS[1]);
867  vSS[1].SetHalo(mTau);
868  break;
869  }
870  }
871 
872  // select pixels
873  if(cfg.simulation) {cout<<"ifactor|clusters|pixels ";cout.flush();}
874  else {cout<<"lag|clusters|pixels "; cout.flush();}
875  int csize_tot=0;int psize_tot=0;
876  for(int j=0; j<(int)NET.nLag; j++) {
877 
878  NET.getNetworkPixels(j,Eo);
879  pwc = NET.getwc(j);
880  if(NET.pattern!=0) {
881  NET.cluster(2,3);
882  wc.cpf(*(pwc),false);
883  wc.select(const_cast<char*>("subrho"),SELECT_SUBRHO);
884  wc.select(const_cast<char*>("subnet"),SELECT_SUBNET);
885  pwc->cpf(wc,false);
886  } else NET.cluster(1,1);
887  // store cluster into temporary job file
888  int cycle = cfg.simulation ? ifactor : Long_t(pwc->shift);
889  pwc->write(jfile,"coherence","clusters",0,cycle);
890  pwc->write(jfile,"coherence","clusters",-1,cycle,-(rateANA>>(cfg.l_high-i)));
891  cout<<cycle<<"|"<<pwc->csize()<<"|"<<pwc->size()<<" ";cout.flush();
892  csize_tot+=pwc->csize(); psize_tot+=pwc->size();
893 
894  // add core pixels to sparse table
895  for(int n=0; n<nIFO; n++) vSS[n].AddCore(n,pwc);
896 
897  pwc->clear();
898  }
899  // write clusters to the job file & free trees memory
900  jfile->Write();
901  TList* fList = gDirectory->GetList();
902  TObject *obj;
903  TIter nextobj(fList);
904  while ((obj = (TObject *) nextobj())) {
905  if(TString(obj->GetName()).Contains("clusters")) delete obj;
906  }
907  // update sparse table (halo added to core pixels)
908  for(int n=0; n<nIFO; n++) {vSS[n].UpdateSparseTable();}
909  // write sparse table to job file
910  sdir->cd();
911  for(int n=0; n<nIFO; n++) {
912  vSS[n].Clean();
913  char wsname[32];
914  if(cfg.simulation) sprintf(wsname,"%s-level:%d:%d",ifo[n],ifactor,cfg.l_high-i);
915  else sprintf(wsname,"%s-level:%d",ifo[n],cfg.l_high-i);
916  vSS[n].Write(wsname,TObject::kWriteDelete);
917  }
918  // print benchmark infos
919  watchCoh.Stop(); cout<<endl;
920  PrintElapsedTime(watchCoh.RealTime(),"Coherence Elapsed Time for this level : ");
921  cout<<endl; watchCoh.Reset();
922  // add infos to history
923  sprintf(info,"-RES:%d-CSIZE:%d-PSIZE:%d",i,(int)csize_tot/NET.nLag,(int)psize_tot/NET.nLag);
924  PrintAnalysisInfo(CWB_STAGE_COHERENCE,"cwb2G::Coherence",info,false);
925  }
926  }
927 
928  if(bplugin) {
929  char sfactor[8];sprintf(sfactor,"%d",ifactor);
930  CWB_Plugin(jfile,&cfg,&NET,NULL,sfactor,CWB_PLUGIN_OCOHERENCE);
931  }
932 
933  jfile->Close();
934 
935  return;
936 }
937 
938 void
940 //
941 // Multi resolution clustering & Rejection of the sub-threshold clusters
942 //
943 // Loop over time lags
944 // - Read clusters from job file (netcluster::read)
945 // - Multi resolution clustering (netcluster::supercluster)
946 // - Compute for each pixel the time delay amplitudes (netcluster::loadTDampSSE)
947 // - Rejection of the sub-threshold clusters (network::subNetCut)
948 // - Defragment clusters (netcluster::defragment)
949 // - Store superclusters to job file (netcluster::write)
950 // Build & Write to job file the sparse TF maps (WriteSparseTFmap)
951 //
952 
953  // if 2G analysis istage>=CWB_STAGE_SUPERCLUSTER then skip super cluster analysis
954  if(istage>=CWB_STAGE_SUPERCLUSTER) return;
955 
956  PrintStageInfo(CWB_STAGE_SUPERCLUSTER,"cwb2G::SuperCluster");
957 
958  char info[256];
959 
960  // open input job file
961  TFile* ifile = ((istage==CWB_STAGE_COHERENCE)&&(iname!="")) ? new TFile(iname) : NULL;
962  // open temporary job file
963  jfile = new TFile(jname,"UPDATE");
964  if(jfile==NULL||!jfile->IsOpen())
965  {cout << "cwb2G::SuperCluster - Error opening : " << jname << endl;EXIT(1);}
966 
967  // create prod/sim/lag directories in the output root file to store dignostic histograms
968  if(froot==NULL) {cout << "cwb2G::SuperCluster - Error opening : " << froot->GetPath() << endl;EXIT(1);}
969  TDirectory* wdir = (TDirectory*)froot->Get("histogram");
970  if(wdir==NULL) wdir = froot->mkdir("histogram");
971 
972  // decrease skymap resolution to improve subNetCut performances
973  double skyres=0;
975  else skyres = cfg.angle<MIN_SKYRES_ANGLE ? MIN_SKYRES_ANGLE : 0;
976  if(skyres) {
977  if(cfg.healpix) NET.setSkyMaps(int(skyres));
978  else NET.setSkyMaps(skyres,cfg.Theta1,cfg.Theta2,cfg.Phi1,cfg.Phi2);
979  NET.setAntenna();
981  // the down resampling of the skymask works only for the built-in skymask
982  if(strlen(cfg.skyMaskFile)>0) SetSkyMask(&NET,&cfg,cfg.skyMaskFile,'e',skyres);
983  if(strlen(cfg.skyMaskCCFile)>0) SetSkyMask(&NET,&cfg,cfg.skyMaskCCFile,'c',skyres);
984  }
985 
986  for(int i=0; i<nIFO; i++) pTF[i] = pD[i]->getTFmap();
987  // set low-rate TD filters
988  for(int k=0;k<nRES;k++) pwdm[k]->setTDFilter(cfg.TDSize, 1);
989  // read sparse map from job file
990  cout << "Loading sparse TF map ... " << endl;
991  for(int n=0; n<nIFO; n++) {
992  pD[n]->sclear(); // clear vector with sparse maps
993  for(int i=0; i<nRES; i++) {
994  char swname[32];
995  if(cfg.simulation) sprintf(swname,"csparse/%s-level:%d:%d",ifo[n],ifactor,i+cfg.l_low);
996  else sprintf(swname,"csparse/%s-level:%d",ifo[n],i+cfg.l_low);
997  SSeries<double>* psw;
998  if(ifile!=NULL) psw = (SSeries<double>*)ifile->Get(swname);
999  else psw = (SSeries<double>*)jfile->Get(swname);
1000  if(psw==NULL) {
1001  cout << "cwb2G::SuperCluster : sparse map " << swname
1002  << " not exist in job file" << endl;EXIT(1);
1003  }
1004  SSeries<double> SS = *psw;
1005  pD[n]->vSS.push_back(SS);
1006  delete psw;
1007  }
1008  cout<<endl;
1009  }
1010 
1011  // export to CINT ifile (used by plugins)
1012  char cmd[128];
1013  if(ifile!=NULL) sprintf(cmd,"gIFILE = (void*)%p;",ifile);
1014  else sprintf(cmd,"gIFILE = NULL;");
1015  EXPORT(void*,gIFILE,cmd);
1016  // in supercluster plugin
1018 
1019  if(!cfg.scPlugin) { // built in supercluster function
1020 
1021  int nevt = 0;
1022  int nnn = 0;
1023  int mmm = 0;
1024  size_t count = 0;
1025  netcluster wc;
1026  netcluster* pwc;
1027 
1028  for(int j=0; j<(int)lags; j++) {
1029 
1030  int cycle = cfg.simulation ? ifactor : Long_t(NET.wc_List[j].shift);
1031 
1032  // read cluster metadata
1033  if(ifile!=NULL) wc.read(ifile,"coherence","clusters",0,cycle);
1034  else wc.read(jfile,"coherence","clusters",0,cycle);
1035  // read clusters from temporary job file, loop over TF resolutions
1036  if(ifile!=NULL) {
1037  for(int i=nRES-1; i>=0; i--) // reverse loop is faster loading cluster (?)
1038  wc.read(ifile,"coherence","clusters",-2,cycle,-(rateANA>>(i+cfg.l_low)));
1039  } else {
1040  for(int i=nRES-1; i>=0; i--) // reverse loop is faster loading cluster (?)
1041  wc.read(jfile,"coherence","clusters",-2,cycle,-(rateANA>>(i+cfg.l_low)));
1042  }
1043  cout<<"-----------------------------------------------------"<<endl;
1044  char cycle_name[32];
1045  if(cfg.simulation) sprintf(cycle_name," factor[%d]=%g",ifactor,cfg.factors[ifactor]);
1046  else sprintf(cycle_name," lag=%d",cycle);
1047  cout<<"-> Processing " <<cycle_name<<" ..."<<endl;
1048  cout<<" --------------------------------------------------"<<endl;
1049  cout<<" coher clusters|pixels : "
1050  <<setfill(' ')<<setw(6)<<wc.csize()<<"|"<<wc.size()<<endl;
1051 
1052  // supercluster analysis
1053  if(cfg.l_high==cfg.l_low) wc.pair=false; // if only one resolution is used pair is false
1054  if(NET.pattern!=0) wc.pair=false; // if other than pattern=0 - allow one resolution cluster
1055  wc.supercluster('L',NET.e2or,cfg.TFgap,false); // likehood2G
1056  cout<<" super clusters|pixels : "
1057  <<setfill(' ')<<setw(6)<<wc.esize(0)<<"|"<<wc.psize(0)<<endl;
1058 
1059  // defragmentation for pattern != 0
1060  if(NET.pattern!=0) {
1061  wc.defragment(cfg.Tgap,cfg.Fgap);
1062  cout<<" defrag clusters|pixels : "
1063  <<setfill(' ')<<setw(6)<<wc.esize(0)<<"|"<<wc.psize(0)<<"\n";
1064  }
1065 
1066  // copy selected clusters to network
1067  pwc = NET.getwc(j);
1068  pwc->cpf(wc, false);
1069 
1070  // apply subNetCut() only for pattern=0 || cfg.subnet>0 || cfg.subcut>0
1071  if(NET.pattern==0 || cfg.subnet>0 || cfg.subcut>0) {
1072  NET.setDelayIndex(hot[0]->rate());
1073  pwc->setcore(false);
1074  int psel = 0;
1075  while(1) {
1076  count = pwc->loadTDampSSE(NET, 'a', cfg.BATCH, cfg.LOUD);
1077  psel += NET.subNetCut((int)j,cfg.subnet,cfg.subcut,NULL);
1078  int ptot = pwc->psize(1)+pwc->psize(-1);
1079  double pfrac = ptot>0 ? double(psel)/double(ptot) : 0.;
1080  //cout<<"selected pixels: "<<psel<<", fraction: "<<pfrac<< endl;
1081  if(count<10000) break;
1082  }
1083  cout<<" subnet clusters|pixels : "
1084  <<setfill(' ')<<setw(6)<<NET.events()<<"|"<<pwc->psize(-1)<<"\n";
1085  }
1086  if(NET.pattern==0) {
1087  // defragmentation
1088  pwc->defragment(cfg.Tgap,cfg.Fgap);
1089  cout<<" defrag clusters|pixels : "
1090  <<setfill(' ')<<setw(6)<<NET.events()<<"|"<<pwc->psize(-1)<<"\n";
1091  }
1092 
1093  nevt += NET.events();
1094  nnn += pwc->psize(-1);
1095  mmm += pwc->psize(1)+pwc->psize(-1);
1096 
1097  // store cluster into temporary job file [NEWSS]
1098  pwc->write(jfile,"supercluster","clusters",0,cycle);
1099  pwc->write(jfile,"supercluster","clusters",-1,cycle);
1100  //cout<<cycle<<"|"<<pwc->csize()<<"|"<<pwc->size()<<" ";cout.flush();
1101 
1102  pwc->clear();
1103  cout<<endl;cout.flush();
1104  }
1105 
1106  // print final statistic
1107  cout<<endl<<"Supercluster done"<<endl;
1108  if(mmm) cout<<"total clusters|pixels|frac : "
1109  <<setfill(' ')<<setw(6)<<nevt<<"|"<<nnn<<"|"<<nnn/double(mmm)<<"\n";
1110  else cout<<"total clusters : "<<nevt<<"\n";
1111  cout<<endl;cout.flush();
1112 
1113  // add infos to history
1114  if(mmm) sprintf(info,"-NEVT:%d-PSIZE:%d-FRAC:%g",nevt,nnn,nnn/double(mmm));
1115  else sprintf(info,"-NEVT:%d",nevt);
1116  PrintAnalysisInfo(CWB_STAGE_SUPERCLUSTER,"cwb2G::SuperCluster",info,false);
1117  }
1118 
1119  // out supercluster plugin
1121 
1122  // restore skymap resolution
1123  if(skyres) {
1124  if(cfg.healpix) NET.setSkyMaps(int(cfg.healpix));
1126  NET.setAntenna();
1128  if(strlen(cfg.skyMaskFile)>0) SetSkyMask(&NET,&cfg,cfg.skyMaskFile,'e');
1129  if(strlen(cfg.skyMaskCCFile)>0) SetSkyMask(&NET,&cfg,cfg.skyMaskCCFile,'c');
1130  }
1131 
1132  if(ifile!=NULL) {
1133  for(int i=0; i<nIFO; i++) {
1135  LoadWaveforms(ifile, pD[i], ifactor); // read inj waveforms from input job file
1136  SaveWaveforms(jfile, pD[i], ifactor); // write inj waveforms to output job file
1137  }
1138  }
1139  }
1140 
1141  jfile->Write();
1142  jfile->Close();
1143 
1144  // clear vector with sparse maps
1145  for(int n=0; n<nIFO; n++) pD[n]->sclear();
1146  // write sparse table to job file
1147  jfile = new TFile(jname,"UPDATE","",9); // compression level 9
1148  WriteSparseTFmap(jfile, ifactor, "sparse", "supercluster");
1149  jfile->Close();
1150 
1151  // job root file garbage collector
1152  vector<TString> delObjList;
1153  // coherence clusters is removed if not set in the jobfOptions
1155  delObjList.push_back("coherence");
1156  }
1157  // cstrains and rms data are removed if not set in the jobfOptions
1159  char cdrms_name[32];sprintf(cdrms_name,"rms/rms-f%d",ifactor);
1160  char cdcstrain_name[32];sprintf(cdcstrain_name,"cstrain/cstrain-f%d",ifactor);
1161  delObjList.push_back(cdrms_name);
1162  delObjList.push_back(cdcstrain_name);
1163  }
1164  // sparse maps are removed if not set in the jobfOptions (only for the last factor)
1165  if(ifactor==cfg.nfactor-1) { // the last factor
1166  if(!(jobfOptions&CWB_JOBF_SAVE_CSPARSE)) delObjList.push_back("csparse");
1167  }
1168  FileGarbageCollector(jname,"",delObjList);
1169 
1170  return;
1171 }
1172 
1173 bool
1174 cwb2G::Likelihood(int ifactor, char* ced_dir, netevent* netburst, TTree* net_tree, char* outDump) {
1175 //
1176 // Event reconstruction & parameters estimation
1177 //
1178 // Read sparse map from job file
1179 // Loop over time lags
1180 // - Read cluster list from job file (netcluster::read)
1181 // - Loop over cluster list
1182 // - Read pixels (netcluster::read)
1183 // - Compute for each pixel the time delay amplitudes (netcluster::loadTDampSSE)
1184 // - Event reconstruction+parameter estimation (network::likelihood2G)
1185 // - Store event parameters to job file (netevent::output2G)
1186 // - If(config::cedDump>0) Generate Coherent Event Display (CWB::ced)
1187 //
1188 
1189  // if 2G analysis istage>=CWB_STAGE_LIKELIHOOD then skip likelihood analysis
1190  if(istage>=CWB_STAGE_LIKELIHOOD) return false;
1191 
1192  PrintStageInfo(CWB_STAGE_LIKELIHOOD,"cwb2G::Likelihood");
1193 
1194  char info[256];
1195  netcluster* pwc;
1196  int ceddir = 0; // flag if ced directory exists
1197  double factor = cfg.factors[ifactor];
1198 
1200  if(singleDetector) NET.setIndexMode(cfg.mode); // when nIFO=1 exclude duplicate delay configurations
1201 
1202  if(bplugin) {
1203  // export to CINT variables
1204  EXPORT(float*,gSLAGSHIFT,TString::Format("gSLAGSHIFT = (float*)%p;",slagShift).Data());
1205  }
1206 
1207  // open temporary job file
1208  TString xname = ((istage==CWB_STAGE_SUPERCLUSTER)&&(iname!="")) ? iname : jname;
1209  jfile = (xname==jname) ? new TFile(xname,"UPDATE") : new TFile(xname);
1210  if(jfile==NULL||!jfile->IsOpen())
1211  {cout << "cwb2G::Likelihood - Error : file " << xname.Data() << " not found" << endl;EXIT(1);}
1212 
1214  // restore in detector object the inj waveforms from input job file
1215  for(int i=0; i<nIFO; i++) LoadWaveforms(jfile, pD[i], ifactor);
1216  }
1218  // save to job file whitened inj/rec waveforms
1219  TFile* ifile = jfile;
1220  if(xname!=jname) {
1221  ifile = new TFile(jname,"UPDATE");
1222  if(ifile==NULL||!ifile->IsOpen()) {
1223  cout << "cwb2G::Likelihood - Error : file " << jname << " not found" << endl; EXIT(1); }
1224  }
1225  int wfSAVE = 0;
1226  if(jobfOptions&CWB_JOBF_SAVE_WFINJ) wfSAVE+=1;
1227  if(jobfOptions&CWB_JOBF_SAVE_WFREC) wfSAVE+=2;
1228  for(int i=0; i<nIFO; i++) SaveWaveforms(ifile, pD[i], ifactor, wfSAVE);
1229  ifile->Write();
1230  if(xname!=jname) ifile->Close();
1231  }
1232 
1233  // set low-rate TD filters
1234  for(int k=0; k<nRES; k++) pwdm[k]->setTDFilter(cfg.TDSize, cfg.upTDF);
1236 
1237  // read sparse map from job file
1238  cout << "Loading sparse TF map ... " << endl;
1239  for(int n=0; n<nIFO; n++) {
1240  pD[n]->sclear(); // clear vector with sparse maps
1241  for(int i=0; i<nRES; i++) {
1242  char swname[32];
1243  if(cfg.simulation) sprintf(swname,"sparse/%s-level:%d:%d",ifo[n],ifactor,i+cfg.l_low);
1244  else sprintf(swname,"sparse/%s-level:%d",ifo[n],i+cfg.l_low);
1245  SSeries<double>* psw = (SSeries<double>*)jfile->Get(swname);
1246  if(psw==NULL) {
1247  cout << "cwb2G::Likelihood : sparse map " << swname
1248  << " not exist in job file" << endl;EXIT(1);
1249  }
1250  SSeries<double> SS = *psw;
1251  pD[n]->vSS.push_back(SS);
1252  delete psw;
1253  }
1254  cout<<endl;
1255  }
1256 
1257  if(cfg.dump && (!cfg.outPlugin)) // write header to ascii dump file
1258  {netburst->dopen(outDump,const_cast<char*>("a"),true); netburst->dclose();}
1259 
1260  int LRETRY = 0; // number of likelihood2G retry for each event
1261  int NEVENTS = 0; // total recontructed events for all lags
1262  for(int j=0; j<(int)lags; j++) {
1263 
1264  // init likelihood plugin
1265  EXPORT(int,gLRETRY,"gLRETRY = 0;") // needed to avoid error msg when gLRETRY is not defined in the plugin
1266  if(bplugin) {
1267  EXPORT(int,gRET,"gRET = 0;") // needed to avoid error msg when gRET is not defined in the plugin
1268  char strcycle[8];sprintf(strcycle,"%d",cfg.simulation==0 ? j : ifactor);
1269  CWB_Plugin(jfile,&cfg,&NET,NULL,strcycle,CWB_PLUGIN_ILIKELIHOOD);
1270  // get gRET from plugin
1271  int gRET=0; IMPORT(int,gRET) if(gRET==-1) continue;
1272  }
1273  int gLRETRY=0; IMPORT(int,gLRETRY) LRETRY=gLRETRY;
1274 
1275  int cycle = cfg.simulation ? ifactor : Long_t(NET.wc_List[j].shift);
1276 
1277  pwc = NET.getwc(j);
1278  pwc->cData.clear();
1279 
1280  // read cluster list & metadata netcluster object
1281  vector<int> clist = pwc->read(jfile,"supercluster","clusters",0,cycle);
1282  //pwc->print();
1283 
1284  // print header
1285  char cycle_name[32];
1286  if(cfg.simulation) sprintf(cycle_name," factor[%d]=%g",ifactor,cfg.factors[ifactor]);
1287  else sprintf(cycle_name," lag=%d",cycle);
1288  cout<<"-------------------------------------------------------"<<endl;
1289  cout<<"-> Processing " << clist.size() << " clusters in" << cycle_name<<endl;
1290  cout<<" ----------------------------------------------------"<<endl;cout.flush();
1291 
1292  //int nmax = 1000; // load tdAmp associated to the first nmax loudest pixels
1293  int nmax = -1; // load all tdAmp
1294  int npixels = 0; // total loaded pixels per lag
1295  int nevents = 0; // total recontructed events per lag
1296  int nselected_core_pixels = 0;
1297  int nrejected_weak_pixels = 0; // remove weak glitches
1298  int nrejected_loud_pixels = 0; // remove loud glitches
1299  for(int k=0;k<(int)clist.size();k++) { // loop over the cluster list
1300 
1301  // read pixels & tdAmp into netcluster pwc
1302  pwc->read(jfile,"supercluster","clusters",nmax,cycle,0,clist[k]);
1303 
1304  // likelihood plugin
1306 
1307  wavearray<double> cid = pwc->get((char*)"ID", 0,'S',0); // get cluster ID
1308  int id = size_t(cid.data[cid.size()-1]+0.1);
1309  pwc->setcore(false,id);
1310  pwc->loadTDampSSE(NET, 'a', cfg.BATCH, cfg.BATCH); // attach TD amp to pixels
1311 
1312  int lag = j;
1313 
1314  NET.MRA = true;
1315  int ID = cfg.cedDump ? -id : 0;
1316  int selected_core_pixels = 0;
1317  if(NET.pattern>0) {
1318  selected_core_pixels = NET.likelihoodWP(cfg.search, lag, ID, NULL);
1319  } else {
1320  selected_core_pixels = NET.likelihood2G(cfg.search, lag, ID, NULL);
1321  }
1322  if(!cfg.outPlugin) { // if true then output to root file is provided by the user plugin
1323  double ofactor=0;
1324  if(cfg.simulation==4) ofactor=-factor;
1325  else if(cfg.simulation==3) ofactor=-ifactor;
1326  else ofactor=factor;
1327  if(cfg.dump) netburst->dopen(outDump,const_cast<char*>("a"),false);
1328  netburst->output2G(net_tree,&NET,id,lag,ofactor);
1329  if(cfg.dump) netburst->dclose();
1330  }
1331  int rejected_weak_pixels = 0;
1332  int rejected_loud_pixels = 0;
1333 
1334  bool detected = (bool)(NET.getwc(j)->sCuts[k] == -1);
1335 
1336  // print reconstructed event
1337  cout<<" cluster-id|pixels: "<<setfill(' ')<<setw(5)<<clist[k]<<"|"<<pwc->size()-npixels;
1338  if(detected) cout << "\t -> SELECTED !!!" << endl;
1339  else cout << "\t <- rejected " << endl;
1340  cout.flush();
1341 
1342  // likelihood clusters are stored into temporary job file if set in the jobfOptions
1343  if(((k==0)||detected)&&(jobfOptions&CWB_JOBF_SAVE_LIKELIHOOD)) {
1344  TFile* ifile = jfile;
1345  if(xname!=jname) {
1346  ifile = new TFile(jname,"UPDATE");
1347  if(ifile==NULL||!ifile->IsOpen()) {
1348  cout << "cwb2G::Likelihood - Error : file " << jname << " not found" << endl; EXIT(1); }
1349  }
1350  pwc->write(ifile,"likelihood","clusters",0,cycle);
1351  pwc->write(ifile,"likelihood","clusters",-1,cycle,0,k+1);
1352  if(detected) cout<<"saved"<<endl;cout.flush();
1353  ifile->Write();
1354  if(xname!=jname) ifile->Close();
1355  }
1356 
1357  if(detected) nevents++;
1358  if(gLRETRY==0) npixels=pwc->size();
1359  if(!detected && gLRETRY==LRETRY) {
1360  gLRETRY=0;
1361  EXPORT(int,gLRETRY,TString::Format("gLRETRY = %d;",gLRETRY).Data())
1362  }
1363 
1364  // likelihood plugin
1366 
1367  // ced dump
1368  if(detected&&(cfg.cedDump)) {
1369  TFile* ifile = jfile;
1370  if(xname!=jname) {
1371  ifile = new TFile(jname,"UPDATE");
1372  if(ifile==NULL||!ifile->IsOpen()) {
1373  cout << "cwb2G::Likelihood - Error : file " << jname << " not found" << endl; EXIT(1); }
1374  }
1375  CWB::ced *ced = NULL;
1377  // save ced to temporary job file
1378  cout<<"dump ced to job file ..." <<endl;
1379  TDirectory* cdced = NULL;
1380  cdced = (TDirectory*)ifile->Get("ced");
1381  if(cdced == NULL) cdced = ifile->mkdir("ced");
1382  ced = new CWB::ced(&NET,netburst,cdced);
1383  } else {
1384  cout<<"dump ced to disk ..." <<endl;
1385  ced = new CWB::ced(&NET,netburst,ced_dir);
1386  }
1387  switch(istage) {
1388  case CWB_STAGE_FULL:
1389  case CWB_STAGE_INIT:
1390  // use TF map & inj signals
1392  for(int n=0; n<nIFO; n++) {pTF[n]->setlow(cfg.fLow); pTF[n]->sethigh(cfg.fHigh);}
1393  break;
1394  default:
1395  // use sparse map & inj signals
1397  }
1399  bool fullCED = singleDetector ? false : true;
1400  double ofactor=0;
1401  if(cfg.simulation==4) ofactor=-factor;
1402  else if(cfg.simulation==3) ofactor=-ifactor;
1403  else ofactor=factor;
1404  if(ced->Write(ofactor,fullCED)) ceddir = 1;
1405  delete ced;
1406  if(xname!=jname) ifile->Close();
1407  }
1408 
1409  //pwc->print();
1410  pwc->clean(k+1); // clean time delay amplitudes
1411 
1412  IMPORT(int,gLRETRY)
1413  if(gLRETRY-- > 0) { // clear last cluster in pwc
1414  clist = pwc->read(jfile,"supercluster","clusters",0,cycle);
1415  if(pwc->cList.size()) {
1416  int npix = pwc->cList[id-1].size();
1417  for(int p=0;p<npix;p++) pwc->pList.pop_back();
1418  pwc->cList.pop_back(); pwc->cData.pop_back(); pwc->sCuts.pop_back();
1419  pwc->cRate.pop_back(); pwc->cTime.pop_back(); pwc->cFreq.pop_back();
1420  pwc->sArea.pop_back(); pwc->p_Map.pop_back(); pwc->p_Ind.pop_back();
1421  }
1422  k--;
1423  } else gLRETRY=LRETRY; // every new event gLRETRY is reinitialize to LRETRY
1424  EXPORT(int,gLRETRY,TString::Format("gLRETRY = %d;",gLRETRY).Data())
1425  } // end loop over the cluster list
1426  /*
1427  // print final lag statistic
1428  if(nevents==0)
1429  cout << "--------------------------------------------------------------" << endl;
1430  cout<<endl;
1431  cout<<" total pixels : "<<pwc->size()<<endl;
1432  cout<<" selected_core_pixels : "<<nselected_core_pixels<<endl;
1433  cout<<" rejected_weak_pixels : "<<nrejected_weak_pixels<<endl;
1434  cout<<" rejected_loud_pixels : "<<nrejected_loud_pixels <<endl;
1435  cout<<"-> reconstruct events : "<<nevents<<endl;
1436  cout<<endl;
1437  */
1438  cout<<endl<<endl;cout.flush();
1439  NEVENTS+=nevents;
1440  } // end loop over lags
1441 
1442  // add infos to history
1443  sprintf(info,"-NEVT:%d",NEVENTS);
1444  PrintAnalysisInfo(CWB_STAGE_LIKELIHOOD,"cwb2G::Likelihood",info,false);
1445 
1446  jfile->Close();
1447 
1448  // sparse maps & supercluster clusters are removed if not set in the jobfOptions (only for the last factor)
1449  if(ifactor==cfg.nfactor-1) { // the last factor
1450  vector<TString> delObjList;
1451  // supercluster clusters are removed if not set in the jobfOptions
1452  if(!(jobfOptions&CWB_JOBF_SAVE_SUPERCLUSTER)) delObjList.push_back("supercluster");
1453  if(!(jobfOptions&CWB_JOBF_SAVE_SPARSE)) delObjList.push_back("sparse");
1454  // If CED is saved to the job file than FileGarbageCollector is not applied
1455  // FileGarbageCollector do not preserve the style of the plots
1457  }
1458 
1459  return ceddir;
1460 }
1461 
1462 void
1464 //
1465 // Fill sparse map with cluster pixels and write to job file
1466 //
1467 // jfile : pointer to job file
1468 // ifactor : factor ID
1469 // tdir : directory name which contains the sparse map
1470 // tname : tree name : Ex "coherence" or "supercluster"
1471 //
1472 
1473  // create sparse directories in the job root file to store sparse TF maps
1474  TDirectory* sdir = (TDirectory*)jfile->Get(tdir);
1475  if(sdir==NULL) sdir = jfile->mkdir(tdir);
1476 
1477  int ncore_tot=0;
1478  int ncluster_tot=0;
1479  int ccluster_tot=0;
1480  netcluster wc;
1482  std::vector<SSeries<double> > vSS;
1483  for(int n=0; n<nIFO; n++) vSS.push_back(ss);
1484 
1485  for(int i=0; i<nRES; i++) {
1486  // init sparse table
1487  pwdm[i]->setTDFilter(cfg.TDSize, 1);
1488  for(int n=0; n<nIFO; n++) {
1489  pTF[n] = pD[n]->getTFmap();
1490  pTF[n]->Forward(*hot[n],*pwdm[i]);
1491  vSS[n].SetMap(pTF[n]);
1492  vSS[n].SetHalo(mTau);
1493  if(singleDetector) {
1494  pTF[1] = pD[1]->getTFmap();
1495  *pTF[1] = *pTF[0];
1496  vSS[1].SetMap(pTF[1]);
1497  vSS[1].SetHalo(mTau);
1498  break;
1499  }
1500  }
1501 
1502  for(int j=0; j<(int)lags; j++) {
1503 
1504  int cycle = cfg.simulation ? ifactor : Long_t(NET.wc_List[j].shift);
1505 
1506  // read cluster metadata
1507  wc.read(jfile,tname,"clusters",0,cycle);
1508 
1509  // read pixels & tdAmp into netcluster pwc
1510  if(tname=="coherence") {
1511  wc.read(jfile,tname,"clusters",-2,cycle,-vSS[0].wrate());
1512  } else {
1513  wc.read(jfile,tname,"clusters",-1,cycle,vSS[0].wrate());
1514  }
1515  //cout<<"loaded clusters|pixels: "<<wc.csize()<<"|"<<wc.size()<<endl;
1516 
1517  // add core pixels to sparse table
1518  for(int n=0; n<nIFO; n++) vSS[n].AddCore(n,&wc);
1519  wc.clear();
1520  }
1521 
1522  // update sparse table (halo added to core pixels)
1523  for(int n=0; n<nIFO; n++) {vSS[n].UpdateSparseTable();}
1524 
1525  // compute sparse statistic
1526  int ncore=0; // core pixels
1527  int ncluster=0; // core+halo pixels
1528  int ccluster=0; // core+halo pixels associated to each core pixels
1529  for(int n=0; n<nIFO; n++) {ncore+=vSS[n].GetSparseSize();ncluster+=vSS[n].GetSparseSize(0);}
1530  ccluster = 2*(vSS[0].GetHaloSlice()+vSS[0].GetHaloSlice(true))+1;
1531  ccluster*= 2*vSS[0].GetHaloLayer()+1;
1532  ncore_tot+=ncore; ncluster_tot+=ncluster; ccluster_tot+=2*ccluster*ncore;
1533  int rate = rateANA/(rateANA>>(cfg.l_high-i));
1534  /*
1535  // print sparse statistic (per resolution)
1536  cout << "----------------------- SPARSE STATISTIC / DETECTOR / RES -----------------------" << endl;
1537  cout << "rate|sSlice|sLayer|eSlice|ccluster : " << rate << "|" << vSS[0].GetHaloSlice() << "|"
1538  << vSS[0].GetHaloLayer() << "|" <<vSS[0].GetHaloSlice(1) << "|" << ccluster << endl;
1539  cout << "npix_core|npix_cluster|3*npix_cluster|2*ccluster*npix_core|ratio|sfilesize(byte) : " << endl;
1540  cout << ncore << " | " << ncluster << " | " << 3*ncluster
1541  << " | " << 2*ccluster*ncore << " | " << ((ccluster*ncore)?double(3*ncluster)/(2*ccluster*ncore):0)
1542  << " | " << 3*ncluster*4 << endl;
1543  cout<<endl;
1544  */
1545  // write sparse table to job file
1546  sdir->cd();
1547  for(int n=0; n<nIFO; n++) {
1548  if(!(cfg.cedDump && jstage==CWB_STAGE_FULL)) vSS[n].Clean(); // TF map not cleaned if used by ced
1549  char wsname[32];
1550  if(cfg.simulation) sprintf(wsname,"%s-level:%d:%d",ifo[n],ifactor,cfg.l_high-i);
1551  else sprintf(wsname,"%s-level:%d",ifo[n],cfg.l_high-i);
1552  vSS[n].Write(wsname,TObject::kWriteDelete);
1553  }
1554  }
1555 
1556  // print final sparse statistic
1557  cout << "----------------- FINAL SPARSE STATISTIC / DETECTOR -------------------" << endl;
1558  cout << "npix_core_tot|npix_cluster_tot|3*npix_cluster_tot|ccluster_tot|ratio : " << endl;
1559  cout << ncore_tot << " | " << ncluster_tot << " | " << 3*ncluster_tot
1560  << " | " << ccluster_tot << " | " << (ccluster_tot?double(3*ncluster_tot)/(ccluster_tot):0) << endl;
1561 
1562  return;
1563 }
1564 
1565 void
1567 //
1568 // Fill sparse map with cluster pixels
1569 //
1570 // jfile : pointer to job file
1571 // ifactor : factor ID
1572 // tname : tree name : Ex "coherence" or "supercluster"
1573 //
1574 
1575  netcluster wc;
1576 
1577  SSeries<double> SS;
1578  for(int n=0; n<nIFO; n++) pD[n]->sclear(); // clear vector with sparse maps
1579 
1580  cout << "cwb2G::FillSparseTFmap ..." << endl;
1581  for(int i=0; i<nRES; i++) {
1582 
1583  // init sparse table
1584  for(int n=0; n<nIFO; n++) {
1585  pTF[n] = pD[n]->getTFmap();
1586  pTF[n]->Forward(*hot[n],*pwdm[i]);
1587  pD[n]->vSS.push_back(SS);
1588  pD[n]->vSS[i].SetMap(pTF[n]);
1589  pD[n]->vSS[i].SetHalo(mTau);
1590  if(singleDetector) {
1591  pTF[1] = pD[1]->getTFmap();
1592  *pTF[1] = *pTF[0];
1593  pD[1]->vSS.push_back(SS);
1594  pD[1]->vSS[i].SetMap(pTF[1]);
1595  pD[1]->vSS[i].SetHalo(mTau);
1596  break;
1597  }
1598  }
1599 
1600  for(int j=0; j<(int)lags; j++) {
1601 
1602  int cycle = cfg.simulation ? ifactor : Long_t(NET.wc_List[j].shift);
1603 
1604  // read cluster metadata
1605  wc.read(jfile,"coherence","clusters",0,cycle);
1606 
1607  // read pixels & tdAmp into netcluster pwc
1608  if(tname=="coherence") {
1609  wc.read(jfile,tname,"clusters",-2,cycle,-pD[0]->vSS[i].wrate());
1610  } else {
1611  wc.read(jfile,tname,"clusters",-1,cycle,pD[0]->vSS[i].wrate());
1612  }
1613  //cout<<"loaded clusters|pixels: "<<wc.csize()<<"|"<<wc.size()<<endl;
1614 
1615  // add core pixels to sparse table
1616  for(int n=0; n<nIFO; n++) pD[n]->vSS[i].AddCore(n,&wc);
1617 
1618  wc.clear();
1619  }
1620  // update sparse table (halo added to core pixels)
1621  for(int n=0; n<nIFO; n++) {pD[n]->vSS[i].UpdateSparseTable();}
1622  }
1623  return;
1624 }
1625 
1626 void
1627 cwb2G::SaveWaveforms(TFile* jfile, detector* pD, int ifactor, int wfSAVE) {
1628 //
1629 // write injected waveforms to job file (only for simulation>0)
1630 //
1631 // jfile : pointer to job file
1632 // pD : pointer to detector object
1633 // ifactor : factor ID
1634 // wfSAVE : 1/2/3
1635 // 1 : save injected waveforms
1636 // 2 : save reconstructed waveforms
1637 // 3 : save injected & reconstructed waveforms
1638 //
1639 
1640  if(cfg.simulation==0) return;
1641 
1642  if(jfile==NULL)
1643  {cout << "cwb2G::SaveWaveforms - NULL input root file : " << jname << endl;EXIT(1);}
1644  if(wfSAVE==0)
1645  {cout << "cwb2G::SaveWaveforms - save mode must be 1/2/3 " << endl;EXIT(1);}
1646 
1647  // create wf directory
1648  TDirectory* wf = (TDirectory*)jfile->Get("waveform");
1649  if(wf==NULL) wf=jfile->mkdir("waveform");
1650  char cdwf_name[32];sprintf(cdwf_name,"waveform-f%d",ifactor);
1651  TDirectory* cdwf = (TDirectory*)wf->Get(cdwf_name);
1652  if(cdwf==NULL) cdwf=wf->mkdir(cdwf_name);
1653  cdwf->cd();
1654 
1655  pD->wfsave(wfSAVE); // save waveforms
1656  pD->Write(pD->Name,TObject::kSingleKey);
1657  pD->wfsave(0); // restore default value
1658 
1659  return;
1660 }
1661 
1662 void
1663 cwb2G::LoadWaveforms(TFile* ifile, detector* pD, int ifactor, int wfSAVE) {
1664 //
1665 // restore in detector object the wf waveforms from input job file (only for simulation>0)
1666 //
1667 // ifile : pointer to job file
1668 // pD : pointer to detector object
1669 // ifactor : factor ID
1670 // wfSAVE : 1/2/3
1671 // 1 : restore injected waveforms
1672 // 2 : restore reconstructed waveforms
1673 // 3 : restore injected & reconstructed waveforms
1674 //
1675 
1676  if(cfg.simulation==0) return;
1677 
1678  if(ifile==NULL)
1679  {cout << "cwb2G::LoadWaveforms - NULL input root file : " << iname << endl;EXIT(1);}
1680  if(wfSAVE==0)
1681  {cout << "cwb2G::LoadWaveforms - save mode must be 1/2/3 " << endl;EXIT(1);}
1682 
1683  // read wf waveforms
1684  ifile->cd();
1685  char cdwf_name[32];sprintf(cdwf_name,"waveform/waveform-f%d",ifactor);
1686  detector* pd = (detector*)ifile->Get(TString(cdwf_name)+TString("/")+pD->Name);
1687  if(pd==NULL) return;
1688 
1689  pd->wfsave(wfSAVE); // load waveforms
1690  *pd >> *pD;
1691 
1692  delete pd;
1693 }
1694 
char channelNamesMDC[NIFO_MAX][50]
Definition: config.hh:293
monster wdmMRA
list of pixel pointers for MRA
Definition: network.hh:633
void sethigh(double f)
Definition: wseries.hh:114
detector * getifo(size_t n)
param: detector index
Definition: network.hh:418
size_t rateANA
Definition: cwb.hh:267
char analysis[8]
Definition: config.hh:99
virtual size_t defragment(double T, double F, TH2F *=NULL)
T - maximum time gap in seconds F - maximum frequency gap in Hz.
Definition: netcluster.cc:1275
TString outDump
double iwindow
Definition: config.hh:182
virtual void resize(unsigned int)
Definition: wseries.cc:883
CWB::frame fr[2 *NIFO_MAX]
Definition: cwb.hh:239
void PrintElapsedTime(int job_elapsed_time, TString info)
Definition: cwb.cc:1981
virtual size_t size() const
Definition: wavearray.hh:127
void LoadWaveforms(TFile *ifile, detector *pD, int ifactor, int wfSAVE=1)
Definition: cwb2G.cc:1663
size_t write(const char *file, int app=0)
Definition: netcluster.cc:2989
size_t nLag
Definition: network.hh:555
#define REGRESSION_FILTER_LENGTH
Definition: cwb2G.cc:14
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:240
static size_t GetProcInfo(bool mvirtual=true)
Definition: cwb.cc:1829
std::vector< vector_int > cRate
Definition: netcluster.hh:380
void WriteSparseTFmap(TFile *jfile, int ifactor, TString tdir, TString tname)
Definition: cwb2G.cc:1463
void setMatrix(double edge=0., double f=1.)
Definition: regression.cc:407
size_t TDSize
Definition: config.hh:199
void SaveWaveforms(TFile *jfile, detector *pD, int ifactor, int wfSAVE=1)
Definition: cwb2G.cc:1627
void FileGarbageCollector(TString ifName, TString ofName="", vector< TString > delObjList=vector< TString >())
Definition: cwb.cc:2319
std::vector< netcluster > wc_List
Definition: network.hh:592
int stop
Definition: Toolbox.hh:76
size_t add(detector *)
param: detector structure return number of detectors in the network
Definition: network.cc:2528
printf("total live time: non-zero lags = %10.1f \n", liveTot)
bool singleDetector
used for the stage stuff
Definition: cwb.hh:265
char cmd[1024]
WSeries< double > * pTF[NIFO_MAX]
pointers to detectors
Definition: cwb.hh:252
void setAntenna(detector *)
param: detector (use theta, phi index array)
Definition: network.cc:2815
std::vector< double > * getmdcTime()
Definition: network.hh:404
bool mdcPlugin
Definition: config.hh:347
wavearray< double > HoT
Definition: detector.hh:332
size_t setsnr(wavearray< double > &, std::vector< double > *, std::vector< double > *, double=5., double=8.)
Definition: detector.cc:1641
fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(), x.size()/x.rate(), x.rate())
WDM< double > * pwdm[NRES_MAX]
Definition: cwb2G.hh:60
virtual void rate(double r)
Definition: wavearray.hh:123
double cedRHO
Definition: config.hh:280
char skyMaskFile[1024]
Definition: config.hh:290
size_t upTDF
Definition: config.hh:198
#define REGRESSION_MATRIX_FRACTION
Definition: cwb2G.cc:15
bool dataPlugin
Definition: config.hh:346
bool Likelihood(int ifactor, char *ced_dir, netevent *output=NULL, TTree *net_tree=NULL, char *outDump=NULL)
Definition: cwb2G.cc:1174
long getNetworkPixels(int LAG, double Eo, double DD=1., TH1F *hist=NULL)
Definition: network.cc:60
#define B
int n
Definition: cwb_net.C:10
TString iname
stage benchmark
Definition: cwb.hh:229
wavearray< double > z
Definition: Test10.C:32
double mTau
Definition: cwb.hh:273
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
detector * pD[NIFO_MAX]
noise variability
Definition: cwb.hh:251
TString("c")
bool bplugin
Definition: cwb.hh:285
size_t setIndexMode(size_t=0)
Definition: network.cc:8072
bool cohPlugin
Definition: config.hh:349
#define EXIT(ERR)
Definition: cwb2G.cc:29
void bandpass(wavearray< DataType_t > &ts, double flow, double fhigh, int n=-1)
Definition: wseries.cc:295
TFile * jfile
output root file
Definition: cwb.hh:247
int ID
Definition: TestMDC.C:70
int start
Definition: Toolbox.hh:75
int count
Definition: compare_bkg.C:373
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
wavearray< double > get(char *name, size_t index=0, char atype='R', int type=1, bool=true)
param: string with parameter name param: index in the amplitude array, which define detector param: c...
Definition: netcluster.cc:2188
std::vector< wavearray< double > * > RWFP
Definition: detector.hh:364
wavearray< double > HRSS
Definition: detector.hh:353
double whiteWindow
Definition: config.hh:171
double fLow
Definition: config.hh:122
void add(const wavearray< DataType_t > &, int=0, int=0, int=0)
Definition: wavearray.cc:728
TFile * froot
Definition: cwb.hh:244
std::vector< vector_float > sArea
Definition: netcluster.hh:383
netcluster * pwc
Definition: cwb_job_obj.C:20
bool dcPlugin
Definition: config.hh:348
CWB_STAGE istage
Definition: cwb.hh:235
CWB_STAGE jstage
Definition: cwb.hh:236
bool cedDump
Definition: config.hh:279
void setlow(double f)
Definition: wseries.hh:107
std::vector< SSeries< double > > vSS[NIFO_MAX]
int layers
char ifo[NIFO_MAX][8]
Definition: cwb.hh:233
virtual double ReadData(double mdcShift, int ifactor)
Definition: cwb.hh:189
void Coherence(int ifactor)
Definition: cwb2G.cc:755
ss AddCore(ifoID,&wc)
waveform wf
size_t setcore(bool core, int id=0)
Definition: netcluster.cc:224
int nevt
void SetOptions(int simulation, double rho, double inRate, bool useSparse=false, char *gtype=const_cast< char * >("png"), int paletteId=0)
Definition: ced.hh:68
virtual size_t supercluster(char atype, double S, bool core)
param: statistic: E - excess power, L - likelihood param: selection threshold T for likelihood cluste...
Definition: netcluster.cc:789
std::vector< vector_int > cList
Definition: netcluster.hh:379
size_t add(WSeries< double > &target, char *name, double fL=0., double fH=0.)
Definition: regression.cc:73
virtual void start(double s)
Definition: wavearray.hh:119
int j
Definition: cwb_net.C:10
i drho i
size_t lags
Definition: cwb.hh:281
std::vector< double > mdcTime
Definition: network.hh:596
void setTDFilter(int nCoeffs, int L=1)
Definition: WDM.cc:621
long subNetCut(int lag, float subnet=0.6, float subcut=0.33, TH2F *hist=NULL)
Definition: network.cc:983
network NET
pointers to WSeries
Definition: cwb.hh:254
size_t cluster(int kt, int kf)
param: time gap in pixels return: number of reconstructed clusters
Definition: network.hh:303
int ncore
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
double Phi1
Definition: config.hh:261
long likelihood2G(char mode, int lag, int ID, TH2F *hist=NULL)
Definition: network.cc:1356
virtual double mean() const
Definition: wavearray.cc:1053
bool outPlugin
Definition: config.hh:351
std::vector< vector_float > p_Map
Definition: netcluster.hh:384
void dopen(const char *fname, char *mode, bool header=true)
Definition: netevent.hh:291
double Edge
Definition: network.hh:560
Definition: cwb2G.hh:15
cout<< "Selected Pixels : "<< nPix<< endl;wc.cluster(1, 1);SSeries< double > ss
char ced_dir[512]
Definition: test_config1.C:154
double mdcShift
Definition: cwb_net.C:178
void clean(int cID=0)
Definition: netcluster.hh:433
wavearray< double > w
Definition: Test1.C:27
double segEdge
Definition: config.hh:146
size_t mode
Definition: config.hh:257
float slagShift[20]
Definition: cwb.hh:280
double dcCal[NIFO_MAX]
Definition: config.hh:178
int ccluster
double Theta2
Definition: config.hh:260
size_t esize(int k=2)
Definition: netcluster.hh:135
double factor
size_t fResample
Definition: config.hh:124
long likelihoodWP(char mode, int lag, int ID, TH2F *hist=NULL)
Definition: network.cc:275
jfile
Definition: cwb_job_obj.C:25
void output2G(TTree *, network *, size_t, int, double)
Definition: netevent.cc:687
TTree * net_tree
double setVeto(double=5.)
param: time window around injections
Definition: network.cc:3456
char filter_dir[1024]
Definition: config.hh:287
static TString GetMDCLog(TString log, int pos)
Definition: Toolbox.cc:2258
double shift
Definition: netcluster.hh:364
size_t w_mode
Definition: wseries.hh:440
int simulation
Definition: config.hh:181
int l_high
Definition: config.hh:138
double Fgap
Definition: config.hh:118
void PrintAnalysisInfo(CWB_STAGE stage, TString comment, TString info, bool out=true, bool log=true)
Definition: cwb.cc:2110
#define IMPORT(TYPE, VAR)
Definition: cwb.hh:51
WSeries< double > nRMS
Definition: detector.hh:340
int segID[20]
Definition: cwb.hh:279
char search
Definition: config.hh:103
wavearray< double > * px
static void resampleToPowerOfTwo(wavearray< double > &w)
Definition: Toolbox.cc:5818
double maxEnergy(wavearray< DataType_t > &ts, Wavelet &w, double=0, int=1, int=0, TH1F *=NULL)
Definition: wseries.cc:486
wavearray< double > TIME
Definition: detector.hh:357
void SuperCluster(int ifactor)
Definition: cwb2G.cc:939
i() int(T_cor *100))
std::vector< netpixel > pList
Definition: netcluster.hh:372
double TDRate
Definition: cwb2G.hh:58
wavearray< double > * getHoT()
param: no parameters
Definition: detector.hh:157
gwavearray< double > * gx
void setDelayIndex(double rate)
param: MDC log file
Definition: network.cc:2865
std::vector< std::string > mdcList
Definition: network.hh:594
const int NIFO_MAX
Definition: wat.hh:4
void Resample(const wavearray< DataType_t > &, double, int=6)
Definition: wavearray.cc:622
#define MIN_SKYRES_HEALPIX
Definition: cwb2G.cc:10
int BATCH
Definition: config.hh:227
void apply(double threshold=0., char c='a')
Definition: regression.cc:691
void FillSparseTFmap(TFile *jfile, int ifactor, TString tname)
Definition: cwb2G.cc:1566
int getLayer(wavearray< DataType_t > &w, double n)
param: n - layer number
Definition: wseries.cc:175
bool detected
std::vector< vector_int > p_Ind
Definition: netcluster.hh:385
double dataShift[NIFO_MAX]
Definition: config.hh:187
CWB::mdc * gMDC
Definition: cwb_mkfad.C:44
std::vector< float > cFreq
Definition: netcluster.hh:382
std::vector< int > RWFID
Definition: detector.hh:363
int Write(double factor, bool fullCED=true)
Definition: ced.cc:577
char channelNamesRaw[NIFO_MAX][50]
Definition: config.hh:292
double precision
int gRATEANA
friend void CWB_Plugin(TFile *jfile, CWB::config *, network *, WSeries< double > *, TString, int)
COHERENCE.
void SetChannelName(char *chName)
Definition: ced.hh:79
void PrintStageInfo(CWB_STAGE stage, TString comment, bool out=true, bool log=true, TString fname="")
Definition: cwb.cc:2001
int k
int pattern
Definition: network.hh:583
void solve(double th, int nE=0, char c='s')
Definition: regression.cc:592
char jname[1024]
job file object
Definition: cwb.hh:248
#define REGRESSION_SOLVE_EIGEN_THR
Definition: cwb2G.cc:16
int nfactor
Definition: config.hh:183
std::vector< wavearray< double > * > IWFP
Definition: detector.hh:361
size_t healpix
Definition: config.hh:264
size_t cpf(const netcluster &, bool=false, int=0)
Definition: netcluster.cc:99
char refIFO[4]
Definition: config.hh:107
double THRESHOLD(double bpp)
param: selected fraction of LTF pixels assuming Gaussian noise
Definition: network.cc:2584
size_t setFilter(size_t)
Definition: regression.cc:258
void setDelay(const char *="L1")
Definition: network.cc:2736
size_t loadTDampSSE(network &net, char c, size_t BATCH=10000, size_t LOUD=0)
Definition: netcluster.cc:3298
const int NRES_MAX
Definition: wat.hh:5
wavearray< double > TDUR
Definition: detector.hh:358
double e2or
Definition: network.hh:566
std::vector< int > IWFID
Definition: detector.hh:360
wavearray< double > getClean()
Definition: regression.hh:117
WSeries< double > wM
Definition: cwb_job_obj.C:23
TFile * ifile
frfile FRF[2 *NIFO_MAX]
Definition: cwb.hh:241
CWB::Toolbox TB
Definition: cwb.hh:231
size_t size()
Definition: netcluster.hh:129
int nevents
wavearray< double > BAND
Definition: detector.hh:356
int ncluster
char tdir[256]
int npix
double subnet
Definition: config.hh:229
size_t events()
Definition: network.hh:311
static int shiftBurstMDCLog(std::vector< std::string > &mdcList, vector< TString > ifos, double mdc_shift)
Definition: Toolbox.cc:2154
CWB::config cfg
Definition: cwb.hh:180
pWDM setTDFilter(12)
#define REGRESSION_APPLY_THR
Definition: cwb2G.cc:19
int l_low
Definition: config.hh:137
#define EXPORT(TYPE, VAR, CMD)
Definition: config.cc:74
#define SELECT_SUBRHO
Definition: cwb2G.cc:22
void sclear()
Definition: detector.hh:173
#define WDM_PRECISION
Definition: cwb2G.cc:27
double whiteStride
Definition: config.hh:172
std::vector< int > sCuts
Definition: netcluster.hh:374
void dclose()
Definition: netevent.hh:300
std::vector< float > cTime
Definition: netcluster.hh:381
double fHigh
Definition: config.hh:123
WSeries< double > * getTFmap()
param: no parameters
Definition: detector.hh:161
int LOUD
Definition: config.hh:228
#define SELECT_SUBNET
Definition: cwb2G.cc:23
void Init()
Definition: cwb2G.cc:43
Definition: Meyer.hh:18
char Name[16]
Definition: detector.hh:309
size_t csize()
Definition: netcluster.hh:133
unsigned int jobfOptions
history object
Definition: cwb.hh:264
int ifactor
int * layers
Definition: monster.hh:103
static TString SetMDCLog(TString log, int pos, TString val)
Definition: Toolbox.cc:2218
int SetSkyMask(network *net, CWB::config *cfg, char *options, char skycoord, double skyres=-1)
Definition: cwb.cc:2465
double segLen
Definition: config.hh:143
void readFrames(char *filename, char *channel, wavearray< double > &w)
Definition: frame.cc:810
int tag
Definition: monster.hh:98
vector< TString > fList
Definition: LoopChirpMass.C:30
void Forward(int n=-1)
param: wavelet - n is number of steps (-1 means full decomposition)
Definition: wseries.cc:228
netcluster * getwc(size_t n)
param: delay index
Definition: network.hh:421
int l
Definition: cbc_plots.C:434
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
double subcut
Definition: config.hh:230
#define NEVENTS
int nRes
Definition: monster.hh:99
std::vector< clusterdata > cData
Definition: netcluster.hh:373
#define MIN_SKYRES_ANGLE
Definition: cwb2G.cc:11
double Phi2
Definition: config.hh:262
char skyMaskCCFile[1024]
Definition: config.hh:291
virtual wavearray< double > select(char *, double)
Definition: netcluster.cc:244
DataType_t * data
Definition: wavearray.hh:301
double Tgap
Definition: config.hh:116
netcluster wc
wavearray< double > FREQ
Definition: detector.hh:355
Definition: ced.hh:26
void setMRAcatalog(char *fn)
Definition: network.hh:297
double factors[FACTORS_MAX]
Definition: config.hh:184
void DataConditioning(int ifactor)
Definition: cwb2G.cc:432
int BetaOrder
Definition: monster.hh:100
wavearray< double > * hot[NIFO_MAX]
wavelet pointers: pwdm[0] - l_high, wdm[nRES-1] l_low
Definition: cwb2G.hh:61
snr * snr
Definition: ComputeSNR.C:71
cout<< "live time after cat 2 : "<< detSegs_ctime<< endl;if(detSegs_ctime< segTHR){cout<< "job segment live time after cat2 < "<< segTHR<< " sec, job terminated !!!"<< endl;exit(1);}double Tb=detSegs[0].start;double Te=detSegs[0].stop;double dT=Te-Tb;char file[512], tdf00[512], tdf90[512], buFFer[1024];int rnID=int(gRandom->Rndm(13)*1.e9);if(simulation){i=NET.readMDClog(injectionList, double(long(Tb))-mdcShift);printf("GPS: %16.6f saved, injections: %d\n", double(long(Tb)), i);frTB[nIFO].shiftBurstMDCLog(NET.mdcList, ifos, mdcShift);for(int i=0;i< NET.mdcTime.size();i++) NET.mdcTime[i]+=mdcShift;vector< waveSegment > mdcSegs(NET.mdcTime.size());for(int k=0;k< NET.mdcTime.size();k++){mdcSegs[k].start=NET.mdcTime[k]-gap;mdcSegs[k].stop=NET.mdcTime[k]+gap;}vector< waveSegment > mdcSegs_dq2=slagTB.mergeSegLists(detSegs_dq2, mdcSegs);double mdcSegs_ctime=slagTB.getTimeSegList(mdcSegs_dq2);cout<< "live time in zero lag after cat2+inj : "<< mdcSegs_ctime<< endl;if(mdcSegs_ctime==0){cout<< "job segment with zero cat2+inj live time in zero lag, job terminated !!!"<< endl;exit(1);}}if(dump_infos_and_exit) exit(0);if(mask >0.) NET.setSkyMask(mask, skyMaskFile);for(i=0;i< nIFO;i++){frTB[i].readFrames(FRF[i], channelNamesRaw[i], x);x.start(x.start()+dataShift[i]);x.start(x.start()-segLen *(segID[i]-segID[0]));if(singleDetector) TB.resampleToPowerOfTwo(x);sprintf(file,"%s/%s_%d_%s_%d_%d.dat", nodedir, ifo[i], int(Tb), data_label, runID, rnID);if(dump_sensitivity_and_exit){sprintf(file,"%s/sensitivity_%s_%d_%s_job%d.txt", dump_dir, ifo[i], int(Tb), data_label, runID);cout<< endl<< "Dump Sensitivity : "<< file<< endl<< endl;TB.makeSpectrum(file, x);continue;}if(dcCal[i]>0.) x *=dcCal[i];if(fResample >0){x.FFT(1);x.resize(fResample/x.rate()*x.size());x.FFT(-1);x.rate(fResample);}pTF[i]=pD[i]-> getTFmap()
int nIFO
Toolbox.
Definition: cwb.hh:232
char wdmXTalk[1024]
Definition: config.hh:197
std::vector< SSeries< double > > vSS
Definition: detector.hh:334
double lagStep
Definition: config.hh:151
size_t read(const char *)
Definition: netcluster.cc:3096
double ReadData(double mdcShift, int ifactor)
Definition: cwb2G.cc:184
#define REGRESSION_SOLVE_EIGEN_NUM
Definition: cwb2G.cc:17
char fName[256]
#define REGRESSION_SOLVE_REGULATOR
Definition: cwb2G.cc:18
virtual void resize(unsigned int)
Definition: wavearray.cc:445
double TFgap
Definition: config.hh:120
bool MRA
Definition: network.hh:581
double bpp
Definition: config.hh:115
void Inverse(int n=-1)
param: n - number of steps (-1 means full reconstruction)
Definition: wseries.cc:273
wavearray< double > y
Definition: Test10.C:31
double Theta1
Definition: config.hh:259
void putLayer(wavearray< DataType_t > &, double n)
param: n - layer number
Definition: wseries.cc:201
size_t psize(int k=2)
Definition: netcluster.hh:145
size_t setsim(WSeries< double > &, std::vector< double > *, double=5., double=8., bool saveWF=false)
Definition: detector.cc:1348
size_t inRate
Definition: config.hh:114
#define WDM_BETAORDER
Definition: cwb2G.cc:26
double frequency(int l)
Definition: wseries.cc:99
double segMLS
Definition: config.hh:144
wavearray< double > ISNR
Definition: detector.hh:354
int maxLayer()
Definition: wseries.hh:121
int m_H
Definition: Wavelet.hh:103
int levelR
Definition: config.hh:134
detector ** pD
int nRES
Definition: cwb2G.hh:57
int wfsave()
Definition: detector.hh:298
bool scPlugin
Definition: config.hh:350
TString ifos[60]
double angle
Definition: config.hh:258
void setSkyMaps(double, double=0., double=180., double=0., double=360.)
param: sky map granularity step, degrees param: theta begin, degrees param: theta end...
Definition: network.cc:2656
int precision
Definition: monster.hh:101
virtual WSeries< double > white(double, int, double=0., double=0.)
what it does: each wavelet layer is devided into k intervals.
Definition: wseries.cc:1128
void clear()
Definition: netcluster.hh:409
bool dump
Definition: config.hh:277