Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_dump_history.C
Go to the documentation of this file.
1 // dump/view the history infos : used by the cwb_dump command
2 
3 {
5 
6  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
7 
9  if(gSystem->Getenv("CWB_DUMP_HIST_FILE_NAME")==NULL) {
10  cout << "Error : environment CWB_DUMP_HIST_FILE_NAME is not defined!!!" << endl;exit(1);
11  } else {
12  cwb_dump_hist_file_name=TString(gSystem->Getenv("CWB_DUMP_HIST_FILE_NAME"));
13  }
14  if(cwb_dump_hist_file_name.Contains(".root")==0) {
15  cout << "Error : " << cwb_dump_hist_file_name.Data() << " is not a root file!!!" << endl;exit(1);
16  }
17 
19  if(gSystem->Getenv("CWB_DUMP_HIST_MODE")!=NULL) {
20  cwb_dump_hist_mode=TString(gSystem->Getenv("CWB_DUMP_HIST_MODE"));
21  }
22 
23  TFile *ifile = TFile::Open(cwb_dump_hist_file_name);
24  if(ifile==NULL) {cout << "Failed to open " << cwb_dump_hist_file_name.Data() << endl;exit(-1);}
25 
26  CWB::History* ihistory = (CWB::History*)ifile->Get("history");
27  if(ihistory==NULL) {
28  cout << "Error : history is not present!!!" << endl;exit(1);
29  }
30 
31  if(cwb_dump_hist_mode.CompareTo("view")==0) {
32  ihistory->Print();
33  } else {
34  char historyFile[512];
35  TObjArray* token = TString(cwb_dump_hist_file_name).Tokenize(TString("/"));
36  sprintf(historyFile,"%s/%s",dump_dir,
37  TString(((TObjString*)token->At(token->GetEntries()-1))->GetString()).ReplaceAll(".root",".history").Data());
38 
39  ihistory->DumpToTextFile(historyFile);
40  cout << "Write : " << historyFile << endl;
41  }
42 
43  exit(0);
44 }
TString("c")
CWB::History * ihistory
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
CWB::Toolbox TB
Definition: ComputeSNR.C:5
TString cwb_dump_hist_mode
void Print()
Definition: History.cc:297
TObjArray * token
TFile * ifile
sprintf(historyFile,"%s/%s", dump_dir, TString(((TObjString *) token->At(token->GetEntries()-1)) ->GetString()).ReplaceAll(".root",".history").Data())
condor_log_dir ReplaceAll("X_HOME", uhome.Data())
char dump_dir[512]
Definition: test_config1.C:156
TString cwb_dump_hist_file_name
void DumpToTextFile(char *FileName=NULL)
Definition: History.cc:377
exit(0)