Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_dump_history.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 history infos : used by the cwb_dump command
20 
21 {
23 
24  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
25 
27  if(gSystem->Getenv("CWB_DUMP_HIST_FILE_NAME")==NULL) {
28  cout << "Error : environment CWB_DUMP_HIST_FILE_NAME is not defined!!!" << endl;exit(1);
29  } else {
30  cwb_dump_hist_file_name=TString(gSystem->Getenv("CWB_DUMP_HIST_FILE_NAME"));
31  }
32  if(cwb_dump_hist_file_name.Contains(".root")==0) {
33  cout << "Error : " << cwb_dump_hist_file_name.Data() << " is not a root file!!!" << endl;exit(1);
34  }
35 
37  if(gSystem->Getenv("CWB_DUMP_HIST_MODE")!=NULL) {
38  cwb_dump_hist_mode=TString(gSystem->Getenv("CWB_DUMP_HIST_MODE"));
39  }
40 
41  TFile *ifile = TFile::Open(cwb_dump_hist_file_name);
42  if(ifile==NULL) {cout << "Failed to open " << cwb_dump_hist_file_name.Data() << endl;exit(-1);}
43 
44  CWB::History* ihistory = (CWB::History*)ifile->Get("history");
45  if(ihistory==NULL) {
46  cout << "Error : history is not present!!!" << endl;exit(1);
47  }
48 
49  if(cwb_dump_hist_mode.CompareTo("view")==0) {
50  ihistory->Print();
51  } else {
52  char historyFile[512];
53  TObjArray* token = TString(cwb_dump_hist_file_name).Tokenize(TString("/"));
54  sprintf(historyFile,"%s/%s",dump_dir,
55  TString(((TObjString*)token->At(token->GetEntries()-1))->GetString()).ReplaceAll(".root",".history").Data());
56 
57  ihistory->DumpToTextFile(historyFile);
58  cout << "Write : " << historyFile << endl;
59  }
60 
61  exit(0);
62 }
TString("c")
CWB::Toolbox TB
CWB::History * ihistory
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
TString cwb_dump_hist_mode
void Print()
Definition: History.cc:315
sprintf(historyFile,"%s/%s", dump_dir, TString(((TObjString *) token->At(token->GetEntries() -1)) ->GetString()).ReplaceAll(".root",".history").Data())
TObjArray * token
TFile * ifile
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:395
exit(0)