Skip to content

Commit

Permalink
thread-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
threus committed Jun 13, 2014
1 parent 623d781 commit e3d8a02
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 68 deletions.
7 changes: 5 additions & 2 deletions DQM/SiStripMonitorHardware/interface/FEDErrors.hh
Expand Up @@ -204,9 +204,9 @@ public:

const unsigned int fedID();

static FEDCounters & getFEDErrorsCounters();
FEDCounters & getFEDErrorsCounters();

static ChannelCounters & getChannelErrorsCounters();
ChannelCounters & getChannelErrorsCounters();

FECounters & getFEErrorsCounters();

Expand Down Expand Up @@ -268,6 +268,9 @@ private:

FECounters feCounter_;
FEDLevelErrors fedErrors_;
ChannelCounters lChCounter_;
FEDCounters lFedCounter_;

std::vector<FELevelErrors> feErrors_;
std::vector<ChannelLevelErrors> chErrorsDetailed_;
std::vector<APVLevelErrors> apvErrors_;
Expand Down
78 changes: 37 additions & 41 deletions DQM/SiStripMonitorHardware/src/FEDErrors.cc
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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<unsigned int, bool>(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;
Expand All @@ -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++;
}


Expand All @@ -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++;
}
}

Expand Down
29 changes: 8 additions & 21 deletions DQM/SiStripMonitorHardware/src/SiStripFEDDataCheck.cc
Expand Up @@ -43,21 +43,21 @@

#include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"

#include <DQMServices/Core/interface/DQMEDAnalyzer.h>

//
// 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;
Expand All @@ -75,10 +75,8 @@ class SiStripFEDCheckPlugin : public edm::EDAnalyzer
edm::EDGetTokenT<FEDRawDataCollection> rawDataToken_;
std::string dirName_;
bool printDebug_;
bool writeDQMStore_;

//Histograms
DQMStore* dqm_;
MonitorElement* fedsPresent_;
MonitorElement* fedFatalErrors_;
MonitorElement* fedNonFatalErrors_;
Expand Down Expand Up @@ -108,7 +106,6 @@ SiStripFEDCheckPlugin::SiStripFEDCheckPlugin(const edm::ParameterSet& iConfig)
: rawDataTag_(iConfig.getParameter<edm::InputTag>("RawDataTag")),
dirName_(iConfig.getUntrackedParameter<std::string>("DirName","SiStrip/FEDIntegrity/")),
printDebug_(iConfig.getUntrackedParameter<bool>("PrintDebugMessages",false)),
writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)),
updateFrequency_(iConfig.getUntrackedParameter<unsigned int>("HistogramUpdateFrequency",0)),
fedsPresentBinContents_(FEDNumbering::MAXSiStripFEDID+1,0),
fedFatalErrorBinContents_(FEDNumbering::MAXSiStripFEDID+1,0),
Expand Down Expand Up @@ -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<DQMStore>());
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);
Expand All @@ -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<SiStripFedCablingRcd>().cacheIdentifier();
Expand Down
10 changes: 6 additions & 4 deletions DQM/SiStripMonitorHardware/src/SiStripFEDMonitor.cc
Expand Up @@ -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_++;

Expand Down

0 comments on commit e3d8a02

Please sign in to comment.