CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalTriggerNtupleHGCTriggerSums.cc
Go to the documentation of this file.
1 
10 
12 public:
15  void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final;
16  void fill(const edm::Event& e, const HGCalTriggerNtupleEventSetup& es) final;
17 
18 private:
19  void clear() final;
20 
22 
24 
25  int ts_n_;
26  std::vector<uint32_t> ts_id_;
27  std::vector<int> ts_subdet_;
28  std::vector<int> ts_side_;
29  std::vector<int> ts_layer_;
32  std::vector<int> ts_wafer_;
33  std::vector<int> ts_wafertype_;
34  std::vector<uint32_t> ts_data_;
35  std::vector<float> ts_mipPt_;
36  std::vector<float> ts_pt_;
37  std::vector<float> ts_energy_;
38  std::vector<float> ts_eta_;
39  std::vector<float> ts_phi_;
40  std::vector<float> ts_x_;
41  std::vector<float> ts_y_;
42  std::vector<float> ts_z_;
43 };
44 
46 
47 HGCalTriggerNtupleHGCTriggerSums::HGCalTriggerNtupleHGCTriggerSums(const edm::ParameterSet& conf)
48  : HGCalTriggerNtupleBase(conf) {
49  accessEventSetup_ = false;
50 }
51 
53  const edm::ParameterSet& conf,
54  edm::ConsumesCollector&& collector) {
56  collector.consumes<l1t::HGCalTriggerSumsBxCollection>(conf.getParameter<edm::InputTag>("TriggerSums"));
57 
58  std::string prefix(conf.getUntrackedParameter<std::string>("Prefix", "ts"));
59 
60  std::string bname;
61  auto withPrefix([&prefix, &bname](char const* vname) -> char const* {
62  bname = prefix + "_" + vname;
63  return bname.c_str();
64  });
65 
66  tree.Branch(withPrefix("n"), &ts_n_, (prefix + "_n/I").c_str());
67  tree.Branch(withPrefix("id"), &ts_id_);
68  tree.Branch(withPrefix("subdet"), &ts_subdet_);
69  tree.Branch(withPrefix("zside"), &ts_side_);
70  tree.Branch(withPrefix("layer"), &ts_layer_);
71  tree.Branch(withPrefix("wafer"), &ts_wafer_);
72  tree.Branch(withPrefix("wafertype"), &ts_wafertype_);
73  tree.Branch(withPrefix("data"), &ts_data_);
74  tree.Branch(withPrefix("pt"), &ts_pt_);
75  tree.Branch(withPrefix("mipPt"), &ts_mipPt_);
76  tree.Branch(withPrefix("energy"), &ts_energy_);
77  tree.Branch(withPrefix("eta"), &ts_eta_);
78  tree.Branch(withPrefix("phi"), &ts_phi_);
79  tree.Branch(withPrefix("x"), &ts_x_);
80  tree.Branch(withPrefix("y"), &ts_y_);
81  tree.Branch(withPrefix("z"), &ts_z_);
82 }
83 
85  // retrieve trigger cells
87  e.getByToken(trigger_sums_token_, trigger_sums_h);
88  const l1t::HGCalTriggerSumsBxCollection& trigger_sums = *trigger_sums_h;
89 
91 
92  clear();
93  for (auto ts_itr = trigger_sums.begin(0); ts_itr != trigger_sums.end(0); ts_itr++) {
94  if (ts_itr->pt() > 0) {
95  ts_n_++;
96  // hardware data
97  DetId moduleId(ts_itr->detId());
98  ts_id_.emplace_back(ts_itr->detId());
99  ts_side_.emplace_back(triggerTools_.zside(moduleId));
101  if (moduleId.det() == DetId::HGCalTrigger) {
103  ts_subdet_.emplace_back(id.subdet());
104  ts_wafertype_.emplace_back(id.type());
105  } else if (moduleId.det() == DetId::HGCalHSc) {
107  ts_subdet_.emplace_back(id.subdet());
108  ts_wafertype_.emplace_back(id.type());
109  } else {
110  ts_subdet_.emplace_back(-999);
111  ts_wafertype_.emplace_back(-999);
112  }
113  ts_data_.emplace_back(ts_itr->hwPt());
114  ts_mipPt_.emplace_back(ts_itr->mipPt());
115  // physical values
116  ts_pt_.emplace_back(ts_itr->pt());
117  ts_energy_.emplace_back(ts_itr->energy());
118  ts_eta_.emplace_back(ts_itr->eta());
119  ts_phi_.emplace_back(ts_itr->phi());
120  ts_x_.emplace_back(ts_itr->position().x());
121  ts_y_.emplace_back(ts_itr->position().y());
122  ts_z_.emplace_back(ts_itr->position().z());
123  }
124  }
125 }
126 
128  ts_n_ = 0;
129  ts_id_.clear();
130  ts_subdet_.clear();
131  ts_side_.clear();
132  ts_layer_.clear();
133  ts_wafer_.clear();
134  ts_wafertype_.clear();
135  ts_data_.clear();
136  ts_mipPt_.clear();
137  ts_pt_.clear();
138  ts_energy_.clear();
139  ts_eta_.clear();
140  ts_phi_.clear();
141  ts_x_.clear();
142  ts_y_.clear();
143  ts_z_.clear();
144 }
const_iterator end(int bx) const
T getUntrackedParameter(std::string const &, T const &) const
void fill(const edm::Event &e, const HGCalTriggerNtupleEventSetup &es) final
uint16_t *__restrict__ id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
unsigned layerWithOffset(const DetId &) const
edm::ESHandle< HGCalTriggerGeometryBase > geometry
void setGeometry(const HGCalTriggerGeometryBase *const)
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final
int zside(const DetId &) const
uint16_t *__restrict__ uint16_t const *__restrict__ uint32_t const *__restrict__ uint32_t *__restrict__ uint32_t const *__restrict__ moduleId
Definition: DetId.h:17
T const * product() const
Definition: ESHandle.h:86
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HGCalTriggerNtupleHGCTriggerSums(const edm::ParameterSet &conf)
#define DEFINE_EDM_PLUGIN(factory, type, name)
const_iterator begin(int bx) const