CMS 3D CMS Logo

HGCalTriggerNtupleHGCTriggerCells.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 tc_n_ ;
26  std::vector<uint32_t> tc_id_;
27  std::vector<int> tc_subdet_;
28  std::vector<int> tc_side_;
29  std::vector<int> tc_layer_;
30  std::vector<int> tc_wafer_;
31  std::vector<int> tc_wafertype_ ;
32  std::vector<int> tc_cell_;
33  std::vector<uint32_t> tc_data_;
34  std::vector<float> tc_energy_;
35  std::vector<float> tc_eta_;
36  std::vector<float> tc_phi_;
37  std::vector<float> tc_z_;
38 
39 };
40 
43  "HGCalTriggerNtupleHGCTriggerCells" );
44 
45 
48 {
49 }
50 
51 void
53 initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
54 {
55  trigger_cells_token_ = collector.consumes<l1t::HGCalTriggerCellBxCollection>(conf.getParameter<edm::InputTag>("TriggerCells"));
56 
57  tree.Branch("tc_n", &tc_n_, "tc_n/I");
58  tree.Branch("tc_id", &tc_id_);
59  tree.Branch("tc_subdet", &tc_subdet_);
60  tree.Branch("tc_zside", &tc_side_);
61  tree.Branch("tc_layer", &tc_layer_);
62  tree.Branch("tc_wafer", &tc_wafer_);
63  tree.Branch("tc_wafertype", &tc_wafertype_);
64  tree.Branch("tc_cell", &tc_cell_);
65  tree.Branch("tc_data", &tc_data_);
66  tree.Branch("tc_energy", &tc_energy_);
67  tree.Branch("tc_eta", &tc_eta_);
68  tree.Branch("tc_phi", &tc_phi_);
69  tree.Branch("tc_z", &tc_z_);
70 
71 }
72 
73 void
75 fill(const edm::Event& e, const edm::EventSetup& es)
76 {
77 
78  // retrieve trigger cells
80  e.getByToken(trigger_cells_token_, trigger_cells_h);
81  const l1t::HGCalTriggerCellBxCollection& trigger_cells = *trigger_cells_h;
82 
83  // retrieve geometry
85  es.get<CaloGeometryRecord>().get(geometry);
86 
87  clear();
88  for(auto tc_itr=trigger_cells.begin(0); tc_itr!=trigger_cells.end(0); tc_itr++)
89  {
90  if(tc_itr->hwPt()>0)
91  {
92  tc_n_++;
93  // hardware data
94  HGCalDetId id(tc_itr->detId());
95  tc_id_.emplace_back(tc_itr->detId());
96  tc_subdet_.emplace_back(id.subdetId());
97  tc_side_.emplace_back(id.zside());
98  tc_layer_.emplace_back(id.layer());
99  tc_wafer_.emplace_back(id.wafer());
100  tc_wafertype_.emplace_back(id.waferType());
101  tc_cell_.emplace_back(id.cell());
102  tc_data_.emplace_back(tc_itr->hwPt());
103  // physical values
104  tc_energy_.emplace_back(tc_itr->energy());
105  tc_eta_.emplace_back(tc_itr->eta());
106  tc_phi_.emplace_back(tc_itr->phi());
107  tc_z_.emplace_back(tc_itr->position().z());
108  }
109  }
110 }
111 
112 
113 void
116 {
117  tc_n_ = 0;
118  tc_id_.clear();
119  tc_subdet_.clear();
120  tc_side_.clear();
121  tc_layer_.clear();
122  tc_wafer_.clear();
123  tc_wafertype_.clear();
124  tc_cell_.clear();
125  tc_data_.clear();
126  tc_energy_.clear();
127  tc_eta_.clear();
128  tc_phi_.clear();
129  tc_z_.clear();
130 }
131 
132 
133 
134 
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 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:55
ESHandle< TrackerGeometry > geometry
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: tree.py:1
const_iterator begin(int bx) const