CMS 3D CMS Logo

HGCalTriggerNtupleHGCMulticlusters.cc
Go to the documentation of this file.
6 
8 public:
11  void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final;
12  void fill(const edm::Event& e, const edm::EventSetup& es) final;
13 
14 private:
15  void clear() final;
16 
18 
21 
22  std::unique_ptr<HGCalTriggerClusterIdentificationBase> id_;
23 
24  int cl3d_n_;
25  std::vector<uint32_t> cl3d_id_;
26  std::vector<float> cl3d_pt_;
27  std::vector<float> cl3d_energy_;
28  std::vector<float> cl3d_eta_;
29  std::vector<float> cl3d_phi_;
30  std::vector<int> cl3d_clusters_n_;
31  std::vector<std::vector<uint32_t>> cl3d_clusters_id_;
32  std::vector<std::vector<float>> cl3d_layer_pt_;
33  // cluster shower shapes
34  std::vector<int> cl3d_showerlength_;
35  std::vector<int> cl3d_coreshowerlength_;
36  std::vector<int> cl3d_firstlayer_;
37  std::vector<int> cl3d_maxlayer_;
38  std::vector<float> cl3d_seetot_;
39  std::vector<float> cl3d_seemax_;
40  std::vector<float> cl3d_spptot_;
41  std::vector<float> cl3d_sppmax_;
42  std::vector<float> cl3d_szz_;
43  std::vector<float> cl3d_srrtot_;
44  std::vector<float> cl3d_srrmax_;
45  std::vector<float> cl3d_srrmean_;
46  std::vector<float> cl3d_emaxe_;
47  std::vector<float> cl3d_hoe_;
48  std::vector<float> cl3d_meanz_;
49  std::vector<float> cl3d_layer10_;
50  std::vector<float> cl3d_layer50_;
51  std::vector<float> cl3d_layer90_;
52  std::vector<float> cl3d_ntc67_;
53  std::vector<float> cl3d_ntc90_;
54  std::vector<float> cl3d_bdteg_;
55  std::vector<int> cl3d_quality_;
56  std::vector<std::vector<float>> cl3d_ipt_;
57  std::vector<std::vector<float>> cl3d_ienergy_;
58 };
59 
61 
63  : HGCalTriggerNtupleBase(conf),
64  fill_layer_info_(conf.getParameter<bool>("FillLayerInfo")),
65  fill_interpretation_info_(conf.getParameter<bool>("FillInterpretationInfo")) {}
66 
68  const edm::ParameterSet& conf,
69  edm::ConsumesCollector&& collector) {
71  collector.consumes<l1t::HGCalMulticlusterBxCollection>(conf.getParameter<edm::InputTag>("Multiclusters"));
72  id_ = std::unique_ptr<HGCalTriggerClusterIdentificationBase>{
73  HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT")};
74  id_->initialize(conf.getParameter<edm::ParameterSet>("EGIdentification"));
75 
76  std::string prefix(conf.getUntrackedParameter<std::string>("Prefix", "cl3d"));
77 
78  std::string bname;
79  auto withPrefix([&prefix, &bname](char const* vname) -> char const* {
80  bname = prefix + "_" + vname;
81  return bname.c_str();
82  });
83 
84  tree.Branch(withPrefix("n"), &cl3d_n_, (prefix + "_n/I").c_str());
85  tree.Branch(withPrefix("id"), &cl3d_id_);
86  tree.Branch(withPrefix("pt"), &cl3d_pt_);
87  tree.Branch(withPrefix("energy"), &cl3d_energy_);
88  tree.Branch(withPrefix("eta"), &cl3d_eta_);
89  tree.Branch(withPrefix("phi"), &cl3d_phi_);
90  tree.Branch(withPrefix("clusters_n"), &cl3d_clusters_n_);
91  tree.Branch(withPrefix("clusters_id"), &cl3d_clusters_id_);
92  if (fill_layer_info_)
93  tree.Branch(withPrefix("layer_pt"), &cl3d_layer_pt_);
94  tree.Branch(withPrefix("showerlength"), &cl3d_showerlength_);
95  tree.Branch(withPrefix("coreshowerlength"), &cl3d_coreshowerlength_);
96  tree.Branch(withPrefix("firstlayer"), &cl3d_firstlayer_);
97  tree.Branch(withPrefix("maxlayer"), &cl3d_maxlayer_);
98  tree.Branch(withPrefix("seetot"), &cl3d_seetot_);
99  tree.Branch(withPrefix("seemax"), &cl3d_seemax_);
100  tree.Branch(withPrefix("spptot"), &cl3d_spptot_);
101  tree.Branch(withPrefix("sppmax"), &cl3d_sppmax_);
102  tree.Branch(withPrefix("szz"), &cl3d_szz_);
103  tree.Branch(withPrefix("srrtot"), &cl3d_srrtot_);
104  tree.Branch(withPrefix("srrmax"), &cl3d_srrmax_);
105  tree.Branch(withPrefix("srrmean"), &cl3d_srrmean_);
106  tree.Branch(withPrefix("emaxe"), &cl3d_emaxe_);
107  tree.Branch(withPrefix("hoe"), &cl3d_hoe_);
108  tree.Branch(withPrefix("meanz"), &cl3d_meanz_);
109  tree.Branch(withPrefix("layer10"), &cl3d_layer10_);
110  tree.Branch(withPrefix("layer50"), &cl3d_layer50_);
111  tree.Branch(withPrefix("layer90"), &cl3d_layer90_);
112  tree.Branch(withPrefix("ntc67"), &cl3d_ntc67_);
113  tree.Branch(withPrefix("ntc90"), &cl3d_ntc90_);
114  tree.Branch(withPrefix("bdteg"), &cl3d_bdteg_);
115  tree.Branch(withPrefix("quality"), &cl3d_quality_);
117  tree.Branch(withPrefix("ipt"), &cl3d_ipt_);
118  tree.Branch(withPrefix("ienergy"), &cl3d_ienergy_);
119  }
120 }
121 
123  // retrieve clusters 3D
125  e.getByToken(multiclusters_token_, multiclusters_h);
126  const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h;
127 
128  // retrieve geometry
130  es.get<CaloGeometryRecord>().get(geometry);
131 
132  clear();
133  for (auto cl3d_itr = multiclusters.begin(0); cl3d_itr != multiclusters.end(0); cl3d_itr++) {
134  cl3d_n_++;
135  cl3d_id_.emplace_back(cl3d_itr->detId());
136  // physical values
137  cl3d_pt_.emplace_back(cl3d_itr->pt());
138  cl3d_energy_.emplace_back(cl3d_itr->energy());
139  cl3d_eta_.emplace_back(cl3d_itr->eta());
140  cl3d_phi_.emplace_back(cl3d_itr->phi());
141  cl3d_clusters_n_.emplace_back(cl3d_itr->constituents().size());
142  cl3d_showerlength_.emplace_back(cl3d_itr->showerLength());
143  cl3d_coreshowerlength_.emplace_back(cl3d_itr->coreShowerLength());
144  cl3d_firstlayer_.emplace_back(cl3d_itr->firstLayer());
145  cl3d_maxlayer_.emplace_back(cl3d_itr->maxLayer());
146  cl3d_seetot_.emplace_back(cl3d_itr->sigmaEtaEtaTot());
147  cl3d_seemax_.emplace_back(cl3d_itr->sigmaEtaEtaMax());
148  cl3d_spptot_.emplace_back(cl3d_itr->sigmaPhiPhiTot());
149  cl3d_sppmax_.emplace_back(cl3d_itr->sigmaPhiPhiMax());
150  cl3d_szz_.emplace_back(cl3d_itr->sigmaZZ());
151  cl3d_srrtot_.emplace_back(cl3d_itr->sigmaRRTot());
152  cl3d_srrmax_.emplace_back(cl3d_itr->sigmaRRMax());
153  cl3d_srrmean_.emplace_back(cl3d_itr->sigmaRRMean());
154  cl3d_emaxe_.emplace_back(cl3d_itr->eMax() / cl3d_itr->energy());
155  cl3d_hoe_.emplace_back(cl3d_itr->hOverE());
156  cl3d_meanz_.emplace_back(std::abs(cl3d_itr->zBarycenter()));
157  cl3d_layer10_.emplace_back(cl3d_itr->layer10percent());
158  cl3d_layer50_.emplace_back(cl3d_itr->layer50percent());
159  cl3d_layer90_.emplace_back(cl3d_itr->layer90percent());
160  cl3d_ntc67_.emplace_back(cl3d_itr->triggerCells67percent());
161  cl3d_ntc90_.emplace_back(cl3d_itr->triggerCells90percent());
162  cl3d_bdteg_.emplace_back(id_->value(*cl3d_itr));
163  cl3d_quality_.emplace_back(cl3d_itr->hwQual());
165  std::vector<float> iPts(cl3d_itr->interpretations_size());
166  std::vector<float> iEnergies(cl3d_itr->interpretations_size());
167  for (auto interp = cl3d_itr->interpretations_begin(); interp != cl3d_itr->interpretations_end(); ++interp) {
168  iPts.emplace_back(cl3d_itr->iPt(*interp));
169  iEnergies.emplace_back(cl3d_itr->iEnergy(*interp));
170  }
171  cl3d_ipt_.push_back(iPts);
172  cl3d_ienergy_.push_back(iEnergies);
173  }
174 
175  //Per layer cluster information
176  if (fill_layer_info_) {
177  const unsigned nlayers = geometry->lastTriggerLayer();
178  std::vector<float> layer_pt(nlayers, 0.0);
179  for (const auto& cl_ptr : cl3d_itr->constituents()) {
180  unsigned layer = geometry->triggerLayer(cl_ptr.second->detId());
181  layer_pt[layer] += cl_ptr.second->pt();
182  }
183  cl3d_layer_pt_.emplace_back(layer_pt);
184  }
185 
186  // Retrieve indices of trigger cells inside cluster
187  cl3d_clusters_id_.emplace_back(cl3d_itr->constituents().size());
188  std::transform(cl3d_itr->constituents_begin(),
189  cl3d_itr->constituents_end(),
190  cl3d_clusters_id_.back().begin(),
191  [](const std::pair<uint32_t, edm::Ptr<l1t::HGCalCluster>>& id_cl) { return id_cl.second->detId(); });
192  }
193 }
194 
196  cl3d_n_ = 0;
197  cl3d_id_.clear();
198  cl3d_pt_.clear();
199  cl3d_energy_.clear();
200  cl3d_eta_.clear();
201  cl3d_phi_.clear();
202  cl3d_clusters_n_.clear();
203  cl3d_clusters_id_.clear();
204  cl3d_layer_pt_.clear();
205  cl3d_showerlength_.clear();
206  cl3d_coreshowerlength_.clear();
207  cl3d_firstlayer_.clear();
208  cl3d_maxlayer_.clear();
209  cl3d_seetot_.clear();
210  cl3d_seemax_.clear();
211  cl3d_spptot_.clear();
212  cl3d_sppmax_.clear();
213  cl3d_szz_.clear();
214  cl3d_srrtot_.clear();
215  cl3d_srrmax_.clear();
216  cl3d_srrmean_.clear();
217  cl3d_emaxe_.clear();
218  cl3d_hoe_.clear();
219  cl3d_meanz_.clear();
220  cl3d_layer10_.clear();
221  cl3d_layer50_.clear();
222  cl3d_layer90_.clear();
223  cl3d_ntc67_.clear();
224  cl3d_ntc90_.clear();
225  cl3d_bdteg_.clear();
226  cl3d_quality_.clear();
227  cl3d_ipt_.clear();
228  cl3d_ienergy_.clear();
229 }
const_iterator end(int bx) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< std::vector< float > > cl3d_ipt_
HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet &conf)
std::vector< std::vector< float > > cl3d_layer_pt_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual unsigned triggerLayer(const unsigned id) const =0
std::vector< std::vector< uint32_t > > cl3d_clusters_id_
std::vector< std::vector< float > > cl3d_ienergy_
virtual unsigned lastTriggerLayer() const =0
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
ESHandle< TrackerGeometry > geometry
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final
void fill(const edm::Event &e, const edm::EventSetup &es) final
T get() const
Definition: EventSetup.h:73
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: tree.py:1
const_iterator begin(int bx) const
unsigned transform(const HcalDetId &id, unsigned transformCode)