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