CP3-llbb Framework
GenParticlesProducer.h
1 #ifndef GENPARTICLES_PRODUCER
2 #define GENPARTICLES_PRODUCER
3 
4 #include <DataFormats/PatCandidates/interface/PackedGenParticle.h>
5 #include <DataFormats/HepMCCandidate/interface/GenParticle.h>
6 
7 #include <cp3_llbb/Framework/interface/Producer.h>
8 
10  public:
11  GenParticlesProducer(const std::string& name, const ROOT::TreeGroup& tree, const edm::ParameterSet& config):
12  Producer(name, tree, config),
13  tree_packed(tree.group("packed_")),
14  tree_pruned(tree.group("pruned_"))
15  {
16 
17  }
18 
19  virtual void doConsumes(const edm::ParameterSet& config, edm::ConsumesCollector&& collector) override {
20  m_packed_token = collector.consumes<std::vector<pat::PackedGenParticle>>(config.getUntrackedParameter<edm::InputTag>("packed_gen_particles", edm::InputTag("packedGenParticles")));
21  m_pruned_token = collector.consumes<std::vector<reco::GenParticle>>(config.getUntrackedParameter<edm::InputTag>("pruned_gen_particles", edm::InputTag("prunedGenParticles")));
22  }
23 
24  virtual ~GenParticlesProducer() {}
25 
26  virtual void produce(edm::Event& event, const edm::EventSetup& eventSetup) override;
27 
28  private:
29 
30  // Tokens
31  edm::EDGetTokenT<std::vector<pat::PackedGenParticle>> m_packed_token;
32  edm::EDGetTokenT<std::vector<reco::GenParticle>> m_pruned_token;
33 
34  ROOT::TreeGroup tree_packed;
35  ROOT::TreeGroup tree_pruned;
36 
37  public:
38  // Tree members
39  std::vector<LorentzVector>& packed_p4 = tree_packed["p4"].transient_write<std::vector<LorentzVector>>();
40  std::vector<float>& packed_y = tree_packed["y"].transient_write<std::vector<float>>();
41  std::vector<int16_t>& packed_pdg_id = tree_packed["pdg_id"].transient_write<std::vector<int16_t>>();
42  std::vector<int8_t>& packed_status = tree_packed["status"].transient_write<std::vector<int8_t>>();
43  std::vector<int16_t>& packed_status_flags = tree_packed["status_flags"].transient_write<std::vector<int16_t>>();
44  std::vector<std::vector<uint16_t>>& packed_mothers_index = tree_packed["mothers_index"].transient_write<std::vector<std::vector<uint16_t>>>();
45 
46  std::vector<LorentzVector>& pruned_p4 = tree_pruned["p4"].transient_write<std::vector<LorentzVector>>();
47  std::vector<float>& pruned_y = tree_pruned["y"].transient_write<std::vector<float>>();
48  std::vector<int16_t>& pruned_pdg_id = tree_pruned["pdg_id"].transient_write<std::vector<int16_t>>();
49  std::vector<int8_t>& pruned_status = tree_pruned["status"].transient_write<std::vector<int8_t>>();
50  std::vector<int16_t>& pruned_status_flags = tree_pruned["status_flags"].transient_write<std::vector<int16_t>>();
51  std::vector<std::vector<uint16_t>>& pruned_mothers_index = tree_pruned["mothers_index"].transient_write<std::vector<std::vector<uint16_t>>>();
52 };
53 
54 #endif
55 
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: GenParticlesProducer.h:9
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Main method of the producer, called for each event.
Definition: GenParticlesProducer.cc:4
virtual void doConsumes(const edm::ParameterSet &config, edm::ConsumesCollector &&collector) override
Hook for the CMSSW consumes interface.
Definition: GenParticlesProducer.h:19