Skip to content

Commit

Permalink
Use ProcessBlock in Harvesting.
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiml committed Jul 14, 2020
1 parent 692a8d5 commit ddd9303
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 4 additions & 6 deletions DQMServices/Components/plugins/DQMFileSaver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace saverDetails {
// - This includes ALCAHARVEST. TODO: check if the data written there is needed for the PCL.
// This module is not used in online. This module is (hopefully?) not used at HLT.
// Online and HLT use modules in DQMServices/FileIO.
class DQMFileSaver : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
class DQMFileSaver : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::WatchProcessBlock> {
public:
typedef dqm::legacy::DQMStore DQMStore;
typedef dqm::legacy::MonitorElement MonitorElement;
Expand All @@ -35,7 +35,7 @@ class DQMFileSaver : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
void beginRun(edm::Run const &, edm::EventSetup const &) override{};
void analyze(const edm::Event &e, const edm::EventSetup &) override;
void endRun(const edm::Run &, const edm::EventSetup &) override;
void endJob() override;
void endProcessBlock(const edm::ProcessBlock &) override;

private:
void saveForOffline(const std::string &workflow, int run, int lumi);
Expand Down Expand Up @@ -147,10 +147,8 @@ DQMFileSaver::DQMFileSaver(const edm::ParameterSet &ps)
dbe_(&*edm::Service<DQMStore>()),
nrun_(0),
irun_(0) {
// Note: this is insufficient, we also need to enforce running *after* all
// DQMEDAnalyzers (a.k.a. EDProducers) in endJob.
// This is not supported in edm currently.
consumesMany<DQMToken, edm::InRun>();
consumesMany<DQMToken, edm::InProcess>();
workflow_ = ps.getUntrackedParameter<std::string>("workflow", workflow_);
if (workflow_.empty() || workflow_[0] != '/' || *workflow_.rbegin() == '/' ||
std::count(workflow_.begin(), workflow_.end(), '/') != 3 ||
Expand Down Expand Up @@ -208,7 +206,7 @@ void DQMFileSaver::endRun(const edm::Run &iRun, const edm::EventSetup &) {
}
}

void DQMFileSaver::endJob() {
void DQMFileSaver::endProcessBlock(const edm::ProcessBlock &) {
if (saveAtJobEnd_) {
if (forceRunNumber_ > 0)
saveForOffline(workflow_, forceRunNumber_, 0);
Expand Down
9 changes: 8 additions & 1 deletion DQMServices/Core/interface/DQMEDHarvester.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace edm {
class DQMEDHarvester
: public edm::one::EDProducer<edm::EndLuminosityBlockProducer,
edm::EndRunProducer,
edm::EndProcessBlockProducer,
edm::one::WatchLuminosityBlocks,
edm::one::WatchRuns,
// for uncontrolled DQMStore access, and that EDM does not even attempt to
Expand All @@ -55,10 +56,12 @@ class DQMEDHarvester

protected:
DQMStore *dqmstore_;
edm::GetterOfProducts<DQMToken> jobmegetter_;
edm::GetterOfProducts<DQMToken> runmegetter_;
edm::GetterOfProducts<DQMToken> lumimegetter_;
edm::EDPutTokenT<DQMToken> lumiToken_;
edm::EDPutTokenT<DQMToken> runToken_;
edm::EDPutTokenT<DQMToken> jobToken_;

public:
DQMEDHarvester(edm::ParameterSet const &iConfig) {
Expand All @@ -71,18 +74,22 @@ class DQMEDHarvester
// TODO: Run/Lumi suffix should not be needed, complain to CMSSW core in case.
lumiToken_ = produces<DQMToken, edm::Transition::EndLuminosityBlock>(outputgeneration + "Lumi");
runToken_ = produces<DQMToken, edm::Transition::EndRun>(outputgeneration + "Run");
jobToken_ = produces<DQMToken, edm::Transition::EndProcessBlock>(outputgeneration + "Job");

// Use explicitly specified inputs, but if there are none...
auto inputtags =
iConfig.getUntrackedParameter<std::vector<edm::InputTag>>("inputMEs", std::vector<edm::InputTag>());
if (inputtags.empty()) {
// ... use all RECO MEs.
inputtags.push_back(edm::InputTag("", inputgeneration + "Job"));
inputtags.push_back(edm::InputTag("", inputgeneration + "Run"));
inputtags.push_back(edm::InputTag("", inputgeneration + "Lumi"));
}
jobmegetter_ = edm::GetterOfProducts<DQMToken>(edm::VInputTagMatch(inputtags), this, edm::InProcess);
runmegetter_ = edm::GetterOfProducts<DQMToken>(edm::VInputTagMatch(inputtags), this, edm::InRun);
lumimegetter_ = edm::GetterOfProducts<DQMToken>(edm::VInputTagMatch(inputtags), this, edm::InLumi);
callWhenNewProductsRegistered([this](edm::BranchDescription const &bd) {
jobmegetter_(bd);
runmegetter_(bd);
lumimegetter_(bd);
});
Expand Down Expand Up @@ -135,7 +142,7 @@ class DQMEDHarvester

void endRun(edm::Run const &, edm::EventSetup const &) override{};

void endJob() final {
void endProcessBlockProduce(edm::ProcessBlock &) final {
dqmstore_->meBookerGetter([this](DQMStore::IBooker &b, DQMStore::IGetter &g) {
b.setScope(MonitorElementData::Scope::JOB);
this->dqmEndJob(b, g);
Expand Down

0 comments on commit ddd9303

Please sign in to comment.