26 verbose_( pSet_.getUntrackedParameter<bool>(
"verbose",
false))
28 edm::LogInfo(
"TrackingQualityChecker") <<
" Creating TrackingQualityChecker " <<
"\n" ;
35 "\n------------------------------------------"
36 "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
37 "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
38 "\n------------------------------------------";
44 std::vector<edm::ParameterSet> TrackingGlobalQualityMEs =
pSet_.
getParameter< std::vector<edm::ParameterSet> >(
"TrackingGlobalQualityPSets" );
45 for (
auto meQTset : TrackingGlobalQualityMEs ) {
48 tracking_mes.HistoDir = meQTset.getParameter<
std::string>(
"dir");
49 tracking_mes.HistoName = meQTset.getParameter<
std::string>(
"name");
50 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] inserting " << QTname <<
" in TrackingMEsMap" << std::endl;
51 TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>(QTname, tracking_mes));
53 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] created TrackingMEsMap" << std::endl;
56 std::vector<edm::ParameterSet> TrackingLSQualityMEs =
pSet_.
getParameter< std::vector<edm::ParameterSet> >(
"TrackingLSQualityPSets" );
57 for (
auto meQTset : TrackingLSQualityMEs ) {
60 tracking_ls_mes.
HistoLSDir = meQTset.exists(
"LSdir") ? meQTset.getParameter<
std::string>(
"LSdir") :
"";
62 tracking_ls_mes.
HistoLSLowerCut = meQTset.exists(
"LSlowerCut") ? meQTset.getParameter<
double>(
"LSlowerCut") : -1.;
63 tracking_ls_mes.
HistoLSUpperCut = meQTset.exists(
"LSupperCut") ? meQTset.getParameter<
double>(
"LSupperCut") : -1.;
66 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] inserting " << QTname <<
" in TrackingMEsMap" << std::endl;
67 TrackingLSMEsMap.insert(std::pair<std::string, TrackingLSMEs>(QTname, tracking_ls_mes));
69 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] created TrackingLSMEsMap" << std::endl;
76 edm::LogInfo(
"TrackingQualityChecker") <<
" Deleting TrackingQualityChecker " <<
"\n" ;
87 edm::LogInfo(
"TrackingQualityChecker") <<
" booking TrackingQualityStatus" <<
"\n";
96 hname =
"reportSummaryMap";
97 htitle =
"Tracking Report Summary Map";
100 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookGlobalStatus] nQT: " << nQT << std::endl;
112 for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
113 it != TrackingMEsMap.end(); it++) {
115 it->second.TrackingFlag = ibooker.
bookFloat(
"Track"+meQTname);
116 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookGlobalStatus] " << it->first <<
" exists ? " << it->second.TrackingFlag << std::endl;
117 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
131 edm::LogInfo(
"TrackingQualityChecker") <<
" booking TrackingQualityStatus" <<
"\n";
140 hname =
"reportSummaryMap";
141 htitle =
"Tracking Report Summary Map";
146 std::cout <<
"[TrackingQualityChecker::bookLSStatus] nQT: " << nQT << std::endl;
150 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
153 it->second.TrackingFlag = ibooker.
bookFloat(
"Track"+meQTname);
154 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookLSStatus] " << it->first <<
" exists ? " << it->second.TrackingFlag << std::endl;
155 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
167 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyGlobalStatus] starting ..." << std::endl;
179 for (std::map<std::string, TrackingMEs>::iterator it =
TrackingMEsMap.begin();
181 it->second.TrackingFlag->Fill(-1.0);
182 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
187 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyLSStatus] starting ..." << std::endl;
194 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
196 it->second.TrackingFlag->Fill(-1.0);
197 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
213 for (std::map<std::string, TrackingMEs>::iterator it =
TrackingMEsMap.begin();
216 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetGlobalStatus] " << it->second.HistoName <<
" exist ? " << ( it->second.TrackingFlag ==
NULL ?
"nope" :
"yes" ) <<
" ---> " << me << std::endl;
219 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
229 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
232 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetLSStatus] " << it->second.HistoLSName <<
" exist ? " << ( it->second.TrackingFlag ==
NULL ?
"nope" :
"yes" ) <<
" ---> " << me << std::endl;
235 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
250 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillGlobalStatus] DONE" << std::endl;
261 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillLSStatus] DONE" << std::endl;
277 for (std::map<std::string, TrackingMEs>::iterator it =
TrackingMEsMap.begin();
280 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
287 std::vector<MonitorElement*> tmpMEvec = igetter.
getContents(ibooker.
pwd()+
"/"+localMEdirpath);
288 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] tmpMEvec: " << tmpMEvec.size() << std::endl;
292 for (
auto ime : tmpMEvec ) {
294 if (
verbose_)
std::cout <<
"name: " << name <<
" <-- --> " << MEname << std::endl;
295 if ( name.find(MEname) != std::string::npos) {
301 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] nMEs: " << nMEs << std::endl;
304 for (
auto ime : tmpMEvec ) {
306 if (
verbose_)
std::cout <<
"name: " << name <<
" [" << MEname <<
"]" << std::endl;
307 if ( name.find(MEname) != std::string::npos) {
314 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] status: " << status << std::endl;
315 std::vector<QReport *> qt_reports = me->
getQReports();
316 size_t nQTme = qt_reports.size();
319 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] qt_reports: " << qt_reports.size() << std::endl;
321 for (
auto iQT : qt_reports ) {
322 status += iQT->getQTresult();
323 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT: " << iQT->getQRName() << std::endl;
324 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << iQT->getQTresult() <<
" exists ? " << (it->second.TrackingFlag ?
"yes " :
"no ") << it->second.TrackingFlag << std::endl;
325 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT message: " << iQT->getMessage() << std::endl;
326 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT status: " << iQT->getStatus() << std::endl;
328 status = status/float(nQTme);
329 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << status << std::endl;
330 it->second.TrackingFlag->Fill(status);
335 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] gstatus: " << gstatus <<
" x status: " << status << std::endl;
336 if ( status < 0. ) gstatus = -1.;
338 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ===> gstatus: " << gstatus << std::endl;
339 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
343 for (
auto ime : tmpMEvec ) {
344 float tmp_status = 1.;
346 if ( name.find(MEname) != std::string::npos) {
349 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] status: " << status << std::endl;
350 std::vector<QReport *> qt_reports = me->
getQReports();
351 size_t nQTme = qt_reports.size();
352 if (
verbose_)
std::cout <<
"nQTme: " << nQTme <<
"[" << name <<
", " << ime->getFullname() <<
"]" << std::endl;
354 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] qt_reports: " << qt_reports.size() << std::endl;
356 for (
auto iQT : qt_reports ) {
357 tmp_status += iQT->getQTresult();
358 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT: " << iQT->getQRName() << std::endl;
359 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << iQT->getQTresult() <<
" exists ? " << (it->second.TrackingFlag ?
"yes " :
"no ") << it->second.TrackingFlag << std::endl;
360 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT message: " << iQT->getMessage() << std::endl;
361 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT status: " << iQT->getStatus() << std::endl;
363 tmp_status = tmp_status/float(nQTme);
366 status = fminf(tmp_status,status);
368 if ( status < 0. ) gstatus = -1.;
370 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << status << std::endl;
371 it->second.TrackingFlag->Fill(status);
378 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] gstatus: " << gstatus << std::endl;
380 if (gstatus < 1.) gstatus = -1.;
381 else gstatus = gstatus/float(nQT);
383 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ===> gstatus: " << gstatus << std::endl;
387 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] DONE" << std::endl;
397 th2d->SetBinContent(xbin, ybin, val);
405 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] starting .. " << std::endl;
413 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
416 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
420 std::string localMEdirpath = it->second.HistoLSDir;
422 float lower_cut = it->second.HistoLSLowerCut;
423 float upper_cut = it->second.HistoLSUpperCut;
427 std::vector<MonitorElement*> tmpMEvec = igetter.
getContents(ibooker.
pwd()+
"/"+localMEdirpath);
428 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] tmpMEvec: " << tmpMEvec.size() << std::endl;
433 for (
auto ime : tmpMEvec ) {
435 if ( name.find(MEname) != std::string::npos) {
442 for (
auto ime : tmpMEvec ) {
444 if ( name.find(MEname) != std::string::npos) {
452 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] MEname: " << MEname <<
" x_mean: " << x_mean << std::endl;
453 if (x_mean <= lower_cut || x_mean > upper_cut) status = 0.0;
457 for (
auto ime : tmpMEvec ) {
458 float tmp_status = 1.;
460 if ( name.find(MEname) != std::string::npos) {
466 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] MEname: " << MEname <<
"[" << me->
getName() <<
"] x_mean: " << x_mean << std::endl;
467 if (x_mean <= lower_cut || x_mean > upper_cut) tmp_status = 0.0;
468 else tmp_status = 1.0;
469 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] tmp_status: " << tmp_status << std::endl;
472 status = fminf(tmp_status,status);
473 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ==> status: " << status << std::endl;
476 it->second.TrackingFlag->Fill(status);
477 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ===> status: " << status <<
" [" << gstatus <<
"]" << std::endl;
478 if (status == 0.0) gstatus = -1.0;
479 else gstatus = gstatus *
status;
480 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ===> gstatus: " << gstatus << std::endl;
481 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
486 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] DONE" << std::endl;
std::vector< MonitorElement * > getContents(Args &&...args)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
MonitorElement * TrackingFlag
MonitorElement * TrackGlobalSummaryReportMap
void fillDummyGlobalStatus()
const std::string & pwd(void)
std::map< std::string, TrackingMEs > TrackingMEsMap
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual ~TrackingQualityChecker()
std::string TopFolderName_
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
TrackingQualityChecker(edm::ParameterSet const &ps)
void fillGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
MonitorElement * TrackLSSummaryReportGlobal
void fillLSStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
bool bookedTrackingGlobalStatus_
static bool goToDir(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string name)
void fillStatusHistogram(MonitorElement *, int xbin, int ybin, float val)
Kind kind(void) const
Get the type of the monitor element.
const std::string getFullname(void) const
get full name of ME including Pathname
void setCurrentFolder(const std::string &fullpath)
std::vector< QReport * > getQReports(void) const
get map of QReports
MonitorElement * book2D(Args &&...args)
bool bookedTrackingLSStatus_
void bookLSStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void bookGlobalStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
int getNbinsX(void) const
get # of bins in X-axis
void fillTrackingStatusAtLumi(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
MonitorElement * TrackGlobalSummaryReportGlobal
void fillTrackingStatus(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
void Reset(std::vector< TH2F > &depth)
MonitorElement * bookFloat(Args &&...args)
volatile std::atomic< bool > shutdown_flag false
TH2F * getTH2F(void) const
if(conf.exists("allCellsPositionCalc"))
static void getTopFolderPath(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string top_dir, std::string &path)
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
std::map< std::string, TrackingLSMEs > TrackingLSMEsMap