CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalTriggerNtupleTowers.cc
Go to the documentation of this file.
3 
5 public:
8  void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final;
9  void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final;
10 
11 private:
12  void clear() final;
13 
15 
16  int tower_n_;
17  std::vector<float> tower_pt_;
18  std::vector<float> tower_energy_;
19  std::vector<float> tower_eta_;
20  std::vector<float> tower_phi_;
21  std::vector<float> tower_etEm_;
22  std::vector<float> tower_etHad_;
23  std::vector<int> tower_iEta_;
24  std::vector<int> tower_iPhi_;
25 };
26 
28 
29 HGCalTriggerNtupleHGCTowers::HGCalTriggerNtupleHGCTowers(const edm::ParameterSet& conf) : HGCalTriggerNtupleBase(conf) {
30  accessEventSetup_ = false;
31 }
32 
34  const edm::ParameterSet& conf,
35  edm::ConsumesCollector&& collector) {
36  towers_token_ = collector.consumes<l1t::HGCalTowerBxCollection>(conf.getParameter<edm::InputTag>("Towers"));
37 
38  std::string prefix(conf.getUntrackedParameter<std::string>("Prefix", "tower"));
39 
40  std::string bname;
41  auto withPrefix([&prefix, &bname](char const* vname) -> char const* {
42  bname = prefix + "_" + vname;
43  return bname.c_str();
44  });
45 
46  tree.Branch(withPrefix("n"), &tower_n_, (prefix + "_n/I").c_str());
47  tree.Branch(withPrefix("pt"), &tower_pt_);
48  tree.Branch(withPrefix("energy"), &tower_energy_);
49  tree.Branch(withPrefix("eta"), &tower_eta_);
50  tree.Branch(withPrefix("phi"), &tower_phi_);
51  tree.Branch(withPrefix("etEm"), &tower_etEm_);
52  tree.Branch(withPrefix("etHad"), &tower_etHad_);
53  tree.Branch(withPrefix("iEta"), &tower_iEta_);
54  tree.Branch(withPrefix("iPhi"), &tower_iPhi_);
55 }
56 
58  // retrieve towers
60  e.getByToken(towers_token_, towers_h);
61  const l1t::HGCalTowerBxCollection& towers = *towers_h;
62 
63  clear();
64  for (auto tower_itr = towers.begin(0); tower_itr != towers.end(0); tower_itr++) {
65  tower_n_++;
66  // physical values
67  tower_pt_.emplace_back(tower_itr->pt());
68  tower_energy_.emplace_back(tower_itr->energy());
69  tower_eta_.emplace_back(tower_itr->eta());
70  tower_phi_.emplace_back(tower_itr->phi());
71  tower_etEm_.emplace_back(tower_itr->etEm());
72  tower_etHad_.emplace_back(tower_itr->etHad());
73 
74  tower_iEta_.emplace_back(tower_itr->id().iEta());
75  tower_iPhi_.emplace_back(tower_itr->id().iPhi());
76  }
77 }
78 
80  tower_n_ = 0;
81  tower_pt_.clear();
82  tower_energy_.clear();
83  tower_eta_.clear();
84  tower_phi_.clear();
85  tower_etEm_.clear();
86  tower_etHad_.clear();
87  tower_iEta_.clear();
88  tower_iPhi_.clear();
89 }
const_iterator end(int bx) const
T getUntrackedParameter(std::string const &, T const &) const
void fill(const edm::Event &e, const HGCalTriggerNtupleEventSetup &es) final
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
HGCalTriggerNtupleHGCTowers(const edm::ParameterSet &conf)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_EDM_PLUGIN(factory, type, name)
const_iterator begin(int bx) const
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final