Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-25 06:38:24

0001 #include "DQM/HcalTasks/interface/TPRunSummary.h"
0002 
0003 namespace hcaldqm {
0004   using namespace constants;
0005   TPRunSummary::TPRunSummary(std::string const& name,
0006                              std::string const& taskname,
0007                              edm::ParameterSet const& ps,
0008                              edm::ConsumesCollector& iC)
0009       : DQClient(name, taskname, ps, iC) {
0010     _thresh_EtMsmRate_high = ps.getUntrackedParameter<double>("thresh_EtMsmRate_high", 0.2);
0011     _thresh_EtMsmRate_low = ps.getUntrackedParameter<double>("thresh_EtMsmRate_low", 0.05);
0012     _thresh_FGMsmRate_high = ps.getUntrackedParameter<double>("thresh_FGMsmRate_high", 0.2);
0013     _thresh_FGMsmRate_low = ps.getUntrackedParameter<double>("thresh_FGMsmRate_low", 0.05);
0014   }
0015 
0016   /* virtual */ void TPRunSummary::beginRun(edm::Run const& r, edm::EventSetup const& es) { DQClient::beginRun(r, es); }
0017 
0018   /* virtual */ void TPRunSummary::endLuminosityBlock(DQMStore::IBooker& ib,
0019                                                       DQMStore::IGetter& ig,
0020                                                       edm::LuminosityBlock const& lb,
0021                                                       edm::EventSetup const& es) {
0022     DQClient::endLuminosityBlock(ib, ig, lb, es);
0023   }
0024 
0025   /* virtual */ std::vector<flag::Flag> TPRunSummary::endJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
0026     //  hahs maps
0027     electronicsmap::ElectronicsMap ehashmap;
0028     ehashmap.initialize(_emap, electronicsmap::fT2EHashMap);
0029     std::vector<flag::Flag> vflags;
0030     vflags.resize(nTPFlag);
0031     vflags[fEtMsm] = flag::Flag("EtMsm");
0032     vflags[fFGMsm] = flag::Flag("FGMsm");
0033 
0034     //  INITIALIZE
0035     ContainerSingle2D cOccupancyData_depthlike, cOccupancyEmul_depthlike;
0036     ContainerSingle2D cEtMsm_depthlike, cFGMsm_depthlike, cEtCorrRatio_depthlike;
0037     ContainerSingle2D cSummary;
0038     ContainerXXX<double> xDeadD, xDeadE, xEtMsm, xFGMsm;
0039     ContainerXXX<double> xNumCorr;
0040     xDeadD.initialize(hashfunctions::fCrate);
0041     xDeadE.initialize(hashfunctions::fCrate);
0042     xEtMsm.initialize(hashfunctions::fCrate);
0043     xFGMsm.initialize(hashfunctions::fCrate);
0044     xNumCorr.initialize(hashfunctions::fCrate);
0045     cOccupancyData_depthlike.initialize(_taskname,
0046                                         "OccupancyData",
0047                                         new quantity::TrigTowerQuantity(quantity::fTTieta),
0048                                         new quantity::TrigTowerQuantity(quantity::fTTiphi),
0049                                         new quantity::ValueQuantity(quantity::fN, true),
0050                                         0);
0051     cOccupancyEmul_depthlike.initialize(_taskname,
0052                                         "OccupancyEmul",
0053                                         new quantity::TrigTowerQuantity(quantity::fTTieta),
0054                                         new quantity::TrigTowerQuantity(quantity::fTTiphi),
0055                                         new quantity::ValueQuantity(quantity::fN, true),
0056                                         0);
0057     cEtMsm_depthlike.initialize(_taskname,
0058                                 "EtMsm",
0059                                 new quantity::TrigTowerQuantity(quantity::fTTieta),
0060                                 new quantity::TrigTowerQuantity(quantity::fTTiphi),
0061                                 new quantity::ValueQuantity(quantity::fN),
0062                                 0);
0063     cFGMsm_depthlike.initialize(_taskname,
0064                                 "FGMsm",
0065                                 new quantity::TrigTowerQuantity(quantity::fTTieta),
0066                                 new quantity::TrigTowerQuantity(quantity::fTTiphi),
0067                                 new quantity::ValueQuantity(quantity::fN),
0068                                 0);
0069     cEtCorrRatio_depthlike.initialize(_taskname,
0070                                       "EtCorrRatio",
0071                                       new quantity::TrigTowerQuantity(quantity::fTTieta),
0072                                       new quantity::TrigTowerQuantity(quantity::fTTiphi),
0073                                       new quantity::ValueQuantity(quantity::fRatio_0to2),
0074                                       0);
0075     _cEtMsmFraction_depthlike.initialize(_taskname,
0076                                          "EtMsmFraction",
0077                                          new quantity::TrigTowerQuantity(quantity::fTTieta),
0078                                          new quantity::TrigTowerQuantity(quantity::fTTiphi),
0079                                          new quantity::ValueQuantity(quantity::fRatio_0to2),
0080                                          0);
0081     _cFGMsmFraction_depthlike.initialize(_taskname,
0082                                          "FGMsmFraction",
0083                                          new quantity::TrigTowerQuantity(quantity::fTTieta),
0084                                          new quantity::TrigTowerQuantity(quantity::fTTiphi),
0085                                          new quantity::ValueQuantity(quantity::fRatio_0to2),
0086                                          0);
0087     cSummary.initialize(_name,
0088                         "Summary",
0089                         new quantity::CrateQuantity(_emap),
0090                         new quantity::FlagQuantity(vflags),
0091                         new quantity::ValueQuantity(quantity::fState),
0092                         0);
0093 
0094     //  BOOK
0095     xDeadD.book(_emap);
0096     xDeadE.book(_emap);
0097     xEtMsm.book(_emap);
0098     xFGMsm.book(_emap);
0099     xNumCorr.book(_emap);
0100 
0101     //  LOAD
0102     cOccupancyData_depthlike.load(ig, _subsystem);
0103     cOccupancyEmul_depthlike.load(ig, _subsystem);
0104     cEtMsm_depthlike.load(ig, _subsystem);
0105     cFGMsm_depthlike.load(ig, _subsystem);
0106     cEtCorrRatio_depthlike.load(ig, _subsystem);
0107     _cEtMsmFraction_depthlike.book(ib, _subsystem);
0108     _cFGMsmFraction_depthlike.book(ib, _subsystem);
0109     cSummary.book(ib, _subsystem);
0110 
0111     //  iterate
0112     std::vector<HcalTrigTowerDetId> tids = _emap->allTriggerId();
0113     for (std::vector<HcalTrigTowerDetId>::const_iterator it = tids.begin(); it != tids.end(); ++it) {
0114       //    skip 2x3
0115       HcalTrigTowerDetId tid = HcalTrigTowerDetId(*it);
0116       if (tid.version() == 0 && tid.ietaAbs() >= 29)
0117         continue;
0118 
0119       //    do the comparison if there are channels that were correlated
0120       //    both had emul and data tps
0121       if (cEtCorrRatio_depthlike.getBinEntries(tid) > 0) {
0122         HcalElectronicsId eid = HcalElectronicsId(ehashmap.lookup(*it));
0123 
0124         double numetmsm = cEtMsm_depthlike.getBinContent(tid);
0125         double numfgmsm = cFGMsm_depthlike.getBinContent(tid);
0126         double numcorr = cEtCorrRatio_depthlike.getBinEntries(tid);
0127 
0128         xEtMsm.get(eid) += numetmsm;
0129         xFGMsm.get(eid) += numfgmsm;
0130         xNumCorr.get(eid) += numcorr;
0131 
0132         _cEtMsmFraction_depthlike.setBinContent(tid, numetmsm / numcorr);
0133         _cFGMsmFraction_depthlike.setBinContent(tid, numfgmsm / numcorr);
0134       }
0135     }
0136 
0137     std::vector<flag::Flag> sumflags;
0138     for (auto& it_hashcrate : _vhashCrates) {
0139       flag::Flag fSum("TP");
0140       HcalElectronicsId eid(it_hashcrate);
0141       HcalDetId did = HcalDetId(_emap->lookup(eid));
0142 
0143       if (did.subdet() == HcalBarrel || did.subdet() == HcalEndcap || did.subdet() == HcalForward) {
0144         double etmsmfr = xNumCorr.get(eid) > 0 ? double(xEtMsm.get(eid)) / double(xNumCorr.get(eid)) : 0;
0145         double fgmsmfr = xNumCorr.get(eid) > 0 ? double(xFGMsm.get(eid)) / double(xNumCorr.get(eid)) : 0;
0146 
0147         if (etmsmfr >= _thresh_EtMsmRate_high)
0148           vflags[fEtMsm]._state = flag::fBAD;
0149         else if (etmsmfr >= _thresh_EtMsmRate_low)
0150           vflags[fEtMsm]._state = flag::fPROBLEMATIC;
0151         else
0152           vflags[fEtMsm]._state = flag::fGOOD;
0153         if (fgmsmfr >= _thresh_FGMsmRate_high)
0154           vflags[fFGMsm]._state = flag::fBAD;
0155         else if (fgmsmfr >= _thresh_FGMsmRate_low)
0156           vflags[fFGMsm]._state = flag::fPROBLEMATIC;
0157         else
0158           vflags[fFGMsm]._state = flag::fGOOD;
0159       }
0160 
0161       //    combine
0162       int iflag = 0;
0163       for (std::vector<flag::Flag>::iterator ft = vflags.begin(); ft != vflags.end(); ++ft) {
0164         cSummary.setBinContent(eid, iflag, ft->_state);
0165         fSum += (*ft);
0166         iflag++;
0167         ft->reset();
0168       }
0169       sumflags.push_back(fSum);
0170     }
0171 
0172     return sumflags;
0173   }
0174 }  // namespace hcaldqm