Logo coherent WaveBurst  
Library Reference Guide
Logo
cwb_condor_create_ced.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 
20 {
21 
22  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
23  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
24  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
25  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_PPARAMETERS_FILE"));
26  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_UPPARAMETERS_FILE"));
27  CWB::Toolbox::checkFile(gSystem->Getenv("CWB_EPPARAMETERS_FILE"));
28 
29  if(TString(condor_tag)=="") {
30  cout << endl;
31  cout << "cwb_condor_create_ced.C : Error - the accounting_group is not defined !!!" << endl;
32  cout << "The accounting_group must be defined in the user_parameters.C file" << endl;
33  cout << "See the following link:" << endl;
34  cout <<" https://ldas-gridmon.ligo.caltech.edu/accounting/condor_groups/determine_condor_account_group.html" << endl;
35  cout << "Examples : " << endl;
36  cout << "strcpy(condor_tag,\"ligo.dev.o2.burst.allsky.cwboffline\");" << endl;
37  cout << "strcpy(condor_tag,\"ligo.prod.o2.burst.allsky.cwboffline\");" << endl;
38  cout << "If you don't need it set : strcpy(condor_tag,\"disabled\");" << endl << endl;
39  exit(1);
40  }
41  if(TString(condor_tag)=="disabled") strcpy(condor_tag,"");
42 
43  // creates ced dir for loudest events
44  TString pp_ced_dir = TString(pp_dir)+TString("/ced");
45  CWB::Toolbox::mkDir(pp_ced_dir,!pp_batch);
46 
47  bool singleDetector=false;
48  if(nIFO==1) { // Single Detector Mode
50  config.Import();
51  config.SetSingleDetectorMode();
52  config.Export();
53  singleDetector=true;
54  }
55  if(nIFO==2) { // 2 detectors with the same name "same detector -> nIFO=1"
56  if(TString(ifo[0])==TString(ifo[1])) singleDetector=true;
57  }
58 
59  char events_sorted[256];
60  sprintf(events_sorted,"%s/events_sorted.txt",netdir);
61  CWB::Toolbox::checkFile(events_sorted);
62 
63  char pm[8];
64  char c3[8];
66  int ifreq, ilow, ihigh;
67  float idur;
68  int isize, irate, irun;
69  float phi, theta, psi;
70 
71  double* itime = new double[nIFO];
72  double* iSNR = new double[nIFO];
73  double* ihrss = new double[nIFO];
74 
75 /*
76  char ofile_name[256];
77  sprintf(ofile_name,"%s/event_ced_parameters.txt",netdir);
78  cout << ofile_name << endl;
79 
80  ofstream out;
81  out.open(ofile_name,ios::out);
82  if (!out.good()) {cout << "Error Opening File : " << ofile_name << endl;exit(1);}
83 
84  int ievt=0;
85  ifstream f_ev(events_sorted);
86  //cout << "jobid gps_evt[0=(full job)/sec] ced_dump[false/true] mdc_factor lag[0=(full lags)/#lag]" << endl;
87  while(ievt<pp_max_nloudest_list) {
88  f_ev>>pm>>c3>>irho>>icc>>iacor>>ilag>>islag>>ilik>>ipen>>icHH>>ifreq>>ilow>>ihigh>>idur>>isize>>irate>>irun;
89  for(int i=0;i<nIFO;i++) f_ev>>itime[i];
90  for(int i=0;i<nIFO;i++) f_ev>>iSNR[i];
91  for(int i=0;i<nIFO;i++) f_ev>>ihrss[i];
92  f_ev>>phi>>theta>>psi;
93  ievt++;
94  if (!f_ev.good()) break;
95  //cout << irun << " " << 0 << " " << "true" << " " << 0 << " " << ilag << " " << ced_dir << endl;
96  out << irun << " " << 0 << " " << "true" << " " << 0 << " " << ilag << " " << ced_dir << endl;
97  }
98  cout << endl;
99  f_ev.close();
100  out.close();
101 */
102 
103  char condor_label[1024];
104  sprintf(condor_label,"%s.%s.R%s.ced",data_label,cwb_merge_label.Data(),pp_label.Data());
105 
106  // create condor sub file
107 
108  char ofile_condor_sub[1024];
109  sprintf(ofile_condor_sub,"%s/%s.sub",condor_dir,condor_label);
110 
111  FILE *fP=NULL;
112  if((fP = fopen(ofile_condor_sub, "w")) == NULL) {
113  cout << "cwb_condor_create_ced.C : Error - cannot open file " << ofile_condor_sub << endl;
114  exit(1);
115  }
116  cout << ofile_condor_sub << endl;
117 
118  char full_condor_dir[1024];
119  char full_condor_out_dir[1024];
120  char full_condor_err_dir[1024];
121 
122  sprintf(full_condor_dir,"%s/%s",work_dir,condor_dir);
123  sprintf(full_condor_out_dir,"%s/%s",work_dir,log_dir);
124  sprintf(full_condor_err_dir,"%s/%s",work_dir,log_dir);
125 
126  fprintf(fP,"universe = vanilla\n");
127  fprintf(fP,"getenv = true\n");
128  fprintf(fP,"priority = $(PRI)\n");
129  fprintf(fP,"on_exit_hold = ( ExitCode != 0 )\n");
130  fprintf(fP,"request_memory = 2000\n");
131  fprintf(fP,"executable = ced.sh\n");
132  fprintf(fP,"job_machine_attrs = Machine\n");
133  fprintf(fP,"job_machine_attrs_history_length = 5\n");
134  fprintf(fP,"requirements = target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && target.machine =!= MachineAttrMachine3 && target.machine =!= MachineAttrMachine4 && target.machine =!= MachineAttrMachine5\n");
135  fprintf(fP,"environment = CWB_JOBID=$(PID);CWB_GPS_EVENT=$(CWB_GPS_EVENT);CWB_INET_OPTIONS=$(CWB_INET_OPTIONS);CWB_MDC_FACTOR=$(CWB_MDC_FACTOR);CWB_JOB_LAG=$(CWB_JOB_LAG);CWB_CED_DIR=$(CWB_CED_DIR);CWB_BATCH=$(CWB_BATCH)\n");
136  if(TString(condor_tag)!="") fprintf(fP,"accounting_group = %s\n",condor_tag);
137  fprintf(fP,"output = %s/$(PID)_$(CWB_JOB_LAG)_%s.out\n",full_condor_out_dir,condor_label);
138  fprintf(fP,"error = %s/$(PID)_$(CWB_JOB_LAG)_%s.err\n",full_condor_err_dir,condor_label);
139  fprintf(fP,"log = %s/%s.log\n",condor_log,condor_label);
140  fprintf(fP,"notification = never\n");
141  fprintf(fP,"rank=memory\n");
142  fprintf(fP,"queue\n");
143 
144  fclose(fP);
145 
146  // create condor dag file
147 
148  char ofile_condor_dag[1024];
149  sprintf(ofile_condor_dag,"%s/%s.dag",condor_dir,condor_label);
150 
151  ofstream out;
152  out.open(ofile_condor_dag,ios::out);
153  if (!out.good()) {cout << "Error Opening File : " << ofile_condor_dag << endl;exit(1);}
154  cout << ofile_condor_dag << endl;
155 
156  int ievt=0;
157  vector<TString> JTAG;
158  ifstream f_ev(events_sorted);
159  while(ievt<pp_max_nloudest_list) {
160  f_ev>>pm>>c3>>irho>>icc>>icc2>>icc3>>iacor>>ilag>>islag>>ilik>>ipen>>icHH>>ifreq>>ilow>>ihigh>>idur>>isize>>irate>>irun;
161  for(int i=0;i<nIFO;i++) f_ev>>itime[i];
162  for(int i=0;i<nIFO;i++) f_ev>>iSNR[i];
163  for(int i=0;i<nIFO;i++) f_ev>>ihrss[i];
164  f_ev>>phi>>theta>>psi;
165  if (!f_ev.good()) break;
166  if (!TString(pm).Contains("+")) continue;
167  ievt++;
168  //cout << irun << " " << 0 << " " << "true" << " " << 0 << " " << ilag << " " << ced_dir << endl;
169  //out << irun << " " << 0 << " " << "true" << " " << 0 << " " << ilag << " " << ced_dir << endl;
170  //int jID = irun;
171  int jID = ievt;
172  char jtag[1024];sprintf(jtag,"%i_%i",irun,(int)ilag);
173  bool bjtag=false;for(int j=0;j<JTAG.size();j++) if(JTAG[j]==jtag) bjtag=true;
174  if(!bjtag) JTAG.push_back(jtag); else continue; // skip job if already created
175  char ostring[1024];
176  sprintf(ostring,"JOB A%i_%s %s.sub",jID,jtag,condor_label);
177  out << ostring << endl;
178  int evt_gps_time = singleDetector ? itime[0] : 0;
179  sprintf(ostring,"VARS A%i_%s PID=\"%i\" CWB_GPS_EVENT=\"%i\" CWB_INET_OPTIONS=\"ced\" CWB_MDC_FACTOR=\"0\" CWB_JOB_LAG=\"%i\" CWB_CED_DIR=\"%s\" CWB_BATCH=\"true\"",jID,jtag,irun,evt_gps_time,(int)ilag,pp_ced_dir.Data());
180  out << ostring << endl;
181  sprintf(ostring,"RETRY A%i_%s 3000",jID,jtag);
182  out << ostring << endl;
183  }
184  out.close();
185  f_ev.close();
186 
187  exit(0);
188 }
189 
void Export(TString fname="")
Definition: config.cc:406
exit(0)
int ihigh
int irate
TString("c")
ofstream out
Definition: cwb_merge.C:214
float icc3
float theta
char full_condor_dir[1024]
float icc
int j
Definition: cwb_net.C:28
i drho i
void Import(TString umacro="")
Definition: config.cc:352
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:4670
int isize
char ifo[NIFO_MAX][8]
float ipen
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
bool singleDetector
#define nIFO
char full_condor_out_dir[1024]
char data_label[512]
Definition: test_config1.C:160
float phi
float psi
double * ihrss
float islag
char netdir[1024]
float ivED
else pp_label
char events_sorted[256]
int ilow
char ofile_condor_sub[1024]
ifstream f_ev(events_sorted)
double * iSNR
float ivHH
char log_dir[512]
Definition: test_config1.C:151
int ifreq
char full_condor_err_dir[1024]
FILE * fP
cwb_merge_label
float icHH
float irho
cout<< ofile_condor_sub<< endl;char full_condor_dir[1024];char full_condor_out_dir[1024];char full_condor_err_dir[1024];sprintf(full_condor_dir,"%s/%s", work_dir, condor_dir);sprintf(full_condor_out_dir,"%s/%s", work_dir, log_dir);sprintf(full_condor_err_dir,"%s/%s", work_dir, log_dir);fprintf(fP,"universe = vanilla\");fprintf(fP,"getenv = true\");fprintf(fP,"priority = $(PRI)\");fprintf(fP,"on_exit_hold = ( ExitCode != 0 )\");fprintf(fP,"request_memory = 2000\");fprintf(fP,"executable = ced.sh\");fprintf(fP,"job_machine_attrs = Machine\");fprintf(fP,"job_machine_attrs_history_length = 5\");fprintf(fP,"requirements = target.machine =!= MachineAttrMachine1 && target.machine =!= MachineAttrMachine2 && target.machine =!= MachineAttrMachine3 && target.machine =!= MachineAttrMachine4 && target.machine =!= MachineAttrMachine5\");fprintf(fP,"environment = CWB_JOBID=$(PID);CWB_GPS_EVENT=$(CWB_GPS_EVENT);CWB_INET_OPTIONS=$(CWB_INET_OPTIONS);CWB_MDC_FACTOR=$(CWB_MDC_FACTOR);CWB_JOB_LAG=$(CWB_JOB_LAG);CWB_CED_DIR=$(CWB_CED_DIR);CWB_BATCH=$(CWB_BATCH)\");if(TString(condor_tag)!="") fprintf(fP,"accounting_group = %s\", condor_tag);fprintf(fP,"output = %s/$(PID)_$(CWB_JOB_LAG)_%s.out\", full_condor_out_dir, condor_label);fprintf(fP,"error = %s/$(PID)_$(CWB_JOB_LAG)_%s.err\", full_condor_err_dir, condor_label);fprintf(fP,"log = %s/%s.log\", condor_log, condor_label);fprintf(fP,"notification = never\");fprintf(fP,"rank=memory\");fprintf(fP,"queue\");fclose(fP);char ofile_condor_dag[1024];sprintf(ofile_condor_dag,"%s/%s.dag", condor_dir, condor_label);ofstream out;out.open(ofile_condor_dag, ios::out);if(!out.good()) {cout<< "Error Opening File : "<< ofile_condor_dag<< endl;exit(1);} cout<< ofile_condor_dag<< endl;int ievt=0;vector< TString > JTAG
sprintf(events_sorted,"%s/events_sorted.txt", netdir)
float iacor
int irun
char pp_dir[512]
Definition: test_config1.C:155
static void mkDir(TString dir, bool question=false, bool remove=true)
Definition: Toolbox.cc:4714
float idur
strcpy(RunLabel, RUN_LABEL)
char condor_label[1024]
float icc2
char condor_log[512]
Definition: test_config1.C:163
int pp_max_nloudest_list
double * itime
char condor_dir[512]
Definition: test_config1.C:148
char work_dir[512]
Definition: test_config1.C:143
float ilik
fclose(ftrig)
TString config
char pm[8]
char c3[8]
float ilag
void SetSingleDetectorMode()
Definition: config.cc:1352