CMS 3D CMS Logo

HGCalTriggerNtupleHGCMulticlusters.cc
Go to the documentation of this file.
1 
7 
8 
9 
11 {
12 
13  public:
16  virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) override final;
17  virtual void fill(const edm::Event& e, const edm::EventSetup& es) override final;
18 
19  private:
20  virtual void clear() override final;
21 
22 
24 
25  int cl3d_n_ ;
26  std::vector<float> cl3d_pt_;
27  std::vector<float> cl3d_energy_;
28  std::vector<float> cl3d_eta_;
29  std::vector<float> cl3d_phi_;
30  std::vector<int> cl3d_nclu_;
31  std::vector<std::vector<unsigned>> cl3d_clusters_;
32 };
33 
36  "HGCalTriggerNtupleHGCMulticlusters" );
37 
38 
41 {
42 }
43 
44 void
46 initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
47 {
48  multiclusters_token_ = collector.consumes<l1t::HGCalMulticlusterBxCollection>(conf.getParameter<edm::InputTag>("Multiclusters"));
49 
50  tree.Branch("cl3d_n", &cl3d_n_, "cl3d_n/I");
51  tree.Branch("cl3d_pt", &cl3d_pt_);
52  tree.Branch("cl3d_energy", &cl3d_energy_);
53  tree.Branch("cl3d_eta", &cl3d_eta_);
54  tree.Branch("cl3d_phi", &cl3d_phi_);
55  tree.Branch("cl3d_nclu", &cl3d_nclu_);
56  tree.Branch("cl3d_clusters", &cl3d_clusters_);
57 
58 }
59 
60 void
62 fill(const edm::Event& e, const edm::EventSetup& es)
63 {
64 
65  // retrieve clusters 3D
67  e.getByToken(multiclusters_token_, multiclusters_h);
68  const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h;
69 
70  // retrieve geometry
72  es.get<CaloGeometryRecord>().get(geometry);
73 
74  clear();
75  for(auto cl3d_itr=multiclusters.begin(0); cl3d_itr!=multiclusters.end(0); cl3d_itr++)
76  {
77  cl3d_n_++;
78  // physical values
79  cl3d_pt_.emplace_back(cl3d_itr->pt());
80  cl3d_energy_.emplace_back(cl3d_itr->energy());
81  cl3d_eta_.emplace_back(cl3d_itr->eta());
82  cl3d_phi_.emplace_back(cl3d_itr->phi());
83  cl3d_nclu_.emplace_back(cl3d_itr->constituents().size());
84  // Retrieve indices of trigger cells inside cluster
85  cl3d_clusters_.emplace_back(cl3d_itr->constituents().size());
86  std::transform(cl3d_itr->constituents_begin(), cl3d_itr->constituents_end(),
87  cl3d_clusters_.back().begin(), [](const edm::Ptr<l1t::HGCalCluster>& cl){return cl.key();}
88  );
89  }
90 }
91 
92 
93 void
96 {
97  cl3d_n_ = 0;
98  cl3d_pt_.clear();
99  cl3d_energy_.clear();
100  cl3d_eta_.clear();
101  cl3d_phi_.clear();
102  cl3d_nclu_.clear();
103  cl3d_clusters_.clear();
104 
105 }
106 
107 
108 
109 
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
HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet &conf)
virtual void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) override final
const T & get() const
Definition: EventSetup.h:55
ESHandle< TrackerGeometry > geometry
std::vector< std::vector< unsigned > > cl3d_clusters_
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: tree.py:1
const_iterator begin(int bx) const