CP3-llbb Framework
EventProducer.h
1 #ifndef EVENT_PRODUCER
2 #define EVENT_PRODUCER
3 
4 #include <cp3_llbb/Framework/interface/Producer.h>
5 #include <cp3_llbb/Framework/interface/PUReweighter.h>
6 #include <cp3_llbb/Framework/interface/GenInfoAndWeights.h>
7 
8 #include <SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h>
9 
10 #include <DataFormats/DetId/interface/DetIdCollection.h>
11 
13  public:
14  EventProducer(const std::string& name, const ROOT::TreeGroup& tree, const edm::ParameterSet& config):
15  Producer(name, tree, config)
16  {
17 
18  if (config.getUntrackedParameter<bool>("compute_pu_weights", true)) {
19  std::string puProfileString = config.getUntrackedParameter<std::string>("pu_profile");
20  Framework::PUProfile puProfile = Framework::stringToPUProfile(puProfileString); // Throw if invalid
21  m_pu_reweighter = std::make_shared<Framework::PUReweighter>(config.getParameterSet("pu_reweighter"), puProfile);
22  m_pu_reweighter_up = std::make_shared<Framework::PUReweighter>(config.getParameterSet("pu_reweighter_up"), puProfile);
23  m_pu_reweighter_down = std::make_shared<Framework::PUReweighter>(config.getParameterSet("pu_reweighter_down"), puProfile);
24  }
25  }
26 
27  virtual ~EventProducer() {}
28 
29  virtual void doConsumes(const edm::ParameterSet& config, edm::ConsumesCollector&& collector) override {
30  m_rho_token = collector.consumes<double>(config.getUntrackedParameter<edm::InputTag>("rho", edm::InputTag("fixedGridRhoFastjetAll")));
31  m_pu_info_token = collector.consumes<std::vector<PileupSummaryInfo>>(config.getUntrackedParameter<edm::InputTag>("pu_summary", edm::InputTag("addPileupInfo")));
32 
33  m_genInfoWeightsToken = collector.consumes<Framework::GenInfoAndWeights>(config.getUntrackedParameter<edm::InputTag>("genInfoWeights", edm::InputTag("genInfoEventWeights")));
34 
35  m_dupECALClusters_token = collector.consumes<bool>(edm::InputTag("particleFlowEGammaGSFixed", "dupECALClusters"));
36  m_hitsNotReplaced_token = collector.consumes<DetIdCollection>(edm::InputTag("ecalMultiAndGSGlobalRecHitEB", "hitsNotReplaced"));
37  }
38 
39  virtual void produce(edm::Event& event, const edm::EventSetup& eventSetup) override;
40 
41  private:
42 
43  // Tokens
44  edm::EDGetTokenT<double> m_rho_token;
45  edm::EDGetTokenT<std::vector<PileupSummaryInfo>> m_pu_info_token;
46 
47  edm::EDGetTokenT<Framework::GenInfoAndWeights> m_genInfoWeightsToken;
48 
49  // Moriond17 reminiaod validation flags
50  edm::EDGetTokenT<bool> m_dupECALClusters_token;
51  edm::EDGetTokenT<DetIdCollection> m_hitsNotReplaced_token;
52 
53  std::shared_ptr<Framework::PUReweighter> m_pu_reweighter;
54  std::shared_ptr<Framework::PUReweighter> m_pu_reweighter_up;
55  std::shared_ptr<Framework::PUReweighter> m_pu_reweighter_down;
56 
57  public:
58  // Tree members
59 
60  BRANCH(run, ULong64_t);
61  BRANCH(lumi, ULong64_t);
62  BRANCH(event, ULong64_t);
63  BRANCH(is_data, bool);
64 
65  BRANCH(rho, float);
66 
67  BRANCH(npu, int);
68  BRANCH(true_interactions, float);
69  BRANCH(pu_weight, float);
70  BRANCH(pu_weight_up, float);
71  BRANCH(pu_weight_down, float);
72 
73  // Moriond17 reminiaod validation flags
74  BRANCH(dupECALClusters, bool);
75  BRANCH(hitsNotReplacedEmpty, bool);
76 
77  BRANCH(pt_hat, float);
78  BRANCH(ht, float);
79  BRANCH(weight, float);
80 
81  BRANCH(alpha_QCD, float);
82  BRANCH(alpha_QED, float);
83  BRANCH(q_scale, float);
84  uint32_t& pdf_set = tree["pdf_set"].write<uint32_t>(false);
85  BRANCH(pdf_id, std::pair<int, int>);
86  BRANCH(pdf_x, std::pair<float, float>);
87  BRANCH(pdf_weight, float);
88  BRANCH(pdf_weight_up, float);
89  BRANCH(pdf_weight_down, float);
90  BRANCH(hdamp_weight_up, float);
91  BRANCH(hdamp_weight_down, float);
92 
93  BRANCH(initial_state, uint8_t);
94 
95  BRANCH(pdf_weight_gg, float);
96  BRANCH(pdf_weight_gg_up, float);
97  BRANCH(pdf_weight_gg_down, float);
98 
99  BRANCH(pdf_weight_qq, float);
100  BRANCH(pdf_weight_qq_up, float);
101  BRANCH(pdf_weight_qq_down, float);
102 
103  BRANCH(pdf_weight_qg, float);
104  BRANCH(pdf_weight_qg_up, float);
105  BRANCH(pdf_weight_qg_down, float);
106 
107  BRANCH(n_ME_partons, int);
108  BRANCH(n_ME_partons_filtered, int);
109 
110  BRANCH(lhe_originalXWGTUP, float);
111  BRANCH(lhe_SCALUP, float);
112  TRANSIENT_BRANCH(lhe_weights, std::vector<std::pair<std::string, float>>);
113 
114  BRANCH(scale_weights, std::vector<float>);
115 };
116 
117 #endif
Definition: EventProducer.h:12
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Main method of the producer, called for each event.
Definition: EventProducer.cc:3
virtual void doConsumes(const edm::ParameterSet &config, edm::ConsumesCollector &&collector) override
Hook for the CMSSW consumes interface.
Definition: EventProducer.h:29
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: GenInfoAndWeights.h:17