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

Fix to allow concurrent processing of lumisections with ECAL DQM #31689

Merged
merged 4 commits into from
Oct 19, 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
13 changes: 9 additions & 4 deletions DQM/EcalCommon/interface/EcalDQMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace edm {
} // namespace edm

namespace ecaldqm {
struct EcalLSCache {
std::map<std::string, bool> ByLumiPlotsResetSwitches;
bool lhcStatusSet_;
};

class EcalDQMonitor {
public:
EcalDQMonitor(edm::ParameterSet const &);
Expand All @@ -28,25 +33,25 @@ namespace ecaldqm {
void ecaldqmGetSetupObjects(edm::EventSetup const &);
void ecaldqmBeginRun(edm::Run const &, edm::EventSetup const &);
void ecaldqmEndRun(edm::Run const &, edm::EventSetup const &);
void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &);
void ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const;
void ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &);

template <typename FuncOnWorker>
void executeOnWorkers_(FuncOnWorker,
std::string const &,
std::string const & = "",
int = 1); // loop over workers and capture exceptions
int = 1) const; // loop over workers and capture exceptions

std::vector<DQWorker *> workers_;
std::string const moduleName_;
int const verbosity_;
const int verbosity_;
};

template <typename FuncOnWorker>
void EcalDQMonitor::executeOnWorkers_(FuncOnWorker _func,
std::string const &_context,
std::string const &_message /* = ""*/,
int _verbThreshold /* = 1*/) {
int _verbThreshold /* = 1*/) const {
std::for_each(workers_.begin(), workers_.end(), [&](DQWorker *worker) {
if (verbosity_ > _verbThreshold && !_message.empty())
edm::LogInfo("EcalDQM") << moduleName_ << ": " << _message << " @ " << worker->getName();
Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalCommon/src/EcalDQMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace ecaldqm {
edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndRun";
}

void EcalDQMonitor::ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &_lumi, edm::EventSetup const &_es) {
void EcalDQMonitor::ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &_lumi, edm::EventSetup const &_es) const {
executeOnWorkers_(
[&_lumi, &_es](DQWorker *worker) {
if (worker->onlineMode())
Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/ClusterTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace ecaldqm {

void addDependencies(DependencySet&) override;

void beginEvent(edm::Event const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;
void endEvent(edm::Event const&, edm::EventSetup const&) override;

bool analyze(void const*, Collections) override;
Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/DQWorkerTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace ecaldqm {

static void fillDescriptions(edm::ParameterSetDescription&);

virtual void beginEvent(edm::Event const&, edm::EventSetup const&) {}
virtual void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) {}
virtual void endEvent(edm::Event const&, edm::EventSetup const&) {}

virtual bool filterRunType(short const*) { return true; };
Expand Down
14 changes: 8 additions & 6 deletions DQM/EcalMonitorTasks/interface/EcalDQMonitorTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace edm {
class ParameterSetDescription;
} // namespace edm

class EcalDQMonitorTask : public DQMOneLumiEDAnalyzer<>, public ecaldqm::EcalDQMonitor {
class EcalDQMonitorTask : public DQMOneEDAnalyzer<edm::LuminosityBlockCache<ecaldqm::EcalLSCache>>,
public ecaldqm::EcalDQMonitor {
public:
EcalDQMonitorTask(edm::ParameterSet const&);
~EcalDQMonitorTask() override {}
Expand All @@ -27,8 +28,9 @@ class EcalDQMonitorTask : public DQMOneLumiEDAnalyzer<>, public ecaldqm::EcalDQM

private:
void dqmEndRun(edm::Run const&, edm::EventSetup const&) override;
void dqmBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void dqmEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
std::shared_ptr<ecaldqm::EcalLSCache> globalBeginLuminosityBlock(edm::LuminosityBlock const&,
edm::EventSetup const&) const override;
void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void analyze(edm::Event const&, edm::EventSetup const&) override;

typedef void (EcalDQMonitorTask::*Processor)(edm::Event const&,
Expand All @@ -42,9 +44,9 @@ class EcalDQMonitorTask : public DQMOneLumiEDAnalyzer<>, public ecaldqm::EcalDQM

/* DATA MEMBERS */

edm::EDGetToken collectionTokens_[ecaldqm::nCollections]; // list of EDGetTokens
std::vector<std::pair<Processor, ecaldqm::Collections> > schedule_; // schedule of collections to run
bool allowMissingCollections_; // when true, skip missing collections silently
edm::EDGetToken collectionTokens_[ecaldqm::nCollections]; // list of EDGetTokens
std::vector<std::pair<Processor, ecaldqm::Collections>> schedule_; // schedule of collections to run
bool allowMissingCollections_; // when true, skip missing collections silently
int processedEvents_;

/* TASK TIME PROFILING */
Expand Down
3 changes: 1 addition & 2 deletions DQM/EcalMonitorTasks/interface/EnergyTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ namespace ecaldqm {

bool filterRunType(short const*) override;

void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;

void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;
bool analyze(void const*, Collections) override;

void runOnRecHits(EcalRecHitCollection const&);
Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/IntegrityTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ecaldqm {
IntegrityTask();
~IntegrityTask() override {}

void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;

bool analyze(void const*, Collections) override;

Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/LaserTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ecaldqm {

void beginRun(edm::Run const&, edm::EventSetup const&) override;
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;

bool analyze(void const*, Collections) override;

Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/LedTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ecaldqm {

void beginRun(edm::Run const&, edm::EventSetup const&) override;
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;

bool analyze(void const*, Collections) override;

Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/OccupancyTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ecaldqm {

bool filterRunType(short const*) override;

void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;

bool analyze(void const*, Collections) override;

Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/PresampleTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ namespace ecaldqm {

bool filterRunType(short const*) override;

void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;
bool analyze(void const*, Collections) override;

template <typename DigiCollection>
void runOnDigis(DigiCollection const&);

private:
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void setParams(edm::ParameterSet const&) override;

bool doPulseMaxCheck_;
Expand Down
3 changes: 1 addition & 2 deletions DQM/EcalMonitorTasks/interface/RawDataTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ namespace ecaldqm {
void addDependencies(DependencySet&) override;

void beginRun(edm::Run const&, edm::EventSetup const&) override;
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;

bool analyze(void const*, Collections) override;

Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/interface/SelectiveReadoutTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace ecaldqm {
void addDependencies(DependencySet&) override;

void beginRun(edm::Run const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;

bool analyze(void const*, Collections) override;

Expand Down
3 changes: 1 addition & 2 deletions DQM/EcalMonitorTasks/interface/TimingTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ namespace ecaldqm {
void runOnUncalibRecHits(EcalUncalibratedRecHitCollection const&);

private:
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;
void setParams(edm::ParameterSet const&) override;

std::vector<int> bxBinEdges_;
Expand Down
4 changes: 1 addition & 3 deletions DQM/EcalMonitorTasks/interface/TrigPrimTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace ecaldqm {
void addDependencies(DependencySet&) override;

void beginRun(edm::Run const&, edm::EventSetup const&) override;
void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&) override;
void beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) override;

bool analyze(void const*, Collections) override;

Expand Down Expand Up @@ -60,7 +59,6 @@ namespace ecaldqm {

edm::InputTag lhcStatusInfoCollectionTag_;
edm::EDGetTokenT<TCDSRecord> lhcStatusInfoRecordToken_;
bool lhcStatusSet_;
};

inline bool TrigPrimTask::analyze(void const* _p, Collections _collection) {
Expand Down
26 changes: 21 additions & 5 deletions DQM/EcalMonitorTasks/plugins/EcalDQMonitorTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <sstream>

EcalDQMonitorTask::EcalDQMonitorTask(edm::ParameterSet const& _ps)
: DQMOneLumiEDAnalyzer(),
: DQMOneEDAnalyzer<edm::LuminosityBlockCache<ecaldqm::EcalLSCache>>(),
ecaldqm::EcalDQMonitor(_ps),
schedule_(),
allowMissingCollections_(_ps.getUntrackedParameter<bool>("allowMissingCollections")),
Expand Down Expand Up @@ -119,11 +119,22 @@ void EcalDQMonitorTask::dqmEndRun(edm::Run const& _run, edm::EventSetup const& _
executeOnWorkers_([](ecaldqm::DQWorker* worker) { worker->releaseMEs(); }, "releaseMEs", "releasing histograms");
}

void EcalDQMonitorTask::dqmBeginLuminosityBlock(edm::LuminosityBlock const& _lumi, edm::EventSetup const& _es) {
std::shared_ptr<ecaldqm::EcalLSCache> EcalDQMonitorTask::globalBeginLuminosityBlock(edm::LuminosityBlock const& _lumi,
edm::EventSetup const& _es) const {
std::shared_ptr<ecaldqm::EcalLSCache> tmpCache = std::make_shared<ecaldqm::EcalLSCache>();
executeOnWorkers_(
[&tmpCache](ecaldqm::DQWorker* worker) { (tmpCache->ByLumiPlotsResetSwitches)[worker->getName()] = true; },
"globalBeginLuminosityBlock");
if (this->verbosity_ > 2)
edm::LogInfo("EcalDQM") << "Set LS cache.";

// Reset lhcStatusSet_ to false at the beginning of each LS; when LHC status is set in some event this variable will be set to tru
tmpCache->lhcStatusSet_ = false;
ecaldqmBeginLuminosityBlock(_lumi, _es);
return tmpCache;
}

void EcalDQMonitorTask::dqmEndLuminosityBlock(edm::LuminosityBlock const& _lumi, edm::EventSetup const& _es) {
void EcalDQMonitorTask::globalEndLuminosityBlock(edm::LuminosityBlock const& _lumi, edm::EventSetup const& _es) {
ecaldqmEndLuminosityBlock(_lumi, _es);

if (lastResetTime_ != 0 && (time(nullptr) - lastResetTime_) / 3600. > resetInterval_) {
Expand Down Expand Up @@ -185,13 +196,18 @@ void EcalDQMonitorTask::analyze(edm::Event const& _evt, edm::EventSetup const& _
++processedEvents_;

// start event processing
auto lumiCache = luminosityBlockCache(_evt.getLuminosityBlock().index());
executeOnWorkers_(
[&_evt, &_es, &enabledTasks](ecaldqm::DQWorker* worker) {
[&_evt, &_es, &enabledTasks, &lumiCache](ecaldqm::DQWorker* worker) {
if (enabledTasks.find(worker) != enabledTasks.end()) {
if (worker->onlineMode())
worker->setTime(time(nullptr));
worker->setEventNumber(_evt.id().event());
static_cast<ecaldqm::DQWorkerTask*>(worker)->beginEvent(_evt, _es);
bool ByLumiResetSwitch = (lumiCache->ByLumiPlotsResetSwitches).at(worker->getName());
bool lhcStatusSet = lumiCache->lhcStatusSet_;
static_cast<ecaldqm::DQWorkerTask*>(worker)->beginEvent(_evt, _es, ByLumiResetSwitch, lhcStatusSet);
(lumiCache->ByLumiPlotsResetSwitches)[worker->getName()] = false;
lumiCache->lhcStatusSet_ = lhcStatusSet;
}
},
"beginEvent");
Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/src/ClusterTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace ecaldqm {
_dependencies.push_back(Dependency(kEESuperCluster, kEERecHit));
}

void ClusterTask::beginEvent(edm::Event const& _evt, edm::EventSetup const& _es) {
void ClusterTask::beginEvent(edm::Event const& _evt, edm::EventSetup const& _es, bool const&, bool&) {
if (!doExtra_)
return;

Expand Down
7 changes: 4 additions & 3 deletions DQM/EcalMonitorTasks/src/EnergyTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ namespace ecaldqm {
return false;
}

void EnergyTask::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
// Reset by LS plots at beginning of every LS
MEs_.at("HitMapAllByLumi").reset();
void EnergyTask::beginEvent(edm::Event const& _evt, edm::EventSetup const& _es, bool const& ByLumiResetSwitch, bool&) {
if (ByLumiResetSwitch) {
MEs_.at("HitMapAllByLumi").reset();
}
}

void EnergyTask::runOnRecHits(EcalRecHitCollection const& _hits) {
Expand Down
12 changes: 8 additions & 4 deletions DQM/EcalMonitorTasks/src/IntegrityTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
namespace ecaldqm {
IntegrityTask::IntegrityTask() : DQWorkerTask() {}

void IntegrityTask::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
// Reset by LS plots at beginning of every LS
MEs_.at("MapByLumi").reset();
MEs_.at("ByLumi").reset();
void IntegrityTask::beginEvent(edm::Event const& _evt,
edm::EventSetup const& _es,
bool const& ByLumiResetSwitch,
bool&) {
if (ByLumiResetSwitch) {
MEs_.at("MapByLumi").reset();
MEs_.at("ByLumi").reset();
}
}

template <typename IDCollection>
Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/src/LaserTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace ecaldqm {
emptyLS_ = -1;
}

void LaserTask::beginEvent(edm::Event const& _evt, edm::EventSetup const&) { pnAmp_.clear(); }
void LaserTask::beginEvent(edm::Event const& _evt, edm::EventSetup const&, bool const&, bool&) { pnAmp_.clear(); }

void LaserTask::runOnRawData(EcalRawDataCollection const& _rawData) {
MESet& meCalibStatus(MEs_.at("CalibStatus"));
Expand Down
2 changes: 1 addition & 1 deletion DQM/EcalMonitorTasks/src/LedTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace ecaldqm {
emptyLS_ = -1;
}

void LedTask::beginEvent(edm::Event const&, edm::EventSetup const&) { pnAmp_.clear(); }
void LedTask::beginEvent(edm::Event const&, edm::EventSetup const&, bool const&, bool&) { pnAmp_.clear(); }

void LedTask::runOnRawData(EcalRawDataCollection const& _rawData) {
MESet& meCalibStatus(MEs_.at("CalibStatus"));
Expand Down
14 changes: 9 additions & 5 deletions DQM/EcalMonitorTasks/src/OccupancyTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ namespace ecaldqm {
return false;
}

void OccupancyTask::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
// Reset by LS plots at beginning of every LS
MEs_.at("DigiAllByLumi").reset();
MEs_.at("TPDigiThrAllByLumi").reset();
MEs_.at("RecHitThrAllByLumi").reset();
void OccupancyTask::beginEvent(edm::Event const& _evt,
edm::EventSetup const& _es,
bool const& ByLumiResetSwitch,
bool&) {
if (ByLumiResetSwitch) {
MEs_.at("DigiAllByLumi").reset();
MEs_.at("TPDigiThrAllByLumi").reset();
MEs_.at("RecHitThrAllByLumi").reset();
}
}

void OccupancyTask::runOnRawData(EcalRawDataCollection const& _dcchs) {
Expand Down
19 changes: 12 additions & 7 deletions DQM/EcalMonitorTasks/src/PresampleTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ namespace ecaldqm {
return false;
}

void PresampleTask::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
// Fill separate MEs with only 10 LSs worth of stats
// Used to correctly fill Presample Trend plots:
// 1 pt:10 LS in Trend plots
mePedestalByLS = &MEs_.at("PedestalByLS");
if (timestamp_.iLumi % 10 == 0)
mePedestalByLS->reset();
void PresampleTask::beginEvent(edm::Event const& _evt,
edm::EventSetup const& _es,
bool const& ByLumiResetSwitch,
bool&) {
if (ByLumiResetSwitch) {
// Fill separate MEs with only 10 LSs worth of stats
// Used to correctly fill Presample Trend plots:
// 1 pt:10 LS in Trend plots
mePedestalByLS = &MEs_.at("PedestalByLS");
if (timestamp_.iLumi % 10 == 0)
mePedestalByLS->reset();
}
}

template <typename DigiCollection>
Expand Down
14 changes: 6 additions & 8 deletions DQM/EcalMonitorTasks/src/RawDataTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ namespace ecaldqm {

void RawDataTask::beginRun(edm::Run const& _run, edm::EventSetup const&) { runNumber_ = _run.run(); }

void RawDataTask::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
// Reset by LS plots at beginning of every LS
MEs_.at("DesyncByLumi").reset();
MEs_.at("FEByLumi").reset();
MEs_.at("FEStatusErrMapByLumi").reset();
}

void RawDataTask::beginEvent(edm::Event const& _evt, edm::EventSetup const&) {
void RawDataTask::beginEvent(edm::Event const& _evt, edm::EventSetup const&, bool const& ByLumiResetSwitch, bool&) {
orbit_ = _evt.orbitNumber() & 0xffffffff;
bx_ = _evt.bunchCrossing() & 0xfff;
triggerType_ = _evt.experimentType() & 0xf;
l1A_ = 0;
feL1Offset_ = _evt.isRealData() ? 1 : 0;
if (ByLumiResetSwitch) {
MEs_.at("DesyncByLumi").reset();
MEs_.at("FEByLumi").reset();
MEs_.at("FEStatusErrMapByLumi").reset();
}
}

void RawDataTask::runOnSource(FEDRawDataCollection const& _fedRaw) {
Expand Down
Loading