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()));
247 TIter nextTemp(tempDir->GetListOfKeys());
249 while ((keyTemp = dynamic_cast<TKey*>(nextTemp()))) {
250 float tempvalue = -1.;
251 string classname(keyTemp->GetClassName());
253 string sflag = keyTemp->GetName();
254 string tempname = sflag.substr(sflag.find(
"f=") + 2);
255 size_t pos1 = tempname.find(
'<');
256 size_t pos2 = sflag.find_first_of(
'>');
257 string detvalue = tempname.substr(0, pos1);
258 string typecert = sflag.substr(1, pos2 - 1);
260 std::cout << typecert.c_str() << std::endl;
261 tempvalue = atof(detvalue.c_str());
263 for (
int j = 0;
j < smax;
j++) {
264 if (strstr(typecert.c_str(), certflag[
j].c_str()) !=
nullptr)
267 std::cout <<
"Entering value " << tempvalue <<
" " <<
v[
j][
i] <<
" for " << certflag[
j].c_str()
276 for (
int iS = 0; iS < smax; iS++) {
279 vector<int> missingLS;
280 vector<float> allLSthr;
283 for (
int iLS = 0; iLS < vecsize; iLS++) {
285 goodLS.push_back(lsd[iLS]);
286 else if (
v[iS][iLS] > -1)
287 badLS.push_back(lsd[iLS]);
291 for (
int i_ls = 1; i_ls <= nLS_run; i_ls++) {
292 for (
int j = last_idx;
j < vecsize;
j++) {
293 if (lsd[
j] == i_ls) {
296 allLSthr.push_back(0.00001);
298 allLSthr.push_back(
v[iS][
j]);
303 missingLS.push_back(i_ls);
304 allLSthr.push_back(-1);
314 string goodList =
ListOut(goodLS);
315 string badList =
ListOut(badLS);
316 string missingList =
ListOut(missingLS);
319 gLS.push_back(make_pair(goodList, allLSthr));
320 bLS.push_back(make_pair(badList, allLSthr));
321 mLS.push_back(make_pair(missingList, allLSthr));
328 vector<string>& cert_strip,
329 vector<string>& cert_track,
330 vector<string>& cert_pixel,
331 vector<pair<
string, vector<float> > >& LS_strip,
332 vector<pair<
string, vector<float> > >& LS_track,
333 vector<pair<
string, vector<float> > >& LS_pixel) {
336 char plottitles[200];
337 sprintf(plottitles,
"Lumisection Certification: Run %s;Luminosity Section;",
runnum_str(
filename).c_str());
338 TH2D*
cert_plot =
new TH2D(
"cert_plot", plottitles, nLumiSections, 1, nLumiSections + 1, 5, 1, 6);
341 for (
int ityp = 0; ityp < 4; ityp++) {
342 sprintf(
label,
"SiStrip %s", cert_strip[ityp].c_str());
345 for (
unsigned int idx = 0;
idx < LS_strip[ityp].second.size();
idx++)
349 for (
int ityp = 0; ityp < 1; ityp++) {
350 sprintf(
label,
"Tracking %s", cert_track[ityp].c_str());
352 for (
unsigned int idx = 0;
idx < LS_track[ityp].second.size();
idx++)
357 const Int_t colNum = 20;
359 float rgb[colNum][3];
361 for (Int_t
i = 0;
i < colNum;
i++) {
369 rgb[
i][0] = 0.80 + (0.98 - 0.80) / (col_thr - 1) *
i;
370 rgb[
i][1] = 0.00 + (0.79 - 0.00) / (col_thr - 1) *
i;
376 TColor* color = gROOT->GetColor(9001 +
i);
378 color =
new TColor(9001 +
i, 0, 0, 0,
"");
381 gStyle->SetPalette(colNum,
palette);
382 gROOT->SetStyle(
"Plain");
384 TCanvas*
cc =
new TCanvas(
"name",
"title", 1000, 600);
386 gPad->SetLeftMargin(0.17);
388 cc->Print(plotfilename.c_str());
392 TH2D* cert_plot_pixel =
new TH2D(
"cert_plot_pixel", plottitles, nLumiSections, 1, nLumiSections + 1, 4, 1, 5);
393 cert_plot_pixel->SetStats(
false);
395 for (
int ityp = 0; ityp < 4; ityp++) {
396 sprintf(
label,
"Pixel %s", cert_pixel[ityp].c_str());
397 cert_plot_pixel->GetYaxis()->SetBinLabel(4 - ityp,
label);
399 for (
unsigned int idx = 0;
idx < LS_pixel[ityp].second.size();
idx++)
401 cert_plot_pixel->SetBinContent(
idx + 1, 4 - ityp, LS_pixel[ityp].
second[
idx]);
404 int col_thr_pixel = colNum * threshold_pixel;
406 for (Int_t
i = 0;
i < colNum;
i++) {
407 if (
i >= col_thr_pixel) {
414 rgb[
i][0] = 0.80 + (0.98 - 0.80) / (col_thr - 1) *
i;
415 rgb[
i][1] = 0.00 + (0.79 - 0.00) / (col_thr - 1) *
i;
421 TColor* color = gROOT->GetColor(10001 +
i);
423 color =
new TColor(10001 +
i, 0, 0, 0,
"");
426 gStyle->SetPalette(colNum,
palette);
427 gROOT->SetStyle(
"Plain");
429 cert_plot_pixel->Draw(
"colz");
431 string plotfilename_pixel =
"Certification_run_" +
runnum_str(
filename) +
"_pixel.png";
432 cc->Print(plotfilename_pixel.c_str());
445 if (!
file->IsOpen()) {
453 bool isHIRun =
false;
454 if (
filename.find(
"HIRun") != string::npos)
459 string EventInfoDir =
"DQMData/Run " +
run +
"/SiStrip/Run summary/EventInfo";
460 TDirectory* rsEventInfoDir =
dynamic_cast<TDirectory*
>(
file->Get(EventInfoDir.c_str()));
461 rsEventInfoDir->cd();
462 TIter eiKeys(rsEventInfoDir->GetListOfKeys());
464 while ((eiKey = dynamic_cast<TKey*>(eiKeys()))) {
467 string sflag = eiKey->GetName();
468 string tempname = sflag.substr(sflag.find(
"i=") + 2);
469 size_t pos1 = tempname.find(
'<');
470 size_t pos2 = sflag.find_first_of(
'>');
471 string detvalue = tempname.substr(0, pos1);
472 string numlumisec = sflag.substr(1, pos2 - 1);
473 if (numlumisec == (
string)
"iLumiSection") {
481 string EventInfoDirHist =
"DQMData/Run " +
run +
"/Info/Run summary/EventInfo/ProcessedLS";
482 TH1F* allLS = (TH1F*)
file->Get(EventInfoDirHist.c_str());
497 int refLS = LSlist[0];
498 for (
unsigned int at = 1; at < LSlist.size() - 1; at++) {
500 if (refLS + 1 == LSlist[at] && LSlist[at] + 1 == LSlist[at + 1]) {
511 bool rangeset =
false;
513 for (
unsigned int at = 0; at < LSlist.size(); at++) {
514 if (LSlist[at] != -1) {
515 if (at > 0 && LSlist[at - 1] != -1)
519 strout += lsnum.str();
522 if (LSlist[at] == -1 && !rangeset) {
void Cleaning(vector< int > &LSlist)
uint32_t cc[maxCellsPerHit]
string runnum_str(string filename)
void cert_plot(float threshold_pixel, float threshold, string filename, vector< string > &cert_strip, vector< string > &cert_track, vector< string > &cert_pixel, vector< pair< string, vector< float > > > &LS_strip, vector< pair< string, vector< float > > > &LS_track, vector< pair< string, vector< float > > > &LS_pixel)
int main(int argc, char *argv[])
U second(std::pair< T, U > const &p)
void ls_cert(float threshold_pixel, float threshold, string filename)
string ListOut(vector< int > &LSlist)
int nlumis(string filename)
def rgb(r, g, b, maximum=1.)
void ls_cert_type(string iDir, float threshold, string filename, vector< string > &cert, vector< pair< string, vector< float > > > &gLS, vector< pair< string, vector< float > > > &bLS, vector< pair< string, vector< float > > > &mLS)