2 #include <TDirectory.h>
12 #include <TPaveStats.h>
34 char* cpixel =
argv[1];
38 float threshold_pixel = 0;
39 sscanf(cpixel,
"%f", &threshold_pixel);
43 std::cout <<
"ready to run ls_cert: pixel thr " << threshold_pixel <<
" threshold " <<
threshold <<
" filename "
60 vector<pair<
string, vector<float> > >&,
61 vector<pair<
string, vector<float> > >&,
62 vector<pair<
string, vector<float> > >&);
69 vector<pair<
string, vector<float> > >&,
70 vector<pair<
string, vector<float> > >&,
71 vector<pair<
string, vector<float> > >&);
77 vector<string> cert_strip;
78 vector<string> cert_track;
79 vector<string> cert_pixel;
82 vector<pair<string, vector<float> > > gLS_strip;
83 vector<pair<string, vector<float> > > gLS_track;
84 vector<pair<string, vector<float> > > gLS_pixel;
87 vector<pair<string, vector<float> > > bLS_strip;
88 vector<pair<string, vector<float> > > bLS_track;
89 vector<pair<string, vector<float> > > bLS_pixel;
92 vector<pair<string, vector<float> > > mLS_strip;
93 vector<pair<string, vector<float> > > mLS_track;
94 vector<pair<string, vector<float> > > mLS_pixel;
102 outfile.open(namefile.c_str());
103 outfile <<
"Lumisection Certification (GOOD: >= " << threshold_pixel <<
" [Pixel]; >= " <<
threshold
104 <<
" [SiStrip,Tracking] "
105 <<
", otherwise BAD):" << endl
107 outfile <<
"GOOD Lumisections:" << endl;
109 for (
int ityp = 0; ityp < 4; ityp++) {
110 sprintf(
line,
" Pixel %*sSummary: %s", 13, cert_pixel[ityp].c_str(), gLS_pixel[ityp].
first.c_str());
113 for (
int ityp = 0; ityp < 4; ityp++) {
114 sprintf(
line,
" SiStrip %*sSummary: %s", 13, cert_strip[ityp].c_str(), gLS_strip[ityp].
first.c_str());
117 for (
int ityp = 0; ityp < 1; ityp++) {
118 sprintf(
line,
" Tracking %*sSummary: %s", 13, cert_track[ityp].c_str(), gLS_track[ityp].
first.c_str());
122 outfile <<
"\nBAD Lumisections:" << endl;
123 for (
int ityp = 0; ityp < 4; ityp++) {
124 sprintf(
line,
" Pixel %*sSummary: %s", 13, cert_pixel[ityp].c_str(), bLS_pixel[ityp].
first.c_str());
127 for (
int ityp = 0; ityp < 4; ityp++) {
128 sprintf(
line,
" SiStrip %*sSummary: %s", 13, cert_strip[ityp].c_str(), bLS_strip[ityp].
first.c_str());
131 for (
int ityp = 0; ityp < 1; ityp++) {
132 sprintf(
line,
" Tracking %*sSummary: %s", 13, cert_track[ityp].c_str(), bLS_track[ityp].
first.c_str());
136 outfile <<
"\nMISSING Lumisections:" << endl;
137 for (
int ityp = 0; ityp < 4; ityp++) {
138 sprintf(
line,
" Pixel %*sSummary: %s", 13, cert_pixel[ityp].c_str(), mLS_pixel[ityp].
first.c_str());
141 for (
int ityp = 0; ityp < 4; ityp++) {
142 sprintf(
line,
" SiStrip %*sSummary: %s", 13, cert_strip[ityp].c_str(), mLS_strip[ityp].
first.c_str());
145 for (
int ityp = 0; ityp < 1; ityp++) {
146 sprintf(
line,
" Tracking %*sSummary: %s", 13, cert_track[ityp].c_str(), mLS_track[ityp].
first.c_str());
151 std::cout <<
"Lumisection Certification summary saved in " << namefile << std::endl;
159 vector<string>& cert,
160 vector<pair<
string, vector<float> > >& gLS,
161 vector<pair<
string, vector<float> > >& bLS,
162 vector<pair<
string, vector<float> > >& mLS) {
175 if (!
file->IsOpen()) {
180 string dir =
"DQMData/Run " +
run +
"/" + iDir;
181 topDir = dynamic_cast<TDirectory*>(
file->Get(
dir.c_str()));
184 std::cout << topDir->GetTitle() << std::endl;
189 TIter
next(topDir->GetListOfKeys());
191 while ((
key = dynamic_cast<TKey*>(
next()))) {
192 string clName(
key->GetClassName());
193 if (clName ==
"TDirectoryFile") {
194 TDirectory* curr_dir = dynamic_cast<TDirectory*>(
key->ReadObj());
195 string name = curr_dir->GetName();
196 if (
name ==
"Run summary")
199 float temp1 = atof(
name.c_str());
204 int vecsize =
ls.size();
209 Float_t* lsd =
new Float_t[vecsize];
211 Float_t**
v =
new Float_t*[4];
212 for (
int k = 0;
k < 4;
k++) {
213 v[
k] =
new Float_t[vecsize];
217 string certflag[4] = {
"DAQSummary",
"DCSSummary",
"reportSummary",
"CertificationSummary"};
218 string certflagPrint[4] = {
"DAQ",
"DCS",
"DQM",
"Certification"};
221 if (iDir ==
"SiStrip" || iDir ==
"Pixel")
224 if (iDir ==
"Tracking") {
225 certflag[0] =
"CertificationSummary";
226 certflagPrint[0] =
"Certification";
227 certflag[1] =
"reportSummary";
228 certflagPrint[1] =
"DQM";
231 for (
int icert_type = 0; icert_type < smax; icert_type++) {
232 cert.push_back(certflagPrint[icert_type]);
236 std::cout << gDirectory->GetName() << std::endl;
238 for (
int i = 0;
i < vecsize;
i++) {
240 lsdir <<
dir <<
"/By Lumi Section " <<
ls[
i] <<
"-" <<
ls[
i] <<
"/EventInfo";
242 std::cout << lsdir.str().c_str() << std::endl;
243 float templs =
ls[
i];
245 TDirectory* tempDir = dynamic_cast<TDirectory*>(
file->Get(lsdir.str().c_str()));
248 TIter nextTemp(tempDir->GetListOfKeys());
250 while ((keyTemp = dynamic_cast<TKey*>(nextTemp()))) {
251 float tempvalue = -1.;
252 string classname(keyTemp->GetClassName());
254 string sflag = keyTemp->GetName();
255 string tempname = sflag.substr(sflag.find(
"f=") + 2);
256 size_t pos1 = tempname.find(
'<');
257 size_t pos2 = sflag.find_first_of(
'>');
258 string detvalue = tempname.substr(0, pos1);
259 string typecert = sflag.substr(1, pos2 - 1);
261 std::cout << typecert.c_str() << std::endl;
262 tempvalue = atof(detvalue.c_str());
264 for (
j = 0;
j < smax;
j++) {
265 if (strstr(typecert.c_str(), certflag[
j].c_str()) !=
nullptr)
268 std::cout <<
"Entering value " << tempvalue <<
" " <<
v[
j][
i] <<
" for " << certflag[
j].c_str()
278 for (
int iS = 0; iS < smax; iS++) {
281 vector<int> missingLS;
282 vector<float> allLSthr;
285 for (
int iLS = 0; iLS < vecsize; iLS++) {
287 goodLS.push_back(lsd[iLS]);
288 else if (
v[iS][iLS] > -1)
289 badLS.push_back(lsd[iLS]);
293 for (
int i_ls = 1; i_ls <= nLS_run; i_ls++) {
294 for (
int j = last_idx;
j < vecsize;
j++) {
295 if (lsd[
j] == i_ls) {
298 allLSthr.push_back(0.00001);
300 allLSthr.push_back(
v[iS][
j]);
305 missingLS.push_back(i_ls);
306 allLSthr.push_back(-1);
316 string goodList =
ListOut(goodLS);
317 string badList =
ListOut(badLS);
318 string missingList =
ListOut(missingLS);
321 gLS.push_back(make_pair(goodList, allLSthr));
322 bLS.push_back(make_pair(badList, allLSthr));
323 mLS.push_back(make_pair(missingList, allLSthr));
330 vector<string>& cert_strip,
331 vector<string>& cert_track,
332 vector<string>& cert_pixel,
333 vector<pair<
string, vector<float> > >& LS_strip,
334 vector<pair<
string, vector<float> > >& LS_track,
335 vector<pair<
string, vector<float> > >& LS_pixel) {
338 char plottitles[200];
339 sprintf(plottitles,
"Lumisection Certification: Run %s;Luminosity Section;",
runnum_str(
filename).c_str());
340 TH2D*
cert_plot =
new TH2D(
"cert_plot", plottitles, nLumiSections, 1, nLumiSections + 1, 5, 1, 6);
343 for (
int ityp = 0; ityp < 4; ityp++) {
344 sprintf(
label,
"SiStrip %s", cert_strip[ityp].c_str());
347 for (
unsigned int idx = 0;
idx < LS_strip[ityp].second.size();
idx++)
351 for (
int ityp = 0; ityp < 1; ityp++) {
352 sprintf(
label,
"Tracking %s", cert_track[ityp].c_str());
354 for (
unsigned int idx = 0;
idx < LS_track[ityp].second.size();
idx++)
359 const Int_t colNum = 20;
361 float rgb[colNum][3];
363 for (Int_t
i = 0;
i < colNum;
i++) {
371 rgb[
i][0] = 0.80 + (0.98 - 0.80) / (col_thr - 1) *
i;
372 rgb[
i][1] = 0.00 + (0.79 - 0.00) / (col_thr - 1) *
i;
378 TColor* color = gROOT->GetColor(9001 +
i);
380 color =
new TColor(9001 +
i, 0, 0, 0,
"");
383 gStyle->SetPalette(colNum,
palette);
384 gROOT->SetStyle(
"Plain");
386 TCanvas*
cc =
new TCanvas(
"name",
"title", 1000, 600);
388 gPad->SetLeftMargin(0.17);
390 cc->Print(plotfilename.c_str());
394 TH2D* cert_plot_pixel =
new TH2D(
"cert_plot_pixel", plottitles, nLumiSections, 1, nLumiSections + 1, 4, 1, 5);
395 cert_plot_pixel->SetStats(
false);
397 for (
int ityp = 0; ityp < 4; ityp++) {
398 sprintf(
label,
"Pixel %s", cert_pixel[ityp].c_str());
399 cert_plot_pixel->GetYaxis()->SetBinLabel(4 - ityp,
label);
401 for (
unsigned int idx = 0;
idx < LS_pixel[ityp].second.size();
idx++)
403 cert_plot_pixel->SetBinContent(
idx + 1, 4 - ityp, LS_pixel[ityp].
second[
idx]);
406 int col_thr_pixel = colNum * threshold_pixel;
408 for (Int_t
i = 0;
i < colNum;
i++) {
409 if (
i >= col_thr_pixel) {
416 rgb[
i][0] = 0.80 + (0.98 - 0.80) / (col_thr - 1) *
i;
417 rgb[
i][1] = 0.00 + (0.79 - 0.00) / (col_thr - 1) *
i;
423 TColor* color = gROOT->GetColor(10001 +
i);
425 color =
new TColor(10001 +
i, 0, 0, 0,
"");
428 gStyle->SetPalette(colNum,
palette);
429 gROOT->SetStyle(
"Plain");
431 cert_plot_pixel->Draw(
"colz");
433 string plotfilename_pixel =
"Certification_run_" +
runnum_str(
filename) +
"_pixel.png";
434 cc->Print(plotfilename_pixel.c_str());
447 if (!
file->IsOpen()) {
455 bool isHIRun =
false;
456 if (
filename.find(
"HIRun") != string::npos)
461 string EventInfoDir =
"DQMData/Run " +
run +
"/SiStrip/Run summary/EventInfo";
462 TDirectory* rsEventInfoDir = dynamic_cast<TDirectory*>(
file->Get(EventInfoDir.c_str()));
463 rsEventInfoDir->cd();
464 TIter eiKeys(rsEventInfoDir->GetListOfKeys());
466 while ((eiKey = dynamic_cast<TKey*>(eiKeys()))) {
469 string sflag = eiKey->GetName();
470 string tempname = sflag.substr(sflag.find(
"i=") + 2);
471 size_t pos1 = tempname.find(
'<');
472 size_t pos2 = sflag.find_first_of(
'>');
473 string detvalue = tempname.substr(0, pos1);
474 string numlumisec = sflag.substr(1, pos2 - 1);
475 if (numlumisec == (
string)
"iLumiSection") {
483 string EventInfoDirHist =
"DQMData/Run " +
run +
"/Info/Run summary/EventInfo/ProcessedLS";
484 TH1F* allLS = (TH1F*)
file->Get(EventInfoDirHist.c_str());
499 int refLS = LSlist[0];
500 for (
unsigned int at = 1; at < LSlist.size() - 1; at++) {
502 if (refLS + 1 == LSlist[at] && LSlist[at] + 1 == LSlist[at + 1]) {
513 bool rangeset =
false;
515 for (
unsigned int at = 0; at < LSlist.size(); at++) {
516 if (LSlist[at] != -1) {
517 if (at > 0 && LSlist[at - 1] != -1)
521 strout += lsnum.str();
524 if (LSlist[at] == -1 && !rangeset) {