CMS 3D CMS Logo

HGCalTriggerNtupleHGCPanels.cc
Go to the documentation of this file.
1 
7 
8 
9 
11 {
12 
13  public:
16  void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final;
17  void fill(const edm::Event& e, const edm::EventSetup& es) final;
18 
19  private:
20  void clear() final;
21 
22 
25 
26  int panel_n_ ;
27  std::vector<uint32_t> panel_id_;
28  std::vector<int> panel_zside_;
29  std::vector<int> panel_layer_;
30  std::vector<int> panel_sector_;
31  std::vector<int> panel_number_;
32  std::vector<unsigned> panel_tc_n_;
33  std::vector<std::vector<uint32_t> > panel_tc_id_;
34  std::vector<std::vector<uint32_t> > panel_tc_mod_;
35  std::vector<std::vector<uint32_t> > panel_tc_third_;
36  std::vector<std::vector<uint32_t> > panel_tc_cell_;
37  std::vector<std::vector<float> > panel_tc_mipPt_;
38  std::vector<std::vector<float> > panel_tc_pt_;
39 
40  private:
41  static const unsigned kPanel_offset_ = 0;
42  static const unsigned kPanel_mask_ = 0x1F;
43  static const unsigned kSector_offset_ = 5;
44  static const unsigned kSector_mask_ = 0x7;
45  static const unsigned kThird_offset_ = 4;
46  static const unsigned kThird_mask_ = 0x3;
47  static const unsigned kCell_mask_ = 0xF;
48 
49 };
50 
53  "HGCalTriggerNtupleHGCPanels" );
54 
55 
58 {
59 }
60 
61 void
63 initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
64 {
65  trigger_cells_token_ = collector.consumes<l1t::HGCalTriggerCellBxCollection>(conf.getParameter<edm::InputTag>("TriggerCells"));
66 
67  tree.Branch("panel_n", &panel_n_, "panel_n/I");
68  tree.Branch("panel_id", &panel_id_);
69  tree.Branch("panel_zside", &panel_zside_);
70  tree.Branch("panel_layer", &panel_layer_);
71  tree.Branch("panel_sector", &panel_sector_);
72  tree.Branch("panel_number", &panel_number_);
73  tree.Branch("panel_tc_n", &panel_tc_n_);
74  tree.Branch("panel_tc_id", &panel_tc_id_);
75  tree.Branch("panel_tc_mod", &panel_tc_mod_);
76  tree.Branch("panel_tc_third", &panel_tc_third_);
77  tree.Branch("panel_tc_cell", &panel_tc_cell_);
78  tree.Branch("panel_tc_mipPt", &panel_tc_mipPt_);
79  tree.Branch("panel_tc_pt", &panel_tc_pt_);
80 
81 }
82 
83 void
85 fill(const edm::Event& e, const edm::EventSetup& es)
86 {
87 
88  // retrieve trigger cells
90  e.getByToken(trigger_cells_token_, trigger_cells_h);
91  const l1t::HGCalTriggerCellBxCollection& trigger_cells = *trigger_cells_h;
92 
93  // retrieve geometry
94  es.get<CaloGeometryRecord>().get(geometry_);
95 
96  clear();
97 
98  // Regroup trigger cells by panel
99  std::unordered_map< uint32_t,vector<l1t::HGCalTriggerCellBxCollection::const_iterator> > panelids_tcs;
100  for(auto tc_itr=trigger_cells.begin(0); tc_itr!=trigger_cells.end(0); tc_itr++)
101  {
102  if(tc_itr->hwPt()>0 && tc_itr->subdetId()!=ForwardSubdetector::HGCHEB)
103  {
104  HGCalDetId id(tc_itr->detId());
106  panelids_tcs[panelid].push_back(tc_itr);
107  }
108  }
109  for (const auto& panelid_tcs : panelids_tcs)
110  {
111  panel_n_++;
112  HGCalDetId panelid(panelid_tcs.first);
113  int panel_sector = (panelid.wafer()>>kSector_offset_) & kSector_mask_ ;
114  int panel_number = (panelid.wafer()>>kPanel_offset_) & kPanel_mask_ ;
115  const auto& tcs = panelid_tcs.second;
116  panel_id_.emplace_back(panelid);
117  panel_zside_.emplace_back(panelid.zside());
118  panel_layer_.emplace_back(geometry_->triggerLayer(panelid));
119  panel_sector_.emplace_back(panel_sector);
120  panel_number_.emplace_back(panel_number);
121  panel_tc_n_.emplace_back(tcs.size());
122  panel_tc_id_.emplace_back();
123  panel_tc_mod_.emplace_back();
124  panel_tc_third_.emplace_back();
125  panel_tc_cell_.emplace_back();
126  panel_tc_mipPt_.emplace_back();
127  panel_tc_pt_.emplace_back();
128 
129  for (const auto& tc : tcs)
130  {
131  panel_tc_id_.back().push_back(tc->detId());
132  panel_tc_mipPt_.back().push_back(tc->mipPt());
133  panel_tc_pt_.back().push_back(tc->pt());
134  HGCalDetId tc_detid(tc->detId());
135  unsigned module_id = tc_detid.wafer();
136  unsigned third_id = (tc_detid.cell()>>kThird_offset_) & kThird_mask_;
137  unsigned cell_id = tc_detid.cell() & kCell_mask_;
138  panel_tc_mod_.back().push_back(module_id);
139  panel_tc_third_.back().push_back(third_id);
140  panel_tc_cell_.back().push_back(cell_id);
141  }
142  }
143 }
144 
145 
146 void
149 {
150  panel_n_ = 0;
151  panel_id_.clear();
152  panel_zside_.clear();
153  panel_layer_.clear();
154  panel_sector_.clear();
155  panel_number_.clear();
156  panel_tc_n_.clear();
157  panel_tc_id_.clear();
158  panel_tc_mod_.clear();
159  panel_tc_third_.clear();
160  panel_tc_cell_.clear();
161  panel_tc_mipPt_.clear();
162  panel_tc_pt_.clear();
163 }
164 
165 
166 
167 
const_iterator end(int bx) const
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::vector< std::vector< uint32_t > > panel_tc_mod_
std::vector< std::vector< float > > panel_tc_pt_
void fill(const edm::Event &e, const edm::EventSetup &es) final
edm::ESHandle< HGCalTriggerGeometryBase > geometry_
std::vector< std::vector< uint32_t > > panel_tc_cell_
int zside() const
get the z-side of the cell (1/-1)
Definition: HGCalDetId.h:51
std::vector< std::vector< float > > panel_tc_mipPt_
HGCalTriggerNtupleHGCPanels(const edm::ParameterSet &conf)
virtual unsigned triggerLayer(const unsigned id) const =0
int wafer() const
get the wafer #
Definition: HGCalDetId.h:42
virtual unsigned getModuleFromTriggerCell(const unsigned trigger_cell_det_id) const =0
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final
T get() const
Definition: EventSetup.h:62
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: tree.py:1
std::vector< std::vector< uint32_t > > panel_tc_id_
const_iterator begin(int bx) const
std::vector< std::vector< uint32_t > > panel_tc_third_