6 #include <unordered_map> 10 : threshold_(conf.getParameter<double>(
"shape_threshold")),
11 distance_(conf.getParameter<double>(
"shape_distance")) {}
19 for (
const auto& energy_X : energy_X_tc) {
20 X_sum += energy_X.first * energy_X.second;
21 Etot += energy_X.first;
26 X_mean = X_sum / Etot;
31 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
35 for (
const auto& id_clu : clustersPtrs) {
36 if (!
pass(*id_clu.second, c3d))
47 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
48 std::unordered_map<int, float> layers_pt;
51 for (
const auto& id_cluster : clustersPtrs) {
52 if (!
pass(*id_cluster.second, c3d))
55 auto itr_insert = layers_pt.emplace(
layer, 0.);
56 itr_insert.first->second += id_cluster.second->pt();
57 if (itr_insert.first->second > max_pt) {
58 max_pt = itr_insert.first->second;
66 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
70 for (
const auto& id_clu : clustersPtrs) {
71 if (!
pass(*id_clu.second, c3d))
83 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
86 for (
const auto& id_cluster : clustersPtrs) {
87 if (!
pass(*id_cluster.second, c3d))
106 if (length > maxlength)
115 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
118 for (
const auto& id_clu : clustersPtrs) {
119 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
122 if (!
pass(*id_tc.second, c3d))
137 unsigned percentile = 0;
139 if (
pt > pt_threshold) {
145 double pt0 = (percentile > 0 ?
layers[percentile - 1] : 0.);
147 return percentile + (
pt1 - pt0 > 0. ? (pt_threshold - pt0) / (
pt1 - pt0) : 0.);
151 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
152 std::set<double> ordered_tcs;
154 for (
const auto& id_clu : clustersPtrs) {
155 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
158 if (!
pass(*id_tc.second, c3d))
160 ordered_tcs.emplace(id_tc.second->pt());
161 pt_sum += id_tc.second->pt();
164 double pt_threshold = pt_sum *
quantile;
165 double partial_sum = 0.;
166 double partial_sum_prev = 0.;
168 for (
auto itr = ordered_tcs.rbegin(); itr != ordered_tcs.rend(); ++itr) {
169 partial_sum_prev = partial_sum;
172 if (partial_sum > pt_threshold) {
178 (partial_sum - partial_sum_prev > 0. ? (pt_threshold - partial_sum_prev) / (partial_sum - partial_sum_prev)
183 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
185 std::vector<std::pair<float, float>> tc_energy_eta;
187 for (
const auto& id_clu : clustersPtrs) {
188 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
191 if (!
pass(*id_tc.second, c3d))
193 tc_energy_eta.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
197 float SeeTot =
sigmaXX(tc_energy_eta, c3d.
eta());
203 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
205 std::vector<std::pair<float, float>> tc_energy_phi;
207 for (
const auto& id_clu : clustersPtrs) {
208 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
211 if (!
pass(*id_tc.second, c3d))
213 tc_energy_phi.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
223 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
225 std::vector<std::pair<float, float>> tc_energy_r;
227 for (
const auto& id_clu : clustersPtrs) {
228 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
231 if (!
pass(*id_tc.second, c3d))
233 float r = (id_tc.second->position().z() != 0.
234 ?
std::sqrt(
pow(id_tc.second->position().x(), 2) +
pow(id_tc.second->position().y(), 2)) /
235 std::abs(id_tc.second->position().z())
237 tc_energy_r.emplace_back(std::make_pair(id_tc.second->energy(),
r));
241 float r_mean =
meanX(tc_energy_r);
242 float Szz =
sigmaXX(tc_energy_r, r_mean);
248 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_eta;
249 std::unordered_map<int, LorentzVector> layer_LV;
251 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
253 for (
const auto& id_clu : clustersPtrs) {
256 layer_LV[
layer] += id_clu.second->p4();
258 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
261 if (!
pass(*id_tc.second, c3d))
263 tc_layer_energy_eta[
layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
267 float SigmaEtaEtaMax = 0;
269 for (
auto& tc_iter : tc_layer_energy_eta) {
270 const std::vector<std::pair<float, float>>& energy_eta_layer = tc_iter.second;
272 float SigmaEtaEtaLayer =
sigmaXX(energy_eta_layer, LV_layer.eta());
273 if (SigmaEtaEtaLayer > SigmaEtaEtaMax)
274 SigmaEtaEtaMax = SigmaEtaEtaLayer;
277 return SigmaEtaEtaMax;
281 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_phi;
282 std::unordered_map<int, LorentzVector> layer_LV;
284 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
286 for (
const auto& id_clu : clustersPtrs) {
289 layer_LV[
layer] += id_clu.second->p4();
291 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
294 if (!
pass(*id_tc.second, c3d))
296 tc_layer_energy_phi[
layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
300 float SigmaPhiPhiMax = 0;
302 for (
auto& tc_iter : tc_layer_energy_phi) {
303 const std::vector<std::pair<float, float>>& energy_phi_layer = tc_iter.second;
305 float SigmaPhiPhiLayer =
sigmaPhiPhi(energy_phi_layer, LV_layer.phi());
306 if (SigmaPhiPhiLayer > SigmaPhiPhiMax)
307 SigmaPhiPhiMax = SigmaPhiPhiLayer;
310 return SigmaPhiPhiMax;
314 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_r;
316 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
318 for (
const auto& id_clu : clustersPtrs) {
321 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
324 if (!
pass(*id_tc.second, c3d))
326 float r = (id_tc.second->position().z() != 0.
327 ?
std::sqrt(
pow(id_tc.second->position().x(), 2) +
pow(id_tc.second->position().y(), 2)) /
328 std::abs(id_tc.second->position().z())
330 tc_layer_energy_r[
layer].emplace_back(std::make_pair(id_tc.second->energy(),
r));
334 float SigmaRRMax = 0;
336 for (
auto& tc_iter : tc_layer_energy_r) {
337 const std::vector<std::pair<float, float>>& energy_r_layer = tc_iter.second;
338 float r_mean_layer =
meanX(energy_r_layer);
339 float SigmaRRLayer =
sigmaXX(energy_r_layer, r_mean_layer);
340 if (SigmaRRLayer > SigmaRRMax)
341 SigmaRRMax = SigmaRRLayer;
348 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
350 std::unordered_map<int, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>> layers_tcs;
351 for (
const auto& id_clu : clustersPtrs) {
353 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
355 if (!
pass(*id_tc.second, c3d))
357 layers_tcs[
layer].emplace_back(id_tc.second);
362 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layers_energy_r;
363 for (
const auto& layer_tcs : layers_tcs) {
364 int layer = layer_tcs.first;
366 for (
const auto& tc : layer_tcs.second) {
367 if (tc->energy() > max_tc->
energy())
370 for (
const auto& tc : layer_tcs.second) {
371 double dx = tc->position().x() - max_tc->
position().
x();
372 double dy = tc->position().y() - max_tc->
position().
y();
374 if (distance_to_max <
radius) {
375 float r = (tc->position().z() != 0.
376 ?
std::sqrt(tc->position().x() * tc->position().x() + tc->position().y() * tc->position().y()) /
379 tc_layers_energy_r[
layer].emplace_back(std::make_pair(tc->energy(),
r));
385 std::vector<std::pair<float, float>> layers_energy_srr2;
386 for (
const auto& layer_energy_r : tc_layers_energy_r) {
387 const auto& energies_r = layer_energy_r.second;
388 float r_mean_layer =
meanX(energies_r);
389 float srr =
sigmaXX(energies_r, r_mean_layer);
390 double energy_sum = 0.;
391 for (
const auto& energy_r : energies_r) {
392 energy_sum += energy_r.first;
394 layers_energy_srr2.emplace_back(std::make_pair(energy_sum, srr * srr));
397 float srr2_mean =
meanX(layers_energy_srr2);
402 std::unordered_map<int, float> layer_energy;
404 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
406 for (
const auto& id_clu : clustersPtrs) {
407 if (!
pass(*id_clu.second, c3d))
410 layer_energy[
layer] += id_clu.second->energy();
415 for (
const auto&
layer : layer_energy) {
416 if (
layer.second > EMax)
424 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
426 std::vector<std::pair<float, float>> tc_energy_z;
428 for (
const auto& id_clu : clustersPtrs) {
429 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
432 if (!
pass(*id_tc.second, c3d))
434 tc_energy_z.emplace_back(id_tc.second->energy(), id_tc.second->position().z());
438 return meanX(tc_energy_z);
442 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
444 std::vector<std::pair<float, float>> tc_energy_z;
446 for (
const auto& id_clu : clustersPtrs) {
447 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
450 if (!
pass(*id_tc.second, c3d))
452 tc_energy_z.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->position().z()));
456 float z_mean =
meanX(tc_energy_z);
457 float Szz =
sigmaXX(tc_energy_z, z_mean);
463 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.
constituents();
465 std::vector<std::pair<float, float>> tc_energy_eta;
467 for (
const auto& id_cell : cellsPtrs) {
468 if (!
pass(*id_cell.second, c2d))
470 tc_energy_eta.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->eta()));
473 float See =
sigmaXX(tc_energy_eta, c2d.
eta());
479 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.
constituents();
481 std::vector<std::pair<float, float>> tc_energy_phi;
483 for (
const auto& id_cell : cellsPtrs) {
484 if (!
pass(*id_cell.second, c2d))
486 tc_energy_phi.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->phi()));
495 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.
constituents();
497 std::vector<std::pair<float, float>> tc_energy_r;
499 for (
const auto& id_cell : cellsPtrs) {
500 if (!
pass(*id_cell.second, c2d))
502 float r = (id_cell.second->position().z() != 0.
503 ?
std::sqrt(
pow(id_cell.second->position().x(), 2) +
pow(id_cell.second->position().y(), 2)) /
504 std::abs(id_cell.second->position().z())
506 tc_energy_r.emplace_back(std::make_pair(id_cell.second->energy(),
r));
509 float r_mean =
meanX(tc_energy_r);
510 float Srr =
sigmaXX(tc_energy_r, r_mean);
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
float sigmaEtaEtaTot() const
float layer50percent() const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
virtual unsigned triggerLayer(const unsigned id) const =0
int coreShowerLength() const
HGCalTriggerTools triggerTools_
float percentileTriggerCells(const l1t::HGCalMulticluster &c3d, float quantile=0.5) const
int lastLayer(const l1t::HGCalMulticluster &c3d) const
float percentileLayer(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry, float quantile=0.5) const
int showerLength(const l1t::HGCalMulticluster &c3d) const
float sigmaEtaEtaTot(const l1t::HGCalMulticluster &c3d) const
float triggerCells90percent() const
float sigmaPhiPhiTot() const
float sigmaZZ(const l1t::HGCalMulticluster &c3d) const
float eMax(const l1t::HGCalMulticluster &c3d) const
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
float sigmaPhiPhiMax() const
float sigmaPhiPhiMax(const l1t::HGCalMulticluster &c3d) const
float zBarycenter() const
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
Abs< T >::type abs(const T &t)
int coreShowerLength(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
math::XYZTLorentzVector LorentzVector
bool pass(const T &obj, const Tref &ref) const
const GlobalPoint & position() const
int maxLayer(const l1t::HGCalMulticluster &c3d) const
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
float layer90percent() const
float sigmaRRMean() const
float sigmaRRTot(const l1t::HGCalMulticluster &c3d) const
float layer10percent() const
float sigmaEtaEtaMax(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiTot(const l1t::HGCalMulticluster &c3d) const
float triggerCells67percent() const
float sigmaEtaEtaMax() const
double phi() const final
momentum azimuthal angle
int firstLayer(const l1t::HGCalMulticluster &c3d) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
float meanZ(const l1t::HGCalMulticluster &c3d) const
Power< A, B >::type pow(const A &a, const B &b)
float sigmaRRMean(const l1t::HGCalMulticluster &c3d, float radius=5.) const
float sigmaPhiPhi(const std::vector< pair< float, float >> &energy_phi_tc, const float phi_cluster) const
double energy() const final
energy
double eta() const final
momentum pseudorapidity