Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_dump_config.C
Go to the documentation of this file.
1 // get the cwb parameters.C used in the last stage : 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 
34  if(ihistory) {
35  TList* stageList = ihistory->GetStageNames(); // get stage list
36  for(int i=0;i<stageList->GetSize();i++) { // get lib versions
37  TObjString* stageObjString = (TObjString*)stageList->At(i);
38  TString stageName = stageObjString->GetString();
39  // check if stage belong to processing stages (skip pp stages)
40  bool isProcessingStage=false;
41  for(int j=0;j<=nStages;j++) {
42  if(cwb::GetStageString((CWB_STAGE)j).Contains(stageName)) isProcessingStage=true;
43  }
44  if(!isProcessingStage) continue;
45  char* stage = const_cast<char*>(stageName.Data());
46  TString log = ihistory->GetHistory(stage,const_cast<char*>("PARAMETERS"));
47  if(log!="") {
48  config = log;
49  config_md5 = ihistory->GetHistory(stage,const_cast<char*>("PARAMETERS_MD5"));
50  }
51  }
52  }
53 
54  if((cwb_dump_hist_mode=="view")||(cwb_dump_hist_mode=="dump")) {
55 
56  TString label = (cwb_dump_hist_mode=="dump") ? "config" : "view";
57 
58  char configFile[512];
59  TObjArray* token = TString(cwb_dump_hist_file_name).Tokenize(TString("/"));
60 
61  TString odir = (cwb_dump_hist_mode=="view") ? "/tmp" : dump_dir;
62  sprintf(configFile,"%s/%s_%s",odir.Data(),label.Data(),
63  TString(((TObjString*)token->At(token->GetEntries()-1))->GetString()).ReplaceAll(".root",".C").Data());
64 
65  ofstream out;
66  out.open(configFile,ios::out);
67  if (!out.good()) {cout << "Error Opening File : " << configFile << endl;exit(1);}
68  out << config.Data();
69  out.close();
70 
71  if(cwb_dump_hist_mode=="view") {
72  char cmd[1024];
73  sprintf(cmd,"vim %s",configFile);
74  cout << cmd << endl;
75  gSystem->Exec(cmd);
76  sprintf(cmd,"rm %s",configFile);
77  cout << cmd << endl;
78  gSystem->Exec(cmd);
79  } else {
80  cout << "Write : " << configFile << endl;
81  }
82 
83  } else {
84  cout << endl << "Config MD5 : " << config_md5.Data() << endl << endl;
85  }
86 
87  exit(0);
88 }
exit(0)
char cmd[1024]
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
TString("c")
char odir[1024]
int j
Definition: cwb_net.C:10
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
CWB::Toolbox TB
Definition: ComputeSNR.C:5
ofstream out
Definition: cwb_merge.C:196
static TString GetStageString(CWB_STAGE jstage)
Definition: cwb.cc:2187
TString label
Definition: MergeTrees.C:21
TString config_md5
bool log
Definition: WaveMDC.C:41
TList * GetStageNames()
Definition: History.cc:409
TString cwb_dump_hist_mode
int nStages
static int GetStageSize()
Definition: cwb.hh:150
TObjArray * token
TFile * ifile
condor_log_dir ReplaceAll("X_HOME", uhome.Data())
TString cwb_dump_hist_file_name
char configFile[1024]
Definition: cwb_merge.C:195
char dump_dir[512]
Definition: test_config1.C:156
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
char * GetHistory(char *StageName, char *Type)
Definition: History.cc:255
TString config
CWB::History * ihistory
CWB_STAGE
Definition: cwb.hh:102