442 std::vector<SimpleCaloHit> ecalhits;
444 for (
const auto&
hit : *pcalohits.
product()) {
445 if (
hit.encodedEt() > 0)
448 float et =
hit.encodedEt() / 8.;
455 ehit.setId(
hit.
id());
456 ehit.setPosition(
GlobalVector(cell->getPosition().x(), cell->getPosition().y(), cell->getPosition().z()));
459 ecalhits.push_back(ehit);
464 std::vector<SimpleCaloHit> hcalhits;
468 float et = decoder.hcaletValue(
hit.
id(),
hit.t0());
472 LogError(
"L1EGCrystalClusterEmulatorProducer")
473 <<
" -- Hcal hit DetID not present in HCAL Geom: " <<
hit.
id() << std::endl;
477 const std::vector<HcalDetId>& hcId = theTrigTowerGeometry.detIds(
hit.
id());
479 LogError(
"L1EGCrystalClusterEmulatorProducer")
480 <<
"Cannot find any HCalDetId corresponding to " <<
hit.
id() << std::endl;
484 if (hcId[0].subdetId() > 1)
487 for (
const auto& hcId_i : hcId) {
488 if (hcId_i.subdetId() > 1)
494 hcal_tp_position = tmpVector;
498 hhit.setId(
hit.
id());
499 hhit.setIdHcal(
hit.
id());
500 hhit.setPosition(hcal_tp_position);
503 hcalhits.push_back(hhit);
529 ECAL_tower_L1Card[
ii][
jj][ll] = 0;
530 HCAL_tower_L1Card[
ii][
jj][ll] = 0;
531 iPhi_tower_L1Card[
ii][
jj][ll] = -999;
532 iEta_tower_L1Card[
ii][
jj][ll] = -999;
539 energy_cluster_L1Card[
ii][
jj][ll] = 0;
540 brem_cluster_L1Card[
ii][
jj][ll] = 0;
541 towerID_cluster_L1Card[
ii][
jj][ll] = 0;
542 crystalID_cluster_L1Card[
ii][
jj][ll] = 0;
556 bool build_cluster =
true;
560 build_cluster =
false;
561 SimpleCaloHit centerhit;
563 for (
const auto&
hit : ecalhits) {
565 if (
hit.isInCardAndRegion(
cc, nregion) && !
hit.used() &&
hit.pt() >= 1.0 &&
hit.pt() > centerhit.pt()) {
567 build_cluster =
true;
574 if (build_cluster && nclusters > 0 && nclusters <=
n_clusters_max) {
577 mc1.cWeightedEta_ = 0.0;
578 mc1.cWeightedPhi_ = 0.0;
588 for (
auto&
hit : ecalhits) {
589 if (
hit.isInCardAndRegion(
cc, nregion) && (
hit.pt() > 0)) {
590 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
591 rightlobe +=
hit.pt();
593 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
594 leftlobe +=
hit.pt();
596 if (
abs(
hit.dieta(centerhit)) <= 2 &&
abs(
hit.diphi(centerhit)) <= 2) {
599 if ((
hit.dieta(centerhit) == 1
or hit.dieta(centerhit) == 0) &&
600 (
hit.diphi(centerhit) == 1
or hit.diphi(centerhit) == 0)) {
601 e2x2_1 +=
hit.energy();
603 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
604 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == 1)) {
605 e2x2_2 +=
hit.energy();
607 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == 1) &&
608 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == -1)) {
609 e2x2_3 +=
hit.energy();
611 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
612 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == -1)) {
613 e2x2_4 +=
hit.energy();
615 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == 1) &&
abs(
hit.diphi(centerhit)) <= 2) {
616 e2x5_1 +=
hit.energy();
618 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
abs(
hit.diphi(centerhit)) <= 2) {
619 e2x5_2 +=
hit.energy();
622 if (
hit.isInCardAndRegion(
cc, nregion) && !
hit.used() &&
hit.pt() > 0 &&
abs(
hit.dieta(centerhit)) <= 1 &&
623 abs(
hit.diphi(centerhit)) <= 2) {
627 mc1.cWeightedEta_ +=
float(
hit.pt()) *
float(
hit.position().eta());
628 mc1.cWeightedPhi_ = mc1.cWeightedPhi_ + (
float(
hit.pt()) *
float(
hit.position().phi()));
631 if (
do_brem && (rightlobe > 0.10 * mc1.cpt
or leftlobe > 0.10 * mc1.cpt)) {
632 for (
auto&
hit : ecalhits) {
633 if (
hit.isInCardAndRegion(
cc, nregion) &&
hit.pt() > 0 && !
hit.used()) {
634 if (rightlobe > 0.10 * mc1.cpt && (leftlobe < 0.10 * mc1.cpt or rightlobe > leftlobe) &&
635 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
640 if (leftlobe > 0.10 * mc1.cpt && (rightlobe < 0.10 * mc1.cpt or leftlobe >= rightlobe) &&
641 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
650 mc1.c2x5_ =
max(e2x5_1, e2x5_2);
652 if (e2x2_2 > mc1.c2x2_)
654 if (e2x2_3 > mc1.c2x2_)
656 if (e2x2_4 > mc1.c2x2_)
658 mc1.cWeightedEta_ = mc1.cWeightedEta_ / mc1.cpt;
659 mc1.cWeightedPhi_ = mc1.cWeightedPhi_ / mc1.cpt;
662 mc1.crawphi_ = centerhit.position().phi();
663 mc1.craweta_ = centerhit.position().eta();
664 cluster_list[
cc].push_back(mc1);
671 for (
unsigned int jj = 0;
jj < unsigned(cluster_list[
cc].
size()); ++
jj) {
672 for (
unsigned int kk =
jj + 1;
kk < unsigned(cluster_list[
cc].
size()); ++
kk) {
673 if (
std::abs(cluster_list[
cc][
jj].ceta_ - cluster_list[
cc][
kk].ceta_) < 2 &&
675 if (cluster_list[
cc][
kk].cpt > cluster_list[
cc][
jj].cpt) {
676 cluster_list[
cc][
kk].cpt += cluster_list[
cc][
jj].cpt;
677 cluster_list[
cc][
kk].c5x5_ += cluster_list[
cc][
jj].c5x5_;
678 cluster_list[
cc][
kk].c2x5_ += cluster_list[
cc][
jj].c2x5_;
679 cluster_list[
cc][
jj].cpt = 0;
680 cluster_list[
cc][
jj].c5x5_ = 0;
681 cluster_list[
cc][
jj].c2x5_ = 0;
682 cluster_list[
cc][
jj].c2x2_ = 0;
684 cluster_list[
cc][
jj].cpt += cluster_list[
cc][
kk].cpt;
685 cluster_list[
cc][
jj].c5x5_ += cluster_list[
cc][
kk].c5x5_;
686 cluster_list[
cc][
jj].c2x5_ += cluster_list[
cc][
kk].c2x5_;
687 cluster_list[
cc][
kk].cpt = 0;
688 cluster_list[
cc][
kk].c2x2_ = 0;
689 cluster_list[
cc][
kk].c2x5_ = 0;
690 cluster_list[
cc][
kk].c5x5_ = 0;
694 if (cluster_list[
cc][
jj].cpt > 0) {
695 cluster_list[
cc][
jj].cpt =
696 cluster_list[
cc][
jj].cpt *
699 cluster_list_merged[
cc].push_back(cluster_list[
cc][
jj]);
703 return a.cpt >
b.cpt;
715 cluster_list_merged[
cc][
jj].c2x5_ / cluster_list_merged[
cc][
jj].c5x5_))
720 cluster_list_merged[
cc][
jj].c2x5_ / cluster_list_merged[
cc][
jj].c5x5_))
725 cluster_list_merged[
cc][
jj].c2x2_ / cluster_list_merged[
cc][
jj].c2x5_))
732 for (
const auto&
hit : ecalhits) {
733 if (
hit.isInCard(
cc) && !
hit.used()) {
747 static constexpr float tower_width = 0.0873;
752 (
ii + 0.5) * tower_width;
761 for (
const auto&
hit : hcalhits) {
762 if (
hit.isInCard(
cc) &&
hit.pt() > 0) {
767 HCAL_tower_L1Card[
jj][
ii][
cc] +=
hit.pt();
779 if (cluster_list_merged[
cc][
kk].cpt > 0) {
810 HCAL_tower_L2Card[
ii][
jj][ll] = 0;
811 ECAL_tower_L2Card[
ii][
jj][ll] = 0;
812 iEta_tower_L2Card[
ii][
jj][ll] = 0;
813 iPhi_tower_L2Card[
ii][
jj][ll] = 0;
820 energy_cluster_L2Card[
ii][
jj][ll] = 0;
821 brem_cluster_L2Card[
ii][
jj][ll] = 0;
822 towerID_cluster_L2Card[
ii][
jj][ll] = 0;
823 crystalID_cluster_L2Card[
ii][
jj][ll] = 0;
824 isolation_cluster_L2Card[
ii][
jj][ll] = 0;
825 HE_cluster_L2Card[
ii][
jj][ll] = 0;
826 photonShowerShape_cluster_L2Card[
ii][
jj][ll] = 0;
827 showerShape_cluster_L2Card[
ii][
jj][ll] = 0;
828 showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] = 0;
839 int card_left = 2 *
ii +
jj;
840 int card_right = 2 *
ii +
jj + 2;
877 int card_left = 2 *
ii +
jj;
878 int card_right = 2 *
ii +
jj + 2;
929 int card_bottom = 2 *
ii;
930 int card_top = 2 *
ii + 1;
970 cluster_list_L2[
ii].push_back(mc1);
974 begin(cluster_list_L2[
ii]),
end(cluster_list_L2[
ii]), [](mycluster
a, mycluster
b) {
return a.cpt >
b.cpt; });
980 if (cluster_list_L2[
ii][
jj].cpt > 0) {
983 cluster_list_L2[
ii][
jj].cpt = 0;
984 cluster_list_L2[
ii][
jj].ctowerid_ = 0;
985 cluster_list_L2[
ii][
jj].ccrystalid_ = 0;
995 float hcal_nrj = 0.0;
1000 for (
unsigned int jjj = 0; jjj <
n_clusters_per_L1card && jjj < cluster_list_L2[iii].size(); ++jjj) {
1001 if (!(iii ==
ii && jjj ==
jj)) {
1004 if (
abs(cluster2_eta - cluster_etaOfTower_fullDetector) <= 2 &&
1005 (
abs(cluster2_phi - cluster_phiOfTower_fullDetector) <= 2
or 1006 abs(cluster2_phi -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1007 isolation += cluster_list_L2[iii][jjj].cpt;
1019 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
1020 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or 1021 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1023 if (!((cluster_phiOfTower_fullDetector == 0 && phiOftower_fullDetector == 71)
or 1024 (cluster_phiOfTower_fullDetector == 23 && phiOftower_fullDetector == 26)
or 1025 (cluster_phiOfTower_fullDetector == 24 && phiOftower_fullDetector == 21)
or 1026 (cluster_phiOfTower_fullDetector == 47 && phiOftower_fullDetector == 50)
or 1027 (cluster_phiOfTower_fullDetector == 48 && phiOftower_fullDetector == 45)
or 1028 (cluster_phiOfTower_fullDetector == 71 && phiOftower_fullDetector == 2))) {
1035 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
1036 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or 1037 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1038 hcal_nrj += HCAL_tower_L1Card[ll][mm][
kk];
1044 int nTowersIn5x5Window = 5 * 5;
1045 cluster_list_L2[
ii][
jj].ciso_ = ((
isolation) * (nTowersIn5x5Window / ntowers)) / cluster_list_L2[
ii][
jj].cpt;
1046 cluster_list_L2[
ii][
jj].crawIso_ = ((
isolation) * (nTowersIn5x5Window / ntowers));
1047 cluster_list_L2[
ii][
jj].chovere_ = hcal_nrj / cluster_list_L2[
ii][
jj].cpt;
1055 for (
int ll = 0; ll < 3; ++ll) {
1056 ECAL_tower_L2Card[
ii][
jj][ll] =
1058 HCAL_tower_L2Card[
ii][
jj][ll] =
1060 iEta_tower_L2Card[
ii][
jj][ll] =
1062 iPhi_tower_L2Card[
ii][
jj][ll] =
1092 auto L1EGXtalClusters = std::make_unique<l1tp2::CaloCrystalClusterCollection>();
1093 auto L1EGammas = std::make_unique<l1t::EGammaBxCollection>();
1094 auto L1CaloTowers = std::make_unique<l1tp2::CaloTowerCollection>();
1100 for (
int jj = 0;
jj < 2; ++
jj) {
1101 if (energy_cluster_L2Card[
ii][
jj][ll] > 0.45) {
1103 energy_cluster_L2Card[
ii][
jj][ll],
1105 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1107 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1109 SimpleCaloHit centerhit;
1110 bool is_iso =
passes_iso(energy_cluster_L2Card[
ii][
jj][ll], isolation_cluster_L2Card[
ii][
jj][ll]);
1111 bool is_looseTkiso =
1113 bool is_ss = (showerShape_cluster_L2Card[
ii][
jj][ll] == 1);
1114 bool is_photon = (photonShowerShape_cluster_L2Card[
ii][
jj][ll] == 1) && is_ss && is_iso;
1115 bool is_looseTkss = (showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] == 1);
1118 energy_cluster_L2Card[
ii][
jj][ll],
1119 HE_cluster_L2Card[
ii][
jj][ll],
1120 isolation_cluster_L2Card[
ii][
jj][ll],
1126 energy_cluster_L2Card[
ii][
jj][ll],
1132 is_looseTkiso && is_looseTkss,
1135 std::map<std::string, float>
params;
1136 params[
"standaloneWP_showerShape"] = is_ss;
1137 params[
"standaloneWP_isolation"] = is_iso;
1138 params[
"trkMatchWP_showerShape"] = is_looseTkss;
1139 params[
"trkMatchWP_isolation"] = is_looseTkiso;
1142 cluster.setExperimentalParams(
params);
1143 L1EGXtalClusters->push_back(cluster);
1145 int standaloneWP = (
int)(is_iso && is_ss);
1146 int looseL1TkMatchWP = (
int)(is_looseTkiso && is_looseTkss);
1147 int photonWP = (
int)(is_photon);
1150 L1EGammas->push_back(
1151 0,
l1t::EGamma(p4calibrated, p4calibrated.pt(), p4calibrated.eta(), p4calibrated.phi(),
quality, 1));
1169 static float constexpr towerEtaUpperUnitialized = -80;
1170 static float constexpr towerPhiUpperUnitialized = -90;
1171 if (l1CaloTower.
towerEta() < towerEtaUpperUnitialized && l1CaloTower.
towerPhi() < towerPhiUpperUnitialized) {
1179 for (
const auto& l1eg : *L1EGXtalClusters) {
1180 if (l1eg.experimentalParam(
"TTiEta") != l1CaloTower.
towerIEta())
1182 if (l1eg.experimentalParam(
"TTiPhi") != l1CaloTower.
towerIPhi())
1185 int n_L1eg = l1CaloTower.
nL1eg();
1189 if (l1CaloTower.
nL1eg() > 1)
1191 l1CaloTower.
setL1egTrkSS(l1eg.experimentalParam(
"trkMatchWP_showerShape"));
1192 l1CaloTower.
setL1egTrkIso(l1eg.experimentalParam(
"trkMatchWP_isolation"));
1197 L1CaloTowers->push_back(l1CaloTower);
static constexpr int n_links_GCTcard
bool validHT(const HcalTrigTowerDetId &id) const
int getCrystal_etaID(float eta)
l1tp2::ParametricCalibration calib_
edm::EDGetTokenT< edm::SortedCollection< HcalTriggerPrimitiveDigi > > hcalTPToken_
int getCrystal_phiID(float phi)
bool passes_looseTkiso(float pt, float iso)
int getTower_phiID(int cluster_phiID)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
static constexpr int n_towers_halfPhi
static constexpr float cut_500_MeV
int getPhiMin_card(int card)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryTag_
void setEcalTowerEt(float et)
uint32_t cc[maxCellsPerHit]
bool passes_iso(float pt, float iso)
void setTowerIPhi(int iPhi)
T const * product() const
void setL1egStandaloneIso(int staIso)
int get_towerEta_fromCardTowerInCard(int card, int towerincard)
int getTowerID(int etaID, int phiID)
int get_towerPhi_fromCardLinkTower(int card, int link, int tower)
static constexpr int n_eta_bins
const HcalTopology * hcTopology_
Log< level::Error, false > LogError
int convert_L2toL1_card(int card, int link)
static constexpr int n_borders_eta
int getEtaMin_card(int card)
void setL1egTrkIso(int trkIso)
static constexpr int n_clusters_max
float getTowerEta_fromAbsoluteID(int id)
static constexpr int n_crystals_towerPhi
void setHcalTowerEt(float et)
static constexpr int n_clusters_4link
void setTowerIEta(int iEta)
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > hbTopologyTag_
int get_towerEta_fromCardLinkTower(int card, int link, int tower)
int getTower_absolutePhiID(float phi)
void setTowerPhi(float phi)
int getTower_absoluteEtaID(float eta)
int getToweriPhi_fromAbsoluteID(int id)
static constexpr int n_clusters_per_link
bool passes_ss(float pt, float ss)
static constexpr bool do_brem
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
float getTowerPhi_fromAbsoluteID(int id)
bool passes_photon(float pt, float pss)
Abs< T >::type abs(const T &t)
static constexpr int n_towers_per_link
void setL1egTrkSS(int trkSS)
edm::EDGetTokenT< EcalEBTrigPrimDigiCollection > ecalTPEBToken_
static constexpr int n_clusters_link
void setIsBarrel(bool isBarrel)
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
int convert_L2toL1_tower(int tower)
void setTowerEta(float eta)
int get_towerPhi_fromCardTowerInCard(int card, int towerincard)
float getEta_fromL2LinkCardTowerCrystal(int link, int card, int tower, int crystal)
int getToweriEta_fromAbsoluteID(int id)
static constexpr int n_links_card
int getTower_etaID(int cluster_etaID)
int convert_L2toL1_link(int link)
void setL1egTowerEt(float et)
static constexpr int n_clusters_per_L1card
float l1egTowerEt() const
static constexpr int n_borders_phi
static constexpr int n_crystals_towerEta
const CaloSubdetectorGeometry * ebGeometry
bool passes_looseTkss(float pt, float ss)
static constexpr int n_GCTcards
static constexpr int n_towers_Phi
float getPhi_fromL2LinkCardTowerCrystal(int link, int card, int tower, int crystal)
int getCrystalIDInTower(int etaID, int phiID)
void setL1egStandaloneSS(int staSS)
Power< A, B >::type pow(const A &a, const B &b)
const CaloSubdetectorGeometry * hbGeometry
Global3DVector GlobalVector
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > decoderTag_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.