CMS 3D CMS Logo

HGCalTriggerNtupleHGCClusters.cc
Go to the documentation of this file.
1 
6 
7 
8 
10 {
11 
12  public:
15  virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) override final;
16  virtual void fill(const edm::Event& e, const edm::EventSetup& es) override final;
17 
18  private:
19  virtual void clear() override final;
20 
21 
23 
24  int cl_n_ ;
25  std::vector<float> cl_pt_;
26  std::vector<float> cl_energy_;
27  std::vector<float> cl_eta_;
28  std::vector<float> cl_phi_;
29  std::vector<int> cl_layer_;
30  std::vector<int> cl_ncells_;
31 
32 };
33 
36  "HGCalTriggerNtupleHGCClusters" );
37 
38 
41 {
42 }
43 
44 void
46 initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
47 {
48  clusters_token_ = collector.consumes<l1t::HGCalClusterBxCollection>(conf.getParameter<edm::InputTag>("Clusters"));
49 
50  tree.Branch("cl_n", &cl_n_, "cl_n/I");
51  tree.Branch("cl_pt", &cl_pt_);
52  tree.Branch("cl_energy", &cl_energy_);
53  tree.Branch("cl_eta", &cl_eta_);
54  tree.Branch("cl_phi", &cl_phi_);
55  tree.Branch("cl_layer", &cl_layer_);
56  tree.Branch("cl_ncells", &cl_ncells_);
57 }
58 
59 void
61 fill(const edm::Event& e, const edm::EventSetup& es)
62 {
63 
64  // retrieve clusters
66  e.getByToken(clusters_token_, clusters_h);
67  const l1t::HGCalClusterBxCollection& clusters = *clusters_h;
68 
69  // retrieve geometry
71  es.get<IdealGeometryRecord>().get(geometry);
72 
73  clear();
74  for(auto cl_itr=clusters.begin(0); cl_itr!=clusters.end(0); cl_itr++)
75  {
76  cl_n_++;
77  // physical values
78  cl_pt_.emplace_back(cl_itr->pt());
79  cl_energy_.emplace_back(cl_itr->energy());
80  cl_eta_.emplace_back(cl_itr->eta());
81  cl_phi_.emplace_back(cl_itr->phi());
82  cl_layer_.emplace_back(cl_itr->layer());
83  cl_ncells_.emplace_back(cl_itr->constituents().size());
84  }
85 }
86 
87 
88 void
91 {
92  cl_n_ = 0;
93  cl_pt_.clear();
94  cl_energy_.clear();
95  cl_eta_.clear();
96  cl_phi_.clear();
97  cl_layer_.clear();
98  cl_ncells_.clear();
99 }
100 
101 
102 
103 
const_iterator end(int bx) const
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
virtual void fill(const edm::Event &e, const edm::EventSetup &es) override final
const T & get() const
Definition: EventSetup.h:56
ESHandle< TrackerGeometry > geometry
HGCalTriggerNtupleHGCClusters(const edm::ParameterSet &conf)
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: tree.py:1
virtual void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) override final
const_iterator begin(int bx) const