CP3-llbb Framework
ElectronsProducer.h
1 #ifndef ELECTRONS_PRODUCER
2 #define ELECTRONS_PRODUCER
3 
4 #include <cp3_llbb/Framework/interface/LeptonsProducer.h>
5 #include <cp3_llbb/Framework/interface/Identifiable.h>
6 #include <cp3_llbb/Framework/interface/ScaleFactors.h>
7 
8 #include <DataFormats/PatCandidates/interface/Electron.h>
9 
10 class ElectronsProducer: public LeptonsProducer<pat::Electron>, public Identifiable, public ScaleFactors {
11  public:
12  ElectronsProducer(const std::string& name, const ROOT::TreeGroup& tree, const edm::ParameterSet& config):
13  LeptonsProducer(name, tree, config), Identifiable(const_cast<ROOT::TreeGroup&>(tree)), ScaleFactors(const_cast<ROOT::TreeGroup&>(tree))
14  {
15  ScaleFactors::create_branches(config);
16  }
17 
18  virtual ~ElectronsProducer() {}
19 
20  virtual void doConsumes(const edm::ParameterSet& config, edm::ConsumesCollector&& collector) override {
21  LeptonsProducer::doConsumes(config, std::forward<edm::ConsumesCollector>(collector));
22  Identifiable::consumes_id_tokens(config, std::forward<edm::ConsumesCollector>(collector));
23  m_vertices_token = collector.consumes<std::vector<reco::Vertex>>(config.getUntrackedParameter<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices")));
24 
25  if (config.exists("mva_id")) {
26  const edm::ParameterSet& mva_id_pset = config.getUntrackedParameter<edm::ParameterSet>("mva_id");
27  m_mva_id_values_map_token = collector.consumes<edm::ValueMap<float>>(mva_id_pset.getUntrackedParameter<edm::InputTag>("values"));
28  m_mva_id_categories_map_token = collector.consumes<edm::ValueMap<int>>(mva_id_pset.getUntrackedParameter<edm::InputTag>("categories"));
29  }
30  }
31 
32  virtual void produce(edm::Event& event, const edm::EventSetup& eventSetup) override;
33 
34  private:
35  // Tokens
36  edm::EDGetTokenT<std::vector<reco::Vertex>> m_vertices_token;
37 
38  // MVA values and categories (optional)
39  edm::EDGetTokenT<edm::ValueMap<float>> m_mva_id_values_map_token;
40  edm::EDGetTokenT<edm::ValueMap<int>> m_mva_id_categories_map_token;
41 
42  public:
43  // Tree members
44  BRANCH(isEB, std::vector<bool>);
45  BRANCH(isEE, std::vector<bool>);
46 
47  BRANCH(dxy, std::vector<float>);
48  BRANCH(dz, std::vector<float>);
49  BRANCH(dca, std::vector<float>);
50 
51  BRANCH(ecalPFClusterIso, std::vector<float>);
52  BRANCH(hcalPFClusterIso, std::vector<float>);
53  BRANCH(trackIso, std::vector<float>);
54 
55  BRANCH(expectedMissingInnerHits, std::vector<unsigned int>);
56 
57  BRANCH(mva_id_values, std::vector<float>);
58  BRANCH(mva_id_categories, std::vector<int>);
59 
60  std::vector<edm::Ref<std::vector<pat::Electron>>> products;
61 };
62 
63 #endif
Definition: ElectronsProducer.h:10
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Main method of the producer, called for each event.
Definition: ElectronsProducer.cc:3
virtual void doConsumes(const edm::ParameterSet &config, edm::ConsumesCollector &&collector) override
Hook for the CMSSW consumes interface.
Definition: ElectronsProducer.h:20
ROOT::TreeGroup tree
Access point to output tree.
Definition: Producer.h:132
Definition: Identifiable.h:14
Definition: LeptonsProducer.h:10
virtual void doConsumes(const edm::ParameterSet &config, edm::ConsumesCollector &&collector) override
Hook for the CMSSW consumes interface.
Definition: LeptonsProducer.h:22
Definition: ScaleFactors.h:13