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