Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_jnet.C
Go to the documentation of this file.
1 // obsolete
2 
3 void
4 cwb_jnet(TString jName="", TString uName="") {
5 
6  bool jshell = jName!="" ? true : false;
7 
8  // if jName!="" jfile is opened from disk otherwise it is opened within TBrowser
9  TFile* jfile = jName=="" ? gROOT->GetFile() : jfile = new TFile(jName);
10  if(jfile==NULL) {
11  cout << "cwb_jnet - Error opening root file : " << jName << endl;
12  if(jshell) exit(1); else return;
13  }
14  jfile->ls();
15 
16  // read config object
17  CWB::config* cfg = (CWB::config*)jfile->Get("config");
18  if(cfg==NULL) {
19  cout << "cwb_jnet - config is not present in : " << jName << endl;
20  if(jshell) exit(1); else return;
21  }
22  // export config to cint
23  cfg->Export();
24  // set auxiliary configuration
25  if(uName!="") cfg.Import(uName); // auxiliary config file
26  //cfg->Print();
27 
28  // get analysis setup
29  TString ANALYSYS = cfg->analysis;
30 
31  // get jName ...
32  if(jName=="") {
33  jName = jfile->GetPath();
34  jName.ReplaceAll(":/","");
35  cout << jName.Data() << endl;
36  }
37 
38  jfile->Close();
39 
40  // create working directory jdir
41  TObjArray* token = TString(jName).Tokenize(TString('/'));
42  TObjString* stoken =(TObjString*)token->At(token->GetEntries()-1);
43  int jobID=TString(stoken->GetString().ReplaceAll("job","").ReplaceAll(".root","")).Atoi();
44  TString jdir = stoken->GetString().ReplaceAll(".root","");
45 
46  // -------------------------------------------------------------------------
47  // Check if output file already exists and asks if you want to overwrite it
48  // -------------------------------------------------------------------------
49  bool overwrite=true;
50  Long_t id,size=0,flags,mt;
51  int estat = gSystem->GetPathInfo(jdir.Data(),&id,&size,&flags,&mt);
52  if (estat==0) {
53  char answer[256];
54  strcpy(answer,"");
55  do {
56  cout << "Dir " << jdir.Data() << " already exist" << endl;
57  cout << "Do you want to overwrite it ? (y/n) ";
58  cin >> answer;
59  cout << endl << endl;
60  } while ((strcmp(answer,"y")!=0)&&(strcmp(answer,"n")!=0));
61  if (strcmp(answer,"n")==0) overwrite=false;
62  }
63  if(overwrite) {
64  // clean working directories
65  gSystem->Exec(TString("rm -rf ")+jdir+"/"+config_dir+"/*");
66  gSystem->Exec(TString("rm -rf ")+jdir+"/"+data_dir+"/*");
67  gSystem->Exec(TString("rm -rf ")+jdir+"/"+tmp_dir+"/*");
68  } else return;
69 
70  gSystem->Exec(TString("mkdir -p ")+jdir+"/"+config_dir);
71  gSystem->Exec(TString("mkdir -p ")+jdir+"/"+data_dir);
72  gSystem->Exec(TString("mkdir -p ")+jdir+"/"+tmp_dir);
73  TString juser_parameters = "config/juser_parameters.C";
74  if(uName!="") gSystem->Exec(TString("cp ")+uName+" "+jdir+"/"+juser_parameters);
75  gSystem->cd(jdir);
76 // else juser_parameters="";
77 // else gSystem->Exec(TString("touch ")+jdir+"/"+juser_parameters);
78  if(uName=="") {
79  gSystem->Exec(TString("echo \"{\n\" >> ")+juser_parameters);
80  gSystem->Exec(TString("echo \"jobfOptions=CWB_JOBF_SAVE_ALL;\n\" >> ")+juser_parameters);
81  gSystem->Exec(TString("echo \"}\n\" >> ")+juser_parameters);
82  }
83 // gSystem->Exec(TString("echo \"strcpy(config_dir,\"config\");\n\" >> ")+juser_parameters);
84  jName="../"+jName;
85 
86  // delete temp cfg
87  delete cfg;
88 
89  int runID=1;
90  if(ANALYSYS=="1G") {
91  cwb1G CWB(jName,juser_parameters);
92  CWB.run(runID);
93  } else
94  if(ANALYSYS=="2G") {
95  cwb2G CWB(jName,juser_parameters);
96  CWB.run(runID);
97  } else {
98  cout << "cwb_jnet - Error : analysis must be 1G or 2G" << endl;
99  if(jshell) exit(1); else return;
100  }
101 
102  jshell ? exit(0) : return;
103 }
CWB::config * cfg
Definition: TestCWB_Plugin.C:5
char analysis[8]
Definition: config.hh:99
void Export(TString fname="")
Definition: config.cc:388
void cwb_jnet(TString jName="", TString uName="")
Definition: cwb_jnet.C:4
TString("c")
Long_t flags
Long_t size
void Import(TString umacro="")
Definition: config.cc:334
int jobID
Definition: cwb_net.C:177
Definition: cwb2G.hh:15
jfile
Definition: cwb_job_obj.C:25
char tmp_dir[512]
Definition: test_config1.C:153
virtual void run(int runID=0)
Definition: cwb.cc:263
char data_dir[512]
Definition: test_config1.C:152
TObjArray * token
char config_dir[512]
Definition: test_config1.C:144
char answer[256]
Definition: cwb1G.hh:13
int estat
strcpy(RunLabel, RUN_LABEL)
Long_t mt
bool overwrite
Definition: cwb_dump_inj.C:82
Long_t id
exit(0)