Go to the documentation of this file.00001 #include <Riostream.h>
00002 #include <TDirectory.h>
00003 #include <TFile.h>
00004 #include <TROOT.h>
00005 #include <TStyle.h>
00006 #include <TKey.h>
00007 #include <TH1.h>
00008 #include <TH2.h>
00009 #include <TH2D.h>
00010 #include <TCanvas.h>
00011 #include <TGraph.h>
00012 #include <TPaveStats.h>
00013 #include <TText.h>
00014 #include <TLegend.h>
00015 #include <string>
00016 #include <utility>
00017 #include <vector>
00018 #include <sstream>
00019 #include <algorithm>
00020 #include <TString.h>
00021 #include <TColor.h>
00022 #include <dirent.h>
00023
00024 #include "check_runcomplete.h"
00025
00026
00027
00028 int main(int argc , char *argv[]) {
00029
00030 if(argc==2) {
00031 char* cfile = argv[1];
00032
00033 std::cout << "ready to check file " << cfile << std::endl;
00034
00035 int returncode = check_runcomplete(cfile);
00036 if(returncode==0) std::cout << "DQM file is ok" << std::endl;
00037
00038 return returncode;
00039
00040 }
00041 else {std::cout << "Too few arguments: " << argc << std::endl; return -1; }
00042
00043 return -9;
00044
00045 }
00046
00047 int check_runcomplete (std::string filename )
00048 {
00049 int runflag = read_runflag ( filename );
00050 if ( runflag == 1 )
00051 {
00052 printf("************************************\n");
00053 printf("**\n");
00054 printf("** W A R N I N G: the DQM file %s does not exist" , filename.c_str() );
00055 printf("**\n");
00056 printf("************************************\n");
00057 }
00058 else if ( runflag == 2 )
00059 {
00060 printf("************************************\n");
00061 printf("**\n");
00062 printf("** W A R N I N G: the DQM file %s is incomplete" , filename.c_str() );
00063 printf("**\n");
00064 printf("************************************\n");
00065 }
00066 else if ( runflag != 0 )
00067 {
00068 printf("************************************\n");
00069 printf("**\n");
00070 printf("** W A R N I N G: problems found in the DQM file %s" , filename.c_str() );
00071 printf("**\n");
00072 printf("************************************\n");
00073 }
00074 return runflag;
00075 }
00076
00077 int read_runflag (std::string filename )
00078 {
00079 std::string nrun = filename.substr ( filename.find( "_R000" ) + 5 , 6 );
00080
00081 TFile *dqmfile = TFile::Open ( filename.c_str() , "READ" );
00082
00083 if(dqmfile==0) return 1;
00084
00085 std::string infodir = "DQMData/Run " + nrun + "/Info/Run summary/ProvInfo";
00086 gDirectory->cd(infodir.c_str());
00087
00088 TIter next ( gDirectory->GetListOfKeys() );
00089 TKey *key;
00090
00091 int isruncomplete = -1;
00092
00093 while ( ( key = dynamic_cast<TKey*> ( next() ) ) )
00094 {
00095 std::string svar = key->GetName();
00096 if ( svar.size() == 0 ) continue;
00097
00098 if ( svar.find( "runIsComplete" ) != std::string::npos )
00099 {
00100 std::string statusflag = svar.substr ( svar.rfind ( "<" ) -1 , 1 );
00101 isruncomplete = atoi ( statusflag.c_str() );
00102 }
00103 }
00104
00105 dqmfile->Close();
00106
00107 if(isruncomplete == -1) return 3;
00108 if(isruncomplete == 0) return 2;
00109 if(isruncomplete == 1) return 0;
00110
00111 return -8;
00112 }
00113
00114
00115
00116