Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:14

0001 #include "DQM/RPCMonitorDigi/interface/RPCMonitorRaw.h"
0002 #include "DQM/RPCMonitorDigi/interface/RPCRawDataCountsHistoMaker.h"
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "CondFormats/RPCObjects/interface/LinkBoardElectronicIndex.h"
0006 #include "DataFormats/RPCDigi/interface/ReadoutError.h"
0007 
0008 RPCMonitorRaw::RPCMonitorRaw(const edm::ParameterSet& cfg) : theConfig(cfg) {
0009   rpcRawDataCountsTag_ = consumes<RPCRawDataCounts>(cfg.getParameter<edm::InputTag>("rpcRawDataCountsTag"));
0010 
0011   for (unsigned int i = 0; i < 10; i++)
0012     theWatchedErrorHistoPos[i] = 0;
0013   std::vector<int> algos = cfg.getUntrackedParameter<std::vector<int> >("watchedErrors");
0014   for (std::vector<int>::const_iterator it = algos.begin(); it != algos.end(); ++it) {
0015     unsigned int ialgo = *it;
0016     if (ialgo < 10)
0017       theWatchedErrorHistoPos[ialgo] = 1;  // real position initialisain is in begin job. here mark just switched on.
0018   }
0019 }
0020 
0021 RPCMonitorRaw::~RPCMonitorRaw() { LogTrace("") << "RPCMonitorRaw destructor"; }
0022 
0023 void RPCMonitorRaw::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
0024   ibooker.cd();
0025   ibooker.setCurrentFolder("RPC/LinkMonitor");
0026 
0027   me_t[0] = ibooker.book1D("recordType_790", RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(790));
0028   me_t[1] = ibooker.book1D("recordType_791", RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(791));
0029   me_t[2] = ibooker.book1D("recordType_792", RPCRawDataCountsHistoMaker::emptyRecordTypeHisto(792));
0030   for (int i = 0; i < 3; ++i)
0031     me_t[i]->getTH1F()->SetStats(false);
0032 
0033   me_e[0] = ibooker.book1D("readoutErrors_790", RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(790));
0034   me_e[1] = ibooker.book1D("readoutErrors_791", RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(791));
0035   me_e[2] = ibooker.book1D("readoutErrors_792", RPCRawDataCountsHistoMaker::emptyReadoutErrorHisto(792));
0036   for (int i = 0; i < 3; ++i)
0037     me_e[i]->getTH1F()->SetStats(false);
0038 
0039   me_mapGoodEvents = ibooker.book2D("mapGoodRecords", "mapGoodRecords", 36, -0.5, 35.5, 3, 789.5, 792.5);
0040   me_mapGoodEvents->getTH2F()->SetNdivisions(3, "y");
0041   me_mapGoodEvents->setAxisTitle("rmb");
0042   me_mapGoodEvents->getTH2F()->SetYTitle("fed");
0043   me_mapGoodEvents->getTH2F()->SetStats(false);
0044   me_mapBadEvents = ibooker.book2D("mapErrorRecords", "mapErrorRecords", 36, -0.5, 35.5, 3, 789.5, 792.5);
0045   me_mapBadEvents->setAxisTitle("fed");
0046   me_mapBadEvents->getTH2F()->SetYTitle("rmb");
0047   me_mapBadEvents->getTH2F()->SetNdivisions(3, "y");
0048   me_mapBadEvents->getTH2F()->SetStats(false);
0049 
0050   for (unsigned int i = 0; i <= 9; ++i) {
0051     if (theWatchedErrorHistoPos[i]) {
0052       for (unsigned int fed = 790; fed <= 792; ++fed) {
0053         TH2F* histo = RPCRawDataCountsHistoMaker::emptyReadoutErrorMapHisto(fed, i);
0054         MonitorElement* watched = ibooker.book2D(histo->GetName(), histo);
0055         theWatchedErrorHistos[fed - 790].push_back(watched);
0056         theWatchedErrorHistoPos[i] = theWatchedErrorHistos[fed - 790].size();
0057       }
0058     }
0059   }
0060 }
0061 
0062 void RPCMonitorRaw::analyze(const edm::Event& ev, const edm::EventSetup& es) {
0063   edm::Handle<RPCRawDataCounts> rawCounts;
0064   ev.getByToken(rpcRawDataCountsTag_, rawCounts);
0065   const RPCRawDataCounts& counts = *rawCounts.product();
0066 
0067   // record type
0068   for (auto cnt : counts.theRecordTypes)
0069     me_t[cnt.first.first - 790]->Fill(cnt.first.second, cnt.second);
0070 
0071   // good events topology
0072   for (auto cnt : counts.theGoodEvents)
0073     me_mapGoodEvents->Fill(cnt.first.second, cnt.first.first, cnt.second);
0074 
0075   // bad events topology
0076   for (auto cnt : counts.theBadEvents)
0077     me_mapBadEvents->Fill(cnt.first.second, cnt.first.first, cnt.second);
0078 
0079   // readout errors
0080   for (auto cnt : counts.theReadoutErrors) {
0081     rpcrawtodigi::ReadoutError error(cnt.first.second);
0082     LinkBoardElectronicIndex ele = error.where();
0083     rpcrawtodigi::ReadoutError::ReadoutErrorType type = error.type();
0084 
0085     int fed = cnt.first.first;
0086     me_e[fed - 790]->Fill(type, cnt.second);
0087 
0088     // in addition fill location map for selected errors
0089     int idx = theWatchedErrorHistoPos[type] - 1;
0090     if (idx >= 0) {
0091       std::vector<MonitorElement*>& wh = theWatchedErrorHistos[fed - 790];
0092       MonitorElement* me = wh[idx];
0093       me->Fill(ele.dccInputChannelNum, ele.tbLinkInputNum, cnt.second);
0094     }
0095   }
0096 }