Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FixLiveTime_PP_DQ.C
Go to the documentation of this file.
1 // Author : GV
2 // this procedure read background files (rho vs rate) computed with livetime before DQ
3 // and write new background files (rho vs rate) computed with livetime after DQ
4 //
5 
6 #define LIVE_TIME_BEFORE_PP_DQ 67953.8 // years
7 #define LIVE_TIME_AFTER_PP_DQ 67406.8 // years
8 
9 void
10 FixLiveTime_PP_DQ(TString ifName, bool icol2=false, bool ocol2=false, bool force_exit=true, TString tag="") {
11 
12  if(!ifName.EndsWith(".txt")) {cout << "Error, file extention not '.txt'" << endl;exit(1);}
13 
14  TString ofName = ifName;
15  if(tag=="") ofName.ReplaceAll(".txt","_LTDQ.txt");
16  else ofName.ReplaceAll(".txt",TString("_")+tag+"_LTDQ.txt");
17 
18  cout << "Input File : " << ifName << endl;
19  cout << "Output File : " << ofName << endl;
20 
21  double live_time_ratio = LIVE_TIME_BEFORE_PP_DQ/LIVE_TIME_AFTER_PP_DQ;
22 
23  double rho,erho;
24  double far,efar;
25 
26  ifstream in;
27  in.open(ifName.Data(),ios::in);
28  if (!in.good()) {cout << "Error Opening File : " << ifName.Data() << endl;exit(1);}
29 
30  ofstream out;
31  out.open(ofName,ios::out);
32  if(!out.good()) {cout << "Error : Opening File : " << ofName << endl;gSystem->Exit(1);}
33 
34  // fixed live time
35  while (1) {
36  if(icol2) in >> rho >> far;
37  else in >> rho >> far >> erho >> efar;
38  if (!in.good()) break;
39  double far_LTDQ = far*live_time_ratio;
40  double efar_LTDQ = efar*live_time_ratio;
41  //cout << rho << " " << far << " " << far_LTDQ << endl;
42  if(ocol2) out << rho << "\t" << far_LTDQ << endl;
43  else out << rho << "\t" << far_LTDQ << "\t" << erho << "\t" << efar_LTDQ << endl;
44  }
45 
46  in.close();
47  out.close();
48 
49  if(force_exit) exit(0);
50 }
double rho
TString ofName
void FixLiveTime_PP_DQ(TString ifName, bool icol2=false, bool ocol2=false, bool force_exit=true, TString tag="")
TString("c")
#define LIVE_TIME_BEFORE_PP_DQ
ofstream out
Definition: cwb_merge.C:196
char tag[256]
Definition: cwb_merge.C:74
ifstream in
#define LIVE_TIME_AFTER_PP_DQ
exit(0)