Logo coherent WaveBurst  
Library Reference Guide
Logo
CWB_Plugin_Template.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 "TSystem.h"
34 #include "mdc.hh"
35 #include "WDM.hh"
36 #include "regression.hh"
37 #include "frame.hh"
38 #include "watplot.hh"
39 #include "Biorthogonal.hh"
40 #include <fstream>
41 #include <vector>
42 
43 
44 using namespace CWB;
45 
46 //______________________________________________________________________________
47 void
49 
50 // Plugin Template
51 //
52 //
53 // jfile - pointer to job file
54 // this file is used by pipeline to store temporary informations like noise,mdc data
55 //
56 // cfg - pointer to the user configuration setup (see config.hh file)
57 // it can be used to read or change setting
58 //
59 // net - pointer to network object (see network.hh file)
60 // this is the class which perform tha main anaalysis
61 // this object contains the detector definitions
62 //
63 // x - this arrays contains the ifo noise or mdc data (see wseries.hh/wavearray.hh files)
64 //
65 // ifo - detector name (Ex: L1,H1,V1)
66 //
67 // type - is the stage of the cwb analysis
68 // this is the list of stage types
69 //
70 // CWB_PLUGIN_CONFIG = 0
71 // CWB_PLUGIN_NETWORK = 1
72 // CWB_PLUGIN_INIT_JOB = 9
73 // CWB_PLUGIN_DATA = 2
74 // CWB_PLUGIN_MDC = 3
75 // CWB_PLUGIN_RMDC = 11
76 // CWB_PLUGIN_OREADDATA = 14
77 // CWB_PLUGIN_IDATA_CONDITIONING = 4
78 // CWB_PLUGIN_DATA_CONDITIONING = 15
79 // CWB_PLUGIN_ODATA_CONDITIONING = 5
80 // CWB_PLUGIN_ICOHERENCE = 6
81 // CWB_PLUGIN_XCOHERENCE = 16
82 // CWB_PLUGIN_OCOHERENCE = 13
83 // CWB_PLUGIN_ISUPERCLUSTER = 7
84 // CWB_PLUGIN_OSUPERCLUSTER = 17
85 // CWB_PLUGIN_ILIKELIHOOD = 12
86 // CWB_PLUGIN_OLIKELIHOOD = 8
87 // CWB_PLUGIN_CLOSE_JOB = 10
88 //
89 
90 
91  cout << endl;
92  cout << "-----> CWB_Plugin_Template.C : " << ifo.Data() << endl;
93  cout << endl;
94 
95  if(type==CWB_PLUGIN_CONFIG) {
96  //
97  // at this stage the config contains the configuration
98  // user can read or change the configuration parameters
99  //
100  // jfile : NULL
101  // cfg : configured
102  // net : not configured
103  // x : NULL
104  // ifo : ""
105  //
106  // Examples
107  //
108  // cfg->Print(); // print configuration
109  // cfg->bpp = 0.0001; // change probability for black pixel selection
110  }
111 
112  if(type==CWB_PLUGIN_NETWORK) {
113  //
114  // at this stage the network object has been created
115  // Ex: user can read/change the detectors objects
116  //
117  // jfile : NULL
118  // cfg : configured
119  // net : configured
120  // x : NULL
121  // ifo : ""
122  //
123  // Examples
124  //
125  // CWB_Plugin_SGW.C : Set Scalar Gravitational Wave Model
126  }
127 
128  if(type==CWB_PLUGIN_INIT_JOB) {
129  //
130  // at this stage the data quality list has been read
131  // the job segment is computed according the DQ and run ID
132  // this stage is performed for each detector, ifo parameter
133  //
134  // jfile : NULL
135  // cfg : configured
136  // net : configured
137  // x : is the pointer to a dummy wavearray
138  // used only to get x.rate(),x.start(),x.size()
139  // ifo : ifo label (L1,H1,V1,...)
140  //
141  }
142 
143  if(type==CWB_PLUGIN_DATA) {
144  //
145  // at this stage the detector strain has been read and stored in x array
146  // user can modify or inject its own noise (Ex: on the fly noise)
147  // user can read/change noise data (Ex: Calibration)
148  //
149  // jfile : opened in update mode
150  // When noise is read it is stored to job file :
151  // TDirectoryFile* strain
152  // KEY: wavearray<double> L1;1
153  // KEY: wavearray<double> H1;1
154  // KEY: wavearray<double> V1;1
155  //
156  // cfg : configured
157  // net : configured
158  // x : is the pointer to noise data wavearray of detector ifo
159  // ifo : ifo label (L1,H1,V1,...)
160  //
161  // Examples
162  //
163  // CWB_Plugin_SimNoise.C : generate simulated gaussian noise
164  //
165  // for(int i=0;i<x->size();i++) x->data[i]=0; // access to ifo noise data array
166  }
167 
168  if(type==CWB_PLUGIN_MDC) {
169  //
170  // at this stage the mdc has been read and stored in x array
171  // user can modify or inject its own mdc (Ex: on the fly mdc)
172  //
173  // jfile : opened in update mode
174  // When mdc is read it is stored to job file :
175  // TDirectoryFile* mdc
176  // KEY: wavearray<double> L1;1
177  // KEY: wavearray<double> H1;1
178  // KEY: wavearray<double> V1;1
179  //
180  // cfg : configured
181  // net : configured
182  // x : is the pointer to MDC data wavearray of detector ifo
183  // ifo : ifo label (L1,H1,V1,...)
184  //
185  // Examples
186  //
187  // CWB_Plugin_MDC_OTF.C : injected MDC 'on the fly'
188  //
189  // for(int i=0;i<x->size();i++) x->data[i]=0; // access to mdc ifo data array
190  }
191 
192  if(type==CWB_PLUGIN_RMDC) {
193  //
194  // at this stage the mdc has been read and stored in x array
195  // user can modify or inject its own mdc (Ex: on the fly mdc)
196  //
197  // jfile : opened in update mode
198  // job file contains :
199  // TDirectoryFile* strain
200  // KEY: wavearray<double> L1;1
201  // KEY: wavearray<double> H1;1
202  // KEY: wavearray<double> V1;1
203  // TDirectoryFile* mdc
204  // KEY: wavearray<double> L1;1
205  // KEY: wavearray<double> H1;1
206  // KEY: wavearray<double> V1;1
207  //
208  // cfg : configured
209  // net : configured
210  // x : is the pointer to MDC data wavearray of detector ifo
211  // ifo : ifo label (L1,H1,V1,...)
212  //
213  }
214 
215  if(type==CWB_PLUGIN_OREADDATA) {
216  //
217  // at this stage the mdc has been read
218  // this plugin is called only if simulation=2
219  // when simulation=2 (fixed input SNR) the MDC are rescaled to snr network = 1
220  // user can modify or inject its own mdc (Ex: on the fly mdc)
221  //
222  // jfile : opened in update mode
223  // job file contains :
224  // TDirectoryFile* strain
225  // KEY: wavearray<double> L1;1
226  // KEY: wavearray<double> H1;1
227  // KEY: wavearray<double> V1;1
228  // TDirectoryFile* mdc
229  // KEY: wavearray<double> L1;1
230  // KEY: wavearray<double> H1;1
231  // KEY: wavearray<double> V1;1
232  //
233  // cfg : configured
234  // net : configured
235  // - MDC rescaled to snr network = 1 : stored in net->getifo(ifoID)->HoT
236  // x : NULL
237  // ifo : ""
238  //
239  // Examples
240  //
241  // CWB_Plugin_SNR.C : compute and save the mdc SNR
242  }
243 
245  //
246  // called at the begining of DATA_CONDITIONING stage
247  // at this stage the rescaled mdc is added to noise data and stored in x array
248  //
249  // jfile : opened in update mode
250  // job file contains :
251  // TDirectoryFile* strain
252  // KEY: wavearray<double> L1;1
253  // KEY: wavearray<double> H1;1
254  // KEY: wavearray<double> V1;1
255  // TDirectoryFile* mdc
256  // KEY: wavearray<double> L1;1
257  // KEY: wavearray<double> H1;1
258  // KEY: wavearray<double> V1;1
259  //
260  // if analysis is done in 2 stages job file contains also :
261  // TDirectoryFile* waveform
262  // TDirectoryFile* waveform-f0
263  // KEY: detector L1;1
264  // KEY: detector H1;1
265  // KEY: detector V1;1
266  //
267  // cfg : configured
268  // net : configured
269  // x : is the pointer to MDC+noise data wavearray of detector ifo
270  // ifo : ifo label (L1,H1,V1,...)
271  //
272  // Examples
273  //
274  // CWB_Plugin_MakeScalogram.C : produce scalograms of input data
275  }
276 
277  if(type==CWB_PLUGIN_DATA_CONDITIONING) {
278  //
279  // at this stage the rescaled mdc is added to noise data and stored in x array
280  // this stage is executed only if cfg.dcPlugin=true
281  // if cfg.dcPlugin=true : user can apply data conditioning (Ex: regression analysis)
282  //
283  // jfile : opened in update mode
284  // job file contains :
285  // TDirectoryFile* strain
286  // KEY: wavearray<double> L1;1
287  // KEY: wavearray<double> H1;1
288  // KEY: wavearray<double> V1;1
289  // TDirectoryFile* mdc
290  // KEY: wavearray<double> L1;1
291  // KEY: wavearray<double> H1;1
292  // KEY: wavearray<double> V1;1
293  //
294  // cfg : configured
295  // net : configured
296  // x : is the pointer to MDC+noise data wavearray of detector ifo
297  // ifo : ifo label (L1,H1,V1,...)
298  //
299  // Examples
300  //
301  // CWB_Plugin_DataConditioning.C : shows how to implement a custom Data Conditioning
302  }
303 
305  //
306  // called at the end of DATA_CONDITIONING stage
307  // at this stage the noise+mdc data is whitened and stored in x array
308  // Ex : user can monitor if whitened is correct
309  //
310  // jfile : opened in update mode
311  // job file contains :
312  // TDirectoryFile* strain
313  // KEY: wavearray<double> L1;1
314  // KEY: wavearray<double> H1;1
315  // KEY: wavearray<double> V1;1
316  // TDirectoryFile* mdc
317  // KEY: wavearray<double> L1;1
318  // KEY: wavearray<double> H1;1
319  // KEY: wavearray<double> V1;1
320  //
321  // if analysis is done in 2 stages job file contains also :
322  // TDirectoryFile* waveform
323  // TDirectoryFile* waveform-f0
324  // KEY: detector L1;1
325  // KEY: detector H1;1
326  // KEY: detector V1;1
327  // .. for each factor
328  //
329  // cfg : configured
330  // net : configured
331  // x : is the pointer to MDC+noise whitened data wavearray of detector ifo
332  // ifo : ifo label (L1,H1,V1,...)
333  //
334  // Examples
335  //
336  // CWB_Plugin_WDM_freqCuts.C : Implements the 2G frequency cuts after the whitening
337  // CWB_Plugin_MakeWhiteFrame.C : produces frames of whitened data
338  }
339 
340  if(type==CWB_PLUGIN_ICOHERENCE) {
341  //
342  // called at the begining of COHERENCE stage
343  // at this stage the noise+mdc data is whitened and stored in x array
344  // Ex : user can monitor if whitened is correct
345  //
346  // jfile : opened in update mode
347  //
348  // if analysis is done in 2 stages job file contains also :
349  // TDirectoryFile* waveform
350  //
351  // cfg : configured
352  // net : configured
353  // x : NULL
354  // ifo : factor index
355  //
356  }
357 
358  if(type==CWB_PLUGIN_XCOHERENCE) {
359  //
360  // called at the inside the resolution level loop in the COHERENCE stage
361  //
362  // to get the factor the variable gIFACTOR must be imported
363  // int gIFACTOR=-1; IMPORT(int,gIFACTOR)
364  // to get the resolution level the variable gILEVEL must be imported
365  // size_t gILEVEL=-1; IMPORT(size_t,gILEVEL)
366  //
367  // at this stage the max energy TF has been computed
368  // max energy TF are stored in net->getifo(ifoID)->getTFmap()
369  // Ex : user can monitor the max energy TF
370  //
371  // jfile : opened in update mode
372  // TDirectoryFile* coherence
373  // OBJ: TTree clusters-cycle:0
374  //
375  // if analysis is done in 2 stages job file contains also :
376  // TDirectoryFile* waveform
377  //
378  // cfg : configured
379  // net : configured
380  // - TF max energy is stored net->getifo(ifoID)->getTFmap()
381  // x : NULL
382  // ifo : factor index
383  //
384  // Examples
385  //
386  // CWB_Plugin_fCuts.C : Implements the 2G frequency cuts in pixel selection stage
387  }
388 
389  if(type==CWB_PLUGIN_OCOHERENCE) {
390  //
391  // called at the end of COHERENCE stage
392  // at this stage the coherence analysis has been done
393  // selected pixels are stored in jfile
394  // user can read/modify pixels
395  //
396  // jfile : opened in update mode
397  // TDirectoryFile* coherence
398  // OBJ: TTree clusters-cycle:0
399  //
400  // if analysis is done in 2 stages job file contains also :
401  // TDirectoryFile* waveform
402  //
403  // cfg : configured
404  // net : configured
405  // - clusters are stored in the net
406  // x : NULL
407  // ifo : factor index
408  //
409  }
410 
411  if(type==CWB_PLUGIN_ISUPERCLUSTER) {
412  //
413  // at this stage the supercluster analysis started
414  //
415  }
416 
417  if(type==CWB_PLUGIN_OSUPERCLUSTER) {
418  //
419  // at this stage the supercluster analysis has been done and stored in net object
420  // user can read clusters
421  //
422  // jfile : opened in update mode
423  // TDirectoryFile* coherence
424  // KEY: TTree clusters-cycle:0;1
425  // TDirectoryFile* supercluster
426  // OBJ: TTree clusters-cycle:0
427  //
428  // if analysis is done in 2 stages job file contains also :
429  // TDirectoryFile* waveform
430  //
431  // cfg : configured
432  // net : configured
433  // - clusters are stored in the net
434  // x : NULL
435  // ifo : ""
436  //
437  }
438 
439  if(type==CWB_PLUGIN_ILIKELIHOOD) {
440  //
441  // this stage is the bebinning of likelihood analysis
442  // sparse maps are loaded
443  // reconstructed events are stored net object
444  // user can extract reconstructed events (waveform, params) and compute parameters estimation
445  //
446  // jfile : opened in update mode
447  // TDirectoryFile* sparse
448  // KEY: SSeries<double> L1-level:0:8;1
449  // KEY: SSeries<double> H1-level:0:8;1
450  // KEY: SSeries<double> V1-level:0:8;1
451  // .. for all resolution levels
452  // KEY: TDirectoryFile supercluster;1
453  // KEY: TTree clusters-cycle:0;1
454  //
455  // if analysis is done in 2 stages job file contains also :
456  // KEY: TDirectoryFile waveform;1
457  // KEY: CWB::config config;1
458  // KEY: network network;1
459  // KEY: CWB::History history;1
460  // KEY: cwb2G cwb;1
461  //
462  // cfg : configured
463  // net : configured
464  // - sparse map is stored net->getifo(ifoID)->vSS[ifoID]
465  // - clusters are stored in the net
466  // x : NULL
467  // ifo : factor-id or lag id
468  //
469  // Examples
470  //
471  // CWB_Plugin_cwb_inet.C : plot sparse TF maps
472  }
473 
474  if(type==CWB_PLUGIN_OLIKELIHOOD) {
475  //
476  // at this stage the likelihood analysis has been done
477  // reconstructed events are stored net object
478  // user can extract reconstructed events (waveform, params) and compute parameters estimation
479  // user can store custom results to jfile
480  //
481  // jfile : opened in update mode
482  // TDirectoryFile* sparse
483  // KEY: SSeries<double> L1-level:0:8;1
484  // KEY: SSeries<double> H1-level:0:8;1
485  // KEY: SSeries<double> V1-level:0:8;1
486  // .. all resolution levels
487  // KEY: TDirectoryFile supercluster;1
488  // KEY: TTree clusters-cycle:0;1 0
489  //
490  // if analysis is done in 2 stages job file contains also :
491  // KEY: TDirectoryFile waveform;1
492  // KEY: CWB::config config;1
493  // KEY: network network;1
494  // KEY: CWB::History history;1
495  // KEY: cwb2G cwb;1
496  //
497  // cfg : configured
498  // net : configured
499  // - reconstructed clusters are contained in net object net->getwc(lag)
500  // x : NULL
501  // ifo : ""
502  //
503  // Examples
504  //
505  // CWB_Plugin_NN.C : includes netcluster event stricture into the output wave root file
506  // CWB_Plugin_SkyProb.C : save SkyProb into the output wave root file
507  // CWB_Plugin_pixeLHood.C : dump/plot the likelihood/null pixels of the detected/reconstructed event
508  }
509 
510  if(type==CWB_PLUGIN_CLOSE_JOB) {
511  //
512  // at this stage job is finished and
513  //
514  // jfile : opened in update mode
515  // if analysis is done in 2 stages job file contains also :
516  // This is the trigger file used as input for the final stage analysis
517  // KEY: TDirectoryFile waveform;1
518  // KEY: TDirectoryFile supercluster;1
519  // KEY: TDirectoryFile sparse;1
520  // KEY: CWB::config config;1
521  // KEY: network network;1
522  // KEY: CWB::History history;1
523  // KEY: cwb2G cwb;1
524  //
525  // cfg : configured
526  // net : configured
527  // x : is the pointer to a dummy wavearray
528  // used only to get x.rate(),x.start(),x.size()
529  // ifo : ifo label (L1,H1,V1,...)
530  //
531  }
532 
533  return;
534 }
CWB::config * cfg
Definition: ced.hh:42
TString("c")
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1) *itime+ifreq;double time=itime *dT;double freq=(ifreq >0) ? ifreq *dF :dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
char ifo[NIFO_MAX][8]
network ** net
NOISE_MDC_SIMULATION.
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