24 verbose_( pSet_.getUntrackedParameter<bool>(
"verbose",
false))
26 edm::LogInfo(
"TrackingQualityChecker") <<
" Creating TrackingQualityChecker " <<
"\n" ;
33 "\n------------------------------------------"
34 "\nUnAvailable Service TkHistoMap: please insert in the configuration file an instance like"
35 "\n\tprocess.TkDetMap = cms.Service(\"TkDetMap\")"
36 "\n------------------------------------------";
42 std::vector<edm::ParameterSet> TrackingGlobalQualityMEs =
pSet_.
getParameter< std::vector<edm::ParameterSet> >(
"TrackingGlobalQualityPSets" );
43 for (
auto meQTset : TrackingGlobalQualityMEs ) {
46 tracking_mes.HistoDir = meQTset.getParameter<
std::string>(
"dir");
47 tracking_mes.HistoName = meQTset.getParameter<
std::string>(
"name");
48 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] inserting " << QTname <<
" in TrackingMEsMap" << std::endl;
49 TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>(QTname, tracking_mes));
51 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] created TrackingMEsMap" << std::endl;
54 std::vector<edm::ParameterSet> TrackingLSQualityMEs =
pSet_.
getParameter< std::vector<edm::ParameterSet> >(
"TrackingLSQualityPSets" );
55 for (
auto meQTset : TrackingLSQualityMEs ) {
58 tracking_ls_mes.
HistoLSDir = meQTset.exists(
"LSdir") ? meQTset.getParameter<
std::string>(
"LSdir") :
"";
60 tracking_ls_mes.
HistoLSLowerCut = meQTset.exists(
"LSlowerCut") ? meQTset.getParameter<
double>(
"LSlowerCut") : -1.;
61 tracking_ls_mes.
HistoLSUpperCut = meQTset.exists(
"LSupperCut") ? meQTset.getParameter<
double>(
"LSupperCut") : -1.;
64 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] inserting " << QTname <<
" in TrackingMEsMap" << std::endl;
65 TrackingLSMEsMap.insert(std::pair<std::string, TrackingLSMEs>(QTname, tracking_ls_mes));
67 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::TrackingQualityChecker] created TrackingLSMEsMap" << std::endl;
74 edm::LogInfo(
"TrackingQualityChecker") <<
" Deleting TrackingQualityChecker " <<
"\n" ;
85 edm::LogInfo(
"TrackingQualityChecker") <<
" booking TrackingQualityStatus" <<
"\n";
94 hname =
"reportSummaryMap";
95 htitle =
"Tracking Report Summary Map";
98 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookGlobalStatus] nQT: " << nQT << std::endl;
110 for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin();
111 it != TrackingMEsMap.end(); it++) {
113 it->second.TrackingFlag = ibooker.
bookFloat(
"Track"+meQTname);
114 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookGlobalStatus] " << it->first <<
" exists ? " << it->second.TrackingFlag << std::endl;
115 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
129 edm::LogInfo(
"TrackingQualityChecker") <<
" booking TrackingQualityStatus" <<
"\n";
138 hname =
"reportSummaryMap";
139 htitle =
"Tracking Report Summary Map";
144 std::cout <<
"[TrackingQualityChecker::bookLSStatus] nQT: " << nQT << std::endl;
148 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
151 it->second.TrackingFlag = ibooker.
bookFloat(
"Track"+meQTname);
152 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookLSStatus] " << it->first <<
" exists ? " << it->second.TrackingFlag << std::endl;
153 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::bookLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
165 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyGlobalStatus] starting ..." << std::endl;
177 for (std::map<std::string, TrackingMEs>::iterator it =
TrackingMEsMap.begin();
179 it->second.TrackingFlag->Fill(-1.0);
180 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
185 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyLSStatus] starting ..." << std::endl;
192 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
194 it->second.TrackingFlag->Fill(-1.0);
195 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillDummyLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
211 for (std::map<std::string, TrackingMEs>::iterator it =
TrackingMEsMap.begin();
214 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetGlobalStatus] " << it->second.HistoName <<
" exist ? " << ( it->second.TrackingFlag ==
NULL ?
"nope" :
"yes" ) <<
" ---> " << me << std::endl;
217 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
227 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
230 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetLSStatus] " << it->second.HistoLSName <<
" exist ? " << ( it->second.TrackingFlag ==
NULL ?
"nope" :
"yes" ) <<
" ---> " << me << std::endl;
233 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::resetLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
248 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillGlobalStatus] DONE" << std::endl;
259 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillLSStatus] DONE" << std::endl;
275 for (std::map<std::string, TrackingMEs>::iterator it =
TrackingMEsMap.begin();
278 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
285 std::vector<MonitorElement*> tmpMEvec = igetter.
getContents(ibooker.
pwd()+
"/"+localMEdirpath);
286 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] tmpMEvec: " << tmpMEvec.size() << std::endl;
290 for (
auto ime : tmpMEvec ) {
292 if (
verbose_)
std::cout <<
"name: " << name <<
" <-- --> " << MEname << std::endl;
293 if ( name.find(MEname) != std::string::npos) {
299 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] nMEs: " << nMEs << std::endl;
302 for (
auto ime : tmpMEvec ) {
304 if (
verbose_)
std::cout <<
"name: " << name <<
" [" << MEname <<
"]" << std::endl;
305 if ( name.find(MEname) != std::string::npos) {
312 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] status: " << status << std::endl;
313 std::vector<QReport *> qt_reports = me->
getQReports();
314 size_t nQTme = qt_reports.size();
317 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] qt_reports: " << qt_reports.size() << std::endl;
319 for (
auto iQT : qt_reports ) {
320 status += iQT->getQTresult();
321 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT: " << iQT->getQRName() << std::endl;
322 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << iQT->getQTresult() <<
" exists ? " << (it->second.TrackingFlag ?
"yes " :
"no ") << it->second.TrackingFlag << std::endl;
323 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT message: " << iQT->getMessage() << std::endl;
324 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT status: " << iQT->getStatus() << std::endl;
326 status = status/float(nQTme);
327 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << status << std::endl;
328 it->second.TrackingFlag->Fill(status);
333 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] gstatus: " << gstatus <<
" x status: " << status << std::endl;
334 if ( status < 0. ) gstatus = -1.;
336 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ===> gstatus: " << gstatus << std::endl;
337 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
341 for (
auto ime : tmpMEvec ) {
342 float tmp_status = 1.;
344 if ( name.find(MEname) != std::string::npos) {
347 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] status: " << status << std::endl;
348 std::vector<QReport *> qt_reports = me->
getQReports();
349 size_t nQTme = qt_reports.size();
350 if (
verbose_)
std::cout <<
"nQTme: " << nQTme <<
"[" << name <<
", " << ime->getFullname() <<
"]" << std::endl;
352 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] qt_reports: " << qt_reports.size() << std::endl;
354 for (
auto iQT : qt_reports ) {
355 tmp_status += iQT->getQTresult();
356 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT: " << iQT->getQRName() << std::endl;
357 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << iQT->getQTresult() <<
" exists ? " << (it->second.TrackingFlag ?
"yes " :
"no ") << it->second.TrackingFlag << std::endl;
358 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT message: " << iQT->getMessage() << std::endl;
359 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] iQT status: " << iQT->getStatus() << std::endl;
361 tmp_status = tmp_status/float(nQTme);
364 status = fminf(tmp_status,status);
366 if ( status < 0. ) gstatus = -1.;
368 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] MEname: " << MEname <<
" status: " << status << std::endl;
369 it->second.TrackingFlag->Fill(status);
376 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] gstatus: " << gstatus << std::endl;
378 if (gstatus < 1.) gstatus = -1.;
379 else gstatus = gstatus/float(nQT);
381 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] ===> gstatus: " << gstatus << std::endl;
385 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatus] DONE" << std::endl;
395 th2d->SetBinContent(xbin, ybin, val);
403 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] starting .. " << std::endl;
411 for (std::map<std::string, TrackingLSMEs>::iterator it =
TrackingLSMEsMap.begin();
414 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
418 std::string localMEdirpath = it->second.HistoLSDir;
420 float lower_cut = it->second.HistoLSLowerCut;
421 float upper_cut = it->second.HistoLSUpperCut;
425 std::vector<MonitorElement*> tmpMEvec = igetter.
getContents(ibooker.
pwd()+
"/"+localMEdirpath);
426 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] tmpMEvec: " << tmpMEvec.size() << std::endl;
431 for (
auto ime : tmpMEvec ) {
433 if ( name.find(MEname) != std::string::npos) {
440 for (
auto ime : tmpMEvec ) {
442 if ( name.find(MEname) != std::string::npos) {
450 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] MEname: " << MEname <<
" x_mean: " << x_mean << std::endl;
451 if (x_mean <= lower_cut || x_mean > upper_cut) status = 0.0;
455 for (
auto ime : tmpMEvec ) {
456 float tmp_status = 1.;
458 if ( name.find(MEname) != std::string::npos) {
464 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] MEname: " << MEname <<
"[" << me->
getName() <<
"] x_mean: " << x_mean << std::endl;
465 if (x_mean <= lower_cut || x_mean > upper_cut) tmp_status = 0.0;
466 else tmp_status = 1.0;
467 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] tmp_status: " << tmp_status << std::endl;
470 status = fminf(tmp_status,status);
471 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ==> status: " << status << std::endl;
474 it->second.TrackingFlag->Fill(status);
475 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ===> status: " << status <<
" [" << gstatus <<
"]" << std::endl;
476 if (status == 0.0) gstatus = -1.0;
477 else gstatus = gstatus *
status;
478 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ===> gstatus: " << gstatus << std::endl;
479 if (
verbose_)
std::cout <<
"[TrackingQualityChecker::fillTrackingStatusAtLumi] ME: " << it->first <<
" [" << it->second.TrackingFlag->getFullname() <<
"] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
484 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