Logo coherent WaveBurst  
Library Reference Guide
Logo
TestLiveTime.C
Go to the documentation of this file.
1 // This macro compare the livetime computed by the CWB pipeline and the approximate one
2 // computed CWB::Toolbox::getLiveTime
3 // usage : root -n -l -b ${CWB_PARMS_FILES} 'TestLiveTime.C("live.root",3)'
4 // WARNING : this macro works only for standard lags (not for slag) !!!
5 // Author : Gabriele Vedovato
6 
7 
8 void TestLiveTime(TString liveName, int nIFO=3, TString fName="live_bech.txt") {
9 // liveName : live root file name
10 // nIFO : number of detectors
11 // fName : output benchmark file name
12 
14 
15  // check if liveName exist
16  TB.checkFile(liveName);
17 
18  // check if parameter files exist
19  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
20  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
21  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
22 
23  // compute cat2List & jobList
24  vector<waveSegment> cat1List=TB.readSegList(nDQF, DQF, CWB_CAT1);
25  vector<waveSegment> cat2List=TB.readSegList(nDQF, DQF, CWB_CAT2);
26  vector<waveSegment> jobList=TB.getJobList(cat1List, cat2List, segLen, segMLS, segTHR, segEdge);
27  cout<<"Number of standard jobs : " << jobList.size() <<endl<<endl;
28 
29  // open livetime root file
30  TChain live("liveTime");
31  live.Add(liveName);
32 
33  wavearray<double> Trun(500000); Trun = 0.;
41 
42  int lag_number=-1; // get all lag except zero lag
43  int slag_number=0;
44  // get total livetime
45  double liveTOT=TB.getLiveTime(nIFO,live,Trun,Wlag,Wslag,Tlag,Tdlag,lag_number,slag_number);
46  cout << "total livetime from cWB : " << (int)liveTOT << endl;
47 
48  // Wlag don't contains lag zero, a new lag array is made which contains the zero lag
49  vector<wavearray<double> > lag(nIFO+1);
50  for(int i=0;i<nIFO+1;i++) {
51  lag[i].resize(Wlag[i].size()+1);
52  lag[i][0]=0; // add lag zero
53  for(int j=0;j<Wlag[i].size();j++) lag[i][j+1]=Wlag[i][j];
54  }
55 
56  // build a sub jobList which contains only the processed set
57  vector<waveSegment> sjobList;
58  for(int i=0;i<jobList.size();i++) {
59  int jobID = jobList[i].index;
60  if(Trun[jobID-1]==0) continue; // skip jobID with 0 livetime
61  sjobList.push_back(jobList[i]);
62  }
63 
64  FILE *fP;
65  if((fP = fopen(fName.Data(), "w")) == NULL) {
66  cout << "cannot open output file " << fName.Data() <<". \n";
67  gSystem->Exit(1);
68  };
69  cout << "Write output file : " << fName.Data() << endl;
70  fprintf(fP,"# lagID\t liveCWB\t liveTB\t\t 100*(TB-CWB)/CWB\n");
71 
72  // get cWB livetime for each lag and compare with the approximate value from CWB::Toolbox::getLiveTime
73  vector<double> shiftList(nIFO);
74  for(int i=0;i<lag[0].size();i++) {
75 
76  lag_number = lag[nIFO][i];
77 
78  cout << endl;
79  cout << i << " lagID " << lag_number << " -> ";
80  for(int j=0;j<nIFO;j++) shiftList[j]=lag[j][i];
81  for(int j=0;j<nIFO;j++) cout << shiftList[j] << " ";
82  cout << endl;
83 
84  double liveCWB=TB.getLiveTime(nIFO,live,Trun,Wlag,Wslag,Tlag,Tdlag,lag_number,slag_number);
85  cout << "livetime from CWB : " << (int)liveCWB << endl;
86 
87  double liveTB = TB.getLiveTime(sjobList, cat2List, shiftList);
88  cout << "livetime from TB : " << (int)liveTB << endl;
89 
90  double liveDif = 100*(liveTB-liveCWB)/liveCWB;
91  cout << "livetime diff 100*(TB-CWB)/CWB " << liveDif << endl;
92 
93  fprintf(fP,"%d\t %f\t %f\t %g\t \n",lag_number,liveCWB,liveTB,liveDif);
94  }
95  if(fP!=NULL) fclose(fP);
96 
97  delete [] Wlag;
98  delete [] Wslag;
99 
100  exit(0);
101 }
double segMLS
Definition: test_config1.C:47
TString live
wavearray< double > Trun(500000)
TString("c")
wavearray< double > Olag
CWB::Toolbox TB
Long_t size
static double getLiveTime(vector< waveSegment > &jobList, vector< waveSegment > &dqList)
Definition: Toolbox.cc:2094
double segEdge
Definition: test_config1.C:49
int j
Definition: cwb_net.C:28
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
int jobID
Definition: cwb_net.C:195
nDQF
Definition: cwb_eced.C:109
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
double segTHR
Definition: test_config1.C:48
#define nIFO
virtual size_t size() const
Definition: wavearray.hh:145
void TestLiveTime(TString liveName, int nIFO=3, TString fName="live_bech.txt")
Definition: TestLiveTime.C:8
wavearray< double > Rlag
vector< int > jobList
i() int(T_cor *100))
dqfile DQF[12]
Definition: test_config1.C:171
wavearray< double > Tlag
segLen
Definition: cwb_eced.C:24
wavearray< double > Tdlag
vector< waveSegment > cat1List
static vector< waveSegment > getJobList(vector< waveSegment > ilist, double segLen=600., double segMLS=300., double segEdge=8.)
Definition: Toolbox.cc:646
FILE * fP
static vector< waveSegment > readSegList(dqfile DQF)
Definition: Toolbox.cc:409
cout<< "total cat1 livetime : "<< int(cat1_time)<< " sec "<< cat1_time/3600.<< " h "<< cat1_time/86400.<< " day"<< endl;cout<< endl;vector< waveSegment > cat2List
Definition: cwb_dump_job.C:40
wavearray< double > Wlag[NIFO_MAX+1]
wavearray< double > Elag
fclose(ftrig)
char fName[256]
exit(0)
wavearray< double > Wslag[NIFO_MAX+1]