Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Efficiency2Gvs1G.C
Go to the documentation of this file.
1 // this macro produces an html page : 1G vs 2G efficiency 50% comparison
2 // Author : Gabriele Vedovato
3 //
4 // run ex : root 'Efficiency2Gvs1G.C("definitions.C",50)'
5 // definitions.C contains all definitions
6 //
7 // --------------------------------------------------------------
8 // 1G vs 2G pipeline definitions
9 // --------------------------------------------------------------
10 // #define TITLE_LABEL "" // report title
11 // #define OFILE_LABEL "" // report/dump/s/Efficiency2Gvs1G_OFILE_LABEL
12 // --------------------------------------------------------------
13 // 1G pipeline definitions
14 // --------------------------------------------------------------
15 // #define PDIR_1G "" // working dir
16 // #define SDIR_1G "" // report sub directory (report/postprod/XXX/data)
17 // #define SWWW_1G "" // simulation www link
18 // #define BWWW_1G "" // background www link
19 // --------------------------------------------------------------
20 // 2G pipeline definitions
21 // --------------------------------------------------------------
22 // #define PDIR_2G "" // working dir
23 // #define SDIR_2G "" // report sub directory (report/postprod/XXX/data)
24 // #define SWWW_2G "" // simulation www link
25 // #define BWWW_2G "" // background www link
26 //
27 
28 int GetEfficiency(double eff, TString directory, vector<TString>& vname, vector<double>& vhrss);
29 
30 void Efficiency2Gvs1G(TString cfgFile, int efficiency=50) {
31 
32  if(efficiency<0 || efficiency>100) {
33  cout << "Efficiency2Gvs1G : Error - efficiency must be [0,100]" << endl;
34  exit(1);
35  }
36 
37  gROOT->Macro(cfgFile);
38 
39  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
40  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
41  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
42  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
43 
44  gROOT->Macro(gSystem->ExpandPathName("$CWB_PARAMETERS_FILE"));
45  gROOT->Macro(gSystem->ExpandPathName("$CWB_UPARAMETERS_FILE"));
46 // gROOT->Macro(gSystem->ExpandPathName("$CWB_PPARAMETERS_FILE"));
47 
48  vector<TString> vname[2];
49  vector<double> vhrss[2];
50 
51  GetEfficiency(efficiency/100., TString(PDIR_1G)+"/"+SDIR_1G, vname[0], vhrss[0]);
52  GetEfficiency(efficiency/100., TString(PDIR_2G)+"/"+SDIR_2G, vname[1], vhrss[1]);
53 
54  cout << "1G efficiencies" << endl;
55  for(int i=0;i<vname[0].size();i++) {
56  cout << vname[0][i] << " " << vhrss[0][i] << endl;
57  }
58  cout << endl;
59 
60  cout << "2G efficiencies" << endl;
61  for(int i=0;i<vname[1].size();i++) {
62  cout << vname[1][i] << " " << vhrss[1][i] << endl;
63  }
64  cout << endl;
65 
66  char title[1024];
67  sprintf(title,"%s - Efficiency %d",TITLE_LABEL,efficiency);
68 
69  cout << "1G vs 2G efficiencies" << endl;
70  char eff_file[1024];sprintf(eff_file,"%s/Efficiency2Gvs1G_%s_eff%d.html",dump_dir,OFILE_LABEL,efficiency);
71  ofstream out;
72  out.open(eff_file,ios::out); // create Efficiency2Gvs1G.html
73  char oline[1024];
74  out << "<html>" << endl;
75  out << "<font color=\"red\" style=\"font-weight:bold;\"><center><p><h2>"
76  << title << "</h2><p><center></font>" << endl;
77 
78  out << "<h4>1G : " << endl;
79  sprintf(oline,"<a target=\"_parent\" href=\"%s\">bkg report page</a>",BWWW_1G);
80  out << oline << endl;
81  out << "---" << endl;
82  sprintf(oline,"<a target=\"_parent\" href=\"%s\">sim report page</a>",SWWW_1G);
83  out << oline << endl;
84  out << "</h4>" << endl;
85  out << "<h4>2G : " << endl;
86  sprintf(oline,"<a target=\"_parent\" href=\"%s\">bkg report page</a>",BWWW_2G);
87  out << oline << endl;
88  out << "---" << endl;
89  sprintf(oline,"<a target=\"_parent\" href=\"%s\">sim report page</a>",SWWW_2G);
90  out << oline << endl;
91  out << "</h4>" << endl;
92 
93  out << "<table border=1 cellpadding=12 align=\"center\">" << endl;
94  out << "<br>" << endl;
95 
96  out << "<tr align=\"center\">" << endl;
97  out << "<td align=\"center\"><font color=\"red\"> ID </font></td>" << endl;
98  out << "<td align=\"center\"><font color=\"red\"> MDC </font></td>" << endl;
99  out << "<td align=\"center\"><font color=\"red\"> 1G efficiency 50% </font></td>" << endl;
100  out << "<td align=\"center\"><font color=\"red\"> 2G efficiency 50% </font></td>" << endl;
101  out << "<td align=\"center\"><font color=\"red\"> 100*(2G-1G)/Min(1G,2G) </font></td>" << endl;
102  out << "</tr>" << endl;
103 
104  for(int i=0;i<vname[1].size();i++) {
105  for(int j=0;j<vname[0].size();j++) {
106  if(vname[1][i]==vname[0][j]) {
107 
108  out << "<tr align=\"center\">" << endl;
109  sprintf(oline,"<td align=\"center\"><font color=\"black\">%d</font></td>",i+1);
110  out << oline << endl;
111  sprintf(oline,"<td align=\"center\"><font color=\"blue\">%s</font></td>",vname[1][i].Data());
112  out << oline << endl;
113  sprintf(oline,"<td align=\"center\"><font color=\"black\">%2.2g</font></td>",vhrss[0][j]);
114  out << oline << endl;
115  sprintf(oline,"<td align=\"center\"><font color=\"black\">%2.2g</font></td>",vhrss[1][i]);
116  out << oline << endl;
117  double percentage = 100.*(vhrss[1][i]-vhrss[0][j])/TMath::Min(vhrss[0][j],vhrss[1][i]);
118  if(percentage<=0) {
119  sprintf(oline,"<td align=\"center\"><font color=\"blue\">%2.1f</font></td>",percentage);
120  } else {
121  sprintf(oline,"<td align=\"center\"><font color=\"red\">%2.1f</font></td>",percentage);
122  }
123  out << oline << endl;
124  out << "</tr>" << endl;
125 
126  cout << i << " " << vname[1][i] << " " << vhrss[1][i] << " " << vhrss[0][j] << endl;
127  }
128  }
129  }
130 
131  out << "</table>" << endl;
132  out << "</html>" << endl;
133  out.close();
134 
135  cout << endl << eff_file << endl << endl;
136 
137  exit(0);
138 }
139 
140 int
141 GetEfficiency(double eff, TString directory, vector<TString>& vname, vector<double>& hrss) {
142 
143  vector<TString> fileList = CWB::Toolbox::getFileListFromDir(directory, ".txt", "","fit_parameters");
144 
145  for(int i=0;i<fileList.size();i++) {
146 
147  cout << i << " " << fileList[i].Data() << endl;
148  // 16 2.014E+01 2.695E-21 +- 7.012E-23 3.454E-01 5.000E-01 7.552E-01 SG1615Q100
149 
150  ifstream in(fileList[i]);
151  if(!in.good()) {cout << "Error Opening File : " << fileList[i] << endl;exit(1);}
152 
153  char dummy[1024];
154  char name[1024];
155  double chi2, hrss50, sigma, betam, betap, hrssEr;
156  while(1) {
157  in >> dummy >> chi2 >> hrss50 >> dummy >> dummy >> sigma >> betam >> betap >> name;
158  if (!in.good()) break;
159  vname.push_back(name);
160 
161  double par0=TMath::Log10(hrss50);
162  TF1 fitFunc("logNfit",logNfit,pow(10.0,-23.0),pow(10.0,-18.5),5);
163  fitFunc.SetNpx(10000);
164  fitFunc.SetParameters(par0,sigma,betam,betap,0);
165  fhrss=fitFunc.GetX(eff,pow(10.0,-25.0),pow(10.0,-18.5));
166  hrss.push_back(fhrss);
167  }
168  in.close();
169  }
170 
171  return 0;
172 }
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:4333
TH2F * efficiency
par[0] name
TString("c")
int j
Definition: cwb_net.C:10
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
ofstream out
Definition: cwb_merge.C:196
double hrss
Definition: TestMDC.C:70
char oline[1024]
float chi2
Definition: cbc_plots.C:603
double sigma
char title[256]
Definition: SSeriesExample.C:1
ifstream in
cout<< "Starting reading output directory ..."<< endl;vector< TString > fileList
char dump_dir[512]
Definition: test_config1.C:156
int GetEfficiency(double eff, TString directory, vector< TString > &vname, vector< double > &vhrss)
void Efficiency2Gvs1G(TString cfgFile, int efficiency=50)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
vector< TString > vname
Definition: cwb_report_pe.C:76
Double_t logNfit(Double_t *x, Double_t *par)
Definition: Toolfun.hh:20
exit(0)