CMS 3D CMS Logo

HGCalTriggerNtupleTowers.cc
Go to the documentation of this file.
6 
7 
8 
10 {
11 
12  public:
15  void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final;
16  void fill(const edm::Event& e, const edm::EventSetup& es) final;
17 
18  private:
19  void clear() final;
20 
22 
23  int tower_n_ ;
24  std::vector<float> tower_pt_;
25  std::vector<float> tower_energy_;
26  std::vector<float> tower_eta_;
27  std::vector<float> tower_phi_;
28  std::vector<float> tower_etEm_;
29  std::vector<float> tower_etHad_;
30  std::vector<int> tower_hwEta_;
31  std::vector<int> tower_hwPhi_;
32 
33 };
34 
37  "HGCalTriggerNtupleHGCTowers" );
38 
39 
42 {
43 }
44 
45 void
47 initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
48 {
49  towers_token_ = collector.consumes<l1t::HGCalTowerBxCollection>(conf.getParameter<edm::InputTag>("Towers"));
50 
51  tree.Branch("tower_n", &tower_n_, "tower_n/I");
52  tree.Branch("tower_pt", &tower_pt_);
53  tree.Branch("tower_energy", &tower_energy_);
54  tree.Branch("tower_eta", &tower_eta_);
55  tree.Branch("tower_phi", &tower_phi_);
56  tree.Branch("tower_etEm", &tower_etEm_);
57  tree.Branch("tower_etHad", &tower_etHad_);
58  tree.Branch("tower_hwEta", &tower_hwEta_);
59  tree.Branch("tower_hwPhi", &tower_hwPhi_);
60 
61 }
62 
63 
64 
65 void
67 fill(const edm::Event& e, const edm::EventSetup& es)
68 {
69 
70  // retrieve towers
72  e.getByToken(towers_token_, towers_h);
73  const l1t::HGCalTowerBxCollection& towers = *towers_h;
74 
75  // retrieve geometry
77  es.get<CaloGeometryRecord>().get(geometry);
78 
79  clear();
80  for(auto tower_itr=towers.begin(0); tower_itr!=towers.end(0); tower_itr++)
81  {
82  tower_n_++;
83  // physical values
84  tower_pt_.emplace_back(tower_itr->pt());
85  tower_energy_.emplace_back(tower_itr->energy());
86  tower_eta_.emplace_back(tower_itr->eta());
87  tower_phi_.emplace_back(tower_itr->phi());
88  tower_etEm_.emplace_back(tower_itr->etEm());
89  tower_etHad_.emplace_back(tower_itr->etHad());
90 
91  tower_hwEta_.emplace_back(tower_itr->hwEta());
92  tower_hwPhi_.emplace_back(tower_itr->hwPhi());
93  }
94 }
95 
96 
97 void
100 {
101  tower_n_ = 0;
102  tower_pt_.clear();
103  tower_energy_.clear();
104  tower_eta_.clear();
105  tower_phi_.clear();
106  tower_etEm_.clear();
107  tower_etHad_.clear();
108  tower_hwEta_.clear();
109  tower_hwPhi_.clear();
110 }
111 
112 
113 
114 
const_iterator end(int bx) const
T getParameter(std::string const &) const
void fill(const edm::Event &e, const edm::EventSetup &es) final
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
HGCalTriggerNtupleHGCTowers(const edm::ParameterSet &conf)
const T & get() const
Definition: EventSetup.h:55
ESHandle< TrackerGeometry > geometry
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: tree.py:1
const_iterator begin(int bx) const
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final