Logo coherent WaveBurst  
Library Reference Guide
Logo
ReadFileWAVE.C
Go to the documentation of this file.
1 //
2 // This example show how to read event parameters from root wave file
3 // The full parameter list is defined in trunk/wat/netevent.hh
4 // Author : Gabriele Vedovato
5 
6 
7 void ReadFileWAVE(TString fName, TString cuts="", int nIFO=0) {
8 
9  netevent event(fName.Data(),nIFO); // open wave root file
10  int nevt = event.GetEntries(); // get number of detected events
11  if(nevt==0) {
12  cout << "events are not present in the file : " << fName.Data() << endl;
13  gSystem->Exit(1);
14  } else cout << "nevt : " << nevt << endl;
15 
16  // if detector objects are present then print detector infos
17  TList* ifoList = event.fChain->GetUserInfo();
18  detectorParams dParams[NIFO_MAX];
19  for (int n=0;n<ifoList->GetSize();n++) {
20  detector* pDetector = (detector*)ifoList->At(n);
21  dParams[n] = pDetector->getDetectorParams();
22  cout << dParams[n].name << endl;
23  pDetector->print();
24  }
25 
26  // if nIFO is not provided (nIFO=0) then it is retrieved from the input root file
27  nIFO = nIFO==0 ? ifoList->GetSize() : nIFO;
28  if(nIFO==0) {
29  cout << "nIFO is not contained in the root file, must be declared as the input macro parameter" << endl;
30  gSystem->Exit(1);
31  }
32 
33  // check cuts
34  TTreeFormula* treeformula=NULL;
35  if(cuts!="") {
36  treeformula = new TTreeFormula("cuts", cuts.Data(), event.fChain);
37  int err = treeformula->Compile(cuts.Data());
38  if(err) {
39  cout << "ReadFileWAVE.C - wrong input cuts " << cuts << endl;
40  return -1;
41  }
42  }
43 
44  for(int n=0;n<nevt;n++) { // loop over the detected events
45 
46  event.GetEntry(n); // load event #n
47 
48  if(treeformula!=NULL) {
49  if(treeformula->EvalInstance()==0) { // skip entry if it does not satisfy selection cuts
50  cout << "Skip entry number : " << n << endl;
51  continue;
52  }
53  }
54 
55  cout.precision(14);
56  cout << "-----------------------------------" << endl;
57  cout << " Event Parameters " << n << endl;
58  cout << "-----------------------------------" << endl;
59  cout << endl;
60  cout << "rho : " << "rec = " << event.rho[0] << endl;
61  cout << "cc : " << "rec = " << event.netcc[1] << endl;
62  cout << "subnet : " << "rec = " << event.netcc[3] << endl;
63  cout << "network snr : " << "rec = " << sqrt(event.likelihood) << endl;
64  cout << "frequency : " << "rec = " << event.frequency[0]
65  << " fLow = " << event.low[0] << " fHigh = " << event.high[0] << endl;
66  cout << "phi : " << "rec = " << event.phi[0] << " inj = " << event.phi[1] << endl;
67  cout << "theta : " << "rec = " << event.theta[0] << " inj = " << event.theta[1] << endl;
68  cout << "error region: " << event.erA[0] << endl;
69  cout << endl;
70  for(int i=0;i<nIFO;i++) {
71  cout << "-----------------------------------" << endl;
72  if(ifoList->GetSize()==nIFO)
73  cout << "ifo : " << dParams[i].name << endl;
74  else
75  cout << "ifo : " << i << endl;
76  cout << "-----------------------------------" << endl;
77  cout << endl;
78  cout << "time : " << "rec = " << event.time[i] << " inj = " << event.time[nIFO+i] << endl;
79  cout << "time range : " << "tStart = " << event.start[i] << " tStop = " << event.stop[i] << endl;
80  cout << "snr : " << event.snr[i] << endl;
81  cout << "hrss : " << event.hrss[i] << endl;
82  cout << endl;
83  }
84  }
85 
86  exit(0);
87 }
detectorParams getDetectorParams()
Definition: detector.cc:218
char name[32]
Definition: detector.hh:50
par [0] name
int n
Definition: cwb_net.C:28
TString("c")
int nevt
i drho i
#define nIFO
void ReadFileWAVE(TString fName, TString cuts="", int nIFO=0)
Definition: ReadFileWAVE.C:7
const int NIFO_MAX
Definition: wat.hh:22
void print()
Definition: detector.cc:1797
char fName[256]
exit(0)