File indexing completed on 2024-04-06 12:08:13
0001
0002 #include "DQM/RPCMonitorDigi/interface/RPCFEDIntegrity.h"
0003
0004 #include "DQM/RPCMonitorDigi/interface/RPCRawDataCountsHistoMaker.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006
0007 RPCFEDIntegrity::RPCFEDIntegrity(const edm::ParameterSet& ps) {
0008 edm::LogVerbatim("rpcfedintegrity") << "[RPCFEDIntegrity]: Constructor";
0009
0010 rawCountsLabel_ = consumes<RPCRawDataCounts>(ps.getUntrackedParameter<edm::InputTag>("RPCRawCountsInputTag"));
0011 prefixDir_ = ps.getUntrackedParameter<std::string>("RPCPrefixDir", "RPC/FEDIntegrity");
0012 merge_ = ps.getUntrackedParameter<bool>("MergeRuns", false);
0013 minFEDNum_ = ps.getUntrackedParameter<int>("MinimumFEDID", 790);
0014 maxFEDNum_ = ps.getUntrackedParameter<int>("MaximumFEDID", 792);
0015
0016 init_ = false;
0017 numOfFED_ = maxFEDNum_ - minFEDNum_ + 1;
0018 FATAL_LIMIT = 5;
0019 }
0020
0021 RPCFEDIntegrity::~RPCFEDIntegrity() {
0022 edm::LogVerbatim("rpcfedintegrity") << "[RPCFEDIntegrity]: Destructor ";
0023
0024 }
0025
0026 void RPCFEDIntegrity::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
0027 edm::LogVerbatim("rpcfedintegrity") << "[RPCFEDIntegrity]: Begin booking histograms ";
0028
0029 this->bookFEDMe(ibooker);
0030 }
0031
0032 void RPCFEDIntegrity::analyze(const edm::Event& iEvent, const edm::EventSetup& c) {
0033
0034 edm::Handle<RPCRawDataCounts> rawCounts;
0035 iEvent.getByToken(rawCountsLabel_, rawCounts);
0036 if (!rawCounts.isValid())
0037 return;
0038
0039 const RPCRawDataCounts& counts = *rawCounts.product();
0040
0041 for (int fed = minFEDNum_; fed <= maxFEDNum_; ++fed) {
0042 if (counts.fedBxRecords(fed))
0043 fedMe_[Entries]->Fill(fed);
0044 if (counts.fedFormatErrors(fed))
0045 fedMe_[Fatal]->Fill(fed);
0046 if (counts.fedErrorRecords(fed))
0047 fedMe_[NonFatal]->Fill(fed);
0048 }
0049 }
0050
0051
0052 void RPCFEDIntegrity::bookFEDMe(DQMStore::IBooker& ibooker) {
0053 ibooker.cd();
0054 ibooker.setCurrentFolder(prefixDir_);
0055
0056 fedMe_[Entries] = ibooker.book1D("FEDEntries", "FED Entries", numOfFED_, minFEDNum_, maxFEDNum_ + 1);
0057 this->labelBins(fedMe_[Entries]);
0058 fedMe_[Fatal] = ibooker.book1D("FEDFatal", "FED Fatal Errors", numOfFED_, minFEDNum_, maxFEDNum_ + 1);
0059 this->labelBins(fedMe_[Fatal]);
0060 fedMe_[NonFatal] = ibooker.book1D("FEDNonFatal", "FED NON Fatal Errors", numOfFED_, minFEDNum_, maxFEDNum_ + 1);
0061 this->labelBins(fedMe_[NonFatal]);
0062
0063 init_ = true;
0064 }
0065
0066 void RPCFEDIntegrity::labelBins(MonitorElement* myMe) {
0067 int xbins = myMe->getNbinsX();
0068
0069 if (xbins != numOfFED_)
0070 return;
0071
0072 for (int i = 0; i < xbins; i++) {
0073 const std::string xLabel = fmt::format("{}", minFEDNum_ + i);
0074 myMe->setBinLabel(i + 1, xLabel, 1);
0075 }
0076 }