CMS 3D CMS Logo

DQMEDHarvester.h
Go to the documentation of this file.
1 #ifndef CORE_DQMED_HARVESTER_H
2 #define CORE_DQMED_HARVESTER_H
3 
5 
7 
17 
19 
20 namespace edm {
22  public:
23  VInputTagMatch(std::vector<edm::InputTag> const &inputTags) {
24  for (auto &tag : inputTags) {
25  matchers_.emplace_back(InputTagMatch(tag));
26  }
27  }
28 
29  bool operator()(edm::BranchDescription const &branchDescription) {
30  for (auto &m : matchers_) {
31  if (m(branchDescription)) {
32  return true;
33  }
34  }
35  return false;
36  }
37 
38  private:
39  std::vector<InputTagMatch> matchers_;
40  };
41 } // namespace edm
42 
44  : public edm::one::EDProducer<edm::EndLuminosityBlockProducer,
45  edm::EndRunProducer,
46  edm::EndProcessBlockProducer,
47  edm::one::WatchLuminosityBlocks,
48  edm::one::WatchRuns,
49  // for uncontrolled DQMStore access, and that EDM does not even attempt to
50  // run things in parallel (which would then be blocked by the booking lock).
51  edm::one::SharedResources,
52  edm::Accumulator> {
53 public:
56 
57 protected:
65 
66 public:
68  usesResource("DQMStore");
70 
71  auto inputgeneration = iConfig.getUntrackedParameter<std::string>("inputGeneration", "DQMGenerationReco");
72  auto outputgeneration = iConfig.getUntrackedParameter<std::string>("outputGeneration", "DQMGenerationHarvesting");
73 
74  // TODO: Run/Lumi suffix should not be needed, complain to CMSSW core in case.
75  lumiToken_ = produces<DQMToken, edm::Transition::EndLuminosityBlock>(outputgeneration + "Lumi");
76  runToken_ = produces<DQMToken, edm::Transition::EndRun>(outputgeneration + "Run");
77  jobToken_ = produces<DQMToken, edm::Transition::EndProcessBlock>(outputgeneration + "Job");
78 
79  // Use explicitly specified inputs, but if there are none...
80  auto inputtags =
81  iConfig.getUntrackedParameter<std::vector<edm::InputTag>>("inputMEs", std::vector<edm::InputTag>());
82  if (inputtags.empty()) {
83  // ... use all RECO MEs.
84  inputtags.push_back(edm::InputTag("", inputgeneration + "Job"));
85  inputtags.push_back(edm::InputTag("", inputgeneration + "Run"));
86  inputtags.push_back(edm::InputTag("", inputgeneration + "Lumi"));
87  }
92  jobmegetter_(bd);
93  runmegetter_(bd);
94  lumimegetter_(bd);
95  });
96  };
97 
99 
100  void beginJob() override {}
101 
102  void beginRun(edm::Run const &run, edm::EventSetup const &) override {
103  // According to edm experts, it is never save to look at run products
104  // in beginRun, since they might be merged as new input files how up.
105  }
106 
108  // According to edm experts, it is never save to look at run products
109  // in beginRun, since they might be merged as new input files how up.
110  }
111 
112  void accumulate(edm::Event const &ev, edm::EventSetup const &es) final {
114  b.setScope(MonitorElementData::Scope::JOB);
115  this->dqmAnalyze(b, g, ev, es);
116  });
117  }
118 
120  // No need to actually get products for now
121  //auto refs = std::vector<edm::Handle<DQMToken>>();
122  //lumimegetter_.fillHandles(lumi, refs);
123 
125  b.setScope(MonitorElementData::Scope::JOB);
126  this->dqmEndLuminosityBlock(b, g, lumi, es);
127  });
128 
129  lumi.put(lumiToken_, std::make_unique<DQMToken>());
130  }
131 
133 
134  void endRunProduce(edm::Run &run, edm::EventSetup const &es) final {
136  b.setScope(MonitorElementData::Scope::JOB);
137  this->dqmEndRun(b, g, run, es);
138  });
139 
140  run.put(runToken_, std::make_unique<DQMToken>());
141  }
142 
143  void endRun(edm::Run const &, edm::EventSetup const &) override {}
144 
147  b.setScope(MonitorElementData::Scope::JOB);
148  this->dqmEndJob(b, g);
149  });
150  };
151 
152  ~DQMEDHarvester() override = default;
153 
154  // DQM_EXPERIMENTAL
155  // Could be used for niche workflows like commissioning.
156  // Real harvesting jobs have no events and will never call this.
160  edm::LuminosityBlock const &,
161  edm::EventSetup const &) {};
162  // HARVESTING should happen in endJob (or endLumi, for online), but there can
163  // be applications for end-run harvesting. Better to have a callback than
164  // have unprotected DQMStore access.
165  virtual void dqmEndRun(DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &) {}
166  virtual void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) = 0;
167 };
168 
169 #endif // CORE_DQMED_HARVESTER_H
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: ProducerBase.h:87
void beginRun(edm::Run const &run, edm::EventSetup const &) override
edm::EDPutTokenT< DQMToken > lumiToken_
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
std::vector< InputTagMatch > matchers_
virtual void dqmAnalyze(DQMStore::IBooker &, DQMStore::IGetter &, edm::Event const &, edm::EventSetup const &)
edm::EDPutTokenT< DQMToken > jobToken_
virtual void dqmEndRun(DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &)
~DQMEDHarvester() override=default
edm::GetterOfProducts< DQMToken > lumimegetter_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
void endRun(edm::Run const &, edm::EventSetup const &) override
T getUntrackedParameter(std::string const &, T const &) const
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &) final
dqm::harvesting::MonitorElement MonitorElement
edm::EDPutTokenT< DQMToken > runToken_
void meBookerGetter(iFunc f)
Definition: DQMStore.h:719
VInputTagMatch(std::vector< edm::InputTag > const &inputTags)
void beginJob() override
void endRunProduce(edm::Run &run, edm::EventSetup const &es) final
DQMEDHarvester(edm::ParameterSet const &iConfig)
edm::GetterOfProducts< DQMToken > runmegetter_
inputTags
All input tags are specified in this pset for convenience.
dqm::harvesting::DQMStore DQMStore
double b
Definition: hdecay.h:120
void endLuminosityBlockProduce(edm::LuminosityBlock &lumi, edm::EventSetup const &es) final
void accumulate(edm::Event const &ev, edm::EventSetup const &es) final
HLT enums.
edm::GetterOfProducts< DQMToken > jobmegetter_
bool operator()(edm::BranchDescription const &branchDescription)
void endProcessBlockProduce(edm::ProcessBlock &) final
DQMStore * dqmstore_
virtual void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)=0
Definition: Run.h:45
virtual void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)