File indexing completed on 2025-06-03 00:11:55
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 mapStatusMaskedVFATPerLayer_ = MEMap4Inf(
0211 this, "vfat_statusMaskedSum", "VFAT reporting masked", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
0212 mapStatusVFATPerCh_ =
0213 MEMap5Inf(this, "vfat_status", "VFAT Status", 24, -0.5, 24 - 0.5, nBitVFAT_, 0.5, nBitVFAT_ + 0.5, "VFAT");
0214
0215 if (nRunType_ == GEMDQM_RUNTYPE_OFFLINE || nRunType_ == GEMDQM_RUNTYPE_RELVAL) {
0216 mapStatusOH_.TurnOff();
0217 mapStatusWarnVFATPerLayer_.TurnOff();
0218 mapStatusErrVFATPerLayer_.TurnOff();
0219 mapStatusMaskedVFATPerLayer_.TurnOff();
0220 mapStatusVFATPerCh_.TurnOff();
0221 }
0222
0223 GenerateMEPerChamber(ibooker);
0224
0225 if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0226 h2SummaryStatusAll = CreateSummaryHist(ibooker, "chamberAllStatus");
0227 h2SummaryStatusWarning = CreateSummaryHist(ibooker, "chamberWarnings");
0228 h2SummaryStatusError = CreateSummaryHist(ibooker, "chamberErrors");
0229 }
0230
0231 if (nRunType_ == GEMDQM_RUNTYPE_ALLPLOTS || nRunType_ == GEMDQM_RUNTYPE_ONLINE) {
0232 h2SummaryStatusVFATWarning = CreateSummaryHist(ibooker, "chamberVFATWarnings");
0233 h2SummaryStatusVFATError = CreateSummaryHist(ibooker, "chamberVFATErrors");
0234 h2SummaryStatusOHWarning = CreateSummaryHist(ibooker, "chamberOHWarnings");
0235 h2SummaryStatusOHError = CreateSummaryHist(ibooker, "chamberOHErrors");
0236 h2SummaryStatusAMCWarning = CreateSummaryHist(ibooker, "chamberAMCWarnings");
0237 h2SummaryStatusAMCError = CreateSummaryHist(ibooker, "chamberAMCErrors");
0238 h2SummaryStatusAMC13Error = CreateSummaryHist(ibooker, "chamberAMC13Errors");
0239
0240 h2SummaryStatusAll->setTitle("Summary of all number of OH or VFAT status of each chambers");
0241 h2SummaryStatusWarning->setTitle("Summary of all warnings of each chambers");
0242 h2SummaryStatusError->setTitle("Summary of all errors of each chambers");
0243 h2SummaryStatusVFATWarning->setTitle("Summary of VFAT warnings of each chambers");
0244 h2SummaryStatusVFATError->setTitle("Summary of VFAT errors of each chambers");
0245 h2SummaryStatusOHWarning->setTitle("Summary of OH warnings of each chambers");
0246 h2SummaryStatusOHError->setTitle("Summary of OH errors of each chambers");
0247 h2SummaryStatusAMCWarning->setTitle("Summary of AMC warnings of each chambers");
0248 h2SummaryStatusAMCError->setTitle("Summary of AMC errors of each chambers");
0249 h2SummaryStatusAMC13Error->setTitle("Summary of AMC13 errors of each chambers");
0250 }
0251 }
0252
0253 int GEMDAQStatusSource::ProcessWithMEMap4(BookingHelper &bh, ME4IdsKey key) {
0254 ME3IdsKey key3 = key4Tokey3(key);
0255 MEStationInfo &stationInfo = mapStationInfo_[key3];
0256
0257 Int_t nNewNumCh = stationInfo.nMaxIdxChamber_ - stationInfo.nMinIdxChamber_ + 1;
0258 Int_t nNewMinIdxChamber = (stationInfo.nMinIdxChamber_ - 1) + 1;
0259 Int_t nNewMaxIdxChamber = stationInfo.nMaxIdxChamber_;
0260
0261 mapStatusOH_.SetBinConfX(nNewNumCh, nNewMinIdxChamber - 0.5, nNewMaxIdxChamber + 0.5);
0262 mapStatusOH_.bookND(bh, key);
0263 mapStatusOH_.SetLabelForChambers(key, 1, -1, nNewMinIdxChamber);
0264
0265 if (mapStatusOH_.isOperating()) {
0266 SetLabelOHStatus(mapStatusOH_.FindHist(key));
0267 }
0268
0269 Int_t nNumVFATPerModule = stationInfo.nMaxVFAT_ / stationInfo.nNumModules_;
0270
0271 mapStatusWarnVFATPerLayer_.SetBinConfX(nNewNumCh, nNewMinIdxChamber - 0.5, nNewMaxIdxChamber + 0.5);
0272 mapStatusWarnVFATPerLayer_.SetBinConfY(nNumVFATPerModule, -0.5);
0273 mapStatusWarnVFATPerLayer_.bookND(bh, key);
0274 mapStatusWarnVFATPerLayer_.SetLabelForChambers(key, 1, -1, nNewMinIdxChamber);
0275 mapStatusWarnVFATPerLayer_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 2);
0276
0277 mapStatusErrVFATPerLayer_.SetBinConfX(nNewNumCh, nNewMinIdxChamber - 0.5, nNewMaxIdxChamber + 0.5);
0278 mapStatusErrVFATPerLayer_.SetBinConfY(nNumVFATPerModule, -0.5);
0279 mapStatusErrVFATPerLayer_.bookND(bh, key);
0280 mapStatusErrVFATPerLayer_.SetLabelForChambers(key, 1, -1, nNewMinIdxChamber);
0281 mapStatusErrVFATPerLayer_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 2);
0282
0283 mapStatusMaskedVFATPerLayer_.SetBinConfX(nNewNumCh, nNewMinIdxChamber - 0.5, nNewMaxIdxChamber + 0.5);
0284 mapStatusMaskedVFATPerLayer_.SetBinConfY(nNumVFATPerModule, -0.5);
0285 mapStatusMaskedVFATPerLayer_.bookND(bh, key);
0286 mapStatusMaskedVFATPerLayer_.SetLabelForChambers(key, 1, -1, nNewMinIdxChamber);
0287 mapStatusMaskedVFATPerLayer_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 2);
0288
0289 return 0;
0290 }
0291
0292 int GEMDAQStatusSource::ProcessWithMEMap5WithChamber(BookingHelper &bh, ME5IdsKey key) {
0293 ME4IdsKey key4 = key5Tokey4(key);
0294 ME3IdsKey key3 = key4Tokey3(key4);
0295 MEStationInfo &stationInfo = mapStationInfo_[key3];
0296
0297 Int_t nNumVFATPerModule = stationInfo.nMaxVFAT_ / stationInfo.nNumModules_;
0298
0299 bh.getBooker()->setCurrentFolder(strFolderMain_ + "/VFATStatus_" + getNameDirLayer(key4));
0300
0301 mapStatusVFATPerCh_.SetBinConfX(nNumVFATPerModule, -0.5);
0302 mapStatusVFATPerCh_.bookND(bh, key);
0303 mapStatusVFATPerCh_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 1);
0304 if (mapStatusVFATPerCh_.isOperating()) {
0305 SetLabelVFATStatus(mapStatusVFATPerCh_.FindHist(key));
0306 }
0307
0308 bh.getBooker()->setCurrentFolder(strFolderMain_);
0309
0310 return 0;
0311 }
0312
0313 void GEMDAQStatusSource::analyze(edm::Event const &event, edm::EventSetup const &eventSetup) {
0314 edm::Handle<GEMVFATStatusCollection> gemVFAT;
0315 edm::Handle<GEMOHStatusCollection> gemOH;
0316 edm::Handle<GEMAMCStatusCollection> gemAMC;
0317 edm::Handle<GEMAMC13StatusCollection> gemAMC13;
0318
0319 event.getByToken(tagVFAT_, gemVFAT);
0320 event.getByToken(tagOH_, gemOH);
0321 event.getByToken(tagAMC_, gemAMC);
0322 event.getByToken(tagAMC13_, gemAMC13);
0323
0324 if (!(gemVFAT.isValid() && gemOH.isValid() && gemAMC.isValid() && gemAMC13.isValid())) {
0325 if (!bWarnedNotFound_) {
0326 edm::LogWarning(log_category_) << "DAQ sources from muonGEMDigis are not found";
0327 bWarnedNotFound_ = true;
0328 }
0329 return;
0330 }
0331
0332 std::map<ME5IdsKey, bool> mapChamberAll;
0333 std::map<ME5IdsKey, bool> mapChamberWarning;
0334 std::map<ME5IdsKey, bool> mapChamberError;
0335 std::map<ME5IdsKey, bool> mapChamberVFATWarning;
0336 std::map<ME5IdsKey, bool> mapChamberVFATError;
0337 std::map<ME5IdsKey, bool> mapChamberOHWarning;
0338 std::map<ME5IdsKey, bool> mapChamberOHError;
0339 std::map<ME5IdsKey, bool> mapChamberAMCWarning;
0340 std::map<ME5IdsKey, bool> mapChamberAMCError;
0341 std::map<ME5IdsKey, bool> mapChamberAMC13Error;
0342
0343 for (auto amc13It = gemAMC13->begin(); amc13It != gemAMC13->end(); ++amc13It) {
0344 int fedId = (*amc13It).first;
0345 if (mapFEDIdToPosition_.find(fedId) == mapFEDIdToPosition_.end()) {
0346 continue;
0347 }
0348 int nXBin = mapFEDIdToPosition_[fedId];
0349
0350 const auto &range = (*amc13It).second;
0351 for (auto amc13 = range.first; amc13 != range.second; ++amc13) {
0352 Bool_t bWarn = false;
0353 Bool_t bErr = false;
0354
0355 GEMAMC13Status::Warnings warnings{amc13->warnings()};
0356 GEMAMC13Status::Errors errors{amc13->errors()};
0357
0358 if (bFillAMC_) {
0359 if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0360 if (warnings.InValidAMC)
0361 FillWithRiseErr(h2AMC13Status_, nXBin, 2, bWarn);
0362 }
0363
0364 if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0365 if (errors.InValidSize)
0366 FillWithRiseErr(h2AMC13Status_, nXBin, 3, bErr);
0367 if (errors.failTrailerCheck)
0368 FillWithRiseErr(h2AMC13Status_, nXBin, 4, bErr);
0369 if (errors.failFragmentLength)
0370 FillWithRiseErr(h2AMC13Status_, nXBin, 5, bErr);
0371 if (errors.failTrailerMatch)
0372 FillWithRiseErr(h2AMC13Status_, nXBin, 6, bErr);
0373 if (errors.moreTrailers)
0374 FillWithRiseErr(h2AMC13Status_, nXBin, 7, bErr);
0375 if (errors.crcModified)
0376 FillWithRiseErr(h2AMC13Status_, nXBin, 8, bErr);
0377 if (errors.slinkError)
0378 FillWithRiseErr(h2AMC13Status_, nXBin, 9, bErr);
0379 if (errors.wrongFedId)
0380 FillWithRiseErr(h2AMC13Status_, nXBin, 10, bErr);
0381 }
0382 }
0383
0384 if (!bWarn && !bErr) {
0385 if (bFillAMC_ && nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0386 h2AMC13Status_->Fill(nXBin, 1);
0387 }
0388 } else {
0389 auto &listChamber = mapAMC13ToListChamber_[fedId];
0390 for (auto gid : listChamber) {
0391 ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
0392 MEStationInfo &stationInfo = mapStationInfo_[key3];
0393 for (int nIdxModule = 1; nIdxModule <= stationInfo.nNumModules_; nIdxModule++) {
0394 ME5IdsKey key5Ch{gid.region(), gid.station(), gid.layer(), nIdxModule, gid.chamber()};
0395 if (bErr)
0396 mapChamberAMC13Error[key5Ch] = false;
0397 }
0398 }
0399 }
0400 }
0401 }
0402
0403 MonitorElement *h2AMCStatus = nullptr;
0404
0405 for (auto amcIt = gemAMC->begin(); amcIt != gemAMC->end(); ++amcIt) {
0406 int fedId = (*amcIt).first;
0407 if (mapFEDIdToAMCStatus_.find(fedId) == mapFEDIdToAMCStatus_.end()) {
0408 continue;
0409 }
0410 h2AMCStatus = mapFEDIdToAMCStatus_[fedId];
0411
0412 const GEMAMCStatusCollection::Range &range = (*amcIt).second;
0413 for (auto amc = range.first; amc != range.second; ++amc) {
0414 Bool_t bWarn = false;
0415 Bool_t bErr = false;
0416
0417 Int_t nAMCNum = amc->amcNumber();
0418
0419 GEMAMCStatus::Warnings warnings{amc->warnings()};
0420 GEMAMCStatus::Errors errors{amc->errors()};
0421
0422 if (bFillAMC_) {
0423 if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0424 if (warnings.InValidOH)
0425 FillWithRiseErr(h2AMCStatus, nAMCNum, 2, bWarn);
0426 if (warnings.backPressure)
0427 FillWithRiseErr(h2AMCStatus, nAMCNum, 3, bWarn);
0428 }
0429
0430 if (nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0431 if (errors.badEC)
0432 FillWithRiseErr(h2AMCStatus, nAMCNum, 4, bErr);
0433 if (errors.badBC)
0434 FillWithRiseErr(h2AMCStatus, nAMCNum, 5, bErr);
0435 if (errors.badOC)
0436 FillWithRiseErr(h2AMCStatus, nAMCNum, 6, bErr);
0437 if (errors.badRunType)
0438 FillWithRiseErr(h2AMCStatus, nAMCNum, 7, bErr);
0439 if (errors.badCRC)
0440 FillWithRiseErr(h2AMCStatus, nAMCNum, 8, bErr);
0441 if (errors.MMCMlocked)
0442 FillWithRiseErr(h2AMCStatus, nAMCNum, 9, bErr);
0443 if (errors.DAQclocklocked)
0444 FillWithRiseErr(h2AMCStatus, nAMCNum, 10, bErr);
0445 if (errors.DAQnotReday)
0446 FillWithRiseErr(h2AMCStatus, nAMCNum, 11, bErr);
0447 if (errors.BC0locked)
0448 FillWithRiseErr(h2AMCStatus, nAMCNum, 12, bErr);
0449 }
0450 }
0451
0452 if (!bWarn && !bErr) {
0453 if (bFillAMC_ && nRunType_ != GEMDQM_RUNTYPE_RELVAL) {
0454 h2AMCStatus->Fill(nAMCNum, 1);
0455 }
0456 } else {
0457 auto &listChamber = mapAMCToListChamber_[{fedId, nAMCNum}];
0458 for (auto gid : listChamber) {
0459 ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
0460 MEStationInfo &stationInfo = mapStationInfo_[key3];
0461 for (int nIdxModule = 1; nIdxModule <= stationInfo.nNumModules_; nIdxModule++) {
0462 ME5IdsKey key5Ch{gid.region(), gid.station(), gid.layer(), nIdxModule, gid.chamber()};
0463 if (bErr)
0464 mapChamberAMCError[key5Ch] = false;
0465 if (bWarn)
0466 mapChamberAMCWarning[key5Ch] = false;
0467 }
0468 }
0469 }
0470 }
0471 }
0472
0473 std::map<ME5IdsKey, uint32_t> map_missingVFATs;
0474 std::map<ME5IdsKey, uint32_t> map_vfatMask;
0475
0476 for (auto ohIt = gemOH->begin(); ohIt != gemOH->end(); ++ohIt) {
0477 GEMDetId gid = (*ohIt).first;
0478 ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
0479 MEStationInfo &stationInfo = mapStationInfo_[key3];
0480
0481 Int_t nNumVFATPerModule = stationInfo.nMaxVFAT_ / stationInfo.nNumModules_;
0482
0483 const GEMOHStatusCollection::Range &range = (*ohIt).second;
0484 for (auto OHStatus = range.first; OHStatus != range.second; ++OHStatus) {
0485 Int_t nIdxModule = getIdxModule(gid.station(), OHStatus->chamberType());
0486 Int_t nCh = gid.chamber();
0487 ME4IdsKey key4{gid.region(), gid.station(), gid.layer(), nIdxModule};
0488 ME5IdsKey key5Mod{
0489 gid.region(), gid.station(), gid.layer(), nIdxModule, nCh};
0490
0491 auto vfatMask = OHStatus->vfatMask();
0492 map_missingVFATs[key5Mod] = OHStatus->missingVFATs();
0493 map_vfatMask[key5Mod] = vfatMask;
0494
0495 for (Int_t i = 0; i < nNumVFATPerModule; i++) {
0496 if ((vfatMask & (1 << i)) == 0) {
0497 mapStatusErrVFATPerLayer_.Fill(key4, nCh, i, -16);
0498 mapStatusMaskedVFATPerLayer_.Fill(key4, nCh, i, 1.0);
0499 }
0500 }
0501
0502 GEMOHStatus::Warnings warnings{OHStatus->warnings()};
0503 if (warnings.EvtNF)
0504 mapStatusOH_.Fill(key4, nCh, 2);
0505 if (warnings.InNF)
0506 mapStatusOH_.Fill(key4, nCh, 3);
0507 if (warnings.L1aNF)
0508 mapStatusOH_.Fill(key4, nCh, 4);
0509 if (warnings.EvtSzW)
0510 mapStatusOH_.Fill(key4, nCh, 5);
0511 if (warnings.InValidVFAT)
0512 mapStatusOH_.Fill(key4, nCh, 6);
0513 if (warnings.missingVFAT)
0514 mapStatusOH_.Fill(key4, nCh, 7);
0515
0516 GEMOHStatus::Errors errors{OHStatus->errors()};
0517 if (errors.EvtF)
0518 mapStatusOH_.Fill(key4, nCh, 8);
0519 if (errors.InF)
0520 mapStatusOH_.Fill(key4, nCh, 9);
0521 if (errors.L1aF)
0522 mapStatusOH_.Fill(key4, nCh, 10);
0523 if (errors.EvtSzOFW)
0524 mapStatusOH_.Fill(key4, nCh, 11);
0525 if (errors.Inv)
0526 mapStatusOH_.Fill(key4, nCh, 12);
0527 if (errors.OOScAvV)
0528 mapStatusOH_.Fill(key4, nCh, 13);
0529 if (errors.OOScVvV)
0530 mapStatusOH_.Fill(key4, nCh, 14);
0531 if (errors.BxmAvV)
0532 mapStatusOH_.Fill(key4, nCh, 15);
0533 if (errors.BxmVvV)
0534 mapStatusOH_.Fill(key4, nCh, 16);
0535 if (errors.InUfw)
0536 mapStatusOH_.Fill(key4, nCh, 17);
0537 if (errors.badVFatCount)
0538 mapStatusOH_.Fill(key4, nCh, 18);
0539
0540 Bool_t bWarn = warnings.wcodes != 0;
0541 Bool_t bErr = errors.codes != 0;
0542 if (!bWarn && !bErr)
0543 mapStatusOH_.Fill(key4, nCh, 1);
0544 if (bWarn)
0545 mapChamberOHWarning[key5Mod] = false;
0546 if (bErr)
0547 mapChamberOHError[key5Mod] = false;
0548 mapChamberAll[key5Mod] = true;
0549 }
0550 }
0551
0552 for (auto vfatIt = gemVFAT->begin(); vfatIt != gemVFAT->end(); ++vfatIt) {
0553 GEMDetId gid = (*vfatIt).first;
0554 ME3IdsKey key3{gid.region(), gid.station(), gid.layer()};
0555
0556 const GEMVFATStatusCollection::Range &range = (*vfatIt).second;
0557
0558 for (auto vfatStat = range.first; vfatStat != range.second; ++vfatStat) {
0559 Int_t nIdxModule = getIdxModule(gid.station(), vfatStat->chamberType());
0560 Int_t nCh = gid.chamber();
0561 ME4IdsKey key4{gid.region(), gid.station(), gid.layer(), nIdxModule};
0562 ME5IdsKey key5Mod{
0563 gid.region(), gid.station(), gid.layer(), nIdxModule, nCh};
0564
0565 Int_t nIdxVFAT = vfatStat->vfatPosition();
0566 Int_t nIdxVFATMod = nIdxVFAT;
0567
0568 auto missingVFATs = map_missingVFATs[key5Mod] & (1 << nIdxVFAT);
0569 auto vfatMask = map_vfatMask[key5Mod] & (1 << nIdxVFAT);
0570
0571 if (vfatMask == 0) {
0572 continue;
0573 }
0574
0575 Bool_t bErr_masked = missingVFATs != 0;
0576
0577 GEMVFATStatus::Warnings warnings{vfatStat->warnings()};
0578 if (warnings.basicOFW)
0579 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 2);
0580 if (warnings.zeroSupOFW)
0581 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 3);
0582
0583 GEMVFATStatus::Errors errors{(uint8_t)vfatStat->errors()};
0584 if (errors.vc)
0585 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 4);
0586 if (errors.InValidHeader)
0587 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 5);
0588 if (errors.EC)
0589 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 6);
0590 if (errors.BC)
0591 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 7);
0592 if (bErr_masked)
0593 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 8);
0594
0595 Bool_t bWarn = warnings.wcodes != 0;
0596 Bool_t bErr = errors.codes != 0 || bErr_masked;
0597 if (!bWarn && !bErr)
0598 mapStatusVFATPerCh_.Fill(key5Mod, nIdxVFATMod, 1);
0599 if (bWarn)
0600 mapChamberVFATWarning[key5Mod] = false;
0601 if (bErr)
0602 mapChamberVFATError[key5Mod] = false;
0603 if (bWarn)
0604 mapStatusWarnVFATPerLayer_.Fill(key4, nCh, nIdxVFAT);
0605 if (bErr)
0606 mapStatusErrVFATPerLayer_.Fill(key4, nCh, nIdxVFAT);
0607 mapChamberAll[key5Mod] = true;
0608 }
0609 }
0610
0611 if (nRunType_ == GEMDQM_RUNTYPE_ALLPLOTS || nRunType_ == GEMDQM_RUNTYPE_ONLINE) {
0612
0613 FillStatusSummaryPlot(mapChamberAll, h2SummaryStatusAll);
0614
0615 FillStatusSummaryPlot(mapChamberVFATWarning, h2SummaryStatusVFATWarning, &mapChamberWarning);
0616 FillStatusSummaryPlot(mapChamberVFATError, h2SummaryStatusVFATError, &mapChamberError);
0617 FillStatusSummaryPlot(mapChamberOHWarning, h2SummaryStatusOHWarning, &mapChamberWarning);
0618 FillStatusSummaryPlot(mapChamberOHError, h2SummaryStatusOHError, &mapChamberError);
0619 FillStatusSummaryPlot(mapChamberAMCWarning, h2SummaryStatusAMCWarning, &mapChamberWarning);
0620 FillStatusSummaryPlot(mapChamberAMCError, h2SummaryStatusAMCError, &mapChamberError);
0621 FillStatusSummaryPlot(mapChamberAMC13Error, h2SummaryStatusAMC13Error, &mapChamberError);
0622
0623 FillStatusSummaryPlot(mapChamberWarning, h2SummaryStatusWarning);
0624 FillStatusSummaryPlot(mapChamberError, h2SummaryStatusError);
0625 }
0626 }
0627
0628 DEFINE_FWK_MODULE(GEMDAQStatusSource);