Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_dump_events.C
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 // dump/view the event parameters : used by the cwb_dump events
20 
21 {
23 
24  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
25 
27  if(gSystem->Getenv("CWB_DUMP_EVT_FILE_NAME")==NULL) {
28  cout << "Error : environment CWB_DUMP_EVT_FILE_NAME is not defined!!!" << endl;exit(1);
29  } else {
30  cwb_dump_evt_file_name=TString(gSystem->Getenv("CWB_DUMP_EVT_FILE_NAME"));
31  }
32  if(cwb_dump_evt_file_name.Contains(".root")==0) {
33  cout << "Error : " << cwb_dump_evt_file_name.Data() << " is not a root file!!!" << endl;exit(1);
34  }
35 
37  if(gSystem->Getenv("CWB_DUMP_EVT_MODE")!=NULL) {
38  cwb_dump_evt_mode=TString(gSystem->Getenv("CWB_DUMP_EVT_MODE"));
39  }
40 
41  TFile *ifile = TFile::Open(cwb_dump_evt_file_name);
42  if(ifile==NULL) {cout << "Failed to open " << cwb_dump_evt_file_name.Data() << endl;exit(-1);}
43 
44  // get waveburst tree
45  TTree* itree = (TTree *) ifile->Get("waveburst");
46  if(itree==NULL) {cout << "Error : tree waveburst not present !!!" << endl;exit(1);}
47 
48  // get detector list
49  TList* list = itree->GetUserInfo();
50  int nifo=list->GetSize();
51  if (nifo==0) {cout << "Error : no ifo present in the tree" << endl;exit(1);}
52  detector** pD = new detector*[nifo];
53  for (int n=0;n<nifo;n++) {
54  pD[n] = (detector*)list->At(n);
55  detectorParams dParams = pD[n]->getDetectorParams();
56  //pD[n]->print();
57  }
58 
59  netevent EVT(itree,nifo);
60  for (int n=0;n<nifo;n++) EVT.ifoList.push_back(pD[n]);
61 
62  // build dump file name
63  char evtFile[512];
64  TObjArray* token = TString(cwb_dump_evt_file_name).Tokenize(TString("/"));
65  sprintf(evtFile,"%s/%s",dump_dir,
66  TString(((TObjString*)token->At(token->GetEntries()-1))->GetString()).ReplaceAll(".root",".evt").Data());
67 
68  // dump header
69  if(cwb_dump_evt_mode.CompareTo("view")!=0) {
70  cout << "Write : " << evtFile << endl;
71  EVT.dopen(evtFile,const_cast<char*>("w"),true);
72  EVT.dclose();
73  }
74  // dump events
75  int nEVT = EVT.GetEntries();
76  for(int i=0;i<nEVT;i++) {
77 
78  EVT.GetEntry(i);
79 
80  if(cwb_dump_evt_mode.CompareTo("view")==0) EVT.fP = stdout;
81  else EVT.dopen(evtFile,const_cast<char*>("a"),false);
82  EVT.Dump();
83  if(cwb_dump_evt_mode.CompareTo("view")!=0) EVT.dclose();
84  }
85 
86  exit(0);
87 }
detectorParams getDetectorParams()
Definition: detector.cc:218
int n
Definition: cwb_net.C:28
TString("c")
Int_t GetEntry(Int_t)
Definition: netevent.cc:409
CWB::Toolbox TB
i drho i
TList * list
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
int nEVT
void dopen(const char *fname, char *mode, bool header=true)
Definition: netevent.hh:312
exit(0)
void Dump(TString analysis="2G")
Definition: netevent.hh:327
std::vector< detector * > ifoList
dump file
Definition: netevent.hh:143
TObjArray * token
TString cwb_dump_evt_mode
int nifo
FILE * fP
injected reconstructed xcor waveform
Definition: netevent.hh:141
netevent EVT(itree, nifo)
condor_log_dir ReplaceAll("X_HOME", uhome.Data())
void dclose()
Definition: netevent.hh:321
TFile * ifile
char dump_dir[512]
Definition: test_config1.C:156
TString cwb_dump_evt_file_name
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
TTree * itree
Int_t GetEntries()
Definition: netevent.cc:403
detector ** pD