Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 114 additions & 88 deletions DQM/L1TMonitor/interface/L1TStage2CaloLayer1.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <memory>
#include <string>
#include <array>
#include <map>

#include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h"

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand Down Expand Up @@ -77,19 +80,124 @@ namespace ComparisonHelper {
}
} // namespace ComparisonHelper

class L1TStage2CaloLayer1 : public DQMOneEDAnalyzer<edm::one::WatchLuminosityBlocks> {
namespace CaloL1Information {

struct monitoringDataHolder {
dqm::reco::MonitorElement *ecalDiscrepancy_;
dqm::reco::MonitorElement *ecalLinkError_;
dqm::reco::MonitorElement *ecalOccupancy_;
dqm::reco::MonitorElement *hcalDiscrepancy_;
dqm::reco::MonitorElement *hcalLinkError_;
dqm::reco::MonitorElement *hcalOccupancy_;

dqm::reco::MonitorElement *ecalOccEtDiscrepancy_;
dqm::reco::MonitorElement *ecalOccFgDiscrepancy_;
dqm::reco::MonitorElement *ecalOccLinkMasked_;
dqm::reco::MonitorElement *ecalOccRecdEtWgt_;
dqm::reco::MonitorElement *ecalOccRecdFgVB_;
dqm::reco::MonitorElement *ecalOccSentAndRecd_;
dqm::reco::MonitorElement *ecalOccSentFgVB_;
dqm::reco::MonitorElement *ecalOccSent_;
dqm::reco::MonitorElement *ecalOccTowerMasked_;
dqm::reco::MonitorElement *ecalTPRawEtCorrelation_;
dqm::reco::MonitorElement *ecalTPRawEtDiffNoMatch_;
dqm::reco::MonitorElement *ecalTPRawEtRecd_;
dqm::reco::MonitorElement *ecalTPRawEtSentAndRecd_;
dqm::reco::MonitorElement *ecalTPRawEtSent_;

dqm::reco::MonitorElement *ecalOccSentNotRecd_;
dqm::reco::MonitorElement *ecalOccRecdNotSent_;
dqm::reco::MonitorElement *ecalOccNoMatch_;

dqm::reco::MonitorElement *hcalOccEtDiscrepancy_;
dqm::reco::MonitorElement *hcalOccFbDiscrepancy_;
dqm::reco::MonitorElement *hcalOccFb2Discrepancy_;
dqm::reco::MonitorElement *hcalOccLinkMasked_;
dqm::reco::MonitorElement *hcalOccRecdEtWgt_;
dqm::reco::MonitorElement *hcalOccRecdFb_;
dqm::reco::MonitorElement *hcalOccRecdFb2_;
dqm::reco::MonitorElement *hcalOccSentAndRecd_;
dqm::reco::MonitorElement *hcalOccSentFb_;
dqm::reco::MonitorElement *hcalOccSentFb2_;
dqm::reco::MonitorElement *hcalOccSent_;
dqm::reco::MonitorElement *hcalOccTowerMasked_;
dqm::reco::MonitorElement *hcalTPRawEtCorrelationHBHE_;
dqm::reco::MonitorElement *hcalTPRawEtCorrelationHF_;
dqm::reco::MonitorElement *hcalTPRawEtDiffNoMatch_;
dqm::reco::MonitorElement *hcalTPRawEtRecd_;
dqm::reco::MonitorElement *hcalTPRawEtSentAndRecd_;
dqm::reco::MonitorElement *hcalTPRawEtSent_;

dqm::reco::MonitorElement *hcalOccSentNotRecd_;
dqm::reco::MonitorElement *hcalOccRecdNotSent_;
dqm::reco::MonitorElement *hcalOccNoMatch_;

dqm::reco::MonitorElement *ECALmismatchesPerBx_;
dqm::reco::MonitorElement *HBHEmismatchesPerBx_;
dqm::reco::MonitorElement *HFmismatchesPerBx_;

dqm::reco::MonitorElement *bxidErrors_;
dqm::reco::MonitorElement *l1idErrors_;
dqm::reco::MonitorElement *orbitErrors_;

dqm::reco::MonitorElement *ecalLinkErrorByLumi_;
dqm::reco::MonitorElement *ecalMismatchByLumi_;
dqm::reco::MonitorElement *hcalLinkErrorByLumi_;
dqm::reco::MonitorElement *hcalMismatchByLumi_;

dqm::reco::MonitorElement *maxEvtLinkErrorsByLumiECAL_;
dqm::reco::MonitorElement *maxEvtLinkErrorsByLumiHCAL_;
dqm::reco::MonitorElement *maxEvtLinkErrorsByLumi_;

dqm::reco::MonitorElement *maxEvtMismatchByLumiECAL_;
dqm::reco::MonitorElement *maxEvtMismatchByLumiHCAL_;
dqm::reco::MonitorElement *maxEvtMismatchByLumi_;

dqm::reco::MonitorElement *last20Mismatches_;

//these maps store the maximum number of evt and link mismatches per lumi section.
//they are read back at the end of runs
//Made std::unique_ptr's for better memory management
std::unique_ptr<std::map<std::string, int>> maxEvtLinkErrorsMapECAL{std::make_unique<std::map<std::string, int>>()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is unique_ptr better here than

std::map<std::string, int> maxEvtLinkErrorsMapECAL;

?

Copy link
Contributor Author

@aloeliger aloeliger Nov 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the reasoning behind this was, as you were noting above, my way to dodge the compiler errors for a const function modifying class elements by making the class element an unedited pointer to some mutable object that I was working with (which, I grant you, seems like a textbook way to write terminally buggy code).

I think continuing from the above, what is necessary for this module to maintain it's previous functionality and also is a thread safe dynamically sized vector/map type of object whose contents are mutable in the analysis functions for storing luminosity block information at the run cached level. Will tbb::concurrent_vector<>'s provide this? I assume that there's also probably a considerable speed cost associated with an object like this?

Thanks,
Andrew Loeliger

std::unique_ptr<std::map<std::string, int>> maxEvtLinkErrorsMapHCAL{std::make_unique<std::map<std::string, int>>()};
std::unique_ptr<std::map<std::string, int>> maxEvtLinkErrorsMap{std::make_unique<std::map<std::string, int>>()};

std::unique_ptr<std::map<std::string, int>> maxEvtMismatchMapECAL{std::make_unique<std::map<std::string, int>>()};
std::unique_ptr<std::map<std::string, int>> maxEvtMismatchMapHCAL{std::make_unique<std::map<std::string, int>>()};
std::unique_ptr<std::map<std::string, int>> maxEvtMismatchMap{std::make_unique<std::map<std::string, int>>()};

std::unique_ptr<std::array<std::pair<std::string, int>, 20>> last20MismatchArray_{
std::make_unique<std::array<std::pair<std::string, int>, 20>>()};
std::unique_ptr<size_t> lastMismatchIndex_{std::make_unique<size_t>()};
};

} // namespace CaloL1Information

class L1TStage2CaloLayer1 : public DQMGlobalEDAnalyzer<CaloL1Information::monitoringDataHolder> {
public:
L1TStage2CaloLayer1(const edm::ParameterSet &ps);
~L1TStage2CaloLayer1() override;

protected:
void analyze(const edm::Event &e, const edm::EventSetup &c) override;
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override;
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override;
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override;
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, CaloL1Information::monitoringDataHolder &) const override;
void bookHistograms(DQMStore::IBooker &ibooker,
const edm::Run &,
const edm::EventSetup &,
CaloL1Information::monitoringDataHolder &eventMonitors) const override;
void dqmAnalyze(edm::Event const &,
edm::EventSetup const &,
CaloL1Information::monitoringDataHolder const &) const override;
void dqmEndRun(edm::Run const &,
edm::EventSetup const &,
CaloL1Information::monitoringDataHolder const &) const override;

private:
void updateMismatch(const edm::Event &e, int mismatchType);
void updateMismatch(const edm::Event &e,
int mismatchType,
const CaloL1Information::monitoringDataHolder &eventMonitors) const;
void updateMaxErrorMapping(const edm::Event &, const std::unique_ptr<std::map<std::string, int>> &, const int) const;
void readBackMaxErrorMapping(const std::unique_ptr<std::map<std::string, int>> &theMap,
dqm::reco::MonitorElement *monitorElement) const;
// Input and config info
edm::EDGetTokenT<EcalTrigPrimDigiCollection> ecalTPSourceRecd_;
std::string ecalTPSourceRecdLabel_;
Expand All @@ -103,88 +211,6 @@ class L1TStage2CaloLayer1 : public DQMOneEDAnalyzer<edm::one::WatchLuminosityBlo
std::string histFolder_;
int tpFillThreshold_;
bool ignoreHFfbs_;

MonitorElement *ecalDiscrepancy_;
MonitorElement *ecalLinkError_;
MonitorElement *ecalOccupancy_;
MonitorElement *hcalDiscrepancy_;
MonitorElement *hcalLinkError_;
MonitorElement *hcalOccupancy_;

MonitorElement *ecalOccEtDiscrepancy_;
MonitorElement *ecalOccFgDiscrepancy_;
MonitorElement *ecalOccLinkMasked_;
MonitorElement *ecalOccRecdEtWgt_;
MonitorElement *ecalOccRecdFgVB_;
MonitorElement *ecalOccSentAndRecd_;
MonitorElement *ecalOccSentFgVB_;
MonitorElement *ecalOccSent_;
MonitorElement *ecalOccTowerMasked_;
MonitorElement *ecalTPRawEtCorrelation_;
MonitorElement *ecalTPRawEtDiffNoMatch_;
MonitorElement *ecalTPRawEtRecd_;
MonitorElement *ecalTPRawEtSentAndRecd_;
MonitorElement *ecalTPRawEtSent_;

MonitorElement *ecalOccSentNotRecd_;
MonitorElement *ecalOccRecdNotSent_;
MonitorElement *ecalOccNoMatch_;

MonitorElement *hcalOccEtDiscrepancy_;
MonitorElement *hcalOccFbDiscrepancy_;
MonitorElement *hcalOccFb2Discrepancy_;
MonitorElement *hcalOccLinkMasked_;
MonitorElement *hcalOccRecdEtWgt_;
MonitorElement *hcalOccRecdFb_;
MonitorElement *hcalOccRecdFb2_;
MonitorElement *hcalOccSentAndRecd_;
MonitorElement *hcalOccSentFb_;
MonitorElement *hcalOccSentFb2_;
MonitorElement *hcalOccSent_;
MonitorElement *hcalOccTowerMasked_;
MonitorElement *hcalTPRawEtCorrelationHBHE_;
MonitorElement *hcalTPRawEtCorrelationHF_;
MonitorElement *hcalTPRawEtDiffNoMatch_;
MonitorElement *hcalTPRawEtRecd_;
MonitorElement *hcalTPRawEtSentAndRecd_;
MonitorElement *hcalTPRawEtSent_;

MonitorElement *hcalOccSentNotRecd_;
MonitorElement *hcalOccRecdNotSent_;
MonitorElement *hcalOccNoMatch_;

MonitorElement *last20Mismatches_;
std::array<std::pair<std::string, int>, 20> last20MismatchArray_;
size_t lastMismatchIndex_{0};

MonitorElement *ecalLinkErrorByLumi_;
MonitorElement *ecalMismatchByLumi_;
MonitorElement *hcalLinkErrorByLumi_;
MonitorElement *hcalMismatchByLumi_;

MonitorElement *maxEvtLinkErrorsByLumiECAL_;
MonitorElement *maxEvtLinkErrorsByLumiHCAL_;
MonitorElement *maxEvtLinkErrorsByLumi_;
int maxEvtLinkErrorsECALCurrentLumi_{0};
int maxEvtLinkErrorsHCALCurrentLumi_{0};

MonitorElement *maxEvtMismatchByLumiECAL_;
MonitorElement *maxEvtMismatchByLumiHCAL_;
MonitorElement *maxEvtMismatchByLumi_;
int maxEvtMismatchECALCurrentLumi_{0};
int maxEvtMismatchHCALCurrentLumi_{0};

MonitorElement *ECALmismatchesPerBx_;
MonitorElement *HBHEmismatchesPerBx_;
MonitorElement *HFmismatchesPerBx_;

MonitorElement *bxidErrors_;
MonitorElement *l1idErrors_;
MonitorElement *orbitErrors_;

// Prevent reallocation per event
std::vector<std::pair<EcalTriggerPrimitiveDigi, EcalTriggerPrimitiveDigi> > ecalTPSentRecd_;
std::vector<std::pair<HcalTriggerPrimitiveDigi, HcalTriggerPrimitiveDigi> > hcalTPSentRecd_;
};

#endif
Loading