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();
85 std::vector<bool>
layers(nlayers);
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();
117 std::vector<double>
layers(nlayers, 0);
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)
185 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
187 std::vector<std::pair<float, float>> tc_energy_eta;
189 for (
const auto& id_clu : clustersPtrs) {
190 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
193 if (!
pass(*id_tc.second, c3d))
195 tc_energy_eta.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
199 float varee =
varXX(tc_energy_eta, c3d.
eta());
207 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
209 std::vector<std::pair<float, float>> tc_energy_phi;
211 for (
const auto& id_clu : clustersPtrs) {
212 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
215 if (!
pass(*id_tc.second, c3d))
217 tc_energy_phi.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
229 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
231 std::vector<std::pair<float, float>> tc_energy_r;
233 for (
const auto& id_clu : clustersPtrs) {
234 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
237 if (!
pass(*id_tc.second, c3d))
239 float r = (id_tc.second->position().z() != 0.
240 ?
std::sqrt(
pow(id_tc.second->position().x(), 2) +
pow(id_tc.second->position().y(), 2)) /
241 std::abs(id_tc.second->position().z())
243 tc_energy_r.emplace_back(std::make_pair(id_tc.second->energy(),
r));
247 float r_mean =
meanX(tc_energy_r);
248 float vrr =
varXX(tc_energy_r, r_mean);
254 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_eta;
255 std::unordered_map<int, LorentzVector> layer_LV;
257 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
259 for (
const auto& id_clu : clustersPtrs) {
262 layer_LV[
layer] += id_clu.second->p4();
264 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
267 if (!
pass(*id_tc.second, c3d))
269 tc_layer_energy_eta[
layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->eta()));
273 float SigmaEtaEtaMax = 0;
275 for (
auto& tc_iter : tc_layer_energy_eta) {
276 const std::vector<std::pair<float, float>>& energy_eta_layer = tc_iter.second;
278 float SigmaEtaEtaLayer =
sigmaXX(energy_eta_layer, LV_layer.eta());
279 if (SigmaEtaEtaLayer > SigmaEtaEtaMax)
280 SigmaEtaEtaMax = SigmaEtaEtaLayer;
283 return SigmaEtaEtaMax;
287 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_phi;
288 std::unordered_map<int, LorentzVector> layer_LV;
290 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
292 for (
const auto& id_clu : clustersPtrs) {
295 layer_LV[
layer] += id_clu.second->p4();
297 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
300 if (!
pass(*id_tc.second, c3d))
302 tc_layer_energy_phi[
layer].emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->phi()));
306 float SigmaPhiPhiMax = 0;
308 for (
auto& tc_iter : tc_layer_energy_phi) {
309 const std::vector<std::pair<float, float>>& energy_phi_layer = tc_iter.second;
311 float SigmaPhiPhiLayer =
sigmaPhiPhi(energy_phi_layer, LV_layer.phi());
312 if (SigmaPhiPhiLayer > SigmaPhiPhiMax)
313 SigmaPhiPhiMax = SigmaPhiPhiLayer;
316 return SigmaPhiPhiMax;
320 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layer_energy_r;
322 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
324 for (
const auto& id_clu : clustersPtrs) {
327 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
330 if (!
pass(*id_tc.second, c3d))
332 float r = (id_tc.second->position().z() != 0.
333 ?
std::sqrt(
pow(id_tc.second->position().x(), 2) +
pow(id_tc.second->position().y(), 2)) /
334 std::abs(id_tc.second->position().z())
336 tc_layer_energy_r[
layer].emplace_back(std::make_pair(id_tc.second->energy(),
r));
340 float SigmaRRMax = 0;
342 for (
auto& tc_iter : tc_layer_energy_r) {
343 const std::vector<std::pair<float, float>>& energy_r_layer = tc_iter.second;
344 float r_mean_layer =
meanX(energy_r_layer);
345 float SigmaRRLayer =
sigmaXX(energy_r_layer, r_mean_layer);
346 if (SigmaRRLayer > SigmaRRMax)
347 SigmaRRMax = SigmaRRLayer;
354 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
356 std::unordered_map<int, std::vector<edm::Ptr<l1t::HGCalTriggerCell>>> layers_tcs;
357 for (
const auto& id_clu : clustersPtrs) {
359 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
361 if (!
pass(*id_tc.second, c3d))
363 layers_tcs[
layer].emplace_back(id_tc.second);
368 std::unordered_map<int, std::vector<std::pair<float, float>>> tc_layers_energy_r;
369 for (
const auto& layer_tcs : layers_tcs) {
370 int layer = layer_tcs.first;
372 for (
const auto& tc : layer_tcs.second) {
373 if (tc->energy() > max_tc->
energy())
376 for (
const auto& tc : layer_tcs.second) {
377 double dx = tc->position().x() - max_tc->
position().
x();
378 double dy = tc->position().y() - max_tc->
position().
y();
380 if (distance_to_max <
radius) {
381 float r = (tc->position().z() != 0.
382 ?
std::sqrt(tc->position().x() * tc->position().x() + tc->position().y() * tc->position().y()) /
385 tc_layers_energy_r[
layer].emplace_back(std::make_pair(tc->energy(),
r));
391 std::vector<std::pair<float, float>> layers_energy_srr2;
392 for (
const auto& layer_energy_r : tc_layers_energy_r) {
393 const auto& energies_r = layer_energy_r.second;
394 float r_mean_layer =
meanX(energies_r);
395 float srr =
sigmaXX(energies_r, r_mean_layer);
396 double energy_sum = 0.;
397 for (
const auto& energy_r : energies_r) {
398 energy_sum += energy_r.first;
400 layers_energy_srr2.emplace_back(std::make_pair(energy_sum, srr * srr));
403 float srr2_mean =
meanX(layers_energy_srr2);
408 std::unordered_map<int, float> layer_energy;
410 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
412 for (
const auto& id_clu : clustersPtrs) {
413 if (!
pass(*id_clu.second, c3d))
416 layer_energy[
layer] += id_clu.second->energy();
421 for (
const auto&
layer : layer_energy) {
422 if (
layer.second > EMax)
430 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
432 std::vector<std::pair<float, float>> tc_energy_z;
434 for (
const auto& id_clu : clustersPtrs) {
435 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
438 if (!
pass(*id_tc.second, c3d))
440 tc_energy_z.emplace_back(id_tc.second->energy(), id_tc.second->position().z());
444 return meanX(tc_energy_z);
449 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
451 std::vector<std::pair<float, float>> tc_energy_z;
453 for (
const auto& id_clu : clustersPtrs) {
454 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
457 if (!
pass(*id_tc.second, c3d))
459 tc_energy_z.emplace_back(std::make_pair(id_tc.second->energy(), id_tc.second->position().z()));
463 float z_mean =
meanX(tc_energy_z);
464 float varzz =
varXX(tc_energy_z, z_mean);
469 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.
constituents();
471 std::vector<std::pair<float, float>> tc_energy_eta;
473 for (
const auto& id_cell : cellsPtrs) {
474 if (!
pass(*id_cell.second, c2d))
476 tc_energy_eta.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->eta()));
479 float See =
sigmaXX(tc_energy_eta, c2d.
eta());
485 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.
constituents();
487 std::vector<std::pair<float, float>> tc_energy_phi;
489 for (
const auto& id_cell : cellsPtrs) {
490 if (!
pass(*id_cell.second, c2d))
492 tc_energy_phi.emplace_back(std::make_pair(id_cell.second->energy(), id_cell.second->phi()));
501 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& cellsPtrs = c2d.
constituents();
503 std::vector<std::pair<float, float>> tc_energy_r;
505 for (
const auto& id_cell : cellsPtrs) {
506 if (!
pass(*id_cell.second, c2d))
508 float r = (id_cell.second->position().z() != 0.
509 ?
std::sqrt(
pow(id_cell.second->position().x(), 2) +
pow(id_cell.second->position().y(), 2)) /
510 std::abs(id_cell.second->position().z())
512 tc_energy_r.emplace_back(std::make_pair(id_cell.second->energy(),
r));
515 float r_mean =
meanX(tc_energy_r);
516 float Srr =
sigmaXX(tc_energy_r, r_mean);
522 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
524 std::vector<double>
layers(nlayers, 0);
525 for (
const auto& id_clu : clustersPtrs) {
526 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
529 if (!
pass(*id_tc.second, c3d))
542 for (
unsigned i = 0;
i <
layers.size(); ++
i) {
553 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clustersPtrs = c3d.
constituents();
555 std::vector<double>
layers(nlayers, 0);
556 for (
const auto& id_clu : clustersPtrs) {
557 const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>&
triggerCells = id_clu.second->constituents();
560 if (!
pass(*id_tc.second, c3d))
569 const int bitmap_size = 32;
571 edm::LogWarning(
"DataNotFound") <<
"Trying to read layer 0 that doesn't exist, defaulted start to layer 1";
574 if ((
end -
start) + 1 > bitmap_size) {
575 edm::LogWarning(
"TooMuchData") <<
" Specified bounds cannot fit into bitmap size, defaulting to 0.";
587 const unsigned showermaxlayer = 7;
float meanX(const std::vector< pair< float, float >> &energy_X_tc) const
void setFirst1layers(float first1layers)
void setMaxLayer(int maxLayer)
void setSigmaPhiPhiTot(float sigmaPhiPhiTot)
float varZZ(const l1t::HGCalMulticluster &c3d) const
const std::unordered_map< uint32_t, edm::Ptr< C > > & constituents() const
virtual unsigned lastTriggerLayer() const =0
virtual unsigned triggerLayer(const unsigned id) const =0
void setSigmaZZ(float sigmaZZ)
void setVarEtaEta(float varEtaEta)
HGCalTriggerTools triggerTools_
void setSigmaRRMean(float sigmaRRMean)
void setFirst5layers(float first5layers)
float percentileTriggerCells(const l1t::HGCalMulticluster &c3d, float quantile=0.5) const
void setSigmaRRTot(float sigmaRRTot)
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 varEtaEta(const l1t::HGCalMulticluster &c3d) const
float sigmaEtaEtaTot(const l1t::HGCalMulticluster &c3d) const
void setFirstHcal5layers(float firstHcal5layers)
void setCoreShowerLength(int coreShowerLength)
void setEmax5layers(float emax5layers)
void setLayer10percent(float layer10percent)
float sigmaZZ(const l1t::HGCalMulticluster &c3d) const
float eMax(const l1t::HGCalMulticluster &c3d) const
float sigmaXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
float sigmaPhiPhiMax(const l1t::HGCalMulticluster &c3d) const
void setLast1layers(float last1layers)
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
Abs< T >::type abs(const T &t)
int coreShowerLength(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
void setVarPhiPhi(float varPhiPhi)
math::XYZTLorentzVector LorentzVector
void setFirst3layers(float first3layers)
void setLast5layers(float last5layers)
bool pass(const T &obj, const Tref &ref) const
const GlobalPoint & position() const
float varRR(const l1t::HGCalMulticluster &c3d) const
void setEmax1layers(float emax1layers)
void setLast3layers(float last3layers)
void setLayer50percent(float layer50percent)
int maxLayer(const l1t::HGCalMulticluster &c3d) const
void setTriggerCells67percent(float triggerCells67percent)
void setFirstLayer(int firstLayer)
void setTriggerCells90percent(float triggerCells90percent)
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
void setLayer90percent(float layer90percent)
void setFirstHcal3layers(float firstHcal3layers)
void setSigmaEtaEtaTot(float sigmaEtaEtaTot)
void setSigmaEtaEtaMax(float sigmaEtaEtaMax)
float sigmaRRTot(const l1t::HGCalMulticluster &c3d) const
void setSigmaRRMax(float sigmaRRMax)
float varXX(const std::vector< pair< float, float >> &energy_X_tc, const float X_cluster) const
void setEmax3layers(float emax3layers)
float sigmaEtaEtaMax(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiTot(const l1t::HGCalMulticluster &c3d) const
Log< level::Warning, false > LogWarning
float varPhiPhi(const l1t::HGCalMulticluster &c3d) const
void setFirstHcal1layers(float firstHcal1layers)
void setSigmaPhiPhiMax(float sigmaPhiPhiMax)
float sumLayers(const l1t::HGCalMulticluster &c3d, int start=1, int end=0) const
double phi() const final
momentum azimuthal angle
int firstLayer(const l1t::HGCalMulticluster &c3d) const
void setVarZZ(float varZZ)
void setVarRR(float varRR)
float meanZ(const l1t::HGCalMulticluster &c3d) const
void setZBarycenter(float zBarycenter)
Power< A, B >::type pow(const A &a, const B &b)
void setShowerLength(int showerLength)
float sigmaRRMean(const l1t::HGCalMulticluster &c3d, float radius=5.) const
int bitmap(const l1t::HGCalMulticluster &c3d, int start=1, int end=14, float threshold=0) 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