Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:12:24

0001 #include "DQM/TrackingMonitorClient/interface/TrackingQualityChecker.h"
0002 #include "FWCore/ServiceRegistry/interface/Service.h"
0003 #include "DQMServices/Core/interface/DQMStore.h"
0004 
0005 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0006 
0007 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0008 
0009 #include "DQM/TrackingMonitorClient/interface/TrackingUtility.h"
0010 
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 
0014 #include <iomanip>
0015 //
0016 // -- Constructor
0017 //
0018 TrackingQualityChecker::TrackingQualityChecker(edm::ParameterSet const& ps)
0019     : pSet_(ps), verbose_(pSet_.getUntrackedParameter<bool>("verbose", false)) {
0020   edm::LogInfo("TrackingQualityChecker") << " Creating TrackingQualityChecker "
0021                                          << "\n";
0022 
0023   bookedTrackingGlobalStatus_ = false;
0024   bookedTrackingLSStatus_ = false;
0025 
0026   TopFolderName_ = pSet_.getUntrackedParameter<std::string>("TopFolderName", "Tracking");
0027 
0028   TrackingMEs tracking_mes;
0029   std::vector<edm::ParameterSet> TrackingGlobalQualityMEs =
0030       pSet_.getParameter<std::vector<edm::ParameterSet> >("TrackingGlobalQualityPSets");
0031   for (const auto& meQTset : TrackingGlobalQualityMEs) {
0032     std::string QTname = meQTset.getParameter<std::string>("QT");
0033     tracking_mes.HistoDir = meQTset.getParameter<std::string>("dir");
0034     tracking_mes.HistoName = meQTset.getParameter<std::string>("name");
0035     if (verbose_)
0036       edm::LogInfo("TrackingQualityChecker") << " inserting " << QTname << " in TrackingMEsMap" << std::endl;
0037     TrackingMEsMap.insert(std::pair<std::string, TrackingMEs>(QTname, tracking_mes));
0038   }
0039   if (verbose_)
0040     edm::LogInfo("TrackingQualityChecker") << " created TrackingMEsMap" << std::endl;
0041 
0042   TrackingLSMEs tracking_ls_mes;
0043   std::vector<edm::ParameterSet> TrackingLSQualityMEs =
0044       pSet_.getParameter<std::vector<edm::ParameterSet> >("TrackingLSQualityPSets");
0045   for (const auto& meQTset : TrackingLSQualityMEs) {
0046     std::string QTname = meQTset.getParameter<std::string>("QT");
0047     tracking_ls_mes.HistoLSDir = meQTset.exists("LSdir") ? meQTset.getParameter<std::string>("LSdir") : "";
0048     tracking_ls_mes.HistoLSName = meQTset.exists("LSname") ? meQTset.getParameter<std::string>("LSname") : "";
0049     tracking_ls_mes.HistoLSLowerCut = meQTset.exists("LSlowerCut") ? meQTset.getParameter<double>("LSlowerCut") : -1.;
0050     tracking_ls_mes.HistoLSUpperCut = meQTset.exists("LSupperCut") ? meQTset.getParameter<double>("LSupperCut") : -1.;
0051     tracking_ls_mes.TrackingFlag = nullptr;
0052 
0053     if (verbose_)
0054       edm::LogInfo("TrackingQualityChecker") << " inserting " << QTname << " in TrackingMEsMap" << std::endl;
0055     TrackingLSMEsMap.insert(std::pair<std::string, TrackingLSMEs>(QTname, tracking_ls_mes));
0056   }
0057   if (verbose_)
0058     edm::LogInfo("TrackingQualityChecker") << " created TrackingLSMEsMap" << std::endl;
0059 }
0060 //
0061 // --  Destructor
0062 //
0063 TrackingQualityChecker::~TrackingQualityChecker() {
0064   edm::LogInfo("TrackingQualityChecker") << " Deleting TrackingQualityChecker "
0065                                          << "\n";
0066 }
0067 //
0068 // -- create reportSummary MEs
0069 //
0070 void TrackingQualityChecker::bookGlobalStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0071   if (verbose_)
0072     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::bookGlobalStatus] already booked ? "
0073                                            << (bookedTrackingGlobalStatus_ ? "yes" : "nope") << std::endl;
0074 
0075   if (!bookedTrackingGlobalStatus_) {
0076     ibooker.cd();
0077     edm::LogInfo("TrackingQualityChecker") << " booking TrackingQualityStatus"
0078                                            << "\n";
0079 
0080     std::string tracking_dir = "";
0081     TrackingUtility::getTopFolderPath(ibooker, igetter, TopFolderName_, tracking_dir);
0082     ibooker.setCurrentFolder(TopFolderName_ + "/EventInfo");
0083 
0084     TrackGlobalSummaryReportGlobal = ibooker.bookFloat("reportSummary");
0085 
0086     std::string hname, htitle;
0087     hname = "reportSummaryMap";
0088     htitle = "Tracking Report Summary Map";
0089 
0090     size_t nQT = TrackingMEsMap.size();
0091     if (verbose_)
0092       edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::bookGlobalStatus] nQT: " << nQT << std::endl;
0093     TrackGlobalSummaryReportMap = ibooker.book2D(hname, htitle, nQT, 0.5, float(nQT) + 0.5, 1, 0.5, 1.5);
0094     TrackGlobalSummaryReportMap->setAxisTitle("Track Quality Type", 1);
0095     TrackGlobalSummaryReportMap->setAxisTitle("QTest Flag", 2);
0096     size_t ibin = 0;
0097     for (const auto& meQTset : TrackingMEsMap) {
0098       TrackGlobalSummaryReportMap->setBinLabel(ibin + 1, meQTset.first);
0099       ibin++;
0100     }
0101 
0102     ibooker.setCurrentFolder(TopFolderName_ + "/EventInfo/reportSummaryContents");
0103 
0104     for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin(); it != TrackingMEsMap.end(); it++) {
0105       std::string meQTname = it->first;
0106       it->second.TrackingFlag = ibooker.bookFloat("Track" + meQTname);
0107       if (verbose_)
0108         edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::bookGlobalStatus] " << it->first
0109                                                << " exists ? " << it->second.TrackingFlag << std::endl;
0110       if (verbose_)
0111         edm::LogInfo("TrackingQualityChecker")
0112             << "[TrackingQualityChecker::bookGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
0113     }
0114 
0115     bookedTrackingGlobalStatus_ = true;
0116     ibooker.cd();
0117   }
0118 }
0119 
0120 void TrackingQualityChecker::bookLSStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0121   if (verbose_)
0122     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::bookLSStatus] already booked ? "
0123                                            << (bookedTrackingLSStatus_ ? "yes" : "nope") << std::endl;
0124 
0125   if (!bookedTrackingLSStatus_) {
0126     ibooker.cd();
0127     edm::LogInfo("TrackingQualityChecker") << " booking TrackingQualityStatus"
0128                                            << "\n";
0129 
0130     std::string tracking_dir = "";
0131     TrackingUtility::getTopFolderPath(ibooker, igetter, TopFolderName_, tracking_dir);
0132     ibooker.setCurrentFolder(TopFolderName_ + "/EventInfo");
0133 
0134     TrackLSSummaryReportGlobal = ibooker.bookFloat("reportSummary");
0135 
0136     std::string hname, htitle;
0137     hname = "reportSummaryMap";
0138     htitle = "Tracking Report Summary Map";
0139 
0140     if (verbose_) {
0141       size_t nQT = TrackingLSMEsMap.size();
0142       edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::bookLSStatus] nQT: " << nQT << std::endl;
0143     }
0144 
0145     ibooker.setCurrentFolder(TopFolderName_ + "/EventInfo/reportSummaryContents");
0146     for (std::map<std::string, TrackingLSMEs>::iterator it = TrackingLSMEsMap.begin(); it != TrackingLSMEsMap.end();
0147          it++) {
0148       std::string meQTname = it->first;
0149       it->second.TrackingFlag = ibooker.bookFloat("Track" + meQTname);
0150       if (verbose_)
0151         edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::bookLSStatus] " << it->first << " exists ? "
0152                                                << it->second.TrackingFlag << std::endl;
0153       if (verbose_)
0154         edm::LogInfo("TrackingQualityChecker")
0155             << "[TrackingQualityChecker::bookLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
0156     }
0157 
0158     bookedTrackingLSStatus_ = true;
0159     ibooker.cd();
0160   }
0161 }
0162 
0163 //
0164 // -- Fill Dummy  Status
0165 //
0166 void TrackingQualityChecker::fillDummyGlobalStatus() {
0167   if (verbose_)
0168     edm::LogInfo("TrackingQualityChecker")
0169         << "[TrackingQualityChecker::fillDummyGlobalStatus] starting ..." << std::endl;
0170 
0171   resetGlobalStatus();
0172   if (verbose_)
0173     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillDummyGlobalStatus] already booked ? "
0174                                            << (bookedTrackingGlobalStatus_ ? "yes" : "nope") << std::endl;
0175   if (bookedTrackingGlobalStatus_) {
0176     TrackGlobalSummaryReportGlobal->Fill(-1.0);
0177 
0178     for (int ibin = 1; ibin < TrackGlobalSummaryReportMap->getNbinsX() + 1; ibin++) {
0179       fillStatusHistogram(TrackGlobalSummaryReportMap, ibin, 1, -1.0);
0180     }
0181 
0182     for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin(); it != TrackingMEsMap.end(); it++)
0183       it->second.TrackingFlag->Fill(-1.0);
0184     if (verbose_)
0185       edm::LogInfo("TrackingQualityChecker")
0186           << "[TrackingQualityChecker::fillDummyGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
0187   }
0188 }
0189 void TrackingQualityChecker::fillDummyLSStatus() {
0190   if (verbose_)
0191     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillDummyLSStatus] starting ..." << std::endl;
0192 
0193   resetLSStatus();
0194   if (verbose_)
0195     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillDummyLSStatus] already booked ? "
0196                                            << (bookedTrackingLSStatus_ ? "yes" : "nope") << std::endl;
0197   if (bookedTrackingLSStatus_) {
0198     TrackLSSummaryReportGlobal->Fill(-1.0);
0199     for (std::map<std::string, TrackingLSMEs>::iterator it = TrackingLSMEsMap.begin(); it != TrackingLSMEsMap.end();
0200          it++)
0201       it->second.TrackingFlag->Fill(-1.0);
0202     if (verbose_)
0203       edm::LogInfo("TrackingQualityChecker")
0204           << "[TrackingQualityChecker::fillDummyLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
0205   }
0206 }
0207 
0208 //
0209 // -- Reset Status
0210 //
0211 void TrackingQualityChecker::resetGlobalStatus() {
0212   if (verbose_)
0213     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::resetGlobalStatus] already booked ? "
0214                                            << (bookedTrackingGlobalStatus_ ? "yes" : "nope") << std::endl;
0215   if (bookedTrackingGlobalStatus_) {
0216     TrackGlobalSummaryReportGlobal->Reset();
0217     TrackGlobalSummaryReportMap->Reset();
0218 
0219     for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin(); it != TrackingMEsMap.end(); it++) {
0220       MonitorElement* me = it->second.TrackingFlag;
0221       if (verbose_)
0222         edm::LogInfo("TrackingQualityChecker")
0223             << "[TrackingQualityChecker::resetGlobalStatus] " << it->second.HistoName << " exist ? "
0224             << (it->second.TrackingFlag == nullptr ? "nope" : "yes") << " ---> " << me << std::endl;
0225       me->Reset();
0226     }
0227     if (verbose_)
0228       edm::LogInfo("TrackingQualityChecker")
0229           << "[TrackingQualityChecker::resetGlobalStatus] DONE w/ TrackingMEsMap" << std::endl;
0230   }
0231 }
0232 void TrackingQualityChecker::resetLSStatus() {
0233   if (verbose_)
0234     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::resetLSStatus] already booked ? "
0235                                            << (bookedTrackingLSStatus_ ? "yes" : "nope") << std::endl;
0236   if (bookedTrackingLSStatus_) {
0237     TrackLSSummaryReportGlobal->Reset();
0238     for (std::map<std::string, TrackingLSMEs>::iterator it = TrackingLSMEsMap.begin(); it != TrackingLSMEsMap.end();
0239          it++) {
0240       MonitorElement* me = it->second.TrackingFlag;
0241       if (verbose_)
0242         edm::LogInfo("TrackingQualityChecker")
0243             << "[TrackingQualityChecker::resetLSStatus] " << it->second.HistoLSName << " exist ? "
0244             << (it->second.TrackingFlag == nullptr ? "nope" : "yes") << " ---> " << me << std::endl;
0245       me->Reset();
0246     }
0247     if (verbose_)
0248       edm::LogInfo("TrackingQualityChecker")
0249           << "[TrackingQualityChecker::resetLSStatus] DONE w/ TrackingLSMEsMap" << std::endl;
0250   }
0251 }
0252 
0253 //
0254 // -- Fill Status
0255 //
0256 void TrackingQualityChecker::fillGlobalStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0257   if (verbose_)
0258     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillGlobalStatus] already booked ? "
0259                                            << (bookedTrackingGlobalStatus_ ? "yes" : "nope") << std::endl;
0260   if (!bookedTrackingGlobalStatus_)
0261     bookGlobalStatus(ibooker, igetter);
0262 
0263   fillDummyGlobalStatus();
0264   fillTrackingStatus(ibooker, igetter);
0265   if (verbose_)
0266     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillGlobalStatus] DONE" << std::endl;
0267   ibooker.cd();
0268 }
0269 
0270 void TrackingQualityChecker::fillLSStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0271   if (verbose_)
0272     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillLSStatus] already booked ? "
0273                                            << (bookedTrackingLSStatus_ ? "yes" : "nope") << std::endl;
0274   if (!bookedTrackingLSStatus_)
0275     bookLSStatus(ibooker, igetter);
0276 
0277   fillDummyLSStatus();
0278   fillTrackingStatusAtLumi(ibooker, igetter);
0279   if (verbose_)
0280     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillLSStatus] DONE" << std::endl;
0281   ibooker.cd();
0282 }
0283 
0284 //
0285 // -- Fill Tracking Status
0286 //
0287 void TrackingQualityChecker::fillTrackingStatus(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0288   float gstatus = 0.0;
0289 
0290   ibooker.cd();
0291   if (!TrackingUtility::goToDir(ibooker, igetter, TopFolderName_))
0292     return;
0293 
0294   int ibin = 0;
0295   for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin(); it != TrackingMEsMap.end(); it++) {
0296     if (verbose_)
0297       edm::LogInfo("TrackingQualityChecker")
0298           << "fillTrackingStatus ME: " << it->first << " [" << it->second.TrackingFlag->getFullname()
0299           << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
0300 
0301     ibin++;
0302 
0303     std::string localMEdirpath = it->second.HistoDir;
0304     std::string MEname = it->second.HistoName;
0305 
0306     std::vector<MonitorElement*> tmpMEvec = igetter.getContents(ibooker.pwd() + "/" + localMEdirpath);
0307     if (verbose_)
0308       edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus tmpMEvec: " << tmpMEvec.size() << std::endl;
0309     MonitorElement* me = nullptr;
0310 
0311     size_t nMEs = 0;
0312     for (auto ime : tmpMEvec) {
0313       std::string name = ime->getName();
0314       if (verbose_)
0315         edm::LogInfo("TrackingQualityChecker") << "name: " << name << " <-- --> " << MEname << std::endl;
0316       if (name.find(MEname) != std::string::npos) {
0317         me = ime;
0318         nMEs++;
0319       }
0320     }
0321     // only one ME found
0322     if (verbose_)
0323       edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus nMEs: " << nMEs << std::endl;
0324     if (nMEs == 1) {
0325       float status = 0.;
0326       for (auto ime : tmpMEvec) {
0327         std::string name = ime->getName();
0328         if (verbose_)
0329           edm::LogInfo("TrackingQualityChecker") << "name: " << name << " [" << MEname << "]" << std::endl;
0330         if (name.find(MEname) != std::string::npos) {
0331           me = ime;
0332           if (verbose_)
0333             edm::LogInfo("TrackingQualityChecker") << "inside the loop nQTme: " << me->getQReports().size() << "["
0334                                                    << ime->getFullname() << "]" << std::endl;
0335         }
0336       }
0337       if (verbose_)
0338         edm::LogInfo("TrackingQualityChecker")
0339             << "me: " << me << "[" << me->getName() << ", " << me->getFullname() << "]" << std::endl;
0340       if (!me)
0341         continue;
0342       if (verbose_)
0343         edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus status: " << status << std::endl;
0344       std::vector<QReport*> qt_reports = me->getQReports();
0345       size_t nQTme = qt_reports.size();
0346       if (verbose_)
0347         edm::LogInfo("TrackingQualityChecker") << "nQTme: " << nQTme << std::endl;
0348       if (nQTme != 0) {
0349         if (verbose_)
0350           edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus qt_reports: " << qt_reports.size() << std::endl;
0351         // loop on possible QTs
0352         for (auto iQT : qt_reports) {
0353           status += iQT->getQTresult();
0354           if (verbose_)
0355             edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus iQT: " << iQT->getQRName() << std::endl;
0356           if (verbose_)
0357             edm::LogInfo("TrackingQualityChecker")
0358                 << "fillTrackingStatus MEname: " << MEname << " status: " << iQT->getQTresult() << " exists ? "
0359                 << (it->second.TrackingFlag ? "yes " : "no ") << it->second.TrackingFlag << std::endl;
0360           if (verbose_)
0361             edm::LogInfo("TrackingQualityChecker")
0362                 << "fillTrackingStatus iQT message: " << iQT->getMessage() << std::endl;
0363           if (verbose_)
0364             edm::LogInfo("TrackingQualityChecker")
0365                 << "fillTrackingStatus iQT status: " << iQT->getStatus() << std::endl;
0366         }
0367         status = status / float(nQTme);
0368         if (verbose_)
0369           edm::LogInfo("TrackingQualityChecker")
0370               << "fillTrackingStatus MEname: " << MEname << " status: " << status << std::endl;
0371         it->second.TrackingFlag->Fill(status);
0372         if (verbose_)
0373           edm::LogInfo("TrackingQualityChecker")
0374               << "fillTrackingStatus TrackGlobalSummaryReportMap: " << TrackGlobalSummaryReportMap << std::endl;
0375         fillStatusHistogram(TrackGlobalSummaryReportMap, ibin, 1, status);
0376       }
0377 
0378       if (verbose_)
0379         edm::LogInfo("TrackingQualityChecker")
0380             << "fillTrackingStatus gstatus: " << gstatus << " x status: " << status << std::endl;
0381       if (status < 0.)
0382         gstatus = -1.;
0383       else
0384         gstatus += status;
0385       if (verbose_)
0386         edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus ===> gstatus: " << gstatus << std::endl;
0387       if (verbose_)
0388         edm::LogInfo("TrackingQualityChecker")
0389             << "fillTrackingStatus ME: " << it->first << " [" << it->second.TrackingFlag->getFullname()
0390             << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
0391 
0392     } else {  // more than 1 ME w/ the same root => they need to be considered together
0393       float status = 1.;
0394       for (auto ime : tmpMEvec) {
0395         float tmp_status = 1.;
0396         std::string name = ime->getName();
0397         if (name.find(MEname) != std::string::npos) {
0398           me = ime;
0399 
0400           if (verbose_)
0401             edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus status: " << status << std::endl;
0402           std::vector<QReport*> qt_reports = me->getQReports();
0403           size_t nQTme = qt_reports.size();
0404           if (verbose_)
0405             edm::LogInfo("TrackingQualityChecker")
0406                 << "nQTme: " << nQTme << "[" << name << ", " << ime->getFullname() << "]" << std::endl;
0407           if (nQTme != 0) {
0408             if (verbose_)
0409               edm::LogInfo("TrackingQualityChecker")
0410                   << "fillTrackingStatus qt_reports: " << qt_reports.size() << std::endl;
0411             // loop on possible QTs
0412             for (auto iQT : qt_reports) {
0413               tmp_status += iQT->getQTresult();
0414               if (verbose_)
0415                 edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus iQT: " << iQT->getQRName() << std::endl;
0416               if (verbose_)
0417                 edm::LogInfo("TrackingQualityChecker")
0418                     << "fillTrackingStatus MEname: " << MEname << " status: " << iQT->getQTresult() << " exists ? "
0419                     << (it->second.TrackingFlag ? "yes " : "no ") << it->second.TrackingFlag << std::endl;
0420               if (verbose_)
0421                 edm::LogInfo("TrackingQualityChecker")
0422                     << "fillTrackingStatus iQT message: " << iQT->getMessage() << std::endl;
0423               if (verbose_)
0424                 edm::LogInfo("TrackingQualityChecker")
0425                     << "fillTrackingStatus iQT status: " << iQT->getStatus() << std::endl;
0426             }
0427             tmp_status = tmp_status / float(nQTme);
0428           }
0429         }
0430         status = fminf(tmp_status, status);
0431       }
0432       if (status < 0.)
0433         gstatus = -1.;
0434       else
0435         gstatus += status;
0436       if (verbose_)
0437         edm::LogInfo("TrackingQualityChecker")
0438             << "fillTrackingStatus MEname: " << MEname << " status: " << status << std::endl;
0439       it->second.TrackingFlag->Fill(status);
0440       if (verbose_)
0441         edm::LogInfo("TrackingQualityChecker")
0442             << "fillTrackingStatus TrackGlobalSummaryReportMap: " << TrackGlobalSummaryReportMap << std::endl;
0443 
0444       fillStatusHistogram(TrackGlobalSummaryReportMap, ibin, 1, status);
0445     }
0446   }
0447 
0448   // After harvesting, all per-lumi MEs are reset, to make sure we only get
0449   // events of the new lumisection next time.
0450   for (std::map<std::string, TrackingMEs>::iterator it = TrackingMEsMap.begin(); it != TrackingMEsMap.end(); it++) {
0451     std::string localMEdirpath = it->second.HistoDir;
0452     std::vector<MonitorElement*> tmpMEvec = igetter.getContents(ibooker.pwd() + "/" + localMEdirpath);
0453     for (auto ime : tmpMEvec) {
0454       if (ime->getLumiFlag()) {
0455         ime->Reset();
0456       }
0457     }
0458   }
0459 
0460   if (verbose_)
0461     edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus gstatus: " << gstatus << std::endl;
0462   size_t nQT = TrackingMEsMap.size();
0463   if (gstatus < 1.)
0464     gstatus = -1.;
0465   else
0466     gstatus = gstatus / float(nQT);
0467 
0468   if (verbose_)
0469     edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus ===> gstatus: " << gstatus << std::endl;
0470   TrackGlobalSummaryReportGlobal->Fill(gstatus);
0471   ibooker.cd();
0472 
0473   if (verbose_)
0474     edm::LogInfo("TrackingQualityChecker") << "fillTrackingStatus DONE" << std::endl;
0475 }
0476 
0477 //
0478 // -- Fill Report Summary Map
0479 //
0480 void TrackingQualityChecker::fillStatusHistogram(MonitorElement* me, int xbin, int ybin, float val) {
0481   if (me && me->kind() == MonitorElement::Kind::TH2F) {
0482     TH2F* th2d = me->getTH2F();
0483     th2d->SetBinContent(xbin, ybin, val);
0484   }
0485 }
0486 
0487 // Fill Tracking Status MEs at the Lumi block
0488 //
0489 void TrackingQualityChecker::fillTrackingStatusAtLumi(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0490   if (verbose_)
0491     edm::LogInfo("TrackingQualityChecker")
0492         << "[TrackingQualityChecker::fillTrackingStatusAtLumi] starting .. " << std::endl;
0493   float gstatus = 1.0;
0494 
0495   ibooker.cd();
0496   if (!TrackingUtility::goToDir(ibooker, igetter, TopFolderName_))
0497     return;
0498 
0499   int ibin = 0;
0500   for (std::map<std::string, TrackingLSMEs>::iterator it = TrackingLSMEsMap.begin(); it != TrackingLSMEsMap.end();
0501        it++) {
0502     if (verbose_)
0503       edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillTrackingStatusAtLumi] ME: " << it->first
0504                                              << " [" << it->second.TrackingFlag->getFullname()
0505                                              << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
0506 
0507     ibin++;
0508 
0509     std::string localMEdirpath = it->second.HistoLSDir;
0510     std::string MEname = it->second.HistoLSName;
0511     float lower_cut = it->second.HistoLSLowerCut;
0512     float upper_cut = it->second.HistoLSUpperCut;
0513 
0514     float status = 1.0;
0515 
0516     std::vector<MonitorElement*> tmpMEvec = igetter.getContents(ibooker.pwd() + "/" + localMEdirpath);
0517     if (verbose_)
0518       edm::LogInfo("TrackingQualityChecker")
0519           << "[TrackingQualityChecker::fillTrackingStatusAtLumi] tmpMEvec: " << tmpMEvec.size() << std::endl;
0520 
0521     MonitorElement* me = nullptr;
0522 
0523     size_t nMEs = 0;
0524     for (auto ime : tmpMEvec) {
0525       std::string name = ime->getName();
0526       if (name.find(MEname) != std::string::npos) {
0527         me = ime;
0528         nMEs++;
0529       }
0530     }
0531     // only one ME found
0532     if (nMEs == 1) {
0533       for (auto ime : tmpMEvec) {
0534         std::string name = ime->getName();
0535         if (name.find(MEname) != std::string::npos) {
0536           me = ime;
0537         }
0538       }
0539       if (!me)
0540         continue;
0541 
0542       if (me->kind() == MonitorElement::Kind::TH1F) {
0543         float x_mean = me->getMean();
0544         if (verbose_)
0545           edm::LogInfo("TrackingQualityChecker")
0546               << "[TrackingQualityChecker::fillTrackingStatusAtLumi] MEname: " << MEname << " x_mean: " << x_mean
0547               << std::endl;
0548         if (x_mean <= lower_cut || x_mean > upper_cut)
0549           status = 0.0;
0550         else
0551           status = 1.0;
0552       }
0553     } else {  // more than 1 ME w/ the same root => they need to be considered together
0554       for (auto ime : tmpMEvec) {
0555         float tmp_status = 1.;
0556         std::string name = ime->getName();
0557         if (name.find(MEname) != std::string::npos) {
0558           me = ime;
0559           if (!me)
0560             continue;
0561 
0562           if (me->kind() == MonitorElement::Kind::TH1F) {
0563             float x_mean = me->getMean();
0564             if (verbose_)
0565               edm::LogInfo("TrackingQualityChecker")
0566                   << "[TrackingQualityChecker::fillTrackingStatusAtLumi] MEname: " << MEname << "[" << me->getName()
0567                   << "]  x_mean: " << x_mean << std::endl;
0568             if (x_mean <= lower_cut || x_mean > upper_cut)
0569               tmp_status = 0.0;
0570             else
0571               tmp_status = 1.0;
0572             if (verbose_)
0573               edm::LogInfo("TrackingQualityChecker")
0574                   << "[TrackingQualityChecker::fillTrackingStatusAtLumi] tmp_status: " << tmp_status << std::endl;
0575           }
0576         }
0577         status = fminf(tmp_status, status);
0578         if (verbose_)
0579           edm::LogInfo("TrackingQualityChecker")
0580               << "[TrackingQualityChecker::fillTrackingStatusAtLumi] ==> status: " << status << std::endl;
0581       }  // loop on tmpMEvec
0582     }
0583     it->second.TrackingFlag->Fill(status);
0584     if (verbose_)
0585       edm::LogInfo("TrackingQualityChecker")
0586           << "[TrackingQualityChecker::fillTrackingStatusAtLumi] ===> status: " << status << " [" << gstatus << "]"
0587           << std::endl;
0588     if (status == 0.0)
0589       gstatus = -1.0;
0590     else
0591       gstatus = gstatus * status;
0592     if (verbose_)
0593       edm::LogInfo("TrackingQualityChecker")
0594           << "[TrackingQualityChecker::fillTrackingStatusAtLumi] ===> gstatus: " << gstatus << std::endl;
0595     if (verbose_)
0596       edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillTrackingStatusAtLumi] ME: " << it->first
0597                                              << " [" << it->second.TrackingFlag->getFullname()
0598                                              << "] flag: " << it->second.TrackingFlag->getFloatValue() << std::endl;
0599   }
0600   TrackLSSummaryReportGlobal->Fill(gstatus);
0601   ibooker.cd();
0602 
0603   if (verbose_)
0604     edm::LogInfo("TrackingQualityChecker") << "[TrackingQualityChecker::fillTrackingStatusAtLumi] DONE" << std::endl;
0605 }