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