Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_report_prod_1.C
Go to the documentation of this file.
1 // post-production macro for the background report : used by the cwb_report command
2 
3 {
4  cout<<"cwb_report_prod_1.C starts..."<<endl;
5 
6  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
7  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
8  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
9  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
10  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
11  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
12 
13 #ifndef _USE_ROOT6
14  // the CWB_CAT_NAME declared in CWB_EPPARAMETERS_FILE is not visible. why?
15  // the include is defined again
16  #undef GTOOLBOX_HH
17 #endif
18  #include "GToolbox.hh"
19 
20  CWB::Toolbox::mkDir(netdir,!pp_batch);
21 
22  gStyle->SetTitleOffset(1.4,"X");
23  gStyle->SetTitleOffset(1.2,"Y");
24  gStyle->SetLabelOffset(0.014,"X");
25  gStyle->SetLabelOffset(0.010,"Y");
26  gStyle->SetLabelFont(42,"X");
27  gStyle->SetLabelFont(42,"Y");
28  gStyle->SetTitleFont(42,"X");
29  gStyle->SetTitleFont(42,"Y");
30  gStyle->SetLabelSize(0.04,"X");
31  gStyle->SetLabelSize(0.04,"Y");
32 
33  gStyle->SetTitleH(0.050);
34  gStyle->SetTitleW(0.95);
35  gStyle->SetTitleY(0.98);
36  gStyle->SetTitleFont(12,"D");
37  gStyle->SetTitleColor(kBlue,"D");
38  gStyle->SetTextFont(12);
39  gStyle->SetTitleFillColor(kWhite);
40  gStyle->SetLineColor(kWhite);
41  gStyle->SetNumberContours(256);
42  gStyle->SetCanvasColor(kWhite);
43  gStyle->SetStatBorderSize(1);
44  gStyle->SetOptStat(kFALSE);
45 
46  // remove the red box around canvas
47  gStyle->SetFrameBorderMode(0);
48  gROOT->ForceStyle();
49 
50  cout<<"netplot starts..."<<endl;
51 
52  if(nIFO==1) { // Single Detector Mode
54  config.Import();
55  config.SetSingleDetectorMode();
56  config.Export();
57  }
58 
59  // ----------------------------------------------------------
60  // canvas
61  // ----------------------------------------------------------
62  TCanvas *c1 = new TCanvas("c","C",0,0,600,600);
63  c1->SetBorderMode(0);
64  c1->SetFillColor(0);
65  c1->SetBorderSize(2);
66  c1->SetLogx(kFALSE);
67  c1->SetGridx();
68  c1->SetGridy();
69  c1->SetRightMargin(0.1517039);
70  c1->SetTopMargin(0.0772727);
71  c1->SetBottomMargin(0.103939);
72  //gStyle->SetPalette(1,0);
73  //Re-implementing red-yellow palette
74  TColor::InitializeColors();
75  const Int_t nRGBs = 3;
76  Double_t stops[nRGBs] = { 0.00, 0.50, 1.00};
77  Double_t red[nRGBs] = { 0.559, 1.00, 1.00};
78  Double_t green[nRGBs] = { 0.00, 0.00, 1.00};
79  Double_t blue[nRGBs] = { 0.10, 0.00, 0.00};
80  TColor::CreateGradientColorTable(nRGBs, stops, red, green, blue, 255);
81 
82  TChain wave("waveburst");
83  TChain live("liveTime");
84  wave.Add(net_file_name);
85  live.Add(liv_file_name);
87  wave.SetEstimate(wave.GetEntries());
88 
89  // check vetoes
90  bool bcat2 = false;
91  bool bhveto = false;
92  bool bcat3 = false;
93 
94  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_CAT2) bcat2=true;
95  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_HVETO) bhveto=true;
96  for(int i=0;i<nVDQF;i++) if(VDQF[i].cat==CWB_CAT3) bcat3=true;
97 
98  for(int i=0;i<nVDQF;i++) {
99  if((VDQF[i].cat!=CWB_CAT2)&&(VDQF[i].cat!=CWB_HVETO)&&(VDQF[i].cat!=CWB_CAT3)) continue;
100  char veto_name[256];sprintf(veto_name,"%s_%s",CWB_CAT_NAME[VDQF[i].cat].Data(),VDQF[i].ifo);
101  if(!CWB::Toolbox::isLeafInTree(W.fChain,veto_name)) {
102  cout << "cwb_report_prod_1.C Error : Leaf " << veto_name
103  << " is not present in tree" << endl;
104  gSystem->Exit(1);
105  }
106  }
107 
108  gSystem->Exec("date");
109 
110  char fname[1024];
111  char ch1[256];
112  char ch3[256];
113 
114  int n;
115  double sTARt, sTOp;
116 
117  W.GetEntry(0); sTARt = W.gps[0];
118  sTOp = W.gps[0];
119  for(int k=1;k<wave.GetEntries();k++){
120  W.GetEntry(k);
121  if(int(k/100000)*100000 == k) cout << "processed: " << k <<endl;
122  if(W.gps[0]>sTOp) {sTOp = W.gps[0];}
123  if(W.gps[0]<sTARt) {sTARt = W.gps[0];}
124  }
125  double T_bgn = sTARt;
126  double T_end = sTOp;
127  T_bgn-=(T_end-T_bgn)/100.;
128  T_end+=(T_end-T_bgn)/100.;
129  int nBins = 100;
130  sprintf(fname,"%s/time.txt",netdir);
131  FILE* ftrig = fopen(fname,"w");
132  if(ftrig==NULL) {
133  cout << "cwb_report_prod_1.C - File open error : " << fname << endl;
134  gSystem->Exit(1);
135  }
136  fprintf(ftrig,"#Start\tStop\n");
137  fprintf(ftrig,"%d\t%d\n",(int)T_bgn,(int)T_end);
138  fclose(ftrig);
139  sprintf(fname,"Red dots vetoed CAT3 or hveto");
140 
141  TH2F* rho_T = new TH2F("rho_T","",nBins,T_bgn,T_end,pp_rho_bin,pp_rho_min,pp_rho_max);
142  rho_T->SetTitleOffset(1.3,"Y");
143  rho_T->GetXaxis()->SetTitle(fname);
144  rho_T->GetXaxis()->SetTimeDisplay(1);
145  rho_T->GetYaxis()->SetTitle("#rho");
146  rho_T->SetMarkerStyle(20);
147  rho_T->SetMarkerColor(1);
148  rho_T->SetMarkerSize(0.8);
149  rho_T->SetStats(kFALSE);
150 
151  TH2F* rho_T2 = new TH2F("rho_T2","",nBins,T_bgn,T_end,pp_rho_bin,pp_rho_min,pp_rho_max);
152  rho_T2->SetTitle("Red dots vetoed CAT3 or hveto");
153  rho_T2->GetXaxis()->SetTitle(fname);
154  rho_T2->GetXaxis()->SetTimeDisplay(1);
155  rho_T2->GetYaxis()->SetTitle("#rho");
156  rho_T2->SetMarkerStyle(20);
157  rho_T2->SetMarkerColor(2);
158  rho_T2->SetMarkerSize(0.8);
159  rho_T2->SetStats(kFALSE);
160 
161  if(c1) delete c1;
162  c1 = new TCanvas("c","C",0,0,800,600);
163  c1->SetBorderMode(0);
164  c1->SetFillColor(0);
165  c1->SetBorderSize(2);
166  c1->SetGridx();
167  c1->SetGridy();
168  c1->SetBottomMargin(0.143939);
169  c1->SetRightMargin(0.1517039);
170  c1->SetTopMargin(0.0772727);
171 
172  int nfreq = (freqHigh-freqLow)/1.;
173  TH2F* ff=new TH2F("ff","ff",nfreq,freqLow,freqHigh,pp_rho_bin,pp_rho_min,pp_rho_max);
174  ff->SetTitleOffset(1.3,"Y");
175  ff->SetTitle("");
176  ff->GetXaxis()->SetTitle("frequency, Hz");
177  ff->SetStats(kFALSE);
178 
179  c1->Clear();
180  sprintf(ch1,"rho[%d]:frequency[0]>>ff",pp_irho);
181  c1->SetLogz(kTRUE);
182  ff->GetYaxis()->SetTitle("#rho(ECOR)");
183  Draw(wave,ch1,ch2,"colz");
184  sprintf(fname,"%s/ECOR_frequency.eps",netdir);
185  c1->Update(); c1->SaveAs(fname);
186 
187  c1->Clear();
188  sprintf(ch1,"rho[0]:frequency[0]>>ff");
189  c1->SetLogz(kTRUE);
190  ff->GetYaxis()->SetTitle("#rho(ecor)");
191  Draw(wave,ch1,ch2,"colz");
192  sprintf(fname,"%s/ecor_frequency.eps",netdir);
193  cout << fname << endl;
194  c1->Update(); c1->SaveAs(fname);
195 
196  c1->Clear();
197  if(pp_rho_log) c1->SetLogy(kTRUE);
198  sprintf(ch1,"rho[%d]:frequency[0]>>ff",pp_irho);
199  c1->SetLogz(kTRUE);
200  if(fHigh-fLow>256) c1->SetLogx(kTRUE);
201  ff->SetTitle("after pp-cuts (loudest not vetoed : black)");
202  ff->GetYaxis()->SetTitle("#rho");
203  ff->GetXaxis()->SetMoreLogLabels(kTRUE);
204  ff->GetXaxis()->SetNoExponent(kTRUE);
205  Draw(wave,ch1,ch2,"colz");
206 
207  // set marker on the first not vetoed pp_max_nloudest_list loudest events
208  sprintf(ch1,"rho[%d]:frequency[0]:Entry$",pp_irho);
209  Draw(wave,ch1,ch2,"goff");
210  int sel_size = wave.GetSelectedRows();
211  double* sel_rho = wave.GetV1();
212  double* sel_freq = wave.GetV2();
213  double* sel_entry = wave.GetV3();
214  Int_t *_index = new Int_t[sel_size];
215  TMath::Sort(sel_size,sel_rho,_index,true);
216  if(sel_size>pp_max_nloudest_list) sel_size=pp_max_nloudest_list;
217  // get veto branches
218  UChar_t VETO[100];
219  TString VETO_NAME[100];
220  int nveto=0;
221  size_t nbranch = wave.GetListOfBranches()->GetEntries();
222  for(int n=0;n<nbranch;++n) {
223  TBranch *br =dynamic_cast<TBranch*>(wave.GetListOfBranches()->At(n));
224  if(TString(br->GetName()).Contains("veto_")) {
225  // cat2 is a special case, the events tagged with cat2 are not vetoed
226  if(!TString(br->GetName()).Contains("veto_cat2")) {
227  VETO_NAME[nveto] = br->GetName();
228  wave.SetBranchAddress(br->GetName(),&VETO[nveto++]);
229  }
230  }
231  }
232  for(int i=0;i<sel_size;i++) {
233  int l=_index[i];
234  int j=int(sel_entry[l]);
235  wave.GetEntry(j);
236  bool veto=false;
237  for(int k=0;k<nveto;k++) {
238 #ifdef CAT3_VETO
239  if(VETO[k] && VETO_NAME[k].Contains("veto_cat3")) veto=true;
240 #endif
241 #ifdef HVETO_VETO
242  if(VETO[k] && VETO_NAME[k].Contains("veto_hveto")) veto=true;
243 #endif
244 #ifdef USER_VETO
245  if(VETO[k] && VETO_NAME[k].Contains("veto_user")) veto=true;
246 #endif
247  }
248  if(!veto) {
249  // set black marker for not vetoed loudest events
250  TMarker *mP = new TMarker(sel_freq[l], sel_rho[l], 20);
251  mP->SetMarkerSize(0.9);
252  mP->SetMarkerColor(kBlack);
253  mP->Draw();
254  }
255  }
256  sprintf(fname,"%s/rho_frequency.eps",netdir);
257  c1->Update(); c1->SaveAs(fname);
258 
259  c1->Clear();
260  sprintf(ch1,"rho[%d]:time[0]>>rho_T",pp_irho);
261  c1->SetLogz(kFALSE);
262  c1->SetLogx(kFALSE);
263  if(pp_rho_log) c1->SetLogy(kTRUE); else c1->SetLogy(kFALSE);
264  if(bhveto||bcat3) {
265  sprintf(ch1,"rho[%d]:time[0]>>rho_T",pp_irho);
266  Draw(wave,ch1,veto_not_vetoed,"");
267  sprintf(ch1,"rho[%d]:time[0]>>rho_T2",pp_irho);
268  Draw(wave,ch1,veto_vetoed,"P SAME");
269  rho_T->SetTitle("after pp-cuts (black), vetoed by cat3 or hveto (red)");
270  } else {
271  Draw(wave,ch1,ch2,"");
272  rho_T->SetTitle("after pp-cuts");
273  }
274  sprintf(fname,"%s/rho_time.eps",netdir);
275  c1->Update(); c1->Print(fname);
276 
277  /* if (online)
278  {
279  //ONLINE
280  if(c1) delete c1;
281  c1 = new TCanvas("c","C",0,0,1200,800);
282  c1->SetBorderMode(0);
283  c1->SetFillColor(0);
284  c1->SetBorderSize(2);
285  c1->SetGridx();
286  c1->SetGridy();
287  c1->SetBottomMargin(0.143939);
288  c1->SetRightMargin(0.1517039);
289  c1->SetTopMargin(0.0772727);
290 
291  char s_gracedb[2048];
292  sprintf(s_gracedb,"%s && rho[%i]>%f && rho[%i]<%f",ch2,pp_irho,t_rho_lum,pp_irho,t_rho_off);
293  char s_offline[2048];
294  sprintf(s_offline,"%s && rho[%i]>%f",ch2,pp_irho,t_rho_off);
295  char notch2[2048];
296  sprintf(notch2,"!(%s && rho[%i]>%f)",ch2,pp_irho,t_rho_lum);
297  c1->Clear();
298  c1->SetLogz(kFALSE);
299  c1->SetLogx(kFALSE);
300 
301  TH2F* rho_on = new TH2F("rho_on","",nBins,T_bgn,T_end,pp_rho_bin,pp_rho_min,pp_rho_max);
302  rho_on->SetTitleOffset(1.3,"Y");
303  rho_on->GetXaxis()->SetTitle(fname);
304  rho_on->GetXaxis()->SetTimeDisplay(1);
305  rho_on->GetYaxis()->SetTitle("#rho");
306  rho_on->SetMarkerStyle(20);
307  rho_on->SetMarkerColor(1);
308  rho_on->SetMarkerSize(0.8);
309  rho_on->SetStats(kFALSE);
310 
311  TH2F* rho_on2 = new TH2F("rho_on2","",nBins,T_bgn,T_end,pp_rho_bin,pp_rho_min,pp_rho_max);
312  rho_on2->GetXaxis()->SetTitle(fname);
313  rho_on2->GetXaxis()->SetTimeDisplay(1);
314  rho_on2->GetYaxis()->SetTitle("#rho");
315  rho_on2->SetMarkerStyle(20);
316  rho_on2->SetMarkerColor(2);
317  rho_on2->SetMarkerSize(0.8);
318  rho_on2->SetStats(kFALSE);
319 
320  TH2F* rho_on3 = new TH2F("rho_on3","",nBins,T_bgn,T_end,pp_rho_bin,pp_rho_min,pp_rho_max);
321  rho_on3->GetXaxis()->SetTitle(fname);
322  rho_on3->GetXaxis()->SetTimeDisplay(1);
323  rho_on3->GetYaxis()->SetTitle("#rho");
324  rho_on3->SetMarkerStyle(20);
325  rho_on3->SetMarkerColor(3);
326  rho_on3->SetMarkerSize(0.8);
327  rho_on3->SetStats(kFALSE);
328 
329  sprintf(ch1,"rho[%d]:time[0]>>rho_on",pp_irho);
330  Draw(wave,ch1,notch2,"P");
331  sprintf(ch1,"rho[%d]:time[0]>>rho_on2",pp_irho);
332  Draw(wave,ch1,s_gracedb,"P SAME");
333  sprintf(ch1,"rho[%d]:time[0]>>rho_on3",pp_irho);
334  Draw(wave,ch1,s_offline,"P SAME");
335  rho_on->GetXaxis()->SetTitle("time, gps");
336  rho_on->SetTitle("all (black), gracedb (red), offline (green)");
337  sprintf(fname,"%s/rho_time_online.eps",netdir);
338  c1->Update(); c1->Print(fname);
339 
340  TH2F* ff_on=new TH2F("ff_on","ff_on",nfreq,freqLow,freqHigh,pp_rho_bin,pp_rho_min,pp_rho_max);
341  ff_on->SetTitleOffset(1.3,"Y");
342  ff_on->SetTitle("");
343  ff_on->GetXaxis()->SetTitle("frequency, Hz");
344  ff_on->SetStats(kFALSE);
345  ff_on->SetMarkerStyle(20);
346  ff_on->SetMarkerColor(1);
347  ff_on->SetMarkerSize(0.8);
348 
349  TH2F* ff_on2=new TH2F("ff_on2","ff_on2",nfreq,freqLow,freqHigh,pp_rho_bin,pp_rho_min,pp_rho_max);
350  ff_on2->SetTitleOffset(1.3,"Y");
351  ff_on2->SetTitle("");
352  ff_on2->GetXaxis()->SetTitle("frequency, Hz");
353  ff_on2->SetStats(kFALSE);
354  ff_on2->SetMarkerStyle(20);
355  ff_on2->SetMarkerColor(2);
356  ff_on2->SetMarkerSize(0.8);
357 
358  TH2F* ff_on3=new TH2F("ff_on3","ff_on3",nfreq,freqLow,freqHigh,pp_rho_bin,pp_rho_min,pp_rho_max);
359  ff_on3->SetTitleOffset(1.3,"Y");
360  ff_on3->SetTitle("");
361  ff_on3->GetXaxis()->SetTitle("frequency, Hz");
362  ff_on3->SetStats(kFALSE);
363  ff_on3->SetMarkerStyle(20);
364  ff_on3->SetMarkerColor(3);
365  ff_on3->SetMarkerSize(0.8);
366 
367  c1->Clear();
368  ff_on->SetTitle("all (black), lumin (red), offline (green)");
369  ff_on->GetYaxis()->SetTitle("#rho");
370  ff_on->GetXaxis()->SetMoreLogLabels(kTRUE);
371  ff_on->GetXaxis()->SetNoExponent(kTRUE);
372  sprintf(ch1,"rho[%d]:frequency[0]>>ff_on",pp_irho);
373  Draw(wave,ch1,notch2,"P");
374  sprintf(ch1,"rho[%d]:frequency[0]>>ff_on2",pp_irho);
375  Draw(wave,ch1,s_gracedb,"P SAME");
376  sprintf(ch1,"rho[%d]:frequency[0]>>ff_on3",pp_irho);
377  Draw(wave,ch1,s_offline,"P SAME");
378  sprintf(fname,"%s/rho_frequency_online.eps",netdir);
379  c1->Update(); c1->SaveAs(fname);
380 
381  TH2F* tf_on=new TH2F("tf_on","tf_on",nBins,T_bgn,T_end,nfreq,freqLow,freqHigh);
382  tf_on->SetTitleOffset(1.3,"Y");
383  tf_on->SetTitle("");
384  tf_on->GetXaxis()->SetTitle("frequency, Hz");
385  tf_on->SetStats(kFALSE);
386  tf_on->SetMarkerStyle(20);
387  tf_on->SetMarkerColor(1);
388  tf_on->SetMarkerSize(0.8);
389 
390  TH2F* tf_on2=new TH2F("tf_on2","tf_on2",nBins,T_bgn,T_end,nfreq,freqLow,freqHigh);
391  tf_on2->SetTitleOffset(1.3,"Y");
392  tf_on2->SetTitle("");
393  tf_on2->GetXaxis()->SetTitle("frequency, Hz");
394  tf_on2->SetStats(kFALSE);
395  tf_on2->SetMarkerStyle(20);
396  tf_on2->SetMarkerColor(2);
397  tf_on2->SetMarkerSize(0.8);
398 
399  TH2F* tf_on3=new TH2F("tf_on3","tf_on3",nBins,T_bgn,T_end,nfreq,freqLow,freqHigh);
400  tf_on3->SetTitleOffset(1.3,"Y");
401  tf_on3->SetTitle("");
402  tf_on3->GetXaxis()->SetTitle("frequency, Hz");
403  tf_on3->SetStats(kFALSE);
404  tf_on3->SetMarkerStyle(20);
405  tf_on3->SetMarkerColor(3);
406  tf_on3->SetMarkerSize(0.8);
407 
408  c1->Clear();
409  tf_on->SetTitle("all (black), lumin (red), offline (green)");
410  tf_on->GetYaxis()->SetTitle("frequency");
411  tf_on->GetXaxis()->SetTitle("time");
412  tf_on->GetXaxis()->SetTimeDisplay(1);
413  tf_on->GetXaxis()->SetMoreLogLabels(kTRUE);
414  tf_on->GetXaxis()->SetNoExponent(kTRUE);
415  sprintf(ch1,"frequency[0]:time[0]>>tf_on");
416  Draw(wave,ch1,notch2,"P");
417  sprintf(ch1,"frequency[0]:time[0]>>tf_on2");
418  Draw(wave,ch1,s_gracedb,"P SAME");
419  sprintf(ch1,"frequency[0]:time[0]>>tf_on3");
420  Draw(wave,ch1,s_offline,"P SAME");
421  sprintf(fname,"%s/time_frequency_online.eps",netdir);
422  c1->Update(); c1->SaveAs(fname);
423 
424  }
425 */
426 
427  gSystem->Exit(0);
428 }
TH2F * rho_T
char ch2[2048]
double sTARt
Double_t green[nRGBs]
void Export(TString fname="")
Definition: config.cc:388
double fHigh
double T_bgn
char ch1[256]
bool bcat3
gx Draw(GWAT_TIME)
dqfile VDQF[100]
bool bhveto
netevent W & wave
TString("c")
int nBins
Int_t GetEntry(Int_t)
Definition: netevent.cc:387
UChar_t VETO[100]
const Int_t nRGBs
Double_t blue[nRGBs]
static TString CWB_CAT_NAME[14]
Definition: GToolbox.hh:4
int nVDQF
int j
Definition: cwb_net.C:10
i drho i
void Import(TString umacro="")
Definition: config.cc:334
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
tuple ff
Definition: cwb_online.py:394
char ifo[NIFO_MAX][8]
char ch3[256]
#define nIFO
CWB_CAT cat
Definition: Toolbox.hh:68
Double_t stops[nRGBs]
fprintf(ftrig,"#Start\tStop\n")
double pp_rho_min
static bool isLeafInTree(TTree *itree, TString leaf)
Definition: Toolbox.cc:4682
TCanvas * c1
i() int(T_cor *100))
char netdir[1024]
bool pp_rho_log
char fname[1024]
int k
pp_rho_bin
double pp_rho_max
char net_file_name[256]
double T_end
char liv_file_name[256]
sprintf(fname,"%s/time.txt", netdir)
TChain live("liveTime")
bool bcat2
double fLow
int n
FILE * ftrig
double sTOp
static void mkDir(TString dir, bool question=false, bool remove=true)
Definition: Toolbox.cc:4000
int l
Definition: cbc_plots.C:434
char veto_not_vetoed[1024]
int pp_max_nloudest_list
double freqHigh
int cat
TH2F * rho_T2
double freqLow
Int_t GetEntries()
Definition: netevent.cc:381
fclose(ftrig)
TString config
Double_t red[nRGBs]
i drho pp_irho
void SetSingleDetectorMode()
Definition: config.cc:1334
char veto_vetoed[1024]