CP3-llbb Framework
METProducer.h
1 #ifndef MET_PRODUCER
2 #define MET_PRODUCER
3 
4 #include <DataFormats/PatCandidates/interface/MET.h>
5 
6 #include <cp3_llbb/Framework/interface/Producer.h>
7 
9  public:
10  METProducer(const std::string& name, const ROOT::TreeGroup& tree, const edm::ParameterSet& config):
11  Producer(name, tree, config),
12  m_slimmed(config.getUntrackedParameter<bool>("slimmed", true))
13  {
14 
15  }
16 
17  virtual ~METProducer() {}
18 
19  virtual void doConsumes(const edm::ParameterSet& config, edm::ConsumesCollector&& collector) override {
20  m_met_token = collector.consumes<std::vector<pat::MET>>(config.getUntrackedParameter<edm::InputTag>("met", edm::InputTag("slimmedMETs")));
21  }
22 
23  virtual void produce(edm::Event& event, const edm::EventSetup& eventSetup) override;
24 
25  private:
26  float& create_branch(const std::string& name) {
27  static float s_dummy = 0;
28  return (m_slimmed) ? tree[name].write<float>() : s_dummy;
29  }
30 
31  bool m_slimmed;
32 
33  // Tokens
34  edm::EDGetTokenT<std::vector<pat::MET>> m_met_token;
35 
36  public:
37  // Tree members
38  LorentzVector& p4 = tree["p4"].write<LorentzVector>();
39  float& sumEt = tree["sumEt"].write<float>();
40  float& significance = tree["significance"].write<float>();
41 
42  float& CovMatrix00 = tree["CovMatrix00"].write<float>();
43  float& CovMatrix01 = tree["CovMatrix01"].write<float>();
44  float& CovMatrix10 = tree["CovMatrix10"].write<float>();
45  float& CovMatrix11 = tree["CovMatrix11"].write<float>();
46  float& uncorrectedPt = create_branch("uncorrectedPt");
47  float& uncorrectedPhi = create_branch("uncorrectedPhi");
48  float& uncorrectedSumEt = create_branch("uncorrectedSumEt");
49 };
50 
51 #endif
Base class for Framework producers.
Definition: Producer.h:33
ROOT::TreeGroup tree
Access point to output tree.
Definition: Producer.h:132
Producer(const std::string &name, const ROOT::TreeGroup &tree_, const edm::ParameterSet &config)
Base constructor.
Definition: Producer.h:46
Definition: METProducer.h:8
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Main method of the producer, called for each event.
Definition: METProducer.cc:3
virtual void doConsumes(const edm::ParameterSet &config, edm::ConsumesCollector &&collector) override
Hook for the CMSSW consumes interface.
Definition: METProducer.h:19