Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-04 22:54:40

0001 #include "DQM/HcalTasks/interface/RawTask.h"
0002 
0003 using namespace hcaldqm;
0004 using namespace hcaldqm::constants;
0005 
0006 RawTask::RawTask(edm::ParameterSet const& ps)
0007     : DQTask(ps), hcalDbServiceToken_(esConsumes<HcalDbService, HcalDbRecord, edm::Transition::BeginRun>()) {
0008   _tagFEDs = ps.getUntrackedParameter<edm::InputTag>("tagFEDs", edm::InputTag("rawDataCollector"));
0009   _tagReport = ps.getUntrackedParameter<edm::InputTag>("tagReport", edm::InputTag("hcalDigis"));
0010   _calibProcessing = ps.getUntrackedParameter<bool>("calibProcessing", false);
0011   _thresh_calib_nbadq = ps.getUntrackedParameter<int>("thresh_calib_nbadq", 5000);
0012 
0013   _tokFEDs = consumes<FEDRawDataCollection>(_tagFEDs);
0014   _tokReport = consumes<HcalUnpackerReport>(_tagReport);
0015 
0016   _vflags.resize(nRawFlag);
0017   _vflags[fEvnMsm] = flag::Flag("EvnMsm");
0018   _vflags[fBcnMsm] = flag::Flag("BcnMsm");
0019   _vflags[fBadQ] = flag::Flag("BadQ");
0020   _vflags[fOrnMsm] = flag::Flag("OrnMsm");
0021   _NBadQEvent = 0;
0022 }
0023 
0024 /* virtual */ void RawTask::bookHistograms(DQMStore::IBooker& ib, edm::Run const& r, edm::EventSetup const& es) {
0025   DQTask::bookHistograms(ib, r, es);
0026 
0027   //    GET WHAT YOU NEED
0028   edm::ESHandle<HcalDbService> dbs = es.getHandle(hcalDbServiceToken_);
0029   _emap = dbs->getHcalMapping();
0030   std::vector<uint32_t> vVME;
0031   std::vector<uint32_t> vuTCA;
0032   vVME.push_back(
0033       HcalElectronicsId(constants::FIBERCH_MIN, constants::FIBER_VME_MIN, SPIGOT_MIN, CRATE_VME_MIN).rawId());
0034   vuTCA.push_back(HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0035   _filter_VME.initialize(filter::fFilter, hcaldqm::hashfunctions::fElectronics, vVME);
0036   _filter_uTCA.initialize(filter::fFilter, hcaldqm::hashfunctions::fElectronics, vuTCA);
0037 
0038   _cBadQualityvsLS.initialize(_name,
0039                               "BadQualityvsLS",
0040                               new hcaldqm::quantity::LumiSection(_maxLS),
0041                               new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN_m0to10000),
0042                               0);
0043   _cBadQualityvsBX.initialize(_name,
0044                               "BadQualityvsBX",
0045                               new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fBX),
0046                               new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN_m0to10000),
0047                               0);
0048   _cBadQuality_depth.initialize(_name,
0049                                 "BadQuality",
0050                                 hcaldqm::hashfunctions::fdepth,
0051                                 new hcaldqm::quantity::DetectorQuantity(hcaldqm::quantity::fieta),
0052                                 new hcaldqm::quantity::DetectorQuantity(hcaldqm::quantity::fiphi),
0053                                 new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0054                                 0);
0055 
0056   // FED-based plots
0057   if (_ptype != fOffline) {  // hidefed2crate
0058     std::vector<int> vFEDs = hcaldqm::utilities::getFEDList(_emap);
0059     std::vector<int> vFEDsVME = hcaldqm::utilities::getFEDVMEList(_emap);
0060     std::vector<int> vFEDsuTCA = hcaldqm::utilities::getFEDuTCAList(_emap);
0061 
0062     std::vector<uint32_t> vhashFEDsVME;
0063     std::vector<uint32_t> vhashFEDsuTCA;
0064 
0065     for (std::vector<int>::const_iterator it = vFEDsVME.begin(); it != vFEDsVME.end(); ++it) {
0066       vhashFEDsVME.push_back(
0067           HcalElectronicsId(
0068               constants::FIBERCH_MIN, constants::FIBER_VME_MIN, SPIGOT_MIN, (*it) - constants::FED_VME_MIN)
0069               .rawId());
0070       _vhashFEDs.push_back(
0071           HcalElectronicsId(
0072               constants::FIBERCH_MIN, constants::FIBER_VME_MIN, SPIGOT_MIN, (*it) - constants::FED_VME_MIN)
0073               .rawId());
0074     }
0075     for (std::vector<int>::const_iterator it = vFEDsuTCA.begin(); it != vFEDsuTCA.end(); ++it) {
0076       std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(*it);
0077       vhashFEDsuTCA.push_back(
0078           HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0079       _vhashFEDs.push_back(HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0080     }
0081     _filter_FEDsVME.initialize(filter::fPreserver, hcaldqm::hashfunctions::fFED, vhashFEDsVME);
0082     _filter_FEDsuTCA.initialize(filter::fPreserver, hcaldqm::hashfunctions::fFED, vhashFEDsuTCA);
0083 
0084     //  INITIALIZE FIRST
0085     _cEvnMsm_ElectronicsuTCA.initialize(_name,
0086                                         "EvnMsm",
0087                                         hcaldqm::hashfunctions::fElectronics,
0088                                         new hcaldqm::quantity::FEDQuantity(vFEDsuTCA),
0089                                         new hcaldqm::quantity::ElectronicsQuantity(hcaldqm::quantity::fSlotuTCA),
0090                                         new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0091                                         0);
0092     _cBcnMsm_ElectronicsuTCA.initialize(_name,
0093                                         "BcnMsm",
0094                                         hcaldqm::hashfunctions::fElectronics,
0095                                         new hcaldqm::quantity::FEDQuantity(vFEDsuTCA),
0096                                         new hcaldqm::quantity::ElectronicsQuantity(hcaldqm::quantity::fSlotuTCA),
0097                                         new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0098                                         0);
0099     _cOrnMsm_ElectronicsuTCA.initialize(_name,
0100                                         "OrnMsm",
0101                                         hcaldqm::hashfunctions::fElectronics,
0102                                         new hcaldqm::quantity::FEDQuantity(vFEDsuTCA),
0103                                         new hcaldqm::quantity::ElectronicsQuantity(hcaldqm::quantity::fSlotuTCA),
0104                                         new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0105                                         0);
0106 
0107     //  Bad Quality
0108     _cBadQuality_FEDuTCA.initialize(_name,
0109                                     "BadQuality",
0110                                     hcaldqm::hashfunctions::fCrate,
0111                                     new hcaldqm::quantity::ElectronicsQuantity(hcaldqm::quantity::fSlotuTCA),
0112                                     new hcaldqm::quantity::ElectronicsQuantity(hcaldqm::quantity::fFiberuTCA),
0113                                     new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0114                                     0);
0115 
0116     //  Online only
0117     if (_ptype == fOnline) {
0118       _xEvnMsmLS.initialize(hcaldqm::hashfunctions::fFED);
0119       _xBcnMsmLS.initialize(hcaldqm::hashfunctions::fFED);
0120       _xOrnMsmLS.initialize(hcaldqm::hashfunctions::fFED);
0121       _xBadQLS.initialize(hcaldqm::hashfunctions::fFED);
0122       _cSummaryvsLS_FED.initialize(_name,
0123                                    "SummaryvsLS",
0124                                    hcaldqm::hashfunctions::fFED,
0125                                    new hcaldqm::quantity::LumiSection(_maxLS),
0126                                    new hcaldqm::quantity::FlagQuantity(_vflags),
0127                                    new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fState),
0128                                    0);
0129       _cSummaryvsLS.initialize(_name,
0130                                "SummaryvsLS",
0131                                new hcaldqm::quantity::LumiSection(_maxLS),
0132                                new hcaldqm::quantity::FEDQuantity(vFEDs),
0133                                new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fState),
0134                                0);
0135       _cBadQ_FEDvsLS.initialize(_name,
0136                                 "BadQ_FEDvsLS",
0137                                 new hcaldqm::quantity::LumiSectionCoarse(_maxLS, 10),
0138                                 new hcaldqm::quantity::FEDQuantity(vFEDs),
0139                                 new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0140                                 0);
0141       _cBadQ_FEDvsLSmod10.initialize(_name,
0142                                      "BadQ_FEDvsLSmod10",
0143                                      new hcaldqm::quantity::LumiSection(10),
0144                                      new hcaldqm::quantity::FEDQuantity(vFEDs),
0145                                      new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0146                                      0);
0147       //    FED Size vs LS
0148       _cDataSizevsLS_FED.initialize(_name,
0149                                     "DataSizevsLS",
0150                                     hcaldqm::hashfunctions::fFED,
0151                                     new hcaldqm::quantity::LumiSection(_maxLS),
0152                                     new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fDataSize),
0153                                     0);
0154     }
0155   }
0156 
0157   //    BOOK HISTOGRAMS
0158   if (_ptype != fOffline) {
0159     _cEvnMsm_ElectronicsuTCA.book(ib, _emap, _filter_VME, _subsystem);
0160     _cBcnMsm_ElectronicsuTCA.book(ib, _emap, _filter_VME, _subsystem);
0161     _cOrnMsm_ElectronicsuTCA.book(ib, _emap, _filter_VME, _subsystem);
0162 
0163     _cBadQuality_FEDuTCA.book(ib, _emap, _filter_VME, _subsystem);
0164   }
0165   if (_ptype == fOffline) {
0166     auto scope = DQMStore::IBooker::UseLumiScope(ib);
0167     _cBadQuality_depth.book(ib, _emap, _subsystem);
0168   } else {
0169     _cBadQuality_depth.book(ib, _emap, _subsystem);
0170   }
0171   _cBadQualityvsLS.book(ib, _subsystem);
0172   _cBadQualityvsBX.book(ib, _subsystem);
0173 
0174   // BOOK HISTOGRAMS to be used in ONLINE ONLY!
0175   if (_ptype == fOnline) {
0176     _xEvnMsmLS.book(_emap);
0177     _xBcnMsmLS.book(_emap);
0178     _xOrnMsmLS.book(_emap);
0179     _xBadQLS.book(_emap);
0180     _cSummaryvsLS_FED.book(ib, _emap, _subsystem);
0181     _cSummaryvsLS.book(ib, _subsystem);
0182     _cBadQ_FEDvsLSmod10.book(ib, _subsystem);
0183     _cBadQ_FEDvsLS.book(ib, _subsystem);
0184     _cDataSizevsLS_FED.book(ib, _emap, _subsystem);
0185   }
0186 
0187   //    FOR OFFLINE PROCESSING MARK THESE HISTOGRAMS AS LUMI BASED
0188   //if (_ptype == fOffline) {
0189   //if (_ptype != fOffline) {  // hidefed2crate
0190   // Note that this is deliberately contradictory for the fed2crate fix, so it can be reversed if fed2crate is ever fixed properly,
0191   // TODO: set LUMI scope while booking.
0192   // _cEvnMsm_ElectronicsVME.setLumiFlag();
0193   // _cBcnMsm_ElectronicsVME.setLumiFlag();
0194   // _cEvnMsm_ElectronicsuTCA.setLumiFlag();
0195   // _cBcnMsm_ElectronicsuTCA.setLumiFlag();
0196   //}
0197   //}
0198 
0199   //    initialize hash map
0200   _ehashmap.initialize(_emap, hcaldqm::electronicsmap::fD2EHashMap);
0201 }
0202 
0203 /* virtual */ void RawTask::_resetMonitors(hcaldqm::UpdateFreq uf) {
0204   //    base reset
0205   DQTask::_resetMonitors(uf);
0206 }
0207 
0208 /* virtual */ void RawTask::_process(edm::Event const& e, edm::EventSetup const&) {
0209   edm::Handle<FEDRawDataCollection> craw;
0210   edm::Handle<HcalUnpackerReport> creport;
0211   if (!e.getByToken(_tokFEDs, craw))
0212     _logger.dqmthrow("Collection FEDRawDataCollection isn't available" + _tagFEDs.label() + " " + _tagFEDs.instance());
0213   if (!e.getByToken(_tokReport, creport))
0214     _logger.dqmthrow("Collection HcalUnpackerReport isn't available" + _tagReport.label() + " " +
0215                      _tagReport.instance());
0216 
0217   //    extract some info
0218   int bx = e.bunchCrossing();
0219 
0220   auto lumiCache = luminosityBlockCache(e.getLuminosityBlock().index());
0221   _currentLS = lumiCache->currentLS;
0222   _xQuality.reset();
0223   _xQuality = lumiCache->xQuality;
0224 
0225   /*
0226      *  For Calibration/Abort Gap Processing
0227      *  check if the #channels taht are bad from the unpacker 
0228      *  is > 5000. If it is skip...
0229      */
0230   if (_calibProcessing) {
0231     int nbadq = creport->badQualityDigis();
0232     if (nbadq >= _thresh_calib_nbadq)
0233       return;
0234   }
0235 
0236   if (_ptype == fOnline &&
0237       lumiCache->EvtCntLS == 1) {  // Reset the bin for  _cBadQ_FEDvsLSmod10 at the beginning of each new LS
0238     for (std::vector<uint32_t>::const_iterator it = _vhashFEDs.begin(); it != _vhashFEDs.end(); ++it) {
0239       HcalElectronicsId eid = HcalElectronicsId(*it);
0240       _cBadQ_FEDvsLSmod10.setBinContent(eid, _currentLS % 10, 0);
0241     }
0242   }
0243   int nn = 0;
0244   //    loop thru and fill the detIds with bad quality
0245   //    NOTE: Calibration Channels are skipped!
0246   //    TODO: Include for Online Calibration Channels marked as bad
0247   //    a comment below is left on purpose!
0248   //_cBadQualityvsBX.fill(bx, creport->badQualityDigis());
0249 
0250   int Nbadq = creport->badQualityDigis();
0251   if (lumiCache->EvtCntLS == 1)
0252     _NBadQEvent = 0;  // Reset at the beginning of each new LS
0253   if (Nbadq > 0)
0254     _NBadQEvent++;
0255   //std::cout << " Nbadq  "<<  Nbadq   << " NBadQEvent  " <<_NBadQEvent<< std::endl;
0256   for (std::vector<DetId>::const_iterator it = creport->bad_quality_begin(); it != creport->bad_quality_end(); ++it) {
0257     //  skip non HCAL det ids
0258     if (!HcalGenericDetId(*it).isHcalDetId())
0259       continue;
0260 
0261     //  skip those that are of bad quality from conditions
0262     //  Masked or Dead
0263     if (_xQuality.exists(HcalDetId(*it))) {
0264       HcalChannelStatus cs(it->rawId(), _xQuality.get(HcalDetId(*it)));
0265       if (cs.isBitSet(HcalChannelStatus::HcalCellMask) || cs.isBitSet(HcalChannelStatus::HcalCellDead))
0266         continue;
0267     }
0268 
0269     nn++;
0270     HcalElectronicsId eid = HcalElectronicsId(_ehashmap.lookup(*it));
0271     _cBadQuality_depth.fill(HcalDetId(*it));
0272     //  ONLINE ONLY!
0273     if (_ptype == fOnline)
0274       //Number of BadQualityDigis
0275       _xBadQLS.get(eid)++;
0276     //std::cout << " event _xBadQLS "<<  double(_xBadQLS.get(eid)) << std::endl;
0277     if (_ptype != fOffline) {  // hidefed2crate
0278       if (!eid.isVMEid()) {
0279         if (_filter_FEDsuTCA.filter(eid))
0280           continue;
0281         _cBadQuality_FEDuTCA.fill(eid);
0282       }
0283     }
0284   }
0285   _cBadQualityvsLS.fill(_currentLS, nn);
0286   _cBadQualityvsBX.fill(bx, nn);
0287 
0288   if (_ptype != fOffline) {  // hidefed2crate
0289     for (int fed = FEDNumbering::MINHCALFEDID; fed <= FEDNumbering::MAXHCALuTCAFEDID; fed++) {
0290       //    skip nonHCAL FEDs
0291       if ((fed > FEDNumbering::MAXHCALFEDID && fed < FEDNumbering::MINHCALuTCAFEDID) ||
0292           fed > FEDNumbering::MAXHCALuTCAFEDID)
0293         continue;
0294       FEDRawData const& raw = craw->FEDData(fed);
0295       if (raw.size() < constants::RAW_EMPTY)
0296         continue;
0297 
0298       if (fed <= FEDNumbering::MAXHCALFEDID)  // VME
0299       {
0300         HcalDCCHeader const* hdcc = (HcalDCCHeader const*)(raw.data());
0301         if (!hdcc)
0302           continue;
0303 
0304         uint32_t bcn = hdcc->getBunchId();
0305         uint32_t orn = hdcc->getOrbitNumber() & 0x1F;  // LS 5 bits only
0306         uint32_t evn = hdcc->getDCCEventNumber();
0307         int dccId = hdcc->getSourceId() - constants::FED_VME_MIN;
0308 
0309         /* online only */
0310         if (_ptype == fOnline) {
0311           HcalElectronicsId eid =
0312               HcalElectronicsId(constants::FIBERCH_MIN, constants::FIBER_VME_MIN, constants::SPIGOT_MIN, dccId);
0313           if (_filter_FEDsVME.filter(eid))
0314             continue;
0315           _cDataSizevsLS_FED.fill(eid, _currentLS, double(raw.size()) / 1024.);
0316         }
0317 
0318         //  iterate over spigots
0319         HcalHTRData htr;
0320         for (int is = 0; is < HcalDCCHeader::SPIGOT_COUNT; is++) {
0321           int r = hdcc->getSpigotData(is, htr, raw.size());
0322           if (r != 0 || !htr.check())
0323             continue;
0324           HcalElectronicsId eid = HcalElectronicsId(constants::FIBERCH_MIN, constants::FIBER_VME_MIN, is, dccId);
0325           if (_filter_FEDsVME.filter(eid))
0326             continue;
0327 
0328           uint32_t htr_evn = htr.getL1ANumber();
0329           uint32_t htr_orn = htr.getOrbitNumber();
0330           uint32_t htr_bcn = htr.getBunchNumber();
0331           bool qevn = (htr_evn != evn);
0332           bool qbcn = (htr_bcn != bcn);
0333           bool qorn = (htr_orn != orn);
0334           if (qevn) {
0335             if (_ptype == fOnline && is <= constants::SPIGOT_MAX)
0336               _xEvnMsmLS.get(eid)++;
0337           }
0338           if (qorn) {
0339             if (_ptype == fOnline && is <= constants::SPIGOT_MAX)
0340               _xOrnMsmLS.get(eid)++;
0341           }
0342           if (qbcn) {
0343             if (_ptype == fOnline && is <= constants::SPIGOT_MAX)
0344               _xBcnMsmLS.get(eid)++;
0345           }
0346         }
0347       } else  // uTCA
0348       {
0349         hcal::AMC13Header const* hamc13 = (hcal::AMC13Header const*)raw.data();
0350         if (!hamc13)
0351           continue;
0352 
0353         /* online only */
0354         if (_ptype == fOnline) {
0355           std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(fed);
0356           HcalElectronicsId eid = HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false);
0357           if (_filter_FEDsuTCA.filter(eid))
0358             continue;
0359           _cDataSizevsLS_FED.fill(eid, _currentLS, double(raw.size()) / 1024.);
0360         }
0361 
0362         uint32_t bcn = hamc13->bunchId();
0363         uint32_t orn = hamc13->orbitNumber() & 0xFFFF;  // LS 16bits only
0364         uint32_t evn = hamc13->l1aNumber();
0365         int namc = hamc13->NAMC();
0366 
0367         for (int iamc = 0; iamc < namc; iamc++) {
0368           int slot = hamc13->AMCSlot(iamc);
0369           int crate = hamc13->AMCId(iamc) & 0xFF;
0370           HcalElectronicsId eid(crate, slot, FIBER_uTCA_MIN1, FIBERCH_MIN, false);
0371           if (_filter_FEDsuTCA.filter(eid))
0372             continue;
0373           HcalUHTRData uhtr(hamc13->AMCPayload(iamc), hamc13->AMCSize(iamc));
0374 
0375           uint32_t uhtr_evn = uhtr.l1ANumber();
0376           uint32_t uhtr_bcn = uhtr.bunchNumber();
0377           uint32_t uhtr_orn = uhtr.orbitNumber();
0378           bool qevn = (uhtr_evn != evn);
0379           bool qbcn = (uhtr_bcn != bcn);
0380           bool qorn = (uhtr_orn != orn);
0381           if (qevn) {
0382             _cEvnMsm_ElectronicsuTCA.fill(eid);
0383 
0384             if (_ptype == fOnline)
0385               _xEvnMsmLS.get(eid)++;
0386           }
0387           if (qorn) {
0388             _cOrnMsm_ElectronicsuTCA.fill(eid);
0389 
0390             if (_ptype == fOnline)
0391               _xOrnMsmLS.get(eid)++;
0392           }
0393           if (qbcn) {
0394             _cBcnMsm_ElectronicsuTCA.fill(eid);
0395 
0396             if (_ptype == fOnline)
0397               _xBcnMsmLS.get(eid)++;
0398           }
0399         }
0400       }
0401     }
0402   }
0403 }
0404 
0405 std::shared_ptr<hcaldqm::Cache> RawTask::globalBeginLuminosityBlock(edm::LuminosityBlock const& lb,
0406                                                                     edm::EventSetup const& es) const {
0407   return DQTask::globalBeginLuminosityBlock(lb, es);
0408   //    _cBadQualityvsLS.extendAxisRange(_currentLS);
0409   //    _cSummaryvsLS_FED.extendAxisRange(_currentLS);
0410   //    _cSummaryvsLS.extendAxisRange(_currentLS);
0411 }
0412 
0413 /* virtual */ void RawTask::globalEndLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const& es) {
0414   auto lumiCache = luminosityBlockCache(lb.index());
0415   _currentLS = lumiCache->currentLS;
0416   _evsPerLS = lumiCache->EvtCntLS;
0417 
0418   if (_ptype != fOnline)
0419     return;
0420 
0421   //
0422   //    GENERATE STATUS ONLY FOR ONLINE!
0423   //
0424   for (std::vector<uint32_t>::const_iterator it = _vhashFEDs.begin(); it != _vhashFEDs.end(); ++it) {
0425     flag::Flag fSum("RAW");
0426     HcalElectronicsId eid = HcalElectronicsId(*it);
0427     int fed = hcaldqm::utilities::crate2fed(eid.crateId(), eid.slot());
0428     std::vector<uint32_t>::const_iterator cit = std::find(_vcdaqEids.begin(), _vcdaqEids.end(), *it);
0429     if (cit == _vcdaqEids.end()) {
0430       // not @cDAQ
0431       for (uint32_t iflag = 0; iflag < _vflags.size(); iflag++)
0432         _cSummaryvsLS_FED.setBinContent(eid, _currentLS, int(iflag), int(flag::fNCDAQ));
0433       _cSummaryvsLS.setBinContent(eid, _currentLS, int(flag::fNCDAQ));
0434       continue;
0435     }
0436 
0437     //  FED is @cDAQ
0438     if (hcaldqm::utilities::isFEDHBHE(eid) || hcaldqm::utilities::isFEDHF(eid) || hcaldqm::utilities::isFEDHO(eid)) {
0439       if (_xEvnMsmLS.get(eid) > 0)
0440         _vflags[fEvnMsm]._state = flag::fBAD;
0441       else
0442         _vflags[fEvnMsm]._state = flag::fGOOD;
0443       if (_xBcnMsmLS.get(eid) > 0)
0444         _vflags[fBcnMsm]._state = flag::fBAD;
0445       else
0446         _vflags[fBcnMsm]._state = flag::fGOOD;
0447       if (_xOrnMsmLS.get(eid) > 0)
0448         _vflags[fOrnMsm]._state = flag::fBAD;
0449       else
0450         _vflags[fOrnMsm]._state = flag::fGOOD;
0451       if (double(_xBadQLS.get(eid)) > double(12 * _evsPerLS))
0452         _vflags[fBadQ]._state = flag::fBAD;
0453       else if (_xBadQLS.get(eid) > 0) {
0454         _vflags[fBadQ]._state = flag::fPROBLEMATIC;
0455       } else
0456         _vflags[fBadQ]._state = flag::fGOOD;
0457     }
0458 
0459     int iflag = 0;
0460     //  iterate over all flags:
0461     //  - sum them all up in summary flag for this FED
0462     //  - reset each flag right after using it
0463     for (std::vector<flag::Flag>::iterator ft = _vflags.begin(); ft != _vflags.end(); ++ft) {
0464       _cSummaryvsLS_FED.setBinContent(eid, _currentLS, int(iflag), ft->_state);
0465 
0466       // Following line added due to https://gitlab.cern.ch/cmshcal/docs/-/issues/233                                                                                                               // BadQ > (5%) of number of events in this LS.
0467       if (ft->_name == "BadQ" && (double(_xBadQLS.get(eid)) > 0 && double(_NBadQEvent) > double(0.05 * _evsPerLS))) {
0468         if (!hcaldqm::utilities::isFEDHO(eid) && fed != 1136 && ft->_state != 3) {
0469           _cBadQ_FEDvsLSmod10.setBinContent(eid, _currentLS % 10, (double(_NBadQEvent) / double(_evsPerLS)) * 100);
0470           _cBadQ_FEDvsLS.setBinContent(eid, _currentLS, (double(_NBadQEvent) / double(_evsPerLS)) * 100);
0471         }
0472       }
0473       fSum += (*ft);
0474       iflag++;
0475 
0476       //    this is the MUST! We don't keep flags per FED, reset
0477       //    each one of them after using
0478       ft->reset();
0479     }
0480     _cSummaryvsLS.setBinContent(eid, _currentLS, fSum._state);
0481   }
0482 
0483   //    reset...
0484   _xOrnMsmLS.reset();
0485   _xEvnMsmLS.reset();
0486   _xBcnMsmLS.reset();
0487   _xBadQLS.reset();
0488 
0489   //    in the end always do the DQTask::endLumi
0490   DQTask::globalEndLuminosityBlock(lb, es);
0491 }
0492 
0493 DEFINE_FWK_MODULE(RawTask);