CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
30  if(argc==2) {
31  char* cfile = argv[1];
32 
33  std::cout << "ready to check file " << cfile << std::endl;
34 
35  int returncode = check_runcomplete(cfile);
36  if(returncode==0) std::cout << "DQM file is ok" << std::endl;
37 
38  return returncode;
39 
40  }
41  else {std::cout << "Too few arguments: " << argc << std::endl; return -1; }
42 
43  return -9;
44 
45 }
46 
48 {
49  int runflag = read_runflag ( filename );
50  if ( runflag == 1 )
51  {
52  printf("************************************\n");
53  printf("**\n");
54  printf("** W A R N I N G: the DQM file %s does not exist" , filename.c_str() );
55  printf("**\n");
56  printf("************************************\n");
57  }
58  else if ( runflag == 2 )
59  {
60  printf("************************************\n");
61  printf("**\n");
62  printf("** W A R N I N G: the DQM file %s is incomplete" , filename.c_str() );
63  printf("**\n");
64  printf("************************************\n");
65  }
66  else if ( runflag != 0 )
67  {
68  printf("************************************\n");
69  printf("**\n");
70  printf("** W A R N I N G: problems found in the DQM file %s" , filename.c_str() );
71  printf("**\n");
72  printf("************************************\n");
73  }
74  return runflag;
75 }
76 
78 {
79  std::string nrun = filename.substr ( filename.find( "_R000" ) + 5 , 6 );
80 
81  TFile *dqmfile = TFile::Open ( filename.c_str() , "READ" );
82 
83  if(dqmfile==0) return 1;
84 
85  std::string infodir = "DQMData/Run " + nrun + "/Info/Run summary/ProvInfo";
86  gDirectory->cd(infodir.c_str());
87 
88  TIter next ( gDirectory->GetListOfKeys() );
89  TKey *key;
90 
91  int isruncomplete = -1;
92 
93  while ( ( key = dynamic_cast<TKey*> ( next() ) ) )
94  {
95  std::string svar = key->GetName();
96  if ( svar.size() == 0 ) continue;
97 
98  if ( svar.find( "runIsComplete" ) != std::string::npos )
99  {
100  std::string statusflag = svar.substr ( svar.rfind ( "<" ) -1 , 1 );
101  isruncomplete = atoi ( statusflag.c_str() );
102  }
103  }
104 
105  dqmfile->Close();
106 
107  if(isruncomplete == -1) return 3;
108  if(isruncomplete == 0) return 2;
109  if(isruncomplete == 1) return 0;
110 
111  return -8;
112 }
113 
114 
115 
116 
int check_runcomplete(std::string filename)
int read_runflag(std::string filename)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
tuple argc
Definition: dir2webdir.py:38
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121