82 static constexpr
float b0 = 0.38,
b1 = 1.9,
b2 = 0.05;
84 static constexpr
float d0 = 0.96,
d1 = 0.0003;
165 float phi = (
id * size_cell) -
M_PI + 0.5 * size_cell;
297 inline float pt()
const {
return pt_; };
319 static constexpr
int PI = 180;
344 produces<l1tp2::CaloCrystalClusterCollection>();
345 produces<BXVector<l1t::EGamma> >();
346 produces<l1tp2::CaloTowerCollection>();
371 std::vector<SimpleCaloHit> ecalhits;
373 for (
const auto&
hit : *pcalohits.
product()) {
374 if (
hit.encodedEt() > 0)
377 float et =
hit.encodedEt() / 8.;
388 ecalhits.push_back(ehit);
393 std::vector<SimpleCaloHit> hcalhits;
401 LogError(
"L1EGCrystalClusterEmulatorProducer")
402 <<
" -- Hcal hit DetID not present in HCAL Geom: " <<
hit.
id() << std::endl;
406 const std::vector<HcalDetId>& hcId = theTrigTowerGeometry.
detIds(
hit.
id());
408 LogError(
"L1EGCrystalClusterEmulatorProducer")
409 <<
"Cannot find any HCalDetId corresponding to " <<
hit.
id() << std::endl;
413 if (hcId[0].subdetId() > 1)
416 for (
const auto& hcId_i : hcId) {
417 if (hcId_i.subdetId() > 1)
423 hcal_tp_position = tmpVector;
432 hcalhits.push_back(hhit);
458 ECAL_tower_L1Card[
ii][
jj][ll] = 0;
459 HCAL_tower_L1Card[
ii][
jj][ll] = 0;
460 iPhi_tower_L1Card[
ii][
jj][ll] = -999;
461 iEta_tower_L1Card[
ii][
jj][ll] = -999;
468 energy_cluster_L1Card[
ii][
jj][ll] = 0;
469 brem_cluster_L1Card[
ii][
jj][ll] = 0;
470 towerID_cluster_L1Card[
ii][
jj][ll] = 0;
471 crystalID_cluster_L1Card[
ii][
jj][ll] = 0;
485 bool build_cluster =
true;
489 build_cluster =
false;
492 for (
const auto&
hit : ecalhits) {
500 !
hit.used() &&
hit.pt() >= 1.0 &&
hit.pt() > centerhit.
pt())
504 build_cluster =
true;
511 if (build_cluster && nclusters > 0 && nclusters <=
n_clusters_max) {
532 for (
auto&
hit : ecalhits) {
539 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
540 rightlobe +=
hit.pt();
542 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
543 leftlobe +=
hit.pt();
545 if (
abs(
hit.dieta(centerhit)) <= 2 &&
abs(
hit.diphi(centerhit)) <= 2) {
546 e5x5 +=
hit.energy();
549 if ((
hit.dieta(centerhit) == 1
or hit.dieta(centerhit) == 0) &&
550 (
hit.diphi(centerhit) == 1
or hit.diphi(centerhit) == 0)) {
551 e2x2_1 +=
hit.energy();
554 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
555 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == 1)) {
556 e2x2_2 +=
hit.energy();
559 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == 1) &&
560 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == -1)) {
561 e2x2_3 +=
hit.energy();
564 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
565 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == -1)) {
566 e2x2_4 +=
hit.energy();
569 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == 1) &&
abs(
hit.diphi(centerhit)) <= 2) {
570 e2x5_1 +=
hit.energy();
573 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
abs(
hit.diphi(centerhit)) <= 2) {
574 e2x5_2 +=
hit.energy();
582 abs(
hit.dieta(centerhit)) <= 1 &&
abs(
hit.diphi(centerhit)) <= 2 &&
592 if (
do_brem && (rightlobe > 0.10 * mc1.
cpt or leftlobe > 0.10 * mc1.
cpt)) {
593 for (
auto&
hit : ecalhits) {
601 if (rightlobe > 0.10 * mc1.
cpt && (leftlobe < 0.10 * mc1.cpt or rightlobe > leftlobe) &&
602 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
607 if (leftlobe > 0.10 * mc1.
cpt && (rightlobe < 0.10 * mc1.cpt or leftlobe >= rightlobe) &&
608 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
619 if (e2x2_2 > mc1.
c2x2_)
621 if (e2x2_3 > mc1.
c2x2_)
623 if (e2x2_4 > mc1.
c2x2_)
631 cluster_list[
cc].push_back(mc1);
638 for (
unsigned int jj = 0;
jj < unsigned(cluster_list[
cc].
size()); ++
jj) {
639 for (
unsigned int kk =
jj + 1;
kk < unsigned(cluster_list[
cc].
size()); ++
kk) {
640 if (
std::abs(cluster_list[
cc][
jj].ceta_ - cluster_list[
cc][
kk].ceta_) < 2 &&
642 if (cluster_list[
cc][
kk].cpt > cluster_list[
cc][
jj].cpt) {
643 cluster_list[
cc][
kk].cpt += cluster_list[
cc][
jj].cpt;
644 cluster_list[
cc][
kk].c5x5_ += cluster_list[
cc][
jj].c5x5_;
645 cluster_list[
cc][
kk].c2x5_ += cluster_list[
cc][
jj].c2x5_;
646 cluster_list[
cc][
jj].cpt = 0;
647 cluster_list[
cc][
jj].c5x5_ = 0;
648 cluster_list[
cc][
jj].c2x5_ = 0;
649 cluster_list[
cc][
jj].c2x2_ = 0;
651 cluster_list[
cc][
jj].cpt += cluster_list[
cc][
kk].cpt;
652 cluster_list[
cc][
jj].c5x5_ += cluster_list[
cc][
kk].c5x5_;
653 cluster_list[
cc][
jj].c2x5_ += cluster_list[
cc][
kk].c2x5_;
654 cluster_list[
cc][
kk].cpt = 0;
655 cluster_list[
cc][
kk].c2x2_ = 0;
656 cluster_list[
cc][
kk].c2x5_ = 0;
657 cluster_list[
cc][
kk].c5x5_ = 0;
661 if (cluster_list[
cc][
jj].cpt > 0) {
662 cluster_list[
cc][
jj].cpt =
663 cluster_list[
cc][
jj].cpt *
666 cluster_list_merged[
cc].push_back(cluster_list[
cc][
jj]);
670 return a.cpt >
b.cpt;
682 cluster_list_merged[
cc][
jj].c2x5_ / cluster_list_merged[
cc][
jj].c5x5_))
687 cluster_list_merged[
cc][
jj].c2x5_ / cluster_list_merged[
cc][
jj].c5x5_))
692 cluster_list_merged[
cc][
jj].c2x2_ / cluster_list_merged[
cc][
jj].c2x5_))
699 for (
const auto&
hit : ecalhits) {
718 static constexpr
float tower_width = 0.0873;
723 (
ii + 0.5) * tower_width;
733 for (
const auto&
hit : hcalhits) {
742 HCAL_tower_L1Card[
jj][
ii][
cc] +=
hit.pt();
754 if (cluster_list_merged[
cc][
kk].cpt > 0) {
785 HCAL_tower_L2Card[
ii][
jj][ll] = 0;
786 ECAL_tower_L2Card[
ii][
jj][ll] = 0;
787 iEta_tower_L2Card[
ii][
jj][ll] = 0;
788 iPhi_tower_L2Card[
ii][
jj][ll] = 0;
795 energy_cluster_L2Card[
ii][
jj][ll] = 0;
796 brem_cluster_L2Card[
ii][
jj][ll] = 0;
797 towerID_cluster_L2Card[
ii][
jj][ll] = 0;
798 crystalID_cluster_L2Card[
ii][
jj][ll] = 0;
799 isolation_cluster_L2Card[
ii][
jj][ll] = 0;
800 HE_cluster_L2Card[
ii][
jj][ll] = 0;
801 photonShowerShape_cluster_L2Card[
ii][
jj][ll] = 0;
802 showerShape_cluster_L2Card[
ii][
jj][ll] = 0;
803 showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] = 0;
814 int card_left = 2 *
ii +
jj;
815 int card_right = 2 *
ii +
jj + 2;
852 int card_left = 2 *
ii +
jj;
853 int card_right = 2 *
ii +
jj + 2;
904 int card_bottom = 2 *
ii;
905 int card_top = 2 *
ii + 1;
945 cluster_list_L2[
ii].push_back(mc1);
955 if (cluster_list_L2[
ii][
jj].cpt > 0) {
958 cluster_list_L2[
ii][
jj].cpt = 0;
959 cluster_list_L2[
ii][
jj].ctowerid_ = 0;
960 cluster_list_L2[
ii][
jj].ccrystalid_ = 0;
967 for (
unsigned int jj = 0;
jj < 8 &&
jj < cluster_list_L2[
ii].size(); ++
jj) {
970 float hcal_nrj = 0.0;
974 for (
unsigned int jjj = 0; jjj < 8 && jjj < cluster_list_L2[iii].size(); ++jjj) {
975 if (!(iii ==
ii && jjj ==
jj)) {
978 if (
abs(cluster2_eta - cluster_etaOfTower_fullDetector) <= 2 &&
979 (
abs(cluster2_phi - cluster_phiOfTower_fullDetector) <= 2
or
980 abs(cluster2_phi -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
981 isolation += cluster_list_L2[iii][jjj].cpt;
993 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
994 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or
995 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
997 if (!((cluster_phiOfTower_fullDetector == 0 && phiOftower_fullDetector == 71)
or
998 (cluster_phiOfTower_fullDetector == 23 && phiOftower_fullDetector == 26)
or
999 (cluster_phiOfTower_fullDetector == 24 && phiOftower_fullDetector == 21)
or
1000 (cluster_phiOfTower_fullDetector == 47 && phiOftower_fullDetector == 50)
or
1001 (cluster_phiOfTower_fullDetector == 48 && phiOftower_fullDetector == 45)
or
1002 (cluster_phiOfTower_fullDetector == 71 && phiOftower_fullDetector == 2))) {
1009 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
1010 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or
1011 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1012 hcal_nrj += HCAL_tower_L1Card[ll][mm][
kk];
1017 cluster_list_L2[
ii][
jj].ciso_ = ((
isolation) * (25.0 / ntowers)) / cluster_list_L2[
ii][
jj].cpt;
1018 cluster_list_L2[
ii][
jj].chovere_ = hcal_nrj / cluster_list_L2[
ii][
jj].cpt;
1026 for (
int ll = 0; ll < 3; ++ll) {
1027 ECAL_tower_L2Card[
ii][
jj][ll] =
1029 HCAL_tower_L2Card[
ii][
jj][ll] =
1031 iEta_tower_L2Card[
ii][
jj][ll] =
1033 iPhi_tower_L2Card[
ii][
jj][ll] =
1063 auto L1EGXtalClusters = std::make_unique<l1tp2::CaloCrystalClusterCollection>();
1064 auto L1EGammas = std::make_unique<l1t::EGammaBxCollection>();
1065 auto L1CaloTowers = std::make_unique<l1tp2::CaloTowerCollection>();
1071 for (
int jj = 0;
jj < 2; ++
jj) {
1072 if (energy_cluster_L2Card[
ii][
jj][ll] > 0.45) {
1074 energy_cluster_L2Card[
ii][
jj][ll],
1076 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1078 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1081 bool is_iso =
passes_iso(energy_cluster_L2Card[
ii][
jj][ll], isolation_cluster_L2Card[
ii][
jj][ll]);
1082 bool is_looseTkiso =
1084 bool is_ss = (showerShape_cluster_L2Card[
ii][
jj][ll] == 1);
1085 bool is_photon = (photonShowerShape_cluster_L2Card[
ii][
jj][ll] == 1) && is_ss && is_iso;
1086 bool is_looseTkss = (showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] == 1);
1089 energy_cluster_L2Card[
ii][
jj][ll],
1090 HE_cluster_L2Card[
ii][
jj][ll],
1091 isolation_cluster_L2Card[
ii][
jj][ll],
1097 energy_cluster_L2Card[
ii][
jj][ll],
1103 is_looseTkiso&& is_looseTkss,
1106 std::map<std::string, float>
params;
1107 params[
"standaloneWP_showerShape"] = is_ss;
1108 params[
"standaloneWP_isolation"] = is_iso;
1109 params[
"trkMatchWP_showerShape"] = is_looseTkss;
1110 params[
"trkMatchWP_isolation"] = is_looseTkiso;
1113 cluster.setExperimentalParams(
params);
1114 L1EGXtalClusters->push_back(cluster);
1116 int standaloneWP = (
int)(is_iso && is_ss);
1117 int looseL1TkMatchWP = (
int)(is_looseTkiso && is_looseTkss);
1118 int photonWP = (
int)(is_photon);
1121 L1EGammas->push_back(
1122 0,
l1t::EGamma(p4calibrated, p4calibrated.pt(), p4calibrated.eta(), p4calibrated.phi(),
quality, 1));
1140 static float constexpr towerEtaUpperUnitialized = -80;
1141 static float constexpr towerPhiUpperUnitialized = -90;
1142 if (l1CaloTower.
towerEta() < towerEtaUpperUnitialized && l1CaloTower.
towerPhi() < towerPhiUpperUnitialized) {
1150 for (
const auto& l1eg : *L1EGXtalClusters) {
1151 if (l1eg.experimentalParam(
"TTiEta") != l1CaloTower.
towerIEta())
1153 if (l1eg.experimentalParam(
"TTiPhi") != l1CaloTower.
towerIPhi())
1156 int n_L1eg = l1CaloTower.
nL1eg();
1160 if (l1CaloTower.
nL1eg() > 1)
1162 l1CaloTower.
setL1egTrkSS(l1eg.experimentalParam(
"trkMatchWP_showerShape"));
1163 l1CaloTower.
setL1egTrkIso(l1eg.experimentalParam(
"trkMatchWP_isolation"));
1168 L1CaloTowers->push_back(l1CaloTower);