From e3d8a02045b28216f182396c926ac9e943a4e115 Mon Sep 17 00:00:00 2001 From: threus Date: Fri, 13 Jun 2014 10:27:37 +0200 Subject: [PATCH] thread-safe --- .../interface/FEDErrors.hh | 7 +- DQM/SiStripMonitorHardware/src/FEDErrors.cc | 78 +++++++++---------- .../src/SiStripFEDDataCheck.cc | 29 ++----- .../src/SiStripFEDMonitor.cc | 10 ++- 4 files changed, 56 insertions(+), 68 deletions(-) diff --git a/DQM/SiStripMonitorHardware/interface/FEDErrors.hh b/DQM/SiStripMonitorHardware/interface/FEDErrors.hh index 3d464471fcb5a..4701a620dbf44 100644 --- a/DQM/SiStripMonitorHardware/interface/FEDErrors.hh +++ b/DQM/SiStripMonitorHardware/interface/FEDErrors.hh @@ -204,9 +204,9 @@ public: const unsigned int fedID(); - static FEDCounters & getFEDErrorsCounters(); + FEDCounters & getFEDErrorsCounters(); - static ChannelCounters & getChannelErrorsCounters(); + ChannelCounters & getChannelErrorsCounters(); FECounters & getFEErrorsCounters(); @@ -268,6 +268,9 @@ private: FECounters feCounter_; FEDLevelErrors fedErrors_; + ChannelCounters lChCounter_; + FEDCounters lFedCounter_; + std::vector feErrors_; std::vector chErrorsDetailed_; std::vector apvErrors_; diff --git a/DQM/SiStripMonitorHardware/src/FEDErrors.cc b/DQM/SiStripMonitorHardware/src/FEDErrors.cc index e98a9bde91ff6..fbb9f4fcec542 100644 --- a/DQM/SiStripMonitorHardware/src/FEDErrors.cc +++ b/DQM/SiStripMonitorHardware/src/FEDErrors.cc @@ -43,26 +43,24 @@ void FEDErrors::initialiseEvent() { subDetId_.clear(); - FEDCounters & lFedCounter = FEDErrors::getFEDErrorsCounters(); - lFedCounter.nFEDErrors = 0; - lFedCounter.nDAQProblems = 0; - lFedCounter.nFEDsWithFEProblems = 0; - lFedCounter.nCorruptBuffers = 0; - lFedCounter.nBadChannels = 0; - lFedCounter.nBadActiveChannels = 0; - lFedCounter.nFEDsWithFEOverflows = 0; - lFedCounter.nFEDsWithFEBadMajorityAddresses = 0; - lFedCounter.nFEDsWithMissingFEs = 0; - lFedCounter.nTotalBadChannels = 0; - lFedCounter.nTotalBadActiveChannels = 0; - - ChannelCounters & lChCounter = FEDErrors::getChannelErrorsCounters(); - lChCounter.nNotConnected = 0; - lChCounter.nUnlocked = 0; - lChCounter.nOutOfSync = 0; - lChCounter.nAPVStatusBit = 0; - lChCounter.nAPVError = 0; - lChCounter.nAPVAddressError = 0; + lFedCounter_.nFEDErrors = 0; + lFedCounter_.nDAQProblems = 0; + lFedCounter_.nFEDsWithFEProblems = 0; + lFedCounter_.nCorruptBuffers = 0; + lFedCounter_.nBadChannels = 0; + lFedCounter_.nBadActiveChannels = 0; + lFedCounter_.nFEDsWithFEOverflows = 0; + lFedCounter_.nFEDsWithFEBadMajorityAddresses = 0; + lFedCounter_.nFEDsWithMissingFEs = 0; + lFedCounter_.nTotalBadChannels = 0; + lFedCounter_.nTotalBadActiveChannels = 0; + + lChCounter_.nNotConnected = 0; + lChCounter_.nUnlocked = 0; + lChCounter_.nOutOfSync = 0; + lChCounter_.nAPVStatusBit = 0; + lChCounter_.nAPVError = 0; + lChCounter_.nAPVAddressError = 0; feCounter_.nFEOverflows = 0; feCounter_.nFEBadMajorityAddresses = 0; @@ -952,14 +950,12 @@ const unsigned int FEDErrors::fedID(){ FEDErrors::FEDCounters & FEDErrors::getFEDErrorsCounters() { - static FEDCounters lFedCounter; - return lFedCounter; + return lFedCounter_; } FEDErrors::ChannelCounters & FEDErrors::getChannelErrorsCounters() { - static ChannelCounters lChCounter; - return lChCounter; + return lChCounter_; } FEDErrors::FECounters & FEDErrors::getFEErrorsCounters() @@ -1034,12 +1030,12 @@ void FEDErrors::addBadAPV(const FEDErrors::APVLevelErrors & aAPV, bool & aFirst) incrementAPVCounters(aAPV); if (aAPV.APVStatusBit && aFirst) { fedErrors_.BadChannelStatusBit = true; - (FEDErrors::getFEDErrorsCounters().nBadChannels)++; + lFedCounter_.nBadChannels++; chErrors_.push_back(std::pair(aAPV.ChannelID,aAPV.IsActive)); if (aAPV.IsActive) { //print(aAPV); fedErrors_.BadActiveChannelStatusBit = true; - (FEDErrors::getFEDErrorsCounters().nBadActiveChannels)++; + lFedCounter_.nBadActiveChannels++; //std::cout << "------ nBadActiveChannels = " << FEDErrors::getFEDErrorsCounters().nBadActiveChannels << std::endl; } aFirst = false; @@ -1055,31 +1051,31 @@ void FEDErrors::incrementFEDCounters() fedErrors_.BadIDs || fedErrors_.BadDAQPacket ) { - (FEDErrors::getFEDErrorsCounters().nDAQProblems)++; - (FEDErrors::getFEDErrorsCounters().nFEDErrors)++; + lFedCounter_.nDAQProblems++; + lFedCounter_.nFEDErrors++; } //FElevel errors if (fedErrors_.FEsOverflow){ - (FEDErrors::getFEDErrorsCounters().nFEDsWithFEOverflows)++; + lFedCounter_.nFEDsWithFEOverflows++; } else if (fedErrors_.FEsMissing){ - (FEDErrors::getFEDErrorsCounters().nFEDsWithMissingFEs)++; + lFedCounter_.nFEDsWithMissingFEs++; } else if (fedErrors_.FEsBadMajorityAddress){ - (FEDErrors::getFEDErrorsCounters().nFEDsWithFEBadMajorityAddresses)++; + lFedCounter_.nFEDsWithFEBadMajorityAddresses++; } if (fedErrors_.FEsOverflow || fedErrors_.FEsBadMajorityAddress || fedErrors_.FEsMissing ){ - (FEDErrors::getFEDErrorsCounters().nFEDsWithFEProblems)++; - (FEDErrors::getFEDErrorsCounters().nFEDErrors)++; + lFedCounter_.nFEDsWithFEProblems++; + lFedCounter_.nFEDErrors++; } else if (fedErrors_.CorruptBuffer) { - (FEDErrors::getFEDErrorsCounters().nCorruptBuffers)++; - (FEDErrors::getFEDErrorsCounters().nFEDErrors)++; + lFedCounter_.nCorruptBuffers++; + lFedCounter_.nFEDErrors++; } @@ -1088,17 +1084,17 @@ void FEDErrors::incrementFEDCounters() void FEDErrors::incrementChannelCounters(const FEDErrors::ChannelLevelErrors & aChannel) { - if (aChannel.Unlocked && aChannel.Connected) (FEDErrors::getChannelErrorsCounters().nUnlocked)++; - if (aChannel.OutOfSync && aChannel.Connected) (FEDErrors::getChannelErrorsCounters().nOutOfSync)++; - if (!aChannel.Connected) (FEDErrors::getChannelErrorsCounters().nNotConnected)++; + if (aChannel.Unlocked && aChannel.Connected) lChCounter_.nUnlocked++; + if (aChannel.OutOfSync && aChannel.Connected) lChCounter_.nOutOfSync++; + if (!aChannel.Connected) lChCounter_.nNotConnected++; } void FEDErrors::incrementAPVCounters(const FEDErrors::APVLevelErrors & aAPV) { if (aAPV.Connected && aAPV.IsActive){ - if (aAPV.APVStatusBit) (FEDErrors::getChannelErrorsCounters().nAPVStatusBit)++; - if (aAPV.APVAddressError) (FEDErrors::getChannelErrorsCounters().nAPVAddressError)++; - if (aAPV.APVError) (FEDErrors::getChannelErrorsCounters().nAPVError)++; + if (aAPV.APVStatusBit) lChCounter_.nAPVStatusBit++; + if (aAPV.APVAddressError) lChCounter_.nAPVAddressError++; + if (aAPV.APVError) lChCounter_.nAPVError++; } } diff --git a/DQM/SiStripMonitorHardware/src/SiStripFEDDataCheck.cc b/DQM/SiStripMonitorHardware/src/SiStripFEDDataCheck.cc index 9646175ef65d2..2b83a0f2d05a2 100644 --- a/DQM/SiStripMonitorHardware/src/SiStripFEDDataCheck.cc +++ b/DQM/SiStripMonitorHardware/src/SiStripFEDDataCheck.cc @@ -43,21 +43,21 @@ #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh" +#include // // Class declaration // -class SiStripFEDCheckPlugin : public edm::EDAnalyzer +class SiStripFEDCheckPlugin : public DQMEDAnalyzer { public: explicit SiStripFEDCheckPlugin(const edm::ParameterSet&); ~SiStripFEDCheckPlugin(); private: - virtual void beginJob() override; virtual void analyze(const edm::Event&, const edm::EventSetup&) override; - virtual void endJob() override; virtual void endRun(); + void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; bool hasFatalError(const FEDRawData& fedData, unsigned int fedId) const; bool hasNonFatalError(const FEDRawData& fedData, unsigned int fedId) const; @@ -75,10 +75,8 @@ class SiStripFEDCheckPlugin : public edm::EDAnalyzer edm::EDGetTokenT rawDataToken_; std::string dirName_; bool printDebug_; - bool writeDQMStore_; //Histograms - DQMStore* dqm_; MonitorElement* fedsPresent_; MonitorElement* fedFatalErrors_; MonitorElement* fedNonFatalErrors_; @@ -108,7 +106,6 @@ SiStripFEDCheckPlugin::SiStripFEDCheckPlugin(const edm::ParameterSet& iConfig) : rawDataTag_(iConfig.getParameter("RawDataTag")), dirName_(iConfig.getUntrackedParameter("DirName","SiStrip/FEDIntegrity/")), printDebug_(iConfig.getUntrackedParameter("PrintDebugMessages",false)), - writeDQMStore_(iConfig.getUntrackedParameter("WriteDQMStore",false)), updateFrequency_(iConfig.getUntrackedParameter("HistogramUpdateFrequency",0)), fedsPresentBinContents_(FEDNumbering::MAXSiStripFEDID+1,0), fedFatalErrorBinContents_(FEDNumbering::MAXSiStripFEDID+1,0), @@ -250,27 +247,25 @@ SiStripFEDCheckPlugin::analyze(const edm::Event& iEvent, const edm::EventSetup& } // ------------ method called once each job just before starting event loop ------------ -void -SiStripFEDCheckPlugin::beginJob() +void SiStripFEDCheckPlugin::bookHistograms(DQMStore::IBooker & ibooker , const edm::Run & run, const edm::EventSetup & eSetup) { //get FED IDs const unsigned int siStripFedIdMin = FEDNumbering::MINSiStripFEDID; const unsigned int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID; //get DQM store - dqm_ = &(*edm::Service()); - dqm_->setCurrentFolder(dirName_); + ibooker.setCurrentFolder(dirName_); //book histograms - fedsPresent_ = dqm_->book1D("FEDEntries", + fedsPresent_ = ibooker.book1D("FEDEntries", "Number of times FED buffer is present in data", siStripFedIdMax-siStripFedIdMin+1, siStripFedIdMin-0.5,siStripFedIdMax+0.5); fedsPresent_->setAxisTitle("FED-ID",1); - fedFatalErrors_ = dqm_->book1D("FEDFatal", + fedFatalErrors_ = ibooker.book1D("FEDFatal", "Number of fatal errors in FED buffer", siStripFedIdMax-siStripFedIdMin+1, siStripFedIdMin-0.5,siStripFedIdMax+0.5); fedFatalErrors_->setAxisTitle("FED-ID",1); - fedNonFatalErrors_ = dqm_->book1D("FEDNonFatal", + fedNonFatalErrors_ = ibooker.book1D("FEDNonFatal", "Number of non fatal errors in FED buffer", siStripFedIdMax-siStripFedIdMin+1, siStripFedIdMin-0.5,siStripFedIdMax+0.5); @@ -284,14 +279,6 @@ SiStripFEDCheckPlugin::endRun() updateHistograms(); } -// ------------ method called once each job just after ending the event loop ------------ -void -SiStripFEDCheckPlugin::endJob() -{ - if (writeDQMStore_) dqm_->save("DQMStore.root"); -} - - void SiStripFEDCheckPlugin::updateCabling(const edm::EventSetup& eventSetup) { uint32_t currentCacheId = eventSetup.get().cacheIdentifier(); diff --git a/DQM/SiStripMonitorHardware/src/SiStripFEDMonitor.cc b/DQM/SiStripMonitorHardware/src/SiStripFEDMonitor.cc index b9e1f969869dc..531bf4785ddf8 100644 --- a/DQM/SiStripMonitorHardware/src/SiStripFEDMonitor.cc +++ b/DQM/SiStripMonitorHardware/src/SiStripFEDMonitor.cc @@ -379,13 +379,15 @@ SiStripFEDMonitorPlugin::analyze(const edm::Event& iEvent, } - FEDErrors::getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels; - FEDErrors::getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels; + //FEDErrors::getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels; + //FEDErrors::getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels; + fedErrors_.getFEDErrorsCounters().nTotalBadChannels = lNTotBadChannels; + fedErrors_.getFEDErrorsCounters().nTotalBadActiveChannels = lNTotBadActiveChannels; //fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(), nEvt_); //time in seconds since beginning of the run or event number - if (fillWithEvtNum_) fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(),FEDErrors::getChannelErrorsCounters(),maxFedBufferSize_,iEvent.id().event()); - else fedHists_.fillCountersHistograms(FEDErrors::getFEDErrorsCounters(),FEDErrors::getChannelErrorsCounters(),maxFedBufferSize_,iEvent.orbitNumber()/11223.); + if (fillWithEvtNum_) fedHists_.fillCountersHistograms(fedErrors_.getFEDErrorsCounters(),fedErrors_.getChannelErrorsCounters(),maxFedBufferSize_,iEvent.id().event()); + else fedHists_.fillCountersHistograms(fedErrors_.getFEDErrorsCounters(),fedErrors_.getChannelErrorsCounters(),maxFedBufferSize_,iEvent.orbitNumber()/11223.); nEvt_++;