Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES DQM: Enable concurrent processing of lumisections #31829

Merged
merged 4 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions DQM/EcalPreshowerMonitorModule/interface/ESIntegrityTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
#include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

class ESIntegrityTask : public DQMOneLumiEDAnalyzer<> {
struct ESLSCache {
int ievtLS_;
int DIErrorsLS_[2][2][40][40];
};

class ESIntegrityTask : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<ESLSCache>> {
public:
ESIntegrityTask(const edm::ParameterSet& ps);
~ESIntegrityTask() override {}
Expand All @@ -27,13 +32,14 @@ class ESIntegrityTask : public DQMOneLumiEDAnalyzer<> {
void dqmEndRun(const edm::Run& r, const edm::EventSetup& c) override;

/// Begin Lumi
void dqmBeginLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& c) override;
std::shared_ptr<ESLSCache> globalBeginLuminosityBlock(const edm::LuminosityBlock& lumi,
const edm::EventSetup& c) const override;

/// End Lumi
void dqmEndLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& c) override;
void globalEndLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& c) override;

/// Calculate Data Integrity Fraction
void calculateDIFraction(void);
void calculateDIFraction(const edm::LuminosityBlock& lumi, const edm::EventSetup& c);

private:
int ievt_;
Expand Down
44 changes: 26 additions & 18 deletions DQM/EcalPreshowerMonitorModule/src/ESIntegrityTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,29 @@ void ESIntegrityTask::dqmEndRun(const Run& r, const EventSetup& c) {
// TODO: no longer possible, clone histo beforehand if full statisticcs at end of run are required.
}

void ESIntegrityTask::dqmBeginLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& c) {
std::shared_ptr<ESLSCache> ESIntegrityTask::globalBeginLuminosityBlock(const edm::LuminosityBlock& lumi,
const edm::EventSetup& c) const {
LogInfo("ESIntegrityTask") << "analyzed " << ievt_ << " events";
// In case of Lumi based analysis SoftReset the Integrity histogram
auto lumiCache = std::make_shared<ESLSCache>();
lumiCache->ievtLS_ = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below here you reset the MonitorElements. That behavior is incompatible with concurrent Lumis as you are sharing the same MonitorElement so you reset it while events of the previous Lumi are still being processed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dr15Jones In that case, is it impossible to have per-lumisection resets with concurrent processing? What if the MonitorElement were part of the luminosity cache (book a new histogram for each lumisection) -- would that work? Or is there another officially supported solution? Sorry, one reason this fix was difficult for ECAL was I tried to look through other subsystems' code and couldn't find these resets...

if (doLumiAnalysis_) {
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
if (meDIErrors_[i][j]) {
meDIErrors_[i][j]->Reset();
for (int iz = 0; iz < 2; ++iz) {
for (int ip = 0; ip < 2; ++ip) {
for (int ix = 0; ix < 40; ++ix) {
for (int iy = 0; iy < 40; ++iy) {
(lumiCache->DIErrorsLS_)[iz][ip][ix][iy] = 0;
}
}
}
}
ievt_ = 0;
}
return lumiCache;
}

void ESIntegrityTask::dqmEndLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& c) {
void ESIntegrityTask::globalEndLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& c) {
if (doLumiAnalysis_)
calculateDIFraction();
calculateDIFraction(lumi, c);
}

void ESIntegrityTask::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const&, edm::EventSetup const&) {
Expand Down Expand Up @@ -178,7 +183,6 @@ void ESIntegrityTask::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const&

if (doLumiAnalysis_) {
sprintf(histo, "ES Good Channel Fraction");
auto scope = DQMStore::IBooker::UseLumiScope(iBooker);
meDIFraction_ = iBooker.book2D(histo, histo, 3, 1.0, 3.0, 3, 1.0, 3.0);
}
}
Expand All @@ -187,6 +191,8 @@ void ESIntegrityTask::endJob(void) { LogInfo("ESIntegrityTask") << "analyzed " <

void ESIntegrityTask::analyze(const Event& e, const EventSetup& c) {
ievt_++;
auto lumiCache = luminosityBlockCache(e.getLuminosityBlock().index());
++(lumiCache->ievtLS_);

Handle<ESRawDataCollection> dccs;
Handle<ESLocalRawDataCollection> kchips;
Expand Down Expand Up @@ -308,34 +314,36 @@ void ESIntegrityTask::analyze(const Event& e, const EventSetup& c) {
if (fed_[iz][ip][ix][iy] == -1)
continue;

if (nDIErr[fed_[iz][ip][ix][iy] - 520][fiber_[iz][ip][ix][iy]] > 0)
if (nDIErr[fed_[iz][ip][ix][iy] - 520][fiber_[iz][ip][ix][iy]] > 0) {
meDIErrors_[iz][ip]->Fill(ix + 1, iy + 1, 1);
if (doLumiAnalysis_)
(lumiCache->DIErrorsLS_)[iz][ip][ix][iy] += 1;
}
}
}
//
// -- Calculate Data Integrity Fraction
//
void ESIntegrityTask::calculateDIFraction(void) {
void ESIntegrityTask::calculateDIFraction(const edm::LuminosityBlock& lumi, const edm::EventSetup& c) {
float nValidChannels = 0;
float nGlobalErrors = 0;
auto lumiCache = luminosityBlockCache(lumi.index());

for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
float nValidChannelsES = 0;
float nGlobalErrorsES = 0;
float reportSummaryES = -1;
if (!meDIErrors_[i][j])
continue;
for (int x = 0; x < 40; ++x) {
for (int y = 0; y < 40; ++y) {
float val = meDIErrors_[i][j]->getBinContent(x + 1, y + 1);
float val = 1.0 * ((lumiCache->DIErrorsLS_)[i][j][x][y]);
if (fed_[i][j][x][y] == -1)
continue;
if (ievt_ != 0)
nGlobalErrors += val / ievt_;
if ((lumiCache->ievtLS_) != 0)
nGlobalErrors += val / (lumiCache->ievtLS_);
nValidChannels++;
if (ievt_ != 0)
nGlobalErrorsES += val / ievt_;
if ((lumiCache->ievtLS_) != 0)
nGlobalErrorsES += val / (lumiCache->ievtLS_);
nValidChannelsES++;
}
}
Expand Down