Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_report_pe.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 // post-production macro for the simulation report : used by the cwb_report command
20 {
21 
22  #define NMDC_MAX 64
23 
24  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
25  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
26  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
27  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
28  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
29  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
30 
31 #ifndef _USE_ROOT6
32  // the CWB_CAT_NAME declared in CWB_EPPARAMETERS_FILE is not visible. why?
33  // the include is defined again
34  #undef GTOOLBOX_HH
35 #else
36  #include "GToolbox.hh"
37 #endif
38 
39  if(nIFO==1) { // Single Detector Mode
41  config.Import();
42  config.SetSingleDetectorMode();
43  config.Export();
44  }
45 
46  // get merge label
47  TString mlabel=TString(gSystem->Getenv("CWB_MERGE_LABEL"));
48 
49  // initialize the ifo name (takes into account the non built-in detectors)
50  vector<TString> IFO;
51  for(int n=0;n<nIFO;n++) IFO.push_back(ifo[n]);
52 
53  // create output report dir
54  CWB::Toolbox::mkDir(netdir,!pp_batch);
55 
56  TString pp_pe_mdc = CWB::Toolbox::getParameter(pp_pe,"--mdc");
57  // check if format is correct
58  pp_pe_mdc.ReplaceAll("/","");
59  if(!pp_pe_mdc.IsDigit() && pp_pe_mdc!="-1") {
60  cout << "cwb_report_pe.C : Error - bad option '--mdc type' in pp_pe parameter" << endl;
61  cout << " mdc type must be a integer number [-1:N] or i/j/.../k=[1:N]" << endl;
62  cout << endl;
63  exit(1);
64  }
65  // extract list of mdc types
66  vector<int> mtype;
67  TObjArray* token = TString(pp_pe_mdc).Tokenize(TString("/"));
68  if(token) {
69  for(int i=0;i<token->GetEntries();i++) {
70  int itype = ((TObjString*)token->At(i))->GetString().Atoi();
71  mtype.push_back(itype);
72  }
73  delete token;
74  }
75  if(mtype.size()>1) { // multiple mdc types
76  for(int i=0;i<mtype.size();i++) {
77  if(mtype[i]==-1 || mtype[i]==0) {
78  cout << "cwb_report_pe.C : Error - bad option '--mdc type' in pp_pe parameter" << endl;
79  cout << " multiple mdc types must be in the range [1:N]" << endl;
80  cout << endl;
81  exit(1);
82  }
83  }
84  } else {
85  if(mtype[0]<-1) {
86  cout << "cwb_report_pe.C : Error - bad option '--mdc type' in pp_pe parameter" << endl;
87  cout << " mdc type must be in the range [-1:N] " << endl;
88  cout << endl;
89  exit(1);
90  }
91  }
92 
93  vector<int> vtype;
94  vector<TString> vname;
95  if(mtype[0]!=0) { // read injection file types
96  char imdc_set[NMDC_MAX][128]; // injection set
97  size_t imdc_type[NMDC_MAX]; // injection type
98  char imdc_name[NMDC_MAX][128]; // injection name
99  double imdc_fcentral[NMDC_MAX]; // injection central frequencies
100  double imdc_fbandwidth[NMDC_MAX]; // injection bandwidth frequencies
101  size_t imdc_index[NMDC_MAX]; // type reference array
102  size_t imdc_iset[NMDC_MAX]; // injection set index
103 
104  int ninj=ReadInjType(mdc_inj_file,NMDC_MAX,imdc_set,imdc_type,
105  imdc_name,imdc_fcentral,imdc_fbandwidth);
106  if(ninj==0) {
107  cout << "cwb_report_pe.C : Error - no injection - terminated" << endl;
108  exit(1);
109  }
110  if(mtype[0]>0) { // mdc_type>0 : select types from injection file types
111  for(int i=0;i<mtype.size();i++) {
112  for(int j=0;j<ninj;j++) {
113  if(mtype[i]==(imdc_type[j]+1)) {
114  vtype.push_back(imdc_type[j]+1);
115  vname.push_back(imdc_name[j]);
116  }
117  }
118  }
119  } else { // mdc_type=-1 : use full list of types from injection file types
120  for(int j=0;j<ninj;j++) {
121  vtype.push_back(imdc_type[j]+1);
122  vname.push_back(imdc_name[j]);
123  }
124  }
125  } else { // mdc_type=0 : all types are displayed together
126  vtype.push_back(0);
127  vname.push_back("ALL");
128  }
129 
130  Color_t colors[16] = {2, 3, 6, 4, 8, 43, 7, 8, 4, 5, 2, 43, 1, 3, 2, 1};
131 
132  // create setup file for the DrawMedianPRCvsSNR.C macro
133  ofstream out;
134  char listFile[256];
135  sprintf(listFile,"%s/DrawMedianPRCvsSNR.lst", netdir);
136  cout << listFile << endl;
137  out.open(listFile,ios::out);
138  if(!out.good()) {cout << "cwb_report_pe.C : Error Opening File : " << listFile << endl;exit(1);}
139  for(int i=0;i<vtype.size();i++) {
140  char wave_file_name[1024];
141  sprintf(wave_file_name,"%s/wave_%s.%s.root",merge_dir,data_label,mlabel.Data());
142  out << wave_file_name << "\t" << vname[i] << "\t" << vtype[i]
143  << "\t" << (int)colors[i%16] << "\t" << 0 << endl;
144  }
145  out.close();
146 
147  // load PRC macros
148  gROOT->LoadMacro(gSystem->ExpandPathName("$HOME_CWB/macros/DrawWRC.C"));
149  gROOT->LoadMacro(gSystem->ExpandPathName("$HOME_CWB/macros/DrawRECvsINJ.C"));
150  gROOT->LoadMacro(gSystem->ExpandPathName("$HOME_CWB/macros/DrawSkyDistributionPRC.C"));
151  gROOT->LoadMacro(gSystem->ExpandPathName("$HOME_CWB/macros/DrawSearchAreaPRC.C"));
152  gROOT->LoadMacro(gSystem->ExpandPathName("$HOME_CWB/macros/DrawCosOmegaPRC.C"));
153  gROOT->LoadMacro(gSystem->ExpandPathName("$HOME_CWB/macros/DrawCoverageVsPercentagePRC.C"));
154  gROOT->LoadMacro(gSystem->ExpandPathName("$HOME_CWB/macros/DrawMedianPRCvsSNR.C"));
155 
156  // get plugin options (polarization=SCALAR/TENSOR)
157 
159  if(TString(parPlugin)!="") {
160  cout << "pe polarization options : " << parPlugin << endl;
161  TObjArray* token = TString(parPlugin).Tokenize(TString(' '));
162  for(int j=0;j<token->GetEntries();j++) {
163 
164  TObjString* tok = (TObjString*)token->At(j);
165  TString stok = tok->GetString();
166 
167  if(stok.Contains("--pe_polarization=")) {
168  polarization=stok;
169  polarization.Remove(0,polarization.Last('=')+1);
170  polarization.ToUpper();;
171  }
172  }
173  }
174 
175  // execute PRC macros
176 
177  DrawMedianPRCvsSNR(listFile,"","MEDIAN50",TString(netdir)+"/median50_vs_snr.png",
179  DrawMedianPRCvsSNR(listFile,"","MEDIAN90",TString(netdir)+"/median90_vs_snr.png",
181 
183  T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar, true, polarization, true);
185  T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar, false, polarization);
186 
187  DrawWRC("nre",data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
189 
190  DrawWRC("ff",data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
192 
193  DrawWRC("of",data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
195 
196  DrawWRC("ofnre",data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
198 
199  DrawWRC("offf",data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
201 
202  DrawWRC("snr",data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
204 
205  for(int n=1;n<13;n++) {
206  char gtype[16];sprintf(gtype,"mch%d",n);
207  DrawWRC(gtype,data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
209  }
210 
211  DrawRECvsINJ("snr", data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
213 
214  DrawRECvsINJ("distance", data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
216 
217  DrawCosOmegaPRC(data_label, netdir, mlabel, nIFO, T_win, pp_inetcc,
219 
222 
225 
228 
231 
232  exit(0);
233 }
sprintf(listFile,"%s/DrawMedianPRCvsSNR.lst", netdir)
double T_ifar
double T_pen
void Export(TString fname="")
Definition: config.cc:406
char parPlugin[1024]
int n
Definition: cwb_net.C:28
TString("c")
double T_cor
DrawCosOmegaPRC(data_label, netdir, mlabel, nIFO, T_win, pp_inetcc, T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar)
TString polarization
i pp_inetcc
Color_t colors[16]
DrawWRC("nre", data_label, netdir, mlabel, nIFO, T_win, pp_inetcc, T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar)
int j
Definition: cwb_net.C:28
TObjArray * token
Definition: cwb_report_pe.C:67
i drho i
void Import(TString umacro="")
Definition: config.cc:352
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
size_t imdc_iset[NMDC_MAX]
Definition: cwb_mkeff.C:68
char ifo[NIFO_MAX][8]
DrawCoverageVsPercentagePRC("prc", data_label, netdir, mlabel, nIFO, T_win, pp_inetcc, T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar)
#define nIFO
vector< int > mtype
Definition: cwb_report_pe.C:66
char data_label[512]
Definition: test_config1.C:160
size_t imdc_index[NMDC_MAX]
Definition: cwb_mkeff.C:67
exit(0)
char mdc_inj_file[1024]
Definition: cwb_dump_inj.C:98
i() int(T_cor *100))
char netdir[1024]
DrawSkyDistributionPRC(data_label, netdir, mlabel, IFO, detParms, T_win, pp_inetcc, T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar, true, polarization, true)
#define NMDC_MAX
int ninj
Definition: cwb_mkeff.C:70
char merge_dir[512]
Definition: test_config1.C:147
char imdc_name[NMDC_MAX][128]
Definition: cwb_mkeff.C:64
TString GetString(TTree *tree, int run, int lag, TString psfix)
Definition: Toolfun.hh:283
int ReadInjType(TString ifName, int ntype_max, char set[][128], size_t type[], char name[][128], double fcentral[], double fbandwidth[])
Definition: Toolfun.hh:816
TString mlabel
Definition: cwb_report_pe.C:47
DrawRECvsINJ("snr", data_label, netdir, mlabel, nIFO, T_win, pp_inetcc, T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar)
DrawSearchAreaPRC(data_label, netdir, mlabel, nIFO, T_win, pp_inetcc, T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar)
static TString getParameter(TString options, TString param="")
Definition: Toolbox.cc:6727
ofstream out
DrawMedianPRCvsSNR(listFile,"","MEDIAN50", TString(netdir)+"/median50_vs_snr.png", T_win, pp_inetcc, T_cor, pp_irho, T_cut, T_vED, T_pen, T_ifar)
double T_win
static void mkDir(TString dir, bool question=false, bool remove=true)
Definition: Toolbox.cc:4714
double T_cut
TString pp_pe
char listFile[256]
size_t imdc_type[NMDC_MAX]
Definition: cwb_mkeff.C:63
double T_vED
TString config
detectorParams detParms[4]
vector< TString > vname
Definition: cwb_report_pe.C:94
double imdc_fcentral[NMDC_MAX]
Definition: cwb_mkeff.C:65
i drho pp_irho
vector< TString > IFO
Definition: cwb_report_pe.C:50
char imdc_set[NMDC_MAX][128]
Definition: cwb_mkeff.C:62
void SetSingleDetectorMode()
Definition: config.cc:1352
double imdc_fbandwidth[NMDC_MAX]
Definition: cwb_mkeff.C:66