File indexing completed on 2024-04-06 12:07:36
0001 #include "DQM/HcalTasks/interface/DigiRunSummary.h"
0002
0003 namespace hcaldqm {
0004 using namespace constants;
0005
0006 DigiRunSummary::DigiRunSummary(std::string const& name,
0007 std::string const& taskname,
0008 edm::ParameterSet const& ps,
0009 edm::ConsumesCollector& iC)
0010 : DQClient(name, taskname, ps, iC), _booked(false) {
0011 _thresh_unihf = ps.getUntrackedParameter<double>("thresh_unihf", 0.2);
0012
0013 std::vector<uint32_t> vrefDigiSize = ps.getUntrackedParameter<std::vector<uint32_t>>("refDigiSize");
0014 _refDigiSize[HcalBarrel] = vrefDigiSize[0];
0015 _refDigiSize[HcalEndcap] = vrefDigiSize[1];
0016 _refDigiSize[HcalOuter] = vrefDigiSize[2];
0017 _refDigiSize[HcalForward] = vrefDigiSize[3];
0018 }
0019
0020 void DigiRunSummary::beginRun(edm::Run const& r, edm::EventSetup const& es) {
0021 DQClient::beginRun(r, es);
0022
0023 if (_ptype != fOffline)
0024 return;
0025
0026
0027 _ehashmap.initialize(_emap, electronicsmap::fD2EHashMap);
0028 _vhashVME.push_back(
0029 HcalElectronicsId(constants::FIBERCH_MIN, constants::FIBER_VME_MIN, SPIGOT_MIN, CRATE_VME_MIN).rawId());
0030 _vhashuTCA.push_back(HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0031 _filter_VME.initialize(filter::fFilter, hashfunctions::fElectronics,
0032 _vhashVME);
0033 _filter_uTCA.initialize(filter::fFilter, hashfunctions::fElectronics,
0034 _vhashuTCA);
0035 _vhashFEDHF.push_back(HcalElectronicsId(22, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0036 _vhashFEDHF.push_back(HcalElectronicsId(29, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0037 _vhashFEDHF.push_back(HcalElectronicsId(32, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0038 _vhashFEDHF.push_back(HcalElectronicsId(22, SLOT_uTCA_MIN + 6, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0039 _vhashFEDHF.push_back(HcalElectronicsId(29, SLOT_uTCA_MIN + 6, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0040 _vhashFEDHF.push_back(HcalElectronicsId(32, SLOT_uTCA_MIN + 6, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0041 _filter_FEDHF.initialize(filter::fPreserver, hashfunctions::fFED,
0042 _vhashFEDHF);
0043
0044 _xDead.initialize(hashfunctions::fFED);
0045 _xDigiSize.initialize(hashfunctions::fFED);
0046 _xUni.initialize(hashfunctions::fFED);
0047 _xUniHF.initialize(hashfunctions::fFEDSlot);
0048
0049 _xDead.book(_emap);
0050 _xDigiSize.book(_emap);
0051 _xUniHF.book(_emap);
0052 _xUni.book(_emap, _filter_FEDHF);
0053 _xNChs.initialize(hashfunctions::fFED);
0054 _xNChsNominal.initialize(hashfunctions::fFED);
0055 _xNChs.book(_emap);
0056 _xNChsNominal.book(_emap);
0057
0058 _cOccupancy_depth.initialize(_name,
0059 "Occupancy",
0060 hashfunctions::fdepth,
0061 new quantity::DetectorQuantity(quantity::fieta),
0062 new quantity::DetectorQuantity(quantity::fiphi),
0063 new quantity::ValueQuantity(quantity::fN),
0064 0);
0065
0066
0067 std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
0068 for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
0069 if (!it->isHcalDetId())
0070 continue;
0071 HcalDetId did(it->rawId());
0072 HcalElectronicsId eid = HcalElectronicsId(_ehashmap.lookup(did));
0073 _xNChsNominal.get(eid)++;
0074 }
0075 }
0076
0077
0078
0079
0080 void DigiRunSummary::endLuminosityBlock(DQMStore::IBooker& ib,
0081 DQMStore::IGetter& ig,
0082 edm::LuminosityBlock const& lb,
0083 edm::EventSetup const& es) {
0084 DQClient::endLuminosityBlock(ib, ig, lb, es);
0085
0086 if (_ptype != fOffline)
0087 return;
0088
0089 LSSummary lssum;
0090 lssum._LS = _currentLS;
0091
0092 _xDigiSize.reset();
0093 _xNChs.reset();
0094
0095
0096 Container2D cDigiSize_Crate, cOccupancy_depth;
0097 cDigiSize_Crate.initialize(_taskname,
0098 "DigiSize",
0099 hashfunctions::fCrate,
0100 new quantity::ValueQuantity(quantity::fDigiSize),
0101 new quantity::ValueQuantity(quantity::fN),
0102 0);
0103 cOccupancy_depth.initialize(_taskname,
0104 "Occupancy",
0105 hashfunctions::fdepth,
0106 new quantity::DetectorQuantity(quantity::fieta),
0107 new quantity::DetectorQuantity(quantity::fiphi),
0108 new quantity::ValueQuantity(quantity::fN),
0109 0);
0110
0111
0112 cOccupancy_depth.load(ig, _emap, _subsystem);
0113 cDigiSize_Crate.load(ig, _emap, _subsystem);
0114 MonitorElement* meNumEvents = ig.get(_subsystem + "/RunInfo/NumberOfEvents");
0115 int numEvents = meNumEvents->getBinContent(1);
0116 bool unknownIdsPresent = ig.get(_subsystem + "/" + _taskname + "/UnknownIds")->getBinContent(1) > 0;
0117
0118
0119 if (!_booked) {
0120 ib.setCurrentFolder(_subsystem + "/" + _taskname);
0121 _meNumEvents = ib.book1DD("NumberOfEvents", "NumberOfEvents", 1000, 1, 1001);
0122 _meNumEvents->getTH1()->SetCanExtend(TH1::kXaxis);
0123
0124 _cOccupancy_depth.book(ib, _emap, _subsystem);
0125 _booked = true;
0126 }
0127 _meNumEvents->setBinContent(_currentLS, numEvents);
0128
0129
0130 std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
0131 for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
0132 if (!it->isHcalDetId())
0133 continue;
0134
0135 HcalDetId did = HcalDetId(it->rawId());
0136 HcalElectronicsId eid = HcalElectronicsId(_ehashmap.lookup(did));
0137
0138 cOccupancy_depth.getBinContent(did) > 0 ? _xNChs.get(eid)++ : _xNChs.get(eid) += 0;
0139 _cOccupancy_depth.fill(did, cOccupancy_depth.getBinContent(did));
0140
0141 cDigiSize_Crate.getMean(eid) != _refDigiSize[did.subdet()] ? _xDigiSize.get(eid)++ : _xDigiSize.get(eid) += 0;
0142 cDigiSize_Crate.getRMS(eid) != 0 ? _xDigiSize.get(eid)++ : _xDigiSize.get(eid) += 0;
0143 }
0144
0145
0146 std::vector<flag::Flag> vtmpflags;
0147 vtmpflags.resize(nLSFlags);
0148 vtmpflags[fDigiSize] = flag::Flag("DigiSize");
0149 vtmpflags[fNChsHF] = flag::Flag("NChsHF");
0150 vtmpflags[fUnknownIds] = flag::Flag("UnknownIds");
0151 vtmpflags[fLED] = flag::Flag("LEDMisfire");
0152 for (std::vector<uint32_t>::const_iterator it = _vhashCrates.begin(); it != _vhashCrates.end(); ++it) {
0153 HcalElectronicsId eid(*it);
0154
0155
0156 if (HcalGenericDetId(_emap->lookup(eid)).isHcalZDCDetId()) {
0157 for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
0158 ft->reset();
0159 lssum._vflags.push_back(vtmpflags);
0160 continue;
0161 }
0162
0163 HcalDetId did = HcalDetId(_emap->lookup(eid));
0164
0165
0166
0167 for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
0168 ft->reset();
0169
0170 if (_xDigiSize.get(eid) > 0)
0171 vtmpflags[fDigiSize]._state = flag::fBAD;
0172 else
0173 vtmpflags[fDigiSize]._state = flag::fGOOD;
0174
0175 if (did.subdet() == HcalForward) {
0176 if (_xNChs.get(eid) != _xNChsNominal.get(eid))
0177 vtmpflags[fNChsHF]._state = flag::fBAD;
0178 else
0179 vtmpflags[fNChsHF]._state = flag::fGOOD;
0180 } else {
0181 vtmpflags[fNChsHF]._state = flag::fNA;
0182 }
0183 if (unknownIdsPresent)
0184 vtmpflags[fUnknownIds]._state = flag::fBAD;
0185 else
0186 vtmpflags[fUnknownIds]._state = flag::fGOOD;
0187
0188 if ((did.subdet() == HcalBarrel) || (did.subdet() == HcalBarrel) || (did.subdet() == HcalBarrel) ||
0189 (did.subdet() == HcalBarrel)) {
0190 std::string ledHistName = _subsystem + "/" + _taskname + "/LED_CUCountvsLS/Subdet/";
0191 if (did.subdet() == HcalBarrel) {
0192 ledHistName += "HB";
0193 } else if (did.subdet() == HcalEndcap) {
0194 ledHistName += "HE";
0195 } else if (did.subdet() == HcalOuter) {
0196 ledHistName += "HO";
0197 } else if (did.subdet() == HcalForward) {
0198 ledHistName += "HF";
0199 }
0200 MonitorElement* ledHist = ig.get(ledHistName);
0201 if (ledHist) {
0202 bool ledSignalPresent = (ledHist->getEntries() > 0);
0203 if (ledSignalPresent)
0204 vtmpflags[fLED]._state = flag::fBAD;
0205 else
0206 vtmpflags[fLED]._state = flag::fGOOD;
0207 } else {
0208 vtmpflags[fLED]._state = flag::fNA;
0209 }
0210 } else {
0211 vtmpflags[fLED]._state = flag::fNA;
0212 }
0213
0214
0215 lssum._vflags.push_back(vtmpflags);
0216 }
0217
0218
0219 _vflagsLS.push_back(lssum);
0220 cDigiSize_Crate.reset();
0221 cOccupancy_depth.reset();
0222 }
0223
0224
0225
0226
0227 std::vector<flag::Flag> DigiRunSummary::endJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
0228 if (_ptype != fOffline)
0229 return std::vector<flag::Flag>();
0230
0231 _xDead.reset();
0232 _xUniHF.reset();
0233 _xUni.reset();
0234
0235
0236 std::vector<flag::Flag> vflagsPerLS;
0237 std::vector<flag::Flag> vflagsPerRun;
0238 vflagsPerLS.resize(nLSFlags);
0239 vflagsPerRun.resize(nDigiFlag - nLSFlags + 1);
0240 vflagsPerLS[fDigiSize] = flag::Flag("DigiSize");
0241 vflagsPerLS[fNChsHF] = flag::Flag("NChsHF");
0242 vflagsPerLS[fUnknownIds] = flag::Flag("UnknownIds");
0243 vflagsPerLS[fLED] = flag::Flag("LEDMisfire");
0244 vflagsPerRun[fDigiSize] = flag::Flag("DigiSize");
0245 vflagsPerRun[fNChsHF] = flag::Flag("NChsHF");
0246 vflagsPerRun[fUniHF - nLSFlags + 1] = flag::Flag("UniSlotHF");
0247 vflagsPerRun[fDead - nLSFlags + 1] = flag::Flag("Dead");
0248
0249
0250 ContainerSingle2D cSummaryvsLS;
0251 Container2D cSummaryvsLS_Crate;
0252 cSummaryvsLS.initialize(_name,
0253 "SummaryvsLS",
0254 new quantity::LumiSection(_maxProcessedLS),
0255 new quantity::CrateQuantity(_emap),
0256 new quantity::ValueQuantity(quantity::fState),
0257 0);
0258 cSummaryvsLS.book(ib, _subsystem);
0259 cSummaryvsLS_Crate.initialize(_name,
0260 "SummaryvsLS",
0261 hashfunctions::fCrate,
0262 new quantity::LumiSection(_maxProcessedLS),
0263 new quantity::FlagQuantity(vflagsPerLS),
0264 new quantity::ValueQuantity(quantity::fState),
0265 0);
0266 cSummaryvsLS_Crate.book(ib, _emap, _subsystem);
0267
0268
0269 Container2D cOccupancyCut_depth;
0270 Container2D cDead_depth, cDead_Crate;
0271 cOccupancyCut_depth.initialize(_taskname,
0272 "OccupancyCut",
0273 hashfunctions::fdepth,
0274 new quantity::DetectorQuantity(quantity::fieta),
0275 new quantity::DetectorQuantity(quantity::fiphi),
0276 new quantity::ValueQuantity(quantity::fN),
0277 0);
0278 cDead_depth.initialize(_name,
0279 "Dead",
0280 hashfunctions::fdepth,
0281 new quantity::DetectorQuantity(quantity::fieta),
0282 new quantity::DetectorQuantity(quantity::fiphi),
0283 new quantity::ValueQuantity(quantity::fN),
0284 0);
0285 cDead_Crate.initialize(_name,
0286 "Dead",
0287 hashfunctions::fCrate,
0288 new quantity::ElectronicsQuantity(quantity::fSpigot),
0289 new quantity::ElectronicsQuantity(quantity::fFiberVMEFiberCh),
0290 new quantity::ValueQuantity(quantity::fN),
0291 0);
0292
0293
0294 cOccupancyCut_depth.load(ig, _emap, _subsystem);
0295 cDead_depth.book(ib, _emap, _subsystem);
0296 cDead_Crate.book(ib, _emap, _subsystem);
0297
0298
0299 std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
0300 for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
0301 if (!it->isHcalDetId())
0302 continue;
0303
0304 HcalDetId did = HcalDetId(it->rawId());
0305 HcalElectronicsId eid = HcalElectronicsId(_ehashmap.lookup(did));
0306
0307 if (_cOccupancy_depth.getBinContent(did) < 1) {
0308 _xDead.get(eid)++;
0309 cDead_depth.fill(did);
0310 cDead_Crate.fill(eid);
0311 }
0312 if (did.subdet() == HcalForward)
0313 _xUniHF.get(eid) += cOccupancyCut_depth.getBinContent(did);
0314 }
0315
0316 for (uintCompactMap::const_iterator it = _xUniHF.begin(); it != _xUniHF.end(); ++it) {
0317 uint32_t hash1 = it->first;
0318 HcalElectronicsId eid1(hash1);
0319 double x1 = it->second;
0320
0321 for (uintCompactMap::const_iterator jt = _xUniHF.begin(); jt != _xUniHF.end(); ++jt) {
0322 if (jt == it)
0323 continue;
0324
0325 double x2 = jt->second;
0326 if (x2 == 0)
0327 continue;
0328 if (x1 / x2 < _thresh_unihf)
0329 _xUni.get(eid1)++;
0330 }
0331 }
0332
0333
0334
0335
0336
0337
0338
0339
0340 std::vector<flag::Flag> sumflags;
0341 int icrate = 0;
0342 for (auto& it_crate : _vhashCrates) {
0343 flag::Flag fSumRun("DIGI");
0344 flag::Flag ffDead("Dead");
0345 flag::Flag ffUniSlotHF("UniSlotHF");
0346 HcalElectronicsId eid(it_crate);
0347
0348
0349 if (HcalGenericDetId(_emap->lookup(eid)).isHcalZDCDetId()) {
0350 sumflags.push_back(fSumRun);
0351 continue;
0352 }
0353
0354 HcalDetId did = HcalDetId(_emap->lookup(eid));
0355
0356
0357 for (std::vector<LSSummary>::const_iterator itls = _vflagsLS.begin(); itls != _vflagsLS.end(); ++itls) {
0358 int iflag = 0;
0359 flag::Flag fSumLS("DIGI");
0360 for (std::vector<flag::Flag>::const_iterator ft = itls->_vflags[icrate].begin();
0361 ft != itls->_vflags[icrate].end();
0362 ++ft) {
0363 cSummaryvsLS_Crate.setBinContent(eid, itls->_LS, int(iflag), ft->_state);
0364 fSumLS += (*ft);
0365 iflag++;
0366 }
0367 cSummaryvsLS.setBinContent(eid, itls->_LS, fSumLS._state);
0368 fSumRun += fSumLS;
0369 }
0370
0371
0372 if (_xDead.get(eid) > 0)
0373 ffDead._state = flag::fBAD;
0374 else
0375 ffDead._state = flag::fGOOD;
0376 if (did.subdet() == HcalForward) {
0377 if (_xUni.get(eid) > 0)
0378 ffUniSlotHF._state = flag::fBAD;
0379 else
0380 ffUniSlotHF._state = flag::fGOOD;
0381 }
0382 fSumRun += ffDead + ffUniSlotHF;
0383
0384
0385 sumflags.push_back(fSumRun);
0386
0387
0388 icrate++;
0389 }
0390
0391 return sumflags;
0392 }
0393 }