CMS 3D CMS Logo

check_runcomplete.cc
Go to the documentation of this file.
1 #include <Riostream.h>
2 #include <TDirectory.h>
3 #include <TFile.h>
4 #include <TROOT.h>
5 #include <TStyle.h>
6 #include <TKey.h>
7 #include <TH1.h>
8 #include <TH2.h>
9 #include <TH2D.h>
10 #include <TCanvas.h>
11 #include <TGraph.h>
12 #include <TPaveStats.h>
13 #include <TText.h>
14 #include <TLegend.h>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 #include <sstream>
19 #include <algorithm>
20 #include <TString.h>
21 #include <TColor.h>
22 #include <dirent.h>
23 
24 #include "check_runcomplete.h"
25 
26 //using namespace std;
27 
28 int main(int argc, char *argv[]) {
29  if (argc == 2) {
30  char *cfile = argv[1];
31 
32  std::cout << "ready to check file " << cfile << std::endl;
33 
34  int returncode = check_runcomplete(cfile);
35  if (returncode == 0)
36  std::cout << "DQM file is ok" << std::endl;
37 
38  return returncode;
39 
40  } else {
41  std::cout << "Too few arguments: " << argc << std::endl;
42  return -1;
43  }
44 
45  return -9;
46 }
47 
49  int runflag = read_runflag(filename);
50  if (runflag == 1) {
51  printf("************************************\n");
52  printf("**\n");
53  printf("** W A R N I N G: the DQM file %s does not exist", filename.c_str());
54  printf("**\n");
55  printf("************************************\n");
56  } else if (runflag == 2) {
57  printf("************************************\n");
58  printf("**\n");
59  printf("** W A R N I N G: the DQM file %s is incomplete", filename.c_str());
60  printf("**\n");
61  printf("************************************\n");
62  } else if (runflag != 0) {
63  printf("************************************\n");
64  printf("**\n");
65  printf("** W A R N I N G: problems found in the DQM file %s", filename.c_str());
66  printf("**\n");
67  printf("************************************\n");
68  }
69  return runflag;
70 }
71 
73  std::string nrun = filename.substr(filename.find("_R000") + 5, 6);
74 
75  TFile *dqmfile = TFile::Open(filename.c_str(), "READ");
76 
77  if (dqmfile == nullptr)
78  return 1;
79 
80  std::string infodir = "DQMData/Run " + nrun + "/Info/Run summary/ProvInfo";
81  gDirectory->cd(infodir.c_str());
82 
83  TIter next(gDirectory->GetListOfKeys());
84  TKey *key;
85 
86  int isruncomplete = -1;
87 
88  while ((key = dynamic_cast<TKey *>(next()))) {
89  std::string svar = key->GetName();
90  if (svar.empty())
91  continue;
92 
93  if (svar.find("runIsComplete") != std::string::npos) {
94  std::string statusflag = svar.substr(svar.rfind('<') - 1, 1);
95  isruncomplete = atoi(statusflag.c_str());
96  }
97  }
98 
99  dqmfile->Close();
100 
101  if (isruncomplete == -1)
102  return 3;
103  if (isruncomplete == 0)
104  return 2;
105  if (isruncomplete == 1)
106  return 0;
107 
108  return -8;
109 }
cmsBatch.argv
argv
Definition: cmsBatch.py:279
check_runcomplete
int check_runcomplete(std::string filename)
Definition: check_runcomplete.cc:48
dir2webdir.argc
argc
Definition: dir2webdir.py:39
gather_cfg.cout
cout
Definition: gather_cfg.py:144
fileCollector.dqmfile
dqmfile
Definition: fileCollector.py:162
read_runflag
int read_runflag(std::string filename)
Definition: check_runcomplete.cc:72
check_runcomplete.h
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
crabWrapper.key
key
Definition: crabWrapper.py:19
main
int main(int argc, char *argv[])
Definition: check_runcomplete.cc:28
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31