diff --git a/DQM/L1TMonitor/interface/L1TStage2CaloLayer1.h b/DQM/L1TMonitor/interface/L1TStage2CaloLayer1.h index b75d0fd0a0b82..efa18ac022dac 100644 --- a/DQM/L1TMonitor/interface/L1TStage2CaloLayer1.h +++ b/DQM/L1TMonitor/interface/L1TStage2CaloLayer1.h @@ -155,7 +155,7 @@ namespace CaloL1Information { dqm::reco::MonitorElement *last20Mismatches_; - std::vector> runMismatchList; + std::vector>> runMismatchList; }; struct perStreamMonitoringDataHolder { @@ -166,7 +166,7 @@ namespace CaloL1Information { int streamNumMaxEvtMismatchECAL{0}; int streamNumMaxEvtMismatchHCAL{0}; int streamNumMaxEvtMismatch{0}; - std::vector> streamMismatchList; + std::vector>> streamMismatchList; }; struct perLumiBlockMonitoringInformation { @@ -178,11 +178,11 @@ namespace CaloL1Information { int lumiNumMaxEvtMismatchHCAL{0}; int lumiNumMaxEvtMismatch{0}; - std::vector> lumiMismatchList; + std::vector>> lumiMismatchList; }; struct perRunSummaryMonitoringInformation { - std::vector> runMismatchList; + std::vector>> runMismatchList; }; } // namespace CaloL1Information @@ -248,19 +248,21 @@ class L1TStage2CaloLayer1 CaloL1Information::perRunSummaryMonitoringInformation *) const override; private: - void updateMismatch( - const edm::Event &e, - int mismatchType, - std::vector> &streamMismatches) const; + void updateMismatch(const edm::Event &e, + int mismatchType, + std::vector>> + &streamMismatches) const; - void mergeMismatchVectors(std::vector> &, - std::vector> &) const; + void mergeMismatchVectors( + std::vector>> &, + std::vector>> &) const; - bool isLaterMismatch(std::tuple &candidateMismatch, - std::tuple &comparisonMismatch) const; + bool isLaterMismatch( + std::tuple> &candidateMismatch, + std::tuple> &comparisonMismatch) const; - int findIndex(std::tuple, - std::vector>, + int findIndex(std::tuple>, + std::vector>>, int lowerIndexToSearch, int upperIndexToSearch) const; // Input and config info diff --git a/DQM/L1TMonitor/src/L1TStage2CaloLayer1.cc b/DQM/L1TMonitor/src/L1TStage2CaloLayer1.cc index 86ca56bf10bca..fcb1d91d91ff8 100644 --- a/DQM/L1TMonitor/src/L1TStage2CaloLayer1.cc +++ b/DQM/L1TMonitor/src/L1TStage2CaloLayer1.cc @@ -346,12 +346,38 @@ void L1TStage2CaloLayer1::dqmAnalyze(const edm::Event& event, void L1TStage2CaloLayer1::updateMismatch( const edm::Event& e, int mismatchType, - std::vector>& streamMismatches) const { - std::tuple mismatchToInsert = { - e.getRun().id(), e.getLuminosityBlock().id(), e.id(), mismatchType}; + std::vector>>& streamMismatches) + const { + //check if this combination of Run/Lumi/Event already exists in the stream mismatch list + //if it does, update that entry, otherwise insert a new one with this particular combination. + for (auto mismatchIterator = streamMismatches.begin(); mismatchIterator != streamMismatches.end(); + ++mismatchIterator) { + if (e.getRun().id() == std::get<0>(*mismatchIterator) && + e.getLuminosityBlock().id() == std::get<1>(*mismatchIterator) && e.id() == std::get<2>(*mismatchIterator)) { + //the run, lumi and event exist. Check if this kind of mismatch has been reported before + std::vector& mismatchTypeVector = std::get<3>(*mismatchIterator); + for (auto mismatchTypeIterator = mismatchTypeVector.begin(); mismatchTypeIterator != mismatchTypeVector.end(); + ++mismatchTypeIterator) { + if (mismatchType == *mismatchTypeIterator) { + //this has already been reported + return; + } + } + //A mismatch exists, but it is not a type that has been previously reported. + //Insert it into the vector of types of mismatches reported + mismatchTypeVector.push_back(mismatchType); + return; + } + } + + //The run/lumi/event does not exist in the list, construct an entry + std::vector newMismatchTypeVector; + newMismatchTypeVector.push_back(mismatchType); + std::tuple> mismatchToInsert = { + e.getRun().id(), e.getLuminosityBlock().id(), e.id(), newMismatchTypeVector}; streamMismatches.push_back(mismatchToInsert); - //This 20 is potentially a non-obvious constant "magic number" - //this matches the mismatch detail histogram, but should be upgraded to not use the constant in this manner. + + //maintain the mismatch vector size at 20. if (streamMismatches.size() > 20) streamMismatches.erase(streamMismatches.begin()); } @@ -607,8 +633,8 @@ void L1TStage2CaloLayer1::globalEndLuminosityBlockSummary( // based on Run, Lumisection, and event number //false otherwise bool L1TStage2CaloLayer1::isLaterMismatch( - std::tuple& candidateMismatch, - std::tuple& comparisonMismatch) const { + std::tuple>& candidateMismatch, + std::tuple>& comparisonMismatch) const { //check the run. If the run ID of the candidate mismatch is less than the run ID of the comparison mismatch, it is earlier, if (std::get<0>(candidateMismatch) < std::get<0>(comparisonMismatch)) return false; @@ -637,8 +663,8 @@ bool L1TStage2CaloLayer1::isLaterMismatch( //will find an interger we add to the iterator to get the proper location to find the insertion location //will return -1 if the mismatch should not be inserted into the list int L1TStage2CaloLayer1::findIndex( - std::tuple candidateMismatch, - std::vector> comparisonList, + std::tuple> candidateMismatch, + std::vector>> comparisonList, int lowerIndexToSearch, int upperIndexToSearch) const { //Start by getting the spot in the the vector to start searching @@ -697,8 +723,9 @@ int L1TStage2CaloLayer1::findIndex( //will shuffle the candidate mismatch list into the comparison mismatch list. void L1TStage2CaloLayer1::mergeMismatchVectors( - std::vector>& candidateMismatchList, - std::vector>& comparisonMismatchList) const { + std::vector>>& candidateMismatchList, + std::vector>>& comparisonMismatchList) + const { //okay now we loop over our candidate mismatches for (auto candidateIterator = candidateMismatchList.begin(); candidateIterator != candidateMismatchList.end(); ++candidateIterator) { @@ -748,7 +775,17 @@ void L1TStage2CaloLayer1::globalEndRunSummary( std::to_string(std::get<1>(*mismatchIterator).luminosityBlock()) + ":" + std::to_string(std::get<2>(*mismatchIterator).event()); theRunCache->last20Mismatches_->setBinLabel(ibin, binLabel, 2); - theRunCache->last20Mismatches_->setBinContent(std::get<3>(*mismatchIterator) + 1, ibin, 1); + //Get the vector of mismatches for this particular event and iterate through it. + //Set the bin content to 1 for each type of mismatch seen + std::vector mismatchTypeVector = std::get<3>(*mismatchIterator); + for (auto mismatchTypeIterator = mismatchTypeVector.begin(); mismatchTypeIterator != mismatchTypeVector.end(); + ++mismatchTypeIterator) { + theRunCache->last20Mismatches_->setBinContent(*mismatchTypeIterator + 1, ibin, 1); + } ++ibin; } + //remove the remaining empty string labels to prevent overlap + for (int emptyBinIndex = ibin; emptyBinIndex <= 20; ++emptyBinIndex) { + theRunCache->last20Mismatches_->setBinLabel(emptyBinIndex, std::to_string(emptyBinIndex), 2); + } }