Skip to content

Commit

Permalink
Merge pull request #29798 from sroychow/updatelegacyTkDQM
Browse files Browse the repository at this point in the history
Update Tracker DQM module to allow concurrent LS processing
  • Loading branch information
cmsbuild committed May 12, 2020
2 parents ec67986 + 81b4eff commit a5c9719
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 79 deletions.
18 changes: 7 additions & 11 deletions DQM/SiStripMonitorHardware/interface/FEDErrors.hh
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ public:
bool operator<(const APVLevelErrors& aErr) const;
};

struct LumiErrors {
std::vector<unsigned int> nTotal;
std::vector<unsigned int> nErrors;
};

struct EventProperties {
long long deltaBX;
};
Expand Down Expand Up @@ -185,7 +180,9 @@ public:
MonitorElement* aFedIdVsApvId,
unsigned int& aNBadChannels,
unsigned int& aNBadActiveChannels,
unsigned int& aNBadChannels_perFEDID);
unsigned int& aNBadChannels_perFEDID,
std::vector<unsigned int>& nTotal,
std::vector<unsigned int>& nErrors);

void fillEventProperties(long long dbx);

Expand Down Expand Up @@ -221,8 +218,6 @@ public:

std::vector<std::pair<unsigned int, bool> >& getBadChannels();

const LumiErrors& getLumiErrors();

void addBadFE(const FELevelErrors& aFE);

void addBadChannel(const ChannelLevelErrors& aChannel);
Expand All @@ -244,7 +239,10 @@ public:

protected:
private:
void incrementLumiErrors(const bool hasError, const unsigned int aSubDet);
void incrementLumiErrors(const bool hasError,
const unsigned int aSubDet,
std::vector<unsigned int>& nTotal,
std::vector<unsigned int>& nErrors);

void processDet(const uint32_t aPrevId,
const uint16_t aPrevTot,
Expand Down Expand Up @@ -272,8 +270,6 @@ private:

bool failUnpackerFEDCheck_;

LumiErrors lumiErr_;

EventProperties eventProp_;

}; //class
Expand Down
4 changes: 1 addition & 3 deletions DQM/SiStripMonitorHardware/interface/FEDHistograms.hh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public:

bool feMajHistosEnabled();

void fillLumiHistograms(const FEDErrors::LumiErrors &aLumErr);
void fillLumiHistograms(const std::vector<unsigned int> &nTotal, const std::vector<unsigned int> &nErrors);

bool cmHistosEnabled();

Expand Down Expand Up @@ -153,8 +153,6 @@ private:
HistogramConfig tkMapConfig_;
std::unique_ptr<TkHistoMap> tkmapFED_;

HistogramConfig lumiErrorFraction_;

}; //class

#endif //DQM_SiStripMonitorHardware_FEDHistograms_HH
32 changes: 14 additions & 18 deletions DQM/SiStripMonitorHardware/src/FEDErrors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ FEDErrors::FEDErrors() {

FEDErrors::~FEDErrors() {}

void FEDErrors::initialiseLumiBlock() {
lumiErr_.nTotal.clear();
lumiErr_.nErrors.clear();
//6 subdetectors:
//TECB,TECF,TIB,TIDB,TIDF,TOB
lumiErr_.nTotal.resize(6, 0);
lumiErr_.nErrors.resize(6, 0);
}
void FEDErrors::initialiseLumiBlock() {}

void FEDErrors::initialiseEvent() {
fedID_ = 0;
Expand Down Expand Up @@ -686,7 +679,9 @@ void FEDErrors::fillBadChannelList(const bool doTkHistoMap,
MonitorElement* aFedIdVsApvId,
unsigned int& aNBadChannels,
unsigned int& aNBadActiveChannels,
unsigned int& aNBadChannels_perFEDID) {
unsigned int& aNBadChannels_perFEDID,
std::vector<unsigned int>& nTotal,
std::vector<unsigned int>& nErrors) {
uint32_t lPrevId = 0;
uint16_t nBad = 0;
uint16_t lPrevTot = 0;
Expand Down Expand Up @@ -760,7 +755,7 @@ void FEDErrors::fillBadChannelList(const bool doTkHistoMap,
}

bool lHasErr = lFailFED || isBadFE || isBadChan;
incrementLumiErrors(lHasErr, subDetId_[feNumber]);
incrementLumiErrors(lHasErr, subDetId_[feNumber], nTotal, nErrors);

if (lHasErr) {
nBad++;
Expand All @@ -784,16 +779,19 @@ void FEDErrors::fillBadChannelList(const bool doTkHistoMap,

void FEDErrors::fillEventProperties(long long dbx) { eventProp_.deltaBX = dbx; }

void FEDErrors::incrementLumiErrors(const bool hasError, const unsigned int aSubDet) {
if (lumiErr_.nTotal.empty())
void FEDErrors::incrementLumiErrors(const bool hasError,
const unsigned int aSubDet,
std::vector<unsigned int>& nTotal,
std::vector<unsigned int>& nErrors) {
if (nTotal.empty())
return;
if (aSubDet >= lumiErr_.nTotal.size()) {
if (aSubDet >= nTotal.size()) {
edm::LogError("SiStripMonitorHardware") << " -- FED " << fedID_ << ", invalid subdetid : " << aSubDet
<< ", size of lumiErr : " << lumiErr_.nTotal.size() << std::endl;
<< ", size of lumiErr : " << nTotal.size() << std::endl;
} else {
if (hasError)
lumiErr_.nErrors[aSubDet]++;
lumiErr_.nTotal[aSubDet]++;
nErrors[aSubDet]++;
nTotal[aSubDet]++;
}
}

Expand Down Expand Up @@ -855,8 +853,6 @@ std::vector<FEDErrors::APVLevelErrors>& FEDErrors::getAPVLevelErrors() { return

std::vector<std::pair<unsigned int, bool> >& FEDErrors::getBadChannels() { return chErrors_; }

const FEDErrors::LumiErrors& FEDErrors::getLumiErrors() { return lumiErr_; }

void FEDErrors::addBadFE(const FEDErrors::FELevelErrors& aFE) {
if (aFE.Overflow) {
fedErrors_.FEsOverflow = true;
Expand Down
36 changes: 0 additions & 36 deletions DQM/SiStripMonitorHardware/src/FEDHistograms.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ void FEDHistograms::initialise(const edm::ParameterSet& iConfig, std::ostringstr
getConfigForHistogram(medianAPV0_, "MedianAPV0", iConfig, pDebugStream);
getConfigForHistogram(medianAPV1_, "MedianAPV1", iConfig, pDebugStream);

getConfigForHistogram(lumiErrorFraction_, "ErrorFractionByLumiBlock", iConfig, pDebugStream);

getConfigForHistogram(fedIdVsApvId_, "FedIdVsApvId", iConfig, pDebugStream);

getConfigForHistogram(fedErrorsVsId_, "FedErrorsVsId", iConfig, pDebugStream);
Expand Down Expand Up @@ -337,16 +335,6 @@ bool FEDHistograms::feMajHistosEnabled() {
badMajorityInPartition_.enabled);
}

void FEDHistograms::fillLumiHistograms(const FEDErrors::LumiErrors& aLumErr) {
if (lumiErrorFraction_.enabled && lumiErrorFraction_.monitorEle) {
lumiErrorFraction_.monitorEle->Reset();
for (unsigned int iD(0); iD < aLumErr.nTotal.size(); iD++) {
if (aLumErr.nTotal[iD] > 0)
fillHistogram(lumiErrorFraction_, iD + 1, static_cast<float>(aLumErr.nErrors[iD]) / aLumErr.nTotal[iD]);
}
}
}

bool FEDHistograms::cmHistosEnabled() { return (medianAPV0_.enabled || medianAPV1_.enabled); }

FEDHistograms::MonitorElement* FEDHistograms::cmHistPointer(bool aApv1) {
Expand Down Expand Up @@ -893,30 +881,6 @@ void FEDHistograms::bookTopLevelHistograms(DQMStore::IBooker& ibooker,
"Time",
"# APVs with APVAddressError");

ibooker.setCurrentFolder(lBaseDir + "/PerLumiSection");

{
auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
bookHistogram(ibooker,
lumiErrorFraction_,
"lumiErrorFraction",
"Fraction of error per lumi section vs subdetector",
6,
0.5,
6.5,
"SubDetId");
}

//Set special property for lumi ME
if (lumiErrorFraction_.enabled && lumiErrorFraction_.monitorEle) {
lumiErrorFraction_.monitorEle->setBinLabel(1, "TECB");
lumiErrorFraction_.monitorEle->setBinLabel(2, "TECF");
lumiErrorFraction_.monitorEle->setBinLabel(3, "TIB");
lumiErrorFraction_.monitorEle->setBinLabel(4, "TIDB");
lumiErrorFraction_.monitorEle->setBinLabel(5, "TIDF");
lumiErrorFraction_.monitorEle->setBinLabel(6, "TOB");
}

//book map after, as it creates a new folder...
if (tkMapConfig_.enabled) {
tkmapFED_ = std::make_unique<TkHistoMap>(tkDetMap, topFolderName, "TkHMap_FractionOfBadChannels", 0., true);
Expand Down
76 changes: 65 additions & 11 deletions DQM/SiStripMonitorHardware/src/SiStripFEDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,27 @@
// Class declaration
//

class SiStripFEDMonitorPlugin : public DQMOneLumiEDAnalyzer<> {
//class SiStripFEDMonitorPlugin : public DQMOneLumiEDAnalyzer<> {

namespace sifedmon {
struct LumiErrors {
std::vector<unsigned int> nTotal;
std::vector<unsigned int> nErrors;
};
} // namespace sifedmon
class SiStripFEDMonitorPlugin : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<sifedmon::LumiErrors> > {
public:
explicit SiStripFEDMonitorPlugin(const edm::ParameterSet&);
~SiStripFEDMonitorPlugin() override;

private:
void analyze(const edm::Event&, const edm::EventSetup&) override;
void dqmBeginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context) override;
void dqmEndLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context) override;

std::shared_ptr<sifedmon::LumiErrors> globalBeginLuminosityBlock(const edm::LuminosityBlock& lumi,
const edm::EventSetup& iSetup) const override;

void globalEndLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& iSetup) override;

void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;

//update the cabling if necessary
Expand Down Expand Up @@ -110,8 +122,10 @@ class SiStripFEDMonitorPlugin : public DQMOneLumiEDAnalyzer<> {
//need class member for lumi histograms
FEDErrors fedErrors_;
unsigned int maxFedBufferSize_;

bool fullDebugMode_;

bool enableFEDerrLumi_;
MonitorElement* lumiErrfac_;
};

//
Expand All @@ -133,6 +147,11 @@ SiStripFEDMonitorPlugin::SiStripFEDMonitorPlugin(const edm::ParameterSet& iConfi
rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
heToken_ = consumes<EventWithHistory>(edm::InputTag("consecutiveHEs"));

if (iConfig.exists("ErrorFractionByLumiBlockHistogramConfig")) {
const edm::ParameterSet& ps =
iConfig.getUntrackedParameter<edm::ParameterSet>("ErrorFractionByLumiBlockHistogramConfig");
enableFEDerrLumi_ = (ps.exists("Enabled") ? ps.getUntrackedParameter<bool>("Enabled") : true);
}
//print config to debug log
std::ostringstream debugStream;
if (printDebug_ > 1) {
Expand Down Expand Up @@ -191,6 +210,11 @@ void SiStripFEDMonitorPlugin::analyze(const edm::Event& iEvent, const edm::Event
edm::Handle<EventWithHistory> he;
iEvent.getByToken(heToken_, he);

//get the fedErrors object for each LS
auto lumiErrors = luminosityBlockCache(iEvent.getLuminosityBlock().index());
auto& nToterr = lumiErrors->nTotal;
auto& nErr = lumiErrors->nErrors;

if (he.isValid() && !he.failedToGet()) {
fedErrors_.fillEventProperties(he->deltaBX());
}
Expand Down Expand Up @@ -305,7 +329,9 @@ void SiStripFEDMonitorPlugin::analyze(const edm::Event& iEvent, const edm::Event
fedHists_.getFedvsAPVpointer(),
lNTotBadChannels,
lNTotBadActiveChannels,
lNBadChannels_perFEDID);
lNBadChannels_perFEDID,
nToterr,
nErr);
fedHists_.fillFEDHistograms(fedErrors_, lSize, fullDebugMode_, aLumiSection, lNBadChannels_perFEDID);
} //loop over FED IDs

Expand Down Expand Up @@ -463,16 +489,44 @@ void SiStripFEDMonitorPlugin::bookHistograms(DQMStore::IBooker& ibooker,

if (fillAllDetailedHistograms_)
fedHists_.bookAllFEDHistograms(ibooker, fullDebugMode_);

if (enableFEDerrLumi_) {
ibooker.cd();
ibooker.setCurrentFolder("SiStrip/ReadoutView/PerLumiSection");
{
auto scope = DQMStore::IBooker::UseRunScope(ibooker);
lumiErrfac_ =
ibooker.book1D("lumiErrorFraction", "Fraction of error per lumi section vs subdetector", 6, 0.5, 6.5);
lumiErrfac_->setAxisTitle("SubDetId", 1);
lumiErrfac_->setBinLabel(1, "TECB");
lumiErrfac_->setBinLabel(2, "TECF");
lumiErrfac_->setBinLabel(3, "TIB");
lumiErrfac_->setBinLabel(4, "TIDB");
lumiErrfac_->setBinLabel(5, "TIDF");
lumiErrfac_->setBinLabel(6, "TOB");
}
} else {
lumiErrfac_ = nullptr;
}
}

void SiStripFEDMonitorPlugin::dqmBeginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
const edm::EventSetup& context) {
fedErrors_.initialiseLumiBlock();
std::shared_ptr<sifedmon::LumiErrors> SiStripFEDMonitorPlugin::globalBeginLuminosityBlock(
const edm::LuminosityBlock& lumi, const edm::EventSetup& iSetup) const {
auto lumiErrors = std::make_shared<sifedmon::LumiErrors>();
lumiErrors->nTotal.resize(6, 0);
lumiErrors->nErrors.resize(6, 0);
return lumiErrors;
}

void SiStripFEDMonitorPlugin::dqmEndLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
const edm::EventSetup& context) {
fedHists_.fillLumiHistograms(fedErrors_.getLumiErrors());
void SiStripFEDMonitorPlugin::globalEndLuminosityBlock(const edm::LuminosityBlock& lumi,
const edm::EventSetup& iSetup) {
auto lumiErrors = luminosityBlockCache(lumi.index());
if (enableFEDerrLumi_ && lumiErrfac_) {
for (unsigned int iD(0); iD < lumiErrors->nTotal.size(); iD++) {
if (lumiErrors->nTotal[iD] > 0)
lumiErrfac_->Fill(iD + 1, static_cast<float>(lumiErrors->nErrors[iD]) / lumiErrors->nTotal[iD]);
}
}
}

void SiStripFEDMonitorPlugin::updateCabling(const edm::EventSetup& eventSetup) {
Expand Down

0 comments on commit a5c9719

Please sign in to comment.