CMS 3D CMS Logo

HGCalTriggerNtupleHGCTriggerCells.cc
Go to the documentation of this file.
1 
6 
7 
8 
10 {
11 
12  public:
15  virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) override final;
16  virtual void fill(const edm::Event& e, const edm::EventSetup& es) override final;
17 
18  private:
19  virtual void clear() override final;
20 
21 
23 
24  int tc_n_ ;
25  std::vector<uint32_t> tc_id_;
26  std::vector<int> tc_subdet_;
27  std::vector<int> tc_side_;
28  std::vector<int> tc_layer_;
29  std::vector<int> tc_wafer_;
30  std::vector<int> tc_wafertype_ ;
31  std::vector<int> tc_cell_;
32  std::vector<uint32_t> tc_data_;
33  std::vector<float> tc_energy_;
34  std::vector<float> tc_eta_;
35  std::vector<float> tc_phi_;
36  std::vector<float> tc_z_;
37 
38 };
39 
42  "HGCalTriggerNtupleHGCTriggerCells" );
43 
44 
47 {
48 }
49 
50 void
52 initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
53 {
54  trigger_cells_token_ = collector.consumes<l1t::HGCalTriggerCellBxCollection>(conf.getParameter<edm::InputTag>("TriggerCells"));
55 
56  tree.Branch("tc_n", &tc_n_, "tc_n/I");
57  tree.Branch("tc_id", &tc_id_);
58  tree.Branch("tc_subdet", &tc_subdet_);
59  tree.Branch("tc_zside", &tc_side_);
60  tree.Branch("tc_layer", &tc_layer_);
61  tree.Branch("tc_wafer", &tc_wafer_);
62  tree.Branch("tc_wafertype", &tc_wafertype_);
63  tree.Branch("tc_cell", &tc_cell_);
64  tree.Branch("tc_data", &tc_data_);
65  tree.Branch("tc_energy", &tc_energy_);
66  tree.Branch("tc_eta", &tc_eta_);
67  tree.Branch("tc_phi", &tc_phi_);
68  tree.Branch("tc_z", &tc_z_);
69 
70 }
71 
72 void
74 fill(const edm::Event& e, const edm::EventSetup& es)
75 {
76 
77  // retrieve trigger cells
79  e.getByToken(trigger_cells_token_, trigger_cells_h);
80  const l1t::HGCalTriggerCellBxCollection& trigger_cells = *trigger_cells_h;
81 
82  // retrieve geometry
84  es.get<IdealGeometryRecord>().get(geometry);
85 
86  clear();
87  for(auto tc_itr=trigger_cells.begin(0); tc_itr!=trigger_cells.end(0); tc_itr++)
88  {
89  if(tc_itr->hwPt()>0)
90  {
91  tc_n_++;
92  // hardware data
93  HGCalDetId id(tc_itr->detId());
94  tc_id_.emplace_back(tc_itr->detId());
95  tc_subdet_.emplace_back(id.subdetId());
96  tc_side_.emplace_back(id.zside());
97  tc_layer_.emplace_back(id.layer());
98  tc_wafer_.emplace_back(id.wafer());
99  tc_wafertype_.emplace_back(id.waferType());
100  tc_cell_.emplace_back(id.cell());
101  tc_data_.emplace_back(tc_itr->hwPt());
102  // physical values
103  tc_energy_.emplace_back(tc_itr->energy());
104  tc_eta_.emplace_back(tc_itr->eta());
105  tc_phi_.emplace_back(tc_itr->phi());
106  tc_z_.emplace_back(tc_itr->position().z());
107  }
108  }
109 }
110 
111 
112 void
115 {
116  tc_n_ = 0;
117  tc_id_.clear();
118  tc_subdet_.clear();
119  tc_side_.clear();
120  tc_layer_.clear();
121  tc_wafer_.clear();
122  tc_wafertype_.clear();
123  tc_cell_.clear();
124  tc_data_.clear();
125  tc_energy_.clear();
126  tc_eta_.clear();
127  tc_phi_.clear();
128  tc_z_.clear();
129 }
130 
131 
132 
133 
const_iterator end(int bx) const
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
virtual void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) override final
HGCalTriggerNtupleHGCTriggerCells(const edm::ParameterSet &conf)
virtual void fill(const edm::Event &e, const edm::EventSetup &es) override final
const T & get() const
Definition: EventSetup.h:56
ESHandle< TrackerGeometry > geometry
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: tree.py:1
const_iterator begin(int bx) const