CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 HGCalTriggerNtupleEventSetup& es) final;
13 
14 private:
15  void clear() final;
16 
18 
21 
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_;
31  std::vector<std::vector<uint32_t>> cl3d_clusters_id_;
32  std::vector<std::vector<float>> cl3d_layer_pt_;
33  // cluster shower shapes
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 
62 HGCalTriggerNtupleHGCMulticlusters::HGCalTriggerNtupleHGCMulticlusters(const edm::ParameterSet& conf)
63  : HGCalTriggerNtupleBase(conf),
64  fill_layer_info_(conf.getParameter<bool>("FillLayerInfo")),
65  fill_interpretation_info_(conf.getParameter<bool>("FillInterpretationInfo")) {
66  accessEventSetup_ = false;
67 }
68 
70  const edm::ParameterSet& conf,
71  edm::ConsumesCollector&& collector) {
73  collector.consumes<l1t::HGCalMulticlusterBxCollection>(conf.getParameter<edm::InputTag>("Multiclusters"));
74  id_ = std::unique_ptr<HGCalTriggerClusterIdentificationBase>{
75  HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT")};
76  id_->initialize(conf.getParameter<edm::ParameterSet>("EGIdentification"));
77 
78  std::string prefix(conf.getUntrackedParameter<std::string>("Prefix", "cl3d"));
79 
80  std::string bname;
81  auto withPrefix([&prefix, &bname](char const* vname) -> char const* {
82  bname = prefix + "_" + vname;
83  return bname.c_str();
84  });
85 
86  tree.Branch(withPrefix("n"), &cl3d_n_, (prefix + "_n/I").c_str());
87  tree.Branch(withPrefix("id"), &cl3d_id_);
88  tree.Branch(withPrefix("pt"), &cl3d_pt_);
89  tree.Branch(withPrefix("energy"), &cl3d_energy_);
90  tree.Branch(withPrefix("eta"), &cl3d_eta_);
91  tree.Branch(withPrefix("phi"), &cl3d_phi_);
92  tree.Branch(withPrefix("clusters_n"), &cl3d_clusters_n_);
93  tree.Branch(withPrefix("clusters_id"), &cl3d_clusters_id_);
94  if (fill_layer_info_)
95  tree.Branch(withPrefix("layer_pt"), &cl3d_layer_pt_);
96  tree.Branch(withPrefix("showerlength"), &cl3d_showerlength_);
97  tree.Branch(withPrefix("coreshowerlength"), &cl3d_coreshowerlength_);
98  tree.Branch(withPrefix("firstlayer"), &cl3d_firstlayer_);
99  tree.Branch(withPrefix("maxlayer"), &cl3d_maxlayer_);
100  tree.Branch(withPrefix("seetot"), &cl3d_seetot_);
101  tree.Branch(withPrefix("seemax"), &cl3d_seemax_);
102  tree.Branch(withPrefix("spptot"), &cl3d_spptot_);
103  tree.Branch(withPrefix("sppmax"), &cl3d_sppmax_);
104  tree.Branch(withPrefix("szz"), &cl3d_szz_);
105  tree.Branch(withPrefix("srrtot"), &cl3d_srrtot_);
106  tree.Branch(withPrefix("srrmax"), &cl3d_srrmax_);
107  tree.Branch(withPrefix("srrmean"), &cl3d_srrmean_);
108  tree.Branch(withPrefix("emaxe"), &cl3d_emaxe_);
109  tree.Branch(withPrefix("hoe"), &cl3d_hoe_);
110  tree.Branch(withPrefix("meanz"), &cl3d_meanz_);
111  tree.Branch(withPrefix("layer10"), &cl3d_layer10_);
112  tree.Branch(withPrefix("layer50"), &cl3d_layer50_);
113  tree.Branch(withPrefix("layer90"), &cl3d_layer90_);
114  tree.Branch(withPrefix("ntc67"), &cl3d_ntc67_);
115  tree.Branch(withPrefix("ntc90"), &cl3d_ntc90_);
116  tree.Branch(withPrefix("bdteg"), &cl3d_bdteg_);
117  tree.Branch(withPrefix("quality"), &cl3d_quality_);
119  tree.Branch(withPrefix("ipt"), &cl3d_ipt_);
120  tree.Branch(withPrefix("ienergy"), &cl3d_ienergy_);
121  }
122 }
123 
125  // retrieve clusters 3D
127  e.getByToken(multiclusters_token_, multiclusters_h);
128  const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h;
129 
130  clear();
131  for (auto cl3d_itr = multiclusters.begin(0); cl3d_itr != multiclusters.end(0); cl3d_itr++) {
132  cl3d_n_++;
133  cl3d_id_.emplace_back(cl3d_itr->detId());
134  // physical values
135  cl3d_pt_.emplace_back(cl3d_itr->pt());
136  cl3d_energy_.emplace_back(cl3d_itr->energy());
137  cl3d_eta_.emplace_back(cl3d_itr->eta());
138  cl3d_phi_.emplace_back(cl3d_itr->phi());
139  cl3d_clusters_n_.emplace_back(cl3d_itr->constituents().size());
140  cl3d_showerlength_.emplace_back(cl3d_itr->showerLength());
141  cl3d_coreshowerlength_.emplace_back(cl3d_itr->coreShowerLength());
142  cl3d_firstlayer_.emplace_back(cl3d_itr->firstLayer());
143  cl3d_maxlayer_.emplace_back(cl3d_itr->maxLayer());
144  cl3d_seetot_.emplace_back(cl3d_itr->sigmaEtaEtaTot());
145  cl3d_seemax_.emplace_back(cl3d_itr->sigmaEtaEtaMax());
146  cl3d_spptot_.emplace_back(cl3d_itr->sigmaPhiPhiTot());
147  cl3d_sppmax_.emplace_back(cl3d_itr->sigmaPhiPhiMax());
148  cl3d_szz_.emplace_back(cl3d_itr->sigmaZZ());
149  cl3d_srrtot_.emplace_back(cl3d_itr->sigmaRRTot());
150  cl3d_srrmax_.emplace_back(cl3d_itr->sigmaRRMax());
151  cl3d_srrmean_.emplace_back(cl3d_itr->sigmaRRMean());
152  cl3d_emaxe_.emplace_back(cl3d_itr->eMax() / cl3d_itr->energy());
153  cl3d_hoe_.emplace_back(cl3d_itr->hOverE());
154  cl3d_meanz_.emplace_back(std::abs(cl3d_itr->zBarycenter()));
155  cl3d_layer10_.emplace_back(cl3d_itr->layer10percent());
156  cl3d_layer50_.emplace_back(cl3d_itr->layer50percent());
157  cl3d_layer90_.emplace_back(cl3d_itr->layer90percent());
158  cl3d_ntc67_.emplace_back(cl3d_itr->triggerCells67percent());
159  cl3d_ntc90_.emplace_back(cl3d_itr->triggerCells90percent());
160  cl3d_bdteg_.emplace_back(id_->value(*cl3d_itr));
161  cl3d_quality_.emplace_back(cl3d_itr->hwQual());
163  std::vector<float> iPts(cl3d_itr->interpretations_size());
164  std::vector<float> iEnergies(cl3d_itr->interpretations_size());
165  for (auto interp = cl3d_itr->interpretations_begin(); interp != cl3d_itr->interpretations_end(); ++interp) {
166  iPts.emplace_back(cl3d_itr->iPt(*interp));
167  iEnergies.emplace_back(cl3d_itr->iEnergy(*interp));
168  }
169  cl3d_ipt_.push_back(iPts);
170  cl3d_ienergy_.push_back(iEnergies);
171  }
172 
173  //Per layer cluster information
174  if (fill_layer_info_) {
175  const unsigned nlayers = es.geometry->lastTriggerLayer();
176  std::vector<float> layer_pt(nlayers, 0.0);
177  for (const auto& cl_ptr : cl3d_itr->constituents()) {
178  unsigned layer = es.geometry->triggerLayer(cl_ptr.second->detId());
179  layer_pt[layer] += cl_ptr.second->pt();
180  }
181  cl3d_layer_pt_.emplace_back(layer_pt);
182  }
183 
184  // Retrieve indices of trigger cells inside cluster
185  cl3d_clusters_id_.emplace_back(cl3d_itr->constituents().size());
186  std::transform(cl3d_itr->constituents_begin(),
187  cl3d_itr->constituents_end(),
188  cl3d_clusters_id_.back().begin(),
189  [](const std::pair<uint32_t, edm::Ptr<l1t::HGCalCluster>>& id_cl) { return id_cl.second->detId(); });
190  }
191 }
192 
194  cl3d_n_ = 0;
195  cl3d_id_.clear();
196  cl3d_pt_.clear();
197  cl3d_energy_.clear();
198  cl3d_eta_.clear();
199  cl3d_phi_.clear();
200  cl3d_clusters_n_.clear();
201  cl3d_clusters_id_.clear();
202  cl3d_layer_pt_.clear();
203  cl3d_showerlength_.clear();
204  cl3d_coreshowerlength_.clear();
205  cl3d_firstlayer_.clear();
206  cl3d_maxlayer_.clear();
207  cl3d_seetot_.clear();
208  cl3d_seemax_.clear();
209  cl3d_spptot_.clear();
210  cl3d_sppmax_.clear();
211  cl3d_szz_.clear();
212  cl3d_srrtot_.clear();
213  cl3d_srrmax_.clear();
214  cl3d_srrmean_.clear();
215  cl3d_emaxe_.clear();
216  cl3d_hoe_.clear();
217  cl3d_meanz_.clear();
218  cl3d_layer10_.clear();
219  cl3d_layer50_.clear();
220  cl3d_layer90_.clear();
221  cl3d_ntc67_.clear();
222  cl3d_ntc90_.clear();
223  cl3d_bdteg_.clear();
224  cl3d_quality_.clear();
225  cl3d_ipt_.clear();
226  cl3d_ienergy_.clear();
227 }
const_iterator end(int bx) const
T getUntrackedParameter(std::string const &, T const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::ESHandle< HGCalTriggerGeometryBase > geometry
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
constexpr std::array< uint8_t, layerIndexSize > layer
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
std::vector< std::vector< uint32_t > > cl3d_clusters_id_
std::vector< std::vector< float > > cl3d_ienergy_
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final
#define DEFINE_EDM_PLUGIN(factory, type, name)
#define get
void fill(const edm::Event &e, const HGCalTriggerNtupleEventSetup &es) final
const_iterator begin(int bx) const
unsigned transform(const HcalDetId &id, unsigned transformCode)