CMS 3D CMS Logo

HGCalTriggerNtupleHGCClusters.cc
Go to the documentation of this file.
1 
2 #include <algorithm>
8 
9 
10 
12 {
13 
14  public:
17  virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) override final;
18  virtual void fill(const edm::Event& e, const edm::EventSetup& es) override final;
19 
20  private:
21  virtual void clear() override final;
22 
23 
25 
26  int cl_n_ ;
27  std::vector<float> cl_pt_;
28  std::vector<float> cl_energy_;
29  std::vector<float> cl_eta_;
30  std::vector<float> cl_phi_;
31  std::vector<int> cl_layer_;
32  std::vector<int> cl_ncells_;
33  std::vector<std::vector<unsigned>> cl_cells_;
34 
35 };
36 
39  "HGCalTriggerNtupleHGCClusters" );
40 
41 
44 {
45 }
46 
47 void
49 initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
50 {
51  clusters_token_ = collector.consumes<l1t::HGCalClusterBxCollection>(conf.getParameter<edm::InputTag>("Clusters"));
52 
53  tree.Branch("cl_n", &cl_n_, "cl_n/I");
54  tree.Branch("cl_pt", &cl_pt_);
55  tree.Branch("cl_energy", &cl_energy_);
56  tree.Branch("cl_eta", &cl_eta_);
57  tree.Branch("cl_phi", &cl_phi_);
58  tree.Branch("cl_layer", &cl_layer_);
59  tree.Branch("cl_ncells", &cl_ncells_);
60  tree.Branch("cl_cells", &cl_cells_);
61 }
62 
63 void
65 fill(const edm::Event& e, const edm::EventSetup& es)
66 {
67 
68  // retrieve clusters
70  e.getByToken(clusters_token_, clusters_h);
71  const l1t::HGCalClusterBxCollection& clusters = *clusters_h;
72 
73  // retrieve geometry
75  es.get<CaloGeometryRecord>().get(geometry);
76 
77  clear();
78  for(auto cl_itr=clusters.begin(0); cl_itr!=clusters.end(0); cl_itr++)
79  {
80  cl_n_++;
81  // physical values
82  cl_pt_.emplace_back(cl_itr->pt());
83  cl_energy_.emplace_back(cl_itr->energy());
84  cl_eta_.emplace_back(cl_itr->eta());
85  cl_phi_.emplace_back(cl_itr->phi());
86  cl_layer_.emplace_back(cl_itr->layer());
87  cl_ncells_.emplace_back(cl_itr->constituents().size());
88  // Retrieve indices of trigger cells inside cluster
89  cl_cells_.emplace_back(cl_itr->constituents().size());
90  std::transform(cl_itr->constituents_begin(), cl_itr->constituents_end(),
91  cl_cells_.back().begin(), [](const edm::Ptr<l1t::HGCalTriggerCell>& tc){return tc.key();}
92  );
93  }
94 }
95 
96 
97 void
100 {
101  cl_n_ = 0;
102  cl_pt_.clear();
103  cl_energy_.clear();
104  cl_eta_.clear();
105  cl_phi_.clear();
106  cl_layer_.clear();
107  cl_ncells_.clear();
108  cl_cells_.clear();
109 }
110 
111 
112 
113 
const_iterator end(int bx) const
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
virtual void fill(const edm::Event &e, const edm::EventSetup &es) override final
std::vector< std::vector< unsigned > > cl_cells_
const T & get() const
Definition: EventSetup.h:55
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