Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb.hh
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato, Sergey Klimenko
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 /**********************************************************
20  * Package: CWB Class Library
21  * File name: CWB.hh
22  * Author: Gabriele Vedovato (vedovato@lnl.infn.it)
23  **********************************************************/
24 
25 
26 #ifndef CWB_HH
27 #define CWB_HH
28 
29 #include "TObjString.h"
30 #include "TObjArray.h"
31 #include "TString.h"
32 #include "TROOT.h"
33 #include "TMath.h"
34 #include "TSystem.h"
35 #include "TLatex.h"
36 #include "TTree.h"
37 #include "TFile.h"
38 #include "TNamed.h"
39 #include "TGlobal.h"
40 #include "TFileMerger.h"
41 
42 #include <string>
43 #include <iostream>
44 #include <fstream>
45 #include <stdlib.h>
46 #include <math.h>
47 #include <ctype.h>
48 #include <vector>
49 
50 #include "wavecomplex.hh"
51 #include "wavearray.hh"
52 #include "wat.hh"
53 
54 #include "History.hh"
55 #include "Toolbox.hh"
56 #include "config.hh"
57 #include "time.hh"
58 #include "ced.hh"
59 #include "frame.hh"
60 
61 #include "livetime.hh"
62 #include "variability.hh"
63 #include "wavenoise.hh"
64 
65 #include "CWB_Plugin.h"
66 
67 // macro used by the pipeline to share parameters between pipeline and Plugin
68 
69 #define IMPORT(TYPE,VAR) { \
70  char cmdline[128]; \
71  TGlobal* _global = (TGlobal*)gROOT->GetGlobal("gPOINTER",true); \
72  if(_global==NULL) sprintf(cmdline,"void* gPOINTER = (void*)&%s;",#VAR); \
73  else sprintf(cmdline,"gPOINTER = (void*)&%s;",#VAR); \
74  gROOT->ProcessLine(cmdline); \
75  TGlobal* _gvar = (TGlobal*)gROOT->GetGlobal(#VAR,true); \
76  if(_gvar!=NULL) { \
77  void* gPOINTER=NULL; \
78  _global = (TGlobal*)gROOT->GetGlobal("gPOINTER",true); \
79  memcpy((void*)&gPOINTER,(void*)_global->GetAddress(),sizeof(void*)); \
80  VAR = *(TYPE*)gPOINTER; \
81  } \
82 }
83 
84 #define EXPORT(TYPE,VAR,CMD) { \
85  TGlobal* _global = (TGlobal*)gROOT->GetGlobal(#VAR,true); \
86  char cmdline[128]; \
87  if(_global==NULL) sprintf(cmdline,"%s %s;",#TYPE,CMD); \
88  else sprintf(cmdline,"%s;",CMD); \
89  gROOT->ProcessLine(cmdline); \
90 }
91 
92 enum CWB_PLUGIN {
120 };
121 
122 enum CWB_STAGE {
132 };
133 
134 extern void CWB_Plugin(TFile* jfile, CWB::config*, network*, WSeries<double>*, TString, int);
135 
136 class cwb : public TNamed {
137 
138 public:
139 
143  virtual ~cwb();
144 
145  virtual void run(int runID=0);
146 
147  static size_t GetProcInfo(bool mvirtual=true);
148 
149  // return the pointer to the config object
150  CWB::config* GetConfig() {return &cfg;}
151 
152  // return the pointer to the network object
153  network* GetNetwork() {return &NET;}
154 
155  // return the pointer to the history object
157 
158  // return the final stage to process by the analysis
160 
161  // return the maximun stage value
162  static int GetStageSize() {return CWB_STAGE_LIKELIHOOD;}
163 
165  void SetupStage(CWB_STAGE jstage);
166 
167  int SetSkyMask(network* net, CWB::config* cfg, char* options, char skycoord, double skyres=-1);
168  static void MakeSkyMask(skymap& SkyMask, double theta, double phi, double radius);
169 
170  char GetLagMode() {return lagMode[0];}
171  TArrayC GetLagBuffer() {return lagBuffer;}
172 
173  void print() {PrintAnalysis(false);} // *MENU*
174 
175  // return the FRF frame files list
176  vector<frfile> GetFrList(int ifoID=-1);
177  vector<frfile> GetFrList(TString ifo);
178 
179  // Method used by TBrowser when double click the cwb object
180  virtual void Browse(TBrowser *b) {print();}
181 
182  double GetSegBegin() {return Tb;}
183  double GetSegEnd() {return Te;}
184 
186 
188  bool out=true, bool log=true);
189 
190 //protected: // ROOT6 fix, commented out otherwise not visibles from cWB plugins
191 
193 
194  virtual void InitNetwork();
195  virtual void InitNetwork(TString fName);
196  virtual void InitHistory();
197  virtual double InitJob();
198  virtual double InitJob(TString fName);
199 
200  // virtual base class ReadData method
201  virtual double ReadData(double mdcShift, int ifactor) {return 0.;}
202  virtual double ReadData(TString fName);
203 
204  // virtual base class DataConditioning method
205  virtual void DataConditioning(int ifactor) {return;}
206  virtual void DataConditioning(TString fName, int ifactor);
207 
208  // virtual base class Coherence method
209  virtual void Coherence(int ifactor) {return;}
210  virtual void Coherence(TString fName);
211 
212  // virtual base class SuperCluster method
213  virtual void SuperCluster(int ifactor) {return;}
214  virtual void SuperCluster(TString fName);
215 
216  // virtual base class Likelihood method
217  virtual bool Likelihood(int ifactor, char* ced_dir, netevent* netburst = NULL,
218  TTree* net_tree = NULL, char* outDump = NULL) {return false;}
219 
220  void LoadPlugin(TMacro& plugin, TMacro& configPlugin);
221 
222  void Init();
223  void PrintAnalysis(bool stageInfos=true);
224  void PrintElapsedTime(int job_elapsed_time, TString info);
225  void PrintStageInfo(CWB_STAGE stage, TString comment,
226  bool out=true, bool log=true, TString fname="");
227  TString GetStageInfo(CWB_STAGE stage, TString comment, TString fname="");
228  TString GetAnalysisInfo(CWB_STAGE stage, TString comment, TString info);
229 
230  void Exec(char* command, int maxtry=3, bool verbose=true);
231  void FileGarbageCollector(TString ifName, TString ofName="",
232  vector<TString> delObjList = vector<TString>());
233 
234 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
235 // declarations
236 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
237 
238  TStopwatch watchJob; //! job benchmark
239  TStopwatch watchStage; //! stage benchmark
240 
241  TString iname; // input root data file
242 
243  CWB::Toolbox TB; //! Toolbox
244  int nIFO; // number of detectors
245  char ifo[NIFO_MAX][8]; // detector names array
246  int runID; // job ID
247  CWB_STAGE istage; // initial stage
248  CWB_STAGE jstage; // final stage
249 
250  // the first nIFO positions contains the ifo frFiles, nIFO+1 contains the sim frFile
251  CWB::frame fr[2*NIFO_MAX]; // array of frame objects used to read frame files
252  int nfrFiles[2*NIFO_MAX]; // frame files list names
253  frfile FRF[2*NIFO_MAX]; // frame file structures
254 
255  // output root file variables
256  TFile* froot; //! output root file
257 
258  // temporary job file variables
259  TFile* jfile; //! job file object
260  char jname[1024]; // job file name
261 
262  WSeries<float> v[NIFO_MAX]; //! noise variability
263  detector* pD[NIFO_MAX]; //! pointers to detectors
264  WSeries<double>* pTF[NIFO_MAX]; //! pointers to WSeries
265 
266  network NET; //! network object
267 
268  injection* mdc; //! injection object
269  livetime live; //! livetime object
270  netevent* netburst; //! netburst object
271  variability wavevar; //! variability object
272  wavenoise noiserms; //! wavenoise object
273 
274  CWB::History* history; //! history object
275 
276  unsigned int jobfOptions; //! used for the stage stuff
277  bool singleDetector; // true -> single detector mode
278 
279  size_t rateANA; // analysis data rate
280 
281  double Tb; // start segment gps time (segEdge excluded)
282  double Te; // stop segment gps time (segEdge excluded)
283  double dT; // WB segment duration (segEdge excluded)
284 
285  double mTau; //! maximum time delay
286  double dTau; //! time delay difference
287 
288  vector<waveSegment> detSegs; // detector job segments
289  vector<waveSegment> cat1List; //! category 1 data quality list
290  vector<waveSegment> cat2List; //! category 2 data quality list
291  int jobID;int slagID;int segID[20];
292  float slagShift[20]; // used to store the super lags
293  size_t lags; // number of lags
294  char lagMode[1]; // used to store the the user lagFile mode
295  TArrayC lagBuffer; // used to store the contents of the user lagFile
296 
297  bool bplugin; //! false/true -> defined/not-defined
298 
299  ClassDef(cwb,4)
300 };
301 
302 #endif
size_t rateANA
Definition: cwb.hh:279
TString outDump
int jobID
category 2 data quality list
Definition: cwb.hh:291
double Te
Definition: cwb.hh:282
CWB::frame fr[2 *NIFO_MAX]
Definition: cwb.hh:251
void PrintElapsedTime(int job_elapsed_time, TString info)
Definition: cwb.cc:2000
TString GetAnalysisInfo(CWB_STAGE stage, TString comment, TString info)
Definition: cwb.cc:2148
cwb(CWB_STAGE jstage=CWB_STAGE_FULL)
Definition: cwb.cc:31
double dTau
maximum time delay
Definition: cwb.hh:286
static size_t GetProcInfo(bool mvirtual=true)
Definition: cwb.cc:1847
variability wavevar
netburst object
Definition: cwb.hh:271
TString ofName
void FileGarbageCollector(TString ifName, TString ofName="", vector< TString > delObjList=vector< TString >())
Definition: cwb.cc:2338
bool singleDetector
used for the stage stuff
Definition: cwb.hh:277
WSeries< double > * pTF[NIFO_MAX]
pointers to detectors
Definition: cwb.hh:264
int nfrFiles[2 *NIFO_MAX]
Definition: cwb.hh:252
void Init()
Definition: cwb.cc:230
TString iname
stage benchmark
Definition: cwb.hh:241
double dT
Definition: cwb.hh:283
void CWB_Plugin(TFile *jfile, CWB::config *, network *, WSeries< double > *, TString, int)
COHERENCE.
double mTau
Definition: cwb.hh:285
vector< frfile > GetFrList(int ifoID=-1)
Definition: cwb.cc:2574
detector * pD[NIFO_MAX]
noise variability
Definition: cwb.hh:263
TString("c")
char comment[1024]
bool bplugin
Definition: cwb.hh:297
TFile * jfile
output root file
Definition: cwb.hh:259
double Tb
Definition: cwb.hh:281
virtual double InitJob()
Definition: cwb.cc:1248
ofstream out
Definition: cwb_merge.C:214
CWB_PLUGIN
Definition: cwb.hh:92
float theta
TFile * froot
Definition: cwb.hh:256
CWB_STAGE istage
Definition: cwb.hh:247
CWB_STAGE jstage
Definition: cwb.hh:248
int slagID
Definition: cwb.hh:291
TString GetStageInfo(CWB_STAGE stage, TString comment, TString fname="")
Definition: cwb.cc:2039
char ifo[NIFO_MAX][8]
Definition: cwb.hh:245
virtual double ReadData(double mdcShift, int ifactor)
Definition: cwb.hh:201
char command[1024]
Definition: cwb_compile.C:44
size_t lags
Definition: cwb.hh:293
TStopwatch watchJob
Definition: cwb.hh:238
network NET
pointers to WSeries
Definition: cwb.hh:266
virtual void Browse(TBrowser *b)
Definition: cwb.hh:180
network ** net
NOISE_MDC_SIMULATION.
char ced_dir[512]
Definition: test_config1.C:154
double mdcShift
Definition: cwb_net.C:196
vector< waveSegment > detSegs
time delay difference
Definition: cwb.hh:288
virtual ~cwb()
Definition: cwb.cc:215
float slagShift[20]
Definition: cwb.hh:292
float phi
double GetSegEnd()
Definition: cwb.hh:183
vector< waveSegment > cat2List
category 1 data quality list
Definition: cwb.hh:290
jfile
Definition: cwb_job_obj.C:43
TTree * net_tree
static TString GetStageString(CWB_STAGE jstage)
Definition: cwb.cc:2206
TStopwatch watchStage
job benchmark
Definition: cwb.hh:239
void PrintAnalysisInfo(CWB_STAGE stage, TString comment, TString info, bool out=true, bool log=true)
Definition: cwb.cc:2129
void SetupStage(CWB_STAGE jstage)
Definition: cwb.cc:2242
int segID[20]
Definition: cwb.hh:291
virtual void run(int runID=0)
Definition: cwb.cc:281
int ifactor
const int NIFO_MAX
Definition: wat.hh:22
bool log
Definition: WaveMDC.C:41
char lagMode[1]
Definition: cwb.hh:294
double GetSegBegin()
Definition: cwb.hh:182
wavenoise noiserms
variability object
Definition: cwb.hh:272
char fname[1024]
void PrintStageInfo(CWB_STAGE stage, TString comment, bool out=true, bool log=true, TString fname="")
Definition: cwb.cc:2020
bool IsSingleDetector()
Definition: cwb.hh:185
void Exec(char *command, int maxtry=3, bool verbose=true)
Definition: cwb.cc:2310
char jname[1024]
job file object
Definition: cwb.hh:260
virtual void DataConditioning(int ifactor)
Definition: cwb.hh:205
static int GetStageSize()
Definition: cwb.hh:162
Definition: skymap.hh:63
frfile FRF[2 *NIFO_MAX]
Definition: cwb.hh:253
CWB::Toolbox TB
Definition: cwb.hh:243
vector< waveSegment > cat1List
Definition: cwb.hh:289
CWB_STAGE GetStage()
Definition: cwb.hh:159
livetime live
injection object
Definition: cwb.hh:269
CWB::config cfg
Definition: cwb.hh:192
char options[256]
CWB::History * GetHistory()
Definition: cwb.hh:156
int job_elapsed_time
Definition: cwb_net.C:736
CWB::config * GetConfig()
Definition: cwb.hh:150
void PrintAnalysis(bool stageInfos=true)
Definition: cwb.cc:1705
static void MakeSkyMask(skymap &SkyMask, double theta, double phi, double radius)
Definition: cwb.cc:2417
virtual void InitHistory()
Definition: cwb.cc:1002
unsigned int jobfOptions
history object
Definition: cwb.hh:276
CWB::History * history
wavenoise object
Definition: cwb.hh:274
int SetSkyMask(network *net, CWB::config *cfg, char *options, char skycoord, double skyres=-1)
Definition: cwb.cc:2484
void LoadPlugin(TMacro &plugin, TMacro &configPlugin)
Definition: cwb.cc:1869
TMacro plugin
netevent * netburst
livetime object
Definition: cwb.hh:270
Definition: cwb.hh:136
char GetLagMode()
Definition: cwb.hh:170
TMacro configPlugin
TArrayC lagBuffer
Definition: cwb.hh:295
void print()
Definition: cwb.hh:173
int nIFO
Toolbox.
Definition: cwb.hh:244
virtual void SuperCluster(int ifactor)
Definition: cwb.hh:213
int runID
Definition: cwb.hh:246
virtual void Coherence(int ifactor)
Definition: cwb.hh:209
char fName[256]
TArrayC GetLagBuffer()
Definition: cwb.hh:171
WSeries< float > v[NIFO_MAX]
Definition: cwb.hh:262
virtual void InitNetwork()
Definition: cwb.cc:910
CWB_STAGE
Definition: cwb.hh:122
virtual bool Likelihood(int ifactor, char *ced_dir, netevent *netburst=NULL, TTree *net_tree=NULL, char *outDump=NULL)
Definition: cwb.hh:217
injection * mdc
network object
Definition: cwb.hh:268
network * GetNetwork()
Definition: cwb.hh:153