Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_condor_create.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 // creates dag/sub files under the condor dir : used by the cwb_condor command
20 
21 {
22  #include <vector>
23 
25 
26  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
27  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
28  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
29 
30  if(TString(condor_tag)=="") {
31  cout << endl;
32  cout << "cwb_condor_create.C : Error - the accounting_group is not defined !!!" << endl;
33  cout << "The accounting_group must be defined in the user_parameters.C file" << endl;
34  cout << "See the following link:" << endl;
35  cout <<" https://ldas-gridmon.ligo.caltech.edu/accounting/condor_groups/determine_condor_account_group.html" << endl;
36  cout << "Examples : " << endl;
37  cout << "strcpy(condor_tag,\"ligo.dev.o2.burst.allsky.cwboffline\");" << endl;
38  cout << "strcpy(condor_tag,\"ligo.prod.o2.burst.allsky.cwboffline\");" << endl;
39  cout << "If you don't need it set : strcpy(condor_tag,\"disabled\");" << endl << endl;
40  exit(1);
41  }
42  if(TString(condor_tag)=="disabled") strcpy(condor_tag,"");
43 
44  // get cwb stage name
45  TString cwb_stage_name="CWB_STAGE_FULL";
46  if(gSystem->Getenv("CWB_STAGE_NAME")!=NULL) {
47  cwb_stage_name=TString(gSystem->Getenv("CWB_STAGE_NAME"));
48  }
49 
50  char full_condor_dir[1024];
51  char full_condor_out_dir[1024];
52  char full_condor_err_dir[1024];
53 
54  sprintf(full_condor_dir,"%s/%s",work_dir,condor_dir);
55  sprintf(full_condor_out_dir,"%s/%s",work_dir,log_dir);
56  sprintf(full_condor_err_dir,"%s/%s",work_dir,log_dir);
57 
58 
59  char dagfile[1024];
60  sprintf(dagfile,"%s/%s.dag",condor_dir,data_label);
61 
62  // Check if dag file already exist
63  Long_t id,size,flags,mt;
64  int estat = gSystem->GetPathInfo(dagfile,&id,&size,&flags,&mt);
65  if (estat==0) {
66  char answer[256];
67  strcpy(answer,"");
68  do {
69  cout << "File \"" << dagfile << "\" already exist" << endl;
70  cout << "Do you want to overwrite the file ? (y/n) ";
71  cin >> answer;
72  cout << endl << endl;
73  } while ((strcmp(answer,"y")!=0)&&(strcmp(answer,"n")!=0));
74  if (strcmp(answer,"n")==0) {
75  exit(0);
76  }
77  }
78 
79 
80  if(nIFO==1) { // Single Detector Mode
82  config.Import();
83  config.SetSingleDetectorMode();
84  config.Export();
85  }
86 
87  vector<slag> rslagList;
88  vector<TString> ifos(nIFO);
89  for(int n=0;n<nIFO;n++) {
90  if(strlen(ifo[n])!=0) ifos[n]=ifo[n]; // built in detector
91  else ifos[n]=detParms[n].name; // user define detector
92  }
93 
94  vector<waveSegment> cat1List=TB.readSegList(nDQF, DQF, CWB_CAT1);
95 
96  // extract detector's segments range from dq cat 1
97  if(slagSize==0) {
98  vector<waveSegment> cat2List=TB.readSegList(nDQF, DQF, CWB_CAT2);
99  // segments are standard style !!!
100  vector<waveSegment> jobList=TB.getJobList(cat1List, cat2List, segLen, segMLS, segTHR, segEdge);
101  cout << "Standard Segments : " << jobList.size() << endl;
102  // create dag condor file
103  vector<TString> jobFiles;
104  TB.createDagFile(jobList, full_condor_dir, data_label, jobFiles, cwb_stage_name);
105  } else {
106  // segments are slag style
107  int slagSegs=TB.getSlagJobList(cat1List, segLen).size();
108  // full slag list
109  vector<slag> slagList=TB.getSlagList(nIFO, slagSize, slagSegs, slagOff, slagMin, slagMax, slagSite, slagFile);
110  cout << "slagList size : " << slagList.size() << endl;
111  // reduced slag list (removed slag with max segLength < segMSL after cat1 & segLength < segTHR after cat2)
112  cout << endl << "Start segments selection from dq cat1 list ..." << endl << endl;
113  rslagList=TB.getSlagList( slagList, ifos, segLen, segMLS, segEdge, nDQF, DQF, CWB_CAT1);
114  cout << "Number of selected jobs after cat1 : " << rslagList.size() << endl;
115  cout << endl << "Start segments selection from dq cat2 list ..." << endl << endl;
116  rslagList=TB.getSlagList(rslagList, ifos, segLen, segTHR, segEdge, nDQF, DQF, CWB_CAT2);
117  cout << "Number of selected jobs after cat2 : " << rslagList.size() << endl;
118  // create dag condor file
119  vector<TString> jobFiles;
120  TB.createDagFile(rslagList, full_condor_dir, data_label, jobFiles, cwb_stage_name);
121  }
122 
123  if(gSystem->Getenv("_USE_OSG")!=NULL) {
124  // create tgz of the working dir
125  TString exec_cmd = TString::Format("tar -czf %s/%s.tgz %s %s %s %s %s --exclude='*/.svn' --exclude='%s/*' --exclude='%s/*'",
127  gSystem->Exec(exec_cmd);
128  cout << endl << "Created tgz file : " << condor_dir<<"/"<<data_label<<".tgz" << endl;
129  }
130 
131  if(gSystem->Getenv("_USE_LSF")!=NULL) {
132 
133  // make lsf label
134  char lsf_label[1024];
135  if(cwb_stage_name=="CWB_STAGE_FULL") {
136  sprintf(lsf_label,"%s",data_label);
137  } else {
138  sprintf(lsf_label,"%s_%s",data_label,cwb_stage_name.Data());
139  }
140 
141  // create tgz of the working dir
142  TString exec_cmd = TString::Format("tar -czf %s/%s.tgz %s %s %s %s/*.sh --exclude='*/.svn'",
144  gSystem->Exec(exec_cmd);
145  cout << endl << "Created tgz file : " << condor_dir<<"/"<<lsf_label<<".tgz" << endl;
146 
147  // create LSF file from the DAG file
148  char dagFile[1024];
149  sprintf(dagFile,"%s/%s.dag",condor_dir,data_label);
151  if(lsfFile!="") {
152  cout << endl << "Created LSF file : " << lsfFile << endl << endl;
153  cout << "To submit lsf jobs, type : cwb_lsf submit" << endl;
154  } else {
155  cout << endl << "No jobs to be submitted !!!" << endl << endl;
156  }
157  gSystem->Exit(0);
158  }
159 
160  if(gSystem->Getenv("_USE_PEGASUS")!=NULL) {
161  // create in tgz file
162  ofstream out;
163  char infile[1024];
164  sprintf(infile,"%s/%s.in",full_condor_dir,data_label);
165  out.open(infile,ios::out);
166  out << "../" << config_dir << "/" << endl;
167  out << "../" << input_dir << "/" << endl;
168  out << "../" << macro_dir << "/" << endl;
169  out.close();
170  // execute cwb_pegasus_create.sh
171  sprintf(dagfile,"%s.dag",data_label);
172  TString cwb_scripts = TString(gSystem->Getenv("CWB_SCRIPTS"));
173  TString exec_cmd = TString::Format("cd %s;%s/cwb_pegasus_create.sh %s",
174  condor_dir,cwb_scripts.Data(),dagfile);
175  int ret=gSystem->Exec(exec_cmd);
176  if(ret) {cout << "Error while executing cwb_pegasus_create !!!" << endl;exit(1);}
177 
178  cout << endl;
179  cout << "To submit pegasus jobs, type : cwb_pegasus submit" << endl;
180  cout << endl;
181  } else {
182  // create sub condor file
183  TB.createSubFile(data_label, full_condor_dir, full_condor_out_dir,
184  full_condor_err_dir, condor_log, "", condor_tag);
185 
186  cout << endl;
187  cout << "To submit condor jobs, type : cwb_condor submit" << endl;
188  cout << endl;
189  }
190 
191  gSystem->Exit(0);
192 }
Long_t mt
TString cwb_scripts
double segMLS
Definition: test_config1.C:47
int slagSize
Definition: test_config1.C:65
TString cwb_stage_name
void Export(TString fname="")
Definition: config.cc:406
size_t * slagSite
Definition: test_config1.C:69
int slagOff
Definition: test_config1.C:68
char name[32]
Definition: detector.hh:50
cout<< "slagList size : "<< slagList.size()<< endl;cout<< endl<< "Start segments selection from dq cat1 list ..."<< endl<< endl;rslagList=TB.getSlagList(slagList, ifos, segLen, segMLS, segEdge, nDQF, DQF, CWB_CAT1);cout<< "Number of selected jobs after cat1 : "<< rslagList.size()<< endl;cout<< endl<< "Start segments selection from dq cat2 list ..."<< endl<< endl;rslagList=TB.getSlagList(rslagList, ifos, segLen, segTHR, segEdge, nDQF, DQF, CWB_CAT2);cout<< "Number of selected jobs after cat2 : "<< rslagList.size()<< endl;vector< TString > jobFiles
int n
Definition: cwb_net.C:28
TString("c")
vector< slag > rslagList
ofstream out
Definition: cwb_merge.C:214
int slagMax
Definition: test_config1.C:67
CWB::Toolbox TB
char macro_dir[512]
Definition: test_config1.C:150
double segEdge
Definition: test_config1.C:49
void Import(TString umacro="")
Definition: config.cc:352
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
char ifo[NIFO_MAX][8]
nDQF
Definition: cwb_eced.C:109
double segTHR
Definition: test_config1.C:48
#define nIFO
vector< TString > ifos(nIFO)
char full_condor_out_dir[1024]
char data_label[512]
Definition: test_config1.C:160
char input_dir[512]
Definition: test_config1.C:145
int estat
static int createSubFile(TString label, TString condor_dir, TString out_dir, TString err_dir, TString log_dir, TString ext="", TString condor_tag="")
Definition: Toolbox.cc:1337
vector< int > jobList
vector< slag > slagList
dqfile DQF[12]
Definition: test_config1.C:171
static vector< waveSegment > getSlagJobList(vector< waveSegment > ilist, int seglen=600)
Definition: Toolbox.cc:1791
segLen
Definition: cwb_eced.C:24
Long_t flags
sprintf(full_condor_dir,"%s/%s", work_dir, condor_dir)
char data_dir[512]
Definition: test_config1.C:152
vector< waveSegment > cat1List
char log_dir[512]
Definition: test_config1.C:151
static int createDagFile(vector< waveSegment > jobList, TString condor_dir, TString label, int jobmin=0, int jobmax=0)
Definition: Toolbox.cc:1172
Long_t id
char config_dir[512]
Definition: test_config1.C:144
static vector< waveSegment > getJobList(vector< waveSegment > ilist, double segLen=600., double segMLS=300., double segEdge=8.)
Definition: Toolbox.cc:646
char full_condor_err_dir[1024]
static vector< slag > getSlagList(size_t nIFO, size_t slagSize, int slagSegs, int slagOff, size_t slagMin, size_t slagMax, size_t *slagSite, char *slagFile=NULL)
Definition: Toolbox.cc:809
static vector< waveSegment > readSegList(dqfile DQF)
Definition: Toolbox.cc:409
char answer[256]
static TString DAG2LSF(char *dagFile, char *data_label, char *nodedir, char *data_dir, char *condor_dir, char *log_dir, char *output_dir, char *work_dir)
Definition: Toolbox.cc:1561
char full_condor_dir[1024]
strcpy(RunLabel, RUN_LABEL)
cout<< "total cat1 livetime : "<< int(cat1_time)<< " sec "<< cat1_time/3600.<< " h "<< cat1_time/86400.<< " day"<< endl;cout<< endl;vector< waveSegment > cat2List
Definition: cwb_dump_job.C:40
char condor_log[512]
Definition: test_config1.C:163
Long_t size
slagFile
Definition: cwb_tune_slag.C:25
char nodedir[1024]
Definition: test_config1.C:187
char condor_dir[512]
Definition: test_config1.C:148
char work_dir[512]
Definition: test_config1.C:143
int slagMin
Definition: test_config1.C:66
TString config
detectorParams detParms[4]
char output_dir[512]
Definition: test_config1.C:146
char dagfile[1024]
void SetSingleDetectorMode()
Definition: config.cc:1352
exit(0)