Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-29 02:25:42

0001 #include "DQM/GEM/interface/GEMDAQStatusSource.h"
0002 
0003 using namespace std;
0004 using namespace edm;
0005 
0006 GEMDAQStatusSource::GEMDAQStatusSource(const edm::ParameterSet &cfg)
0007     : GEMDQMBase(cfg), gemChMapToken_(esConsumes<GEMChMap, GEMChMapRcd, edm::Transition::BeginRun>()) {
0008   tagVFAT_ = consumes<GEMVFATStatusCollection>(cfg.getParameter<edm::InputTag>("VFATInputLabel"));
0009   tagOH_ = consumes<GEMOHStatusCollection>(cfg.getParameter<edm::InputTag>("OHInputLabel"));
0010   tagAMC_ = consumes<GEMAMCStatusCollection>(cfg.getParameter<edm::InputTag>("AMCInputLabel"));
0011   tagAMC13_ = consumes<GEMAMC13StatusCollection>(cfg.getParameter<edm::InputTag>("AMC13InputLabel"));
0012 
0013   nAMCSlots_ = cfg.getParameter<Int_t>("AMCSlots");
0014 
0015   bWarnedNotFound_ = false;
0016 }
0017 
0018 void GEMDAQStatusSource::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0019   edm::ParameterSetDescription desc;
0020   desc.add<edm::InputTag>("VFATInputLabel", edm::InputTag("muonGEMDigis", "VFATStatus"));
0021   desc.add<edm::InputTag>("OHInputLabel", edm::InputTag("muonGEMDigis", "OHStatus"));
0022   desc.add<edm::InputTag>("AMCInputLabel", edm::InputTag("muonGEMDigis", "AMCStatus"));
0023   desc.add<edm::InputTag>("AMC13InputLabel", edm::InputTag("muonGEMDigis", "AMC13Status"));
0024 
0025   desc.add<Int_t>("AMCSlots", 13);
0026   desc.addUntracked<std::string>("runType", "relval");
0027   desc.addUntracked<std::string>("logCategory", "GEMDAQStatusSource");
0028 
0029   descriptions.add("GEMDAQStatusSource", desc);
0030 }
0031 
0032 void GEMDAQStatusSource::LoadROMap(edm::EventSetup const &iSetup) {
0033   //if (useDBEMap_)
0034   if (true) {
0035     const auto &chMap = iSetup.getData(gemChMapToken_);
0036     auto gemChMap = std::make_unique<GEMChMap>(chMap);
0037 
0038     std::vector<unsigned int> listFEDId;
0039     for (auto const &[ec, dc] : gemChMap->chamberMap()) {
0040       unsigned int fedId = ec.fedId;
0041       uint8_t amcNum = ec.amcNum;
0042       GEMDetId gemChId(dc.detId);
0043 
0044       if (mapFEDIdToRe_.find(fedId) == mapFEDIdToRe_.end()) {
0045         listFEDId.push_back(fedId);
0046       }
0047       mapFEDIdToRe_[fedId] = gemChId.region();
0048       mapFEDIdToSt_[fedId] = gemChId.station();
0049       mapAMC13ToListChamber_[fedId].push_back(gemChId);
0050       mapAMCToListChamber_[{fedId, amcNum}].push_back(gemChId);
0051     }
0052 
0053     Int_t nIdx = 1;
0054     for (auto fedId : listFEDId) {
0055       mapFEDIdToPosition_[fedId] = nIdx++;
0056     }
0057 
0058   } else {
0059     // no EMap in DB, using dummy
0060     auto gemChMap = std::make_unique<GEMChMap>();
0061     gemChMap->setDummy();
0062 
0063     for (auto const &[ec, dc] : gemChMap->chamberMap()) {
0064       unsigned int fedId = ec.fedId;
0065       uint8_t amcNum = ec.amcNum;
0066       GEMDetId gemChId(dc.detId);
0067 
0068       mapFEDIdToRe_[fedId] = gemChId.region();
0069       mapAMC13ToListChamber_[fedId].push_back(gemChId);
0070       mapAMCToListChamber_[{fedId, amcNum}].push_back(gemChId);
0071     }
0072   }
0073 }
0074 
0075 void GEMDAQStatusSource::SetLabelAMC13Status(MonitorElement *h2Status) {
0076   if (h2Status == nullptr) {
0077     return;
0078   }
0079 
0080   unsigned int unBinPos = 1;
0081   h2Status->setBinLabel(unBinPos++, "Good", 2);
0082   h2Status->setBinLabel(unBinPos++, "Invalid AMC", 2);
0083   h2Status->setBinLabel(unBinPos++, "Invalid size", 2);
0084   h2Status->setBinLabel(unBinPos++, "Fail trailer check", 2);
0085   h2Status->setBinLabel(unBinPos++, "Fail fragment length", 2);
0086   h2Status->setBinLabel(unBinPos++, "Fail trailer match", 2);
0087   h2Status->setBinLabel(unBinPos++, "More trailer", 2);
0088   h2Status->setBinLabel(unBinPos++, "CRC modified", 2);
0089   h2Status->setBinLabel(unBinPos++, "S-link error", 2);
0090   h2Status->setBinLabel(unBinPos++, "Wrong FED ID", 2);
0091 
0092   for (auto const &[fedId, nPos] : mapFEDIdToPosition_) {
0093     auto st = mapFEDIdToSt_[fedId];
0094     auto re = (mapFEDIdToRe_[fedId] > 0 ? 'P' : 'M');
0095     h2Status->setBinLabel(nPos, Form("GE%i1-%c", st, re), 1);
0096   }
0097 }
0098 
0099 void GEMDAQStatusSource::SetLabelAMCStatus(MonitorElement *h2Status) {
0100   if (h2Status == nullptr) {
0101     return;
0102   }
0103 
0104   unsigned int unBinPos = 1;
0105   h2Status->setBinLabel(unBinPos++, "Good", 2);
0106   h2Status->setBinLabel(unBinPos++, "Invalid OH", 2);
0107   h2Status->setBinLabel(unBinPos++, "Back pressure", 2);
0108   h2Status->setBinLabel(unBinPos++, "Bad EC", 2);
0109   h2Status->setBinLabel(unBinPos++, "Bad BC", 2);
0110   h2Status->setBinLabel(unBinPos++, "Bad OC", 2);
0111   h2Status->setBinLabel(unBinPos++, "Bad run type", 2);
0112   h2Status->setBinLabel(unBinPos++, "Bad CRC", 2);
0113   h2Status->setBinLabel(unBinPos++, "MMCM locked", 2);
0114   h2Status->setBinLabel(unBinPos++, "DAQ clock locked", 2);
0115   h2Status->setBinLabel(unBinPos++, "DAQ not ready", 2);
0116   h2Status->setBinLabel(unBinPos++, "BC0 not locked", 2);
0117 }
0118 
0119 void GEMDAQStatusSource::SetLabelOHStatus(MonitorElement *h2Status) {
0120   if (h2Status == nullptr) {
0121     return;
0122   }
0123 
0124   unsigned int unBinPos = 1;
0125   h2Status->setBinLabel(unBinPos++, "Good", 2);
0126   h2Status->setBinLabel(unBinPos++, "Event FIFO near full", 2);
0127   h2Status->setBinLabel(unBinPos++, "Input FIFO near full", 2);
0128   h2Status->setBinLabel(unBinPos++, "L1A FIFO near full", 2);
0129   h2Status->setBinLabel(unBinPos++, "Event size warn", 2);
0130   h2Status->setBinLabel(unBinPos++, "Invalid VFAT", 2);
0131   h2Status->setBinLabel(unBinPos++, "Event FIFO full", 2);
0132   h2Status->setBinLabel(unBinPos++, "Input FIFO full", 2);
0133   h2Status->setBinLabel(unBinPos++, "L1A FIFO full", 2);
0134   h2Status->setBinLabel(unBinPos++, "Event size overflow", 2);
0135   h2Status->setBinLabel(unBinPos++, "Invalid event", 2);
0136   h2Status->setBinLabel(unBinPos++, "Out of Sync AMC vs VFAT", 2);
0137   h2Status->setBinLabel(unBinPos++, "Out of Sync VFAT vs VFAT", 2);
0138   h2Status->setBinLabel(unBinPos++, "BX mismatch AMC vs VFAT", 2);
0139   h2Status->setBinLabel(unBinPos++, "BX mismatch VFAT vs VFAT", 2);
0140   h2Status->setBinLabel(unBinPos++, "Input FIFO underflow", 2);
0141   h2Status->setBinLabel(unBinPos++, "Bad VFAT count", 2);
0142 }
0143 
0144 void GEMDAQStatusSource::SetLabelVFATStatus(MonitorElement *h2Status) {
0145   if (h2Status == nullptr) {
0146     return;
0147   }
0148 
0149   unsigned int unBinPos = 1;
0150   h2Status->setBinLabel(unBinPos++, "Good", 2);
0151   h2Status->setBinLabel(unBinPos++, "Basic overflow", 2);
0152   h2Status->setBinLabel(unBinPos++, "Zero-sup overflow", 2);
0153   h2Status->setBinLabel(unBinPos++, "VFAT CRC error", 2);
0154   h2Status->setBinLabel(unBinPos++, "Invalid header", 2);
0155   h2Status->setBinLabel(unBinPos++, "AMC EC mismatch", 2);
0156   h2Status->setBinLabel(unBinPos++, "AMC BC mismatch", 2);
0157 }
0158 
0159 void GEMDAQStatusSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &iSetup) {
0160   LoadROMap(iSetup);
0161   if (mapAMC13ToListChamber_.empty() || mapAMCToListChamber_.empty())
0162     return;
0163   initGeometry(iSetup);
0164   if (GEMGeometry_ == nullptr)
0165     return;
0166   loadChambers();
0167 
0168   strFolderMain_ = "GEM/DAQStatus";
0169 
0170   nBXMin_ = -10;
0171   nBXMax_ = 10;
0172 
0173   ibooker.cd();
0174   ibooker.setCurrentFolder(strFolderMain_);
0175 
0176   h2AMC13Status_ = nullptr;
0177 
0178   bFillAMC_ = false;
0179 
0180   //if (nRunType_ != GEMDQM_RUNTYPE_RELVAL)
0181   if (nRunType_ == GEMDQM_RUNTYPE_ALLPLOTS || nRunType_ == GEMDQM_RUNTYPE_ONLINE) {
0182     Int_t nNumAMC13 = (Int_t)mapFEDIdToRe_.size();
0183     h2AMC13Status_ = ibooker.book2D(
0184         "amc13_status", "AMC13 Status;AMC13;", nNumAMC13, 0.5, nNumAMC13 + 0.5, nBitAMC13_, 0.5, nBitAMC13_ + 0.5);
0185     SetLabelAMC13Status(h2AMC13Status_);
0186 
0187     for (auto &[fedId, nIdx] : mapFEDIdToPosition_) {
0188       auto st = mapFEDIdToSt_[fedId];
0189       auto re = (mapFEDIdToRe_[fedId] > 0 ? 'P' : 'M');
0190       auto strName = Form("amc_status_GE%i1-%c", st, re);
0191       auto strTitle = Form("AMC Status GE%i1-%c;AMC slot;", st, re);
0192       mapFEDIdToAMCStatus_[fedId] =
0193           ibooker.book2D(strName, strTitle, nAMCSlots_, -0.5, nAMCSlots_ - 0.5, nBitAMC_, 0.5, nBitAMC_ + 0.5);
0194       SetLabelAMCStatus(mapFEDIdToAMCStatus_[fedId]);
0195     }
0196 
0197     bFillAMC_ = true;
0198   }
0199 
0200   mapStatusOH_ =
0201       MEMap3Inf(this, "oh_status", "OptoHybrid Status", 36, 0.5, 36.5, nBitOH_, 0.5, nBitOH_ + 0.5, "Chamber");
0202 
0203   mapStatusWarnVFATPerLayer_ = MEMap3Inf(
0204       this, "vfat_statusWarnSum", "VFAT reporting warnings", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
0205   mapStatusErrVFATPerLayer_ = MEMap3Inf(
0206       this, "vfat_statusErrSum", "VFAT reporting errors", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
0207   mapStatusVFATPerCh_ =
0208       MEMap4Inf(this, "vfat_status", "VFAT Status", 24, -0.5, 24 - 0.5, nBitVFAT_, 0.5, nBitVFAT_ + 0.5, "VFAT");
0209 
0210   if (nRunType_ == GEMDQM_RUNTYPE_OFFLINE || nRunType_ == GEMDQM_RUNTYPE_RELVAL) {
0211     mapStatusOH_.TurnOff();
0212     mapStatusWarnVFATPerLayer_.TurnOff();
0213     mapStatusErrVFATPerLayer_.TurnOff();
0214     mapStatusVFATPerCh_.TurnOff();
0215   }
0216 
0217   GenerateMEPerChamber(ibooker);
0218 
0219   if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0220     h2SummaryStatusAll = CreateSummaryHist(ibooker, "chamberAllStatus");
0221     h2SummaryStatusWarning = CreateSummaryHist(ibooker, "chamberWarnings");
0222     h2SummaryStatusError = CreateSummaryHist(ibooker, "chamberErrors");
0223   }
0224 
0225   if (nRunType_ == GEMDQM_RUNTYPE_ALLPLOTS || nRunType_ == GEMDQM_RUNTYPE_ONLINE) {
0226     h2SummaryStatusVFATWarning = CreateSummaryHist(ibooker, "chamberVFATWarnings");
0227     h2SummaryStatusVFATError = CreateSummaryHist(ibooker, "chamberVFATErrors");
0228     h2SummaryStatusOHWarning = CreateSummaryHist(ibooker, "chamberOHWarnings");
0229     h2SummaryStatusOHError = CreateSummaryHist(ibooker, "chamberOHErrors");
0230     h2SummaryStatusAMCWarning = CreateSummaryHist(ibooker, "chamberAMCWarnings");
0231     h2SummaryStatusAMCError = CreateSummaryHist(ibooker, "chamberAMCErrors");
0232     h2SummaryStatusAMC13Error = CreateSummaryHist(ibooker, "chamberAMC13Errors");
0233 
0234     h2SummaryStatusAll->setTitle("Summary of all number of OH or VFAT status of each chambers");
0235     h2SummaryStatusWarning->setTitle("Summary of all warnings of each chambers");
0236     h2SummaryStatusError->setTitle("Summary of all errors of each chambers");
0237     h2SummaryStatusVFATWarning->setTitle("Summary of VFAT warnings of each chambers");
0238     h2SummaryStatusVFATError->setTitle("Summary of VFAT errors of each chambers");
0239     h2SummaryStatusOHWarning->setTitle("Summary of OH warnings of each chambers");
0240     h2SummaryStatusOHError->setTitle("Summary of OH errors of each chambers");
0241     h2SummaryStatusAMCWarning->setTitle("Summary of AMC warnings of each chambers");
0242     h2SummaryStatusAMCError->setTitle("Summary of AMC errors of each chambers");
0243     h2SummaryStatusAMC13Error->setTitle("Summary of AMC13 errors of each chambers");
0244   }
0245 }
0246 
0247 int GEMDAQStatusSource::ProcessWithMEMap3(BookingHelper &bh, ME3IdsKey key) {
0248   MEStationInfo &stationInfo = mapStationInfo_[key];
0249 
0250   Int_t nNewNumCh = stationInfo.nMaxIdxChamber_ - stationInfo.nMinIdxChamber_ + 1;
0251 
0252   mapStatusOH_.SetBinConfX(nNewNumCh, stationInfo.nMinIdxChamber_ - 0.5, stationInfo.nMaxIdxChamber_ + 0.5);
0253   mapStatusOH_.bookND(bh, key);
0254   mapStatusOH_.SetLabelForChambers(key, 1, -1, stationInfo.nMinIdxChamber_);
0255 
0256   if (mapStatusOH_.isOperating()) {
0257     SetLabelOHStatus(mapStatusOH_.FindHist(key));
0258   }
0259 
0260   mapStatusWarnVFATPerLayer_.SetBinConfX(
0261       nNewNumCh, stationInfo.nMinIdxChamber_ - 0.5, stationInfo.nMaxIdxChamber_ + 0.5);
0262   mapStatusWarnVFATPerLayer_.SetBinConfY(stationInfo.nMaxVFAT_, -0.5);
0263   mapStatusWarnVFATPerLayer_.bookND(bh, key);
0264   mapStatusWarnVFATPerLayer_.SetLabelForChambers(key, 1, -1, stationInfo.nMinIdxChamber_);
0265   mapStatusWarnVFATPerLayer_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 2);
0266 
0267   mapStatusErrVFATPerLayer_.SetBinConfX(
0268       nNewNumCh, stationInfo.nMinIdxChamber_ - 0.5, stationInfo.nMaxIdxChamber_ + 0.5);
0269   mapStatusErrVFATPerLayer_.SetBinConfY(stationInfo.nMaxVFAT_, -0.5);
0270   mapStatusErrVFATPerLayer_.bookND(bh, key);
0271   mapStatusErrVFATPerLayer_.SetLabelForChambers(key, 1, -1, stationInfo.nMinIdxChamber_);
0272   mapStatusErrVFATPerLayer_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 2);
0273 
0274   return 0;
0275 }
0276 
0277 int GEMDAQStatusSource::ProcessWithMEMap3WithChamber(BookingHelper &bh, ME4IdsKey key) {
0278   ME3IdsKey key3 = key4Tokey3(key);
0279   MEStationInfo &stationInfo = mapStationInfo_[key3];
0280 
0281   bh.getBooker()->setCurrentFolder(strFolderMain_ + "/VFATStatus_" + getNameDirLayer(key3));
0282 
0283   mapStatusVFATPerCh_.SetBinConfX(stationInfo.nMaxVFAT_, -0.5);
0284   mapStatusVFATPerCh_.bookND(bh, key);
0285   mapStatusVFATPerCh_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 1);
0286   if (mapStatusVFATPerCh_.isOperating()) {
0287     SetLabelVFATStatus(mapStatusVFATPerCh_.FindHist(key));
0288   }
0289 
0290   bh.getBooker()->setCurrentFolder(strFolderMain_);
0291 
0292   return 0;
0293 }
0294 
0295 void GEMDAQStatusSource::analyze(edm::Event const &event, edm::EventSetup const &eventSetup) {
0296   edm::Handle<GEMVFATStatusCollection> gemVFAT;
0297   edm::Handle<GEMOHStatusCollection> gemOH;
0298   edm::Handle<GEMAMCStatusCollection> gemAMC;
0299   edm::Handle<GEMAMC13StatusCollection> gemAMC13;
0300 
0301   event.getByToken(tagVFAT_, gemVFAT);
0302   event.getByToken(tagOH_, gemOH);
0303   event.getByToken(tagAMC_, gemAMC);
0304   event.getByToken(tagAMC13_, gemAMC13);
0305 
0306   if (!(gemVFAT.isValid() && gemOH.isValid() && gemAMC.isValid() && gemAMC13.isValid())) {
0307     if (!bWarnedNotFound_) {
0308       edm::LogWarning(log_category_) << "DAQ sources from muonGEMDigis are not found";
0309       bWarnedNotFound_ = true;
0310     }
0311     return;
0312   }
0313 
0314   std::map<ME4IdsKey, bool> mapChamberAll;
0315   std::map<ME4IdsKey, bool> mapChamberWarning;
0316   std::map<ME4IdsKey, bool> mapChamberError;
0317   std::map<ME4IdsKey, bool> mapChamberVFATWarning;
0318   std::map<ME4IdsKey, bool> mapChamberVFATError;
0319   std::map<ME4IdsKey, bool> mapChamberOHWarning;
0320   std::map<ME4IdsKey, bool> mapChamberOHError;
0321   std::map<ME4IdsKey, bool> mapChamberAMCWarning;
0322   std::map<ME4IdsKey, bool> mapChamberAMCError;
0323   std::map<ME4IdsKey, bool> mapChamberAMC13Error;
0324 
0325   for (auto amc13It = gemAMC13->begin(); amc13It != gemAMC13->end(); ++amc13It) {
0326     int fedId = (*amc13It).first;
0327     if (mapFEDIdToPosition_.find(fedId) == mapFEDIdToPosition_.end()) {
0328       continue;
0329     }
0330     int nXBin = mapFEDIdToPosition_[fedId];
0331 
0332     const auto &range = (*amc13It).second;
0333     for (auto amc13 = range.first; amc13 != range.second; ++amc13) {
0334       Bool_t bWarn = false;
0335       Bool_t bErr = false;
0336 
0337       GEMAMC13Status::Warnings warnings{amc13->warnings()};
0338       GEMAMC13Status::Errors errors{amc13->errors()};
0339 
0340       if (bFillAMC_) {
0341         if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0342           if (warnings.InValidAMC)
0343             FillWithRiseErr(h2AMC13Status_, nXBin, 2, bWarn);
0344         }
0345 
0346         if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0347           if (errors.InValidSize)
0348             FillWithRiseErr(h2AMC13Status_, nXBin, 3, bErr);
0349           if (errors.failTrailerCheck)
0350             FillWithRiseErr(h2AMC13Status_, nXBin, 4, bErr);
0351           if (errors.failFragmentLength)
0352             FillWithRiseErr(h2AMC13Status_, nXBin, 5, bErr);
0353           if (errors.failTrailerMatch)
0354             FillWithRiseErr(h2AMC13Status_, nXBin, 6, bErr);
0355           if (errors.moreTrailers)
0356             FillWithRiseErr(h2AMC13Status_, nXBin, 7, bErr);
0357           if (errors.crcModified)
0358             FillWithRiseErr(h2AMC13Status_, nXBin, 8, bErr);
0359           if (errors.slinkError)
0360             FillWithRiseErr(h2AMC13Status_, nXBin, 9, bErr);
0361           if (errors.wrongFedId)
0362             FillWithRiseErr(h2AMC13Status_, nXBin, 10, bErr);
0363         }
0364       }
0365 
0366       if (!bWarn && !bErr) {
0367         if (bFillAMC_ && nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0368           h2AMC13Status_->Fill(nXBin, 1);
0369         }
0370       } else {
0371         auto &listChamber = mapAMC13ToListChamber_[fedId];
0372         for (auto gid : listChamber) {
0373           ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
0374           if (bErr)
0375             mapChamberAMC13Error[key4Ch] = false;
0376         }
0377       }
0378     }
0379   }
0380 
0381   MonitorElement *h2AMCStatus = nullptr;
0382 
0383   for (auto amcIt = gemAMC->begin(); amcIt != gemAMC->end(); ++amcIt) {
0384     int fedId = (*amcIt).first;
0385     if (mapFEDIdToAMCStatus_.find(fedId) == mapFEDIdToAMCStatus_.end()) {
0386       continue;
0387     }
0388     h2AMCStatus = mapFEDIdToAMCStatus_[fedId];
0389 
0390     const GEMAMCStatusCollection::Range &range = (*amcIt).second;
0391     for (auto amc = range.first; amc != range.second; ++amc) {
0392       Bool_t bWarn = false;
0393       Bool_t bErr = false;
0394 
0395       Int_t nAMCNum = amc->amcNumber();
0396 
0397       GEMAMCStatus::Warnings warnings{amc->warnings()};
0398       GEMAMCStatus::Errors errors{amc->errors()};
0399 
0400       if (bFillAMC_) {
0401         if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0402           if (warnings.InValidOH)
0403             FillWithRiseErr(h2AMCStatus, nAMCNum, 2, bWarn);
0404           if (warnings.backPressure)
0405             FillWithRiseErr(h2AMCStatus, nAMCNum, 3, bWarn);
0406         }
0407 
0408         if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0409           if (errors.badEC)
0410             FillWithRiseErr(h2AMCStatus, nAMCNum, 4, bErr);
0411           if (errors.badBC)
0412             FillWithRiseErr(h2AMCStatus, nAMCNum, 5, bErr);
0413           if (errors.badOC)
0414             FillWithRiseErr(h2AMCStatus, nAMCNum, 6, bErr);
0415           if (errors.badRunType)
0416             FillWithRiseErr(h2AMCStatus, nAMCNum, 7, bErr);
0417           if (errors.badCRC)
0418             FillWithRiseErr(h2AMCStatus, nAMCNum, 8, bErr);
0419           if (errors.MMCMlocked)
0420             FillWithRiseErr(h2AMCStatus, nAMCNum, 9, bErr);
0421           if (errors.DAQclocklocked)
0422             FillWithRiseErr(h2AMCStatus, nAMCNum, 10, bErr);
0423           if (errors.DAQnotReday)
0424             FillWithRiseErr(h2AMCStatus, nAMCNum, 11, bErr);
0425           if (errors.BC0locked)
0426             FillWithRiseErr(h2AMCStatus, nAMCNum, 12, bErr);
0427         }
0428       }
0429 
0430       if (!bWarn && !bErr) {
0431         if (bFillAMC_ && nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0432           h2AMCStatus->Fill(nAMCNum, 1);
0433         }
0434       } else {
0435         auto &listChamber = mapAMCToListChamber_[{fedId, nAMCNum}];
0436         for (auto gid : listChamber) {
0437           ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
0438           if (bErr)
0439             mapChamberAMCError[key4Ch] = false;
0440           if (bWarn)
0441             mapChamberAMCWarning[key4Ch] = false;
0442         }
0443       }
0444     }
0445   }
0446 
0447   for (auto ohIt = gemOH->begin(); ohIt != gemOH->end(); ++ohIt) {
0448     GEMDetId gid = (*ohIt).first;
0449     ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
0450     ME4IdsKey key4{gid.region(), gid.station(), gid.layer(), gid.chamber()};  // WARNING: Chamber, not iEta
0451 
0452     const GEMOHStatusCollection::Range &range = (*ohIt).second;
0453     for (auto OHStatus = range.first; OHStatus != range.second; ++OHStatus) {
0454       GEMOHStatus::Warnings warnings{OHStatus->warnings()};
0455       if (warnings.EvtNF)
0456         mapStatusOH_.Fill(key3, gid.chamber(), 2);
0457       if (warnings.InNF)
0458         mapStatusOH_.Fill(key3, gid.chamber(), 3);
0459       if (warnings.L1aNF)
0460         mapStatusOH_.Fill(key3, gid.chamber(), 4);
0461       if (warnings.EvtSzW)
0462         mapStatusOH_.Fill(key3, gid.chamber(), 5);
0463       if (warnings.InValidVFAT)
0464         mapStatusOH_.Fill(key3, gid.chamber(), 6);
0465 
0466       GEMOHStatus::Errors errors{OHStatus->errors()};
0467       if (errors.EvtF)
0468         mapStatusOH_.Fill(key3, gid.chamber(), 7);
0469       if (errors.InF)
0470         mapStatusOH_.Fill(key3, gid.chamber(), 8);
0471       if (errors.L1aF)
0472         mapStatusOH_.Fill(key3, gid.chamber(), 9);
0473       if (errors.EvtSzOFW)
0474         mapStatusOH_.Fill(key3, gid.chamber(), 10);
0475       if (errors.Inv)
0476         mapStatusOH_.Fill(key3, gid.chamber(), 11);
0477       if (errors.OOScAvV)
0478         mapStatusOH_.Fill(key3, gid.chamber(), 12);
0479       if (errors.OOScVvV)
0480         mapStatusOH_.Fill(key3, gid.chamber(), 13);
0481       if (errors.BxmAvV)
0482         mapStatusOH_.Fill(key3, gid.chamber(), 14);
0483       if (errors.BxmVvV)
0484         mapStatusOH_.Fill(key3, gid.chamber(), 15);
0485       if (errors.InUfw)
0486         mapStatusOH_.Fill(key3, gid.chamber(), 16);
0487       if (errors.badVFatCount)
0488         mapStatusOH_.Fill(key3, gid.chamber(), 17);
0489 
0490       Bool_t bWarn = warnings.wcodes != 0;
0491       Bool_t bErr = errors.codes != 0;
0492       if (!bWarn && !bErr)
0493         mapStatusOH_.Fill(key3, gid.chamber(), 1);
0494       if (bWarn)
0495         mapChamberOHWarning[key4] = false;
0496       if (bErr)
0497         mapChamberOHError[key4] = false;
0498       mapChamberAll[key4] = true;
0499     }
0500   }
0501 
0502   for (auto vfatIt = gemVFAT->begin(); vfatIt != gemVFAT->end(); ++vfatIt) {
0503     GEMDetId gid = (*vfatIt).first;
0504     ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
0505     ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};  // WARNING: Chamber, not iEta
0506     const GEMVFATStatusCollection::Range &range = (*vfatIt).second;
0507 
0508     for (auto vfatStat = range.first; vfatStat != range.second; ++vfatStat) {
0509       Int_t nIdxVFAT = getVFATNumber(gid.station(), gid.ieta(), vfatStat->vfatPosition());
0510 
0511       GEMVFATStatus::Warnings warnings{vfatStat->warnings()};
0512       if (warnings.basicOFW)
0513         mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 2);
0514       if (warnings.zeroSupOFW)
0515         mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 3);
0516 
0517       GEMVFATStatus::Errors errors{(uint8_t)vfatStat->errors()};
0518       mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 4);
0519       if (errors.InValidHeader)
0520         mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 5);
0521       if (errors.EC)
0522         mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 6);
0523       if (errors.BC)
0524         mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 7);
0525 
0526       Bool_t bWarn = warnings.wcodes != 0;
0527       Bool_t bErr = errors.codes != 0;
0528       if (!bWarn && !bErr)
0529         mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 1);
0530       if (bWarn)
0531         mapChamberVFATWarning[key4Ch] = false;
0532       if (bErr)
0533         mapChamberVFATError[key4Ch] = false;
0534       if (bWarn)
0535         mapStatusWarnVFATPerLayer_.Fill(key3, gid.chamber(), nIdxVFAT);
0536       if (bErr)
0537         mapStatusErrVFATPerLayer_.Fill(key3, gid.chamber(), nIdxVFAT);
0538       mapChamberAll[key4Ch] = true;
0539     }
0540   }
0541 
0542   if (nRunType_ == GEMDQM_RUNTYPE_ALLPLOTS || nRunType_ == GEMDQM_RUNTYPE_ONLINE) {
0543     // Summarizing all presence of status of each chamber
0544     for (auto const &[key4, bErr] : mapChamberAll) {
0545       ME3IdsKey key3 = key4Tokey3(key4);
0546       Int_t nChamber = keyToChamber(key4);
0547       h2SummaryStatusAll->Fill(nChamber, mapStationToIdx_[key3]);
0548     }
0549 
0550     // Summarizing all presence of status of each chamber
0551     FillStatusSummaryPlot(mapChamberAll, h2SummaryStatusAll);
0552     // Summarizing all the error and warning occupancy
0553     FillStatusSummaryPlot(mapChamberVFATWarning, h2SummaryStatusVFATWarning, &mapChamberWarning);
0554     FillStatusSummaryPlot(mapChamberVFATError, h2SummaryStatusVFATError, &mapChamberError);
0555     FillStatusSummaryPlot(mapChamberOHWarning, h2SummaryStatusOHWarning, &mapChamberWarning);
0556     FillStatusSummaryPlot(mapChamberOHError, h2SummaryStatusOHError, &mapChamberError);
0557     FillStatusSummaryPlot(mapChamberAMCWarning, h2SummaryStatusAMCWarning, &mapChamberWarning);
0558     FillStatusSummaryPlot(mapChamberAMCError, h2SummaryStatusAMCError, &mapChamberError);
0559     FillStatusSummaryPlot(mapChamberAMC13Error, h2SummaryStatusAMC13Error, &mapChamberError);
0560 
0561     FillStatusSummaryPlot(mapChamberWarning, h2SummaryStatusWarning);
0562     FillStatusSummaryPlot(mapChamberError, h2SummaryStatusError);
0563   }
0564 }
0565 
0566 DEFINE_FWK_MODULE(GEMDAQStatusSource);