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