Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_condor_check.C
Go to the documentation of this file.
1 // check job finished (look history saved in the output root file) : used by the cwb_condor command
2 
3 {
4  #include <vector>
5 
7 
8  TB.checkFile(gSystem->Getenv("CWB_ROOTLOGON_FILE"));
9  TB.checkFile(gSystem->Getenv("CWB_PARAMETERS_FILE"));
10  TB.checkFile(gSystem->Getenv("CWB_UPARAMETERS_FILE"));
11 
12 /*
13  vector<slag> slagList;
14  vector<slag> rslagList;
15 
16  vector<TString> ifos(nIFO);
17  for(int n=0;n<nIFO;n++) ifos[n]=ifo[n];
18 
19  char* slagFile = new char[256];
20  sprintf(slagFile,"%s/%s.slag",dump_dir,data_label);
21 
22  vector<waveSegment> cat1List=TB.readSegList(nDQF, DQF, CWB_CAT1);
23  int slagSegs=TB.getSlagJobList(cat1List, segLen).size();
24 
25  slagList=TB.getSlagList(nIFO, slagSize, slagSegs, slagOff, slagMin, slagMax, slagSite);
26  rslagList=TB.getSlagList( slagList, ifos, segLen, segMLS, segEdge, nDQF, DQF, CWB_CAT1);
27  rslagList=TB.getSlagList(rslagList, ifos, segLen, segTHR, segEdge, nDQF, DQF, CWB_CAT2);
28 
29  bool* bslag = new bool[slagList.size()];
30  for(int i=0;i<slagList.size();i++) bslag[i]=false;
31  int* jobStatus = new int[slagList.size()];
32  for(int i=0;i<slagList.size();i++) jobStatus[i]=0;
33  for(int i=0;i<rslagList.size();i++) {
34 // printf("%14d %14d", rslagList[i].jobId, rslagList[i].slagId[0]);
35 // for (int n=0; n<nIFO; n++) printf("%14d",rslagList[i].segId[n]);
36 // printf("\n");
37  bslag[rslagList[i].jobId]=true;
38  jobStatus[rslagList[i].jobId]=1;
39  }
40 */
41 
42  if(nfactor<=0) nfactor=1; // fix nfactor when nfactor is not defined
43  // get the number of job submit by condor
44  char full_condor_dir[512];
45  sprintf(full_condor_dir,"%s/%s",work_dir,condor_dir);
46  char condor_dag_file[256];
47  sprintf(condor_dag_file,"%s/%s%s.dag",full_condor_dir,data_label,"");
48  Long_t id,size=0,flags,mt;
49  int estat = gSystem->GetPathInfo(condor_dag_file,&id,&size,&flags,&mt);
50  vector<int> jobList;
51  if (estat==0) {
52  jobList=TB.getCondorJobList(full_condor_dir, data_label);
53  int ncondor_jobs = jobList.size();
54  int* jobStatus = new int[ncondor_jobs+1];
55  for(int i=0;i<=ncondor_jobs;i++) jobStatus[i]=1;
56  }
57 
58  cout << "Starting reading output directory ..." << endl;
59  vector<TString> fileList = TB.getFileListFromDir(output_dir,".root","","wave_");
60  for(int n=0;n<fileList.size();n++) {
61  //cout << n << " " << fileList[n].Data()<< endl;
62 
63  if (n%1000==0) cout << "cwb_condor check - " << n << "/" << fileList.size() << " files" << endl;
64 
65  TFile ifile(fileList[n]);
66  if(!ifile.IsOpen()) {cout << "Failed to open " << fileList[n].Data() << endl;exit(-1);}
67 
68  CWB::History* ihistory = (CWB::History*)ifile.Get("history");
69  if(ihistory==NULL) ihistory = (CWB::History*)ifile.Get("CWB::History"); // for back compatibility
70  if(ihistory==NULL) { cout << "Error : history is not present!!!" << endl;exit(1); }
71 
72  int log_size = ihistory->GetLogSize("FULL");
73  TString log = ihistory->GetLog("FULL",log_size-1);
74 
75  int jobId = TB.getJobId(fileList[n]); // Get JOB ID
76  //cout << jobId << " " << fileList[n].Data() << endl;
77  if(jobId>ncondor_jobs) continue;
78  if(ifile.IsZombie()) {
79  jobStatus[jobId]=2;
80  } else {
81  // Check if "STOP JOB" is in the log history
82  if(log=="STOP JOB") jobStatus[jobId]=3;
83  }
84  }
85 
86  int njobCondor=0;
87  int njobZombie=0;
89  for(int i=1;i<=ncondor_jobs;i++) {
90  if(jobStatus[i]==1) njobCondor++;
91  if(jobStatus[i]==2) njobZombie++;
92  if(jobStatus[i]==3) njobProcessed++;
93  }
94 // cout << "njobZombie : " << njoZombie << endl;
95  cout << endl;
96  cout << "Number of Jobs : " << nfactor*ncondor_jobs << endl;
97  cout << "Number of Processed Jobs : " << njobProcessed << endl;
98  cout << "Number of Jobs to be Processed : " << njobCondor << endl;
99  cout << endl;
100 
101  delete jobStatus;
102 
103  exit(0);
104 }
int njobProcessed
static vector< TString > getFileListFromDir(TString dir_name, TString endString="", TString beginString="", TString containString="", bool fast=false)
Definition: Toolbox.cc:4333
int n
Definition: cwb_net.C:10
TString("c")
Long_t flags
Long_t size
i drho i
static bool checkFile(TString fName, bool question=false, TString message="")
Definition: Toolbox.cc:3956
CWB::Toolbox TB
Definition: ComputeSNR.C:5
char condor_dag_file[256]
char data_label[512]
Definition: test_config1.C:160
vector< int > jobList
char * GetLog(char *Stage, int index)
Definition: History.cc:286
int GetLogSize(char *Stage)
Definition: History.cc:280
bool log
Definition: WaveMDC.C:41
TFile * ifile
static int getJobId(TString file, TString fext="root")
Definition: Toolbox.cc:5913
int njobZombie
static vector< int > getCondorJobList(TString condor_dir, TString label)
Definition: Toolbox.cc:1378
cout<< "Starting reading output directory ..."<< endl;vector< TString > fileList
int estat
nfactor[0]
Definition: cwb_eced.C:10
Long_t mt
int jobId
Long_t id
char condor_dir[512]
Definition: test_config1.C:148
char work_dir[512]
Definition: test_config1.C:143
sprintf(full_condor_dir,"%s/%s", work_dir, condor_dir)
char output_dir[512]
Definition: test_config1.C:146
char full_condor_dir[512]
CWB::History * ihistory
exit(0)
int njobCondor