CP3-llbb Framework
All Classes Functions Variables Enumerations Pages
Producer.h
1 #pragma once
2 
3 #include <FWCore/PluginManager/interface/PluginFactory.h>
4 #include <FWCore/ParameterSet/interface/ParameterSet.h>
5 #include <FWCore/Framework/interface/Event.h>
6 #include <FWCore/Framework/interface/Run.h>
7 #include <FWCore/Framework/interface/LuminosityBlock.h>
8 #include <FWCore/Framework/interface/EventSetup.h>
9 #include <FWCore/Framework/interface/ConsumesCollector.h>
10 #include <FWCore/Utilities/interface/InputTag.h>
11 
12 #include <cp3_llbb/TreeWrapper/interface/TreeWrapper.h>
13 #include <cp3_llbb/Framework/interface/MetadataManager.h>
14 
15 #include <cp3_llbb/Framework/interface/Types.h>
16 
17 #include <vector>
18 #include <map>
19 
20 class ExTreeMaker;
21 
22 namespace Framework {
23 
25 
33  class Producer {
34  friend class ::ExTreeMaker;
35 
36  public:
38 
46  Producer(const std::string& name, const ROOT::TreeGroup& tree_, const edm::ParameterSet& config):
47  m_name(name),
48  tree(tree_),
49  m_systematics(config.getUntrackedParameter<bool>("systematics", false)) {
50  }
51 
53 
61  virtual void produce(edm::Event& event, const edm::EventSetup& setup) = 0;
63 
71  virtual void doConsumes(const edm::ParameterSet& pset, edm::ConsumesCollector&& collector) {}
72 
74 
77  virtual void beginJob(MetadataManager& manager) {}
79 
82  virtual void endJob(MetadataManager& manager) {}
83 
85 
91  virtual void beginRun(const edm::Run& run, const edm::EventSetup& setup) {}
93 
99  virtual void endRun(const edm::Run& run, const edm::EventSetup& setup) {}
100 
102 
108  virtual void beginLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& setup) {}
110  //
117  virtual void endLuminosityBlock(const edm::LuminosityBlock& lumi, const edm::EventSetup& setup) {}
118 
119  // Disable copy of producer
120  Producer(const Producer&) = delete;
121  Producer& operator=(const Producer&) = delete;
122 
123  protected:
124  std::string m_name;
125 
127 
132  ROOT::TreeGroup tree;
133 
134  inline bool doingSystematics() const {
135  return m_systematics;
136  }
137 
138  private:
139  bool hasRun() const {
140  return m_run;
141  }
142 
143  void setRun(bool run) {
144  m_run = run;
145  }
146 
147  bool m_run; //< A flag indicating if the analyzer has already been run for this event
148 
149  // If true, this analyzer is producing systematics related quantities
150  bool m_systematics;
151 
152  };
153 
154 }
155 
156 typedef edmplugin::PluginFactory<Framework::Producer* (const std::string&, const ROOT::TreeGroup&, const edm::ParameterSet&)> ExTreeMakerProducerFactory;
Definition: Framework.h:21
Base class for Framework producers.
Definition: Producer.h:33
virtual void doConsumes(const edm::ParameterSet &pset, edm::ConsumesCollector &&collector)
Hook for the CMSSW consumes interface.
Definition: Producer.h:71
virtual void endLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &setup)
Called at the end of a luminosity section.
Definition: Producer.h:117
ROOT::TreeGroup tree
Access point to output tree.
Definition: Producer.h:132
virtual void beginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &setup)
Called at the beginning of a new luminosity section.
Definition: Producer.h:108
virtual void beginRun(const edm::Run &run, const edm::EventSetup &setup)
Called at the beginning of a new run.
Definition: Producer.h:91
virtual void endJob(MetadataManager &manager)
Called once at the end of the job.
Definition: Producer.h:82
virtual void produce(edm::Event &event, const edm::EventSetup &setup)=0
Main method of the producer, called for each event.
virtual void beginJob(MetadataManager &manager)
Called once at the beginning of the job.
Definition: Producer.h:77
virtual void endRun(const edm::Run &run, const edm::EventSetup &setup)
Called at the end of a run.
Definition: Producer.h:99
Producer(const std::string &name, const ROOT::TreeGroup &tree_, const edm::ParameterSet &config)
Base constructor.
Definition: Producer.h:46
Definition: MetadataManager.h:9