373 std::vector<SimpleCaloHit> ecalhits;
375 for (
const auto&
hit : *pcalohits.
product()) {
376 if (
hit.encodedEt() > 0)
379 float et =
hit.encodedEt() / 8.;
386 ehit.setId(
hit.
id());
387 ehit.setPosition(
GlobalVector(cell->getPosition().x(), cell->getPosition().y(), cell->getPosition().z()));
390 ecalhits.push_back(ehit);
395 std::vector<SimpleCaloHit> hcalhits;
399 float et = decoder.hcaletValue(
hit.
id(),
hit.t0());
403 LogError(
"L1EGCrystalClusterEmulatorProducer")
404 <<
" -- Hcal hit DetID not present in HCAL Geom: " <<
hit.
id() << std::endl;
408 const std::vector<HcalDetId>& hcId = theTrigTowerGeometry.detIds(
hit.
id());
410 LogError(
"L1EGCrystalClusterEmulatorProducer")
411 <<
"Cannot find any HCalDetId corresponding to " <<
hit.
id() << std::endl;
415 if (hcId[0].subdetId() > 1)
418 for (
const auto& hcId_i : hcId) {
419 if (hcId_i.subdetId() > 1)
425 hcal_tp_position = tmpVector;
429 hhit.setId(
hit.
id());
430 hhit.setIdHcal(
hit.
id());
431 hhit.setPosition(hcal_tp_position);
434 hcalhits.push_back(hhit);
460 ECAL_tower_L1Card[
ii][
jj][ll] = 0;
461 HCAL_tower_L1Card[
ii][
jj][ll] = 0;
462 iPhi_tower_L1Card[
ii][
jj][ll] = -999;
463 iEta_tower_L1Card[
ii][
jj][ll] = -999;
470 energy_cluster_L1Card[
ii][
jj][ll] = 0;
471 brem_cluster_L1Card[
ii][
jj][ll] = 0;
472 towerID_cluster_L1Card[
ii][
jj][ll] = 0;
473 crystalID_cluster_L1Card[
ii][
jj][ll] = 0;
487 bool build_cluster =
true;
491 build_cluster =
false;
492 SimpleCaloHit centerhit;
494 for (
const auto&
hit : ecalhits) {
502 !
hit.used() &&
hit.pt() >= 1.0 &&
hit.pt() > centerhit.pt())
506 build_cluster =
true;
513 if (build_cluster && nclusters > 0 && nclusters <=
n_clusters_max) {
516 mc1.cWeightedEta_ = 0.0;
517 mc1.cWeightedPhi_ = 0.0;
534 for (
auto&
hit : ecalhits) {
541 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
542 rightlobe +=
hit.pt();
544 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
545 leftlobe +=
hit.pt();
547 if (
abs(
hit.dieta(centerhit)) <= 2 &&
abs(
hit.diphi(centerhit)) <= 2) {
548 e5x5 +=
hit.energy();
551 if ((
hit.dieta(centerhit) == 1
or hit.dieta(centerhit) == 0) &&
552 (
hit.diphi(centerhit) == 1
or hit.diphi(centerhit) == 0)) {
553 e2x2_1 +=
hit.energy();
556 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
557 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == 1)) {
558 e2x2_2 +=
hit.energy();
561 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == 1) &&
562 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == -1)) {
563 e2x2_3 +=
hit.energy();
566 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
567 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == -1)) {
568 e2x2_4 +=
hit.energy();
571 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == 1) &&
abs(
hit.diphi(centerhit)) <= 2) {
572 e2x5_1 +=
hit.energy();
575 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
abs(
hit.diphi(centerhit)) <= 2) {
576 e2x5_2 +=
hit.energy();
584 abs(
hit.dieta(centerhit)) <= 1 &&
abs(
hit.diphi(centerhit)) <= 2 &&
590 mc1.cWeightedEta_ +=
float(
hit.pt()) *
float(
hit.position().eta());
591 mc1.cWeightedPhi_ = mc1.cWeightedPhi_ + (
float(
hit.pt()) *
float(
hit.position().phi()));
594 if (
do_brem && (rightlobe > 0.10 * mc1.cpt
or leftlobe > 0.10 * mc1.cpt)) {
595 for (
auto&
hit : ecalhits) {
603 if (rightlobe > 0.10 * mc1.cpt && (leftlobe < 0.10 * mc1.cpt or rightlobe > leftlobe) &&
604 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
609 if (leftlobe > 0.10 * mc1.cpt && (rightlobe < 0.10 * mc1.cpt or leftlobe >= rightlobe) &&
610 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
619 mc1.c2x5_ =
max(e2x5_1, e2x5_2);
621 if (e2x2_2 > mc1.c2x2_)
623 if (e2x2_3 > mc1.c2x2_)
625 if (e2x2_4 > mc1.c2x2_)
627 mc1.cWeightedEta_ = mc1.cWeightedEta_ / mc1.cpt;
628 mc1.cWeightedPhi_ = mc1.cWeightedPhi_ / mc1.cpt;
631 mc1.crawphi_ = centerhit.position().phi();
632 mc1.craweta_ = centerhit.position().eta();
633 cluster_list[
cc].push_back(mc1);
640 for (
unsigned int jj = 0;
jj < unsigned(cluster_list[
cc].
size()); ++
jj) {
641 for (
unsigned int kk =
jj + 1;
kk < unsigned(cluster_list[
cc].
size()); ++
kk) {
642 if (
std::abs(cluster_list[
cc][
jj].ceta_ - cluster_list[
cc][
kk].ceta_) < 2 &&
644 if (cluster_list[
cc][
kk].cpt > cluster_list[
cc][
jj].cpt) {
645 cluster_list[
cc][
kk].cpt += cluster_list[
cc][
jj].cpt;
646 cluster_list[
cc][
kk].c5x5_ += cluster_list[
cc][
jj].c5x5_;
647 cluster_list[
cc][
kk].c2x5_ += cluster_list[
cc][
jj].c2x5_;
648 cluster_list[
cc][
jj].cpt = 0;
649 cluster_list[
cc][
jj].c5x5_ = 0;
650 cluster_list[
cc][
jj].c2x5_ = 0;
651 cluster_list[
cc][
jj].c2x2_ = 0;
653 cluster_list[
cc][
jj].cpt += cluster_list[
cc][
kk].cpt;
654 cluster_list[
cc][
jj].c5x5_ += cluster_list[
cc][
kk].c5x5_;
655 cluster_list[
cc][
jj].c2x5_ += cluster_list[
cc][
kk].c2x5_;
656 cluster_list[
cc][
kk].cpt = 0;
657 cluster_list[
cc][
kk].c2x2_ = 0;
658 cluster_list[
cc][
kk].c2x5_ = 0;
659 cluster_list[
cc][
kk].c5x5_ = 0;
663 if (cluster_list[
cc][
jj].cpt > 0) {
664 cluster_list[
cc][
jj].cpt =
665 cluster_list[
cc][
jj].cpt *
668 cluster_list_merged[
cc].push_back(cluster_list[
cc][
jj]);
672 return a.cpt >
b.cpt;
684 cluster_list_merged[
cc][
jj].c2x5_ / cluster_list_merged[
cc][
jj].c5x5_))
689 cluster_list_merged[
cc][
jj].c2x5_ / cluster_list_merged[
cc][
jj].c5x5_))
694 cluster_list_merged[
cc][
jj].c2x2_ / cluster_list_merged[
cc][
jj].c2x5_))
701 for (
const auto&
hit : ecalhits) {
720 static constexpr
float tower_width = 0.0873;
725 (
ii + 0.5) * tower_width;
735 for (
const auto&
hit : hcalhits) {
744 HCAL_tower_L1Card[
jj][
ii][
cc] +=
hit.pt();
756 if (cluster_list_merged[
cc][
kk].cpt > 0) {
787 HCAL_tower_L2Card[
ii][
jj][ll] = 0;
788 ECAL_tower_L2Card[
ii][
jj][ll] = 0;
789 iEta_tower_L2Card[
ii][
jj][ll] = 0;
790 iPhi_tower_L2Card[
ii][
jj][ll] = 0;
797 energy_cluster_L2Card[
ii][
jj][ll] = 0;
798 brem_cluster_L2Card[
ii][
jj][ll] = 0;
799 towerID_cluster_L2Card[
ii][
jj][ll] = 0;
800 crystalID_cluster_L2Card[
ii][
jj][ll] = 0;
801 isolation_cluster_L2Card[
ii][
jj][ll] = 0;
802 HE_cluster_L2Card[
ii][
jj][ll] = 0;
803 photonShowerShape_cluster_L2Card[
ii][
jj][ll] = 0;
804 showerShape_cluster_L2Card[
ii][
jj][ll] = 0;
805 showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] = 0;
816 int card_left = 2 *
ii +
jj;
817 int card_right = 2 *
ii +
jj + 2;
854 int card_left = 2 *
ii +
jj;
855 int card_right = 2 *
ii +
jj + 2;
906 int card_bottom = 2 *
ii;
907 int card_top = 2 *
ii + 1;
947 cluster_list_L2[
ii].push_back(mc1);
951 begin(cluster_list_L2[
ii]),
end(cluster_list_L2[
ii]), [](mycluster
a, mycluster
b) {
return a.cpt >
b.cpt; });
957 if (cluster_list_L2[
ii][
jj].cpt > 0) {
960 cluster_list_L2[
ii][
jj].cpt = 0;
961 cluster_list_L2[
ii][
jj].ctowerid_ = 0;
962 cluster_list_L2[
ii][
jj].ccrystalid_ = 0;
972 float hcal_nrj = 0.0;
976 for (
unsigned int jjj = 0; jjj <
n_clusters_per_L1card && jjj < cluster_list_L2[iii].size(); ++jjj) {
977 if (!(iii ==
ii && jjj ==
jj)) {
980 if (
abs(cluster2_eta - cluster_etaOfTower_fullDetector) <= 2 &&
981 (
abs(cluster2_phi - cluster_phiOfTower_fullDetector) <= 2
or 982 abs(cluster2_phi -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
983 isolation += cluster_list_L2[iii][jjj].cpt;
995 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
996 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or 997 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
999 if (!((cluster_phiOfTower_fullDetector == 0 && phiOftower_fullDetector == 71)
or 1000 (cluster_phiOfTower_fullDetector == 23 && phiOftower_fullDetector == 26)
or 1001 (cluster_phiOfTower_fullDetector == 24 && phiOftower_fullDetector == 21)
or 1002 (cluster_phiOfTower_fullDetector == 47 && phiOftower_fullDetector == 50)
or 1003 (cluster_phiOfTower_fullDetector == 48 && phiOftower_fullDetector == 45)
or 1004 (cluster_phiOfTower_fullDetector == 71 && phiOftower_fullDetector == 2))) {
1011 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
1012 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or 1013 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1014 hcal_nrj += HCAL_tower_L1Card[ll][mm][
kk];
1019 cluster_list_L2[
ii][
jj].ciso_ = ((
isolation) * (25.0 / ntowers)) / cluster_list_L2[
ii][
jj].cpt;
1020 cluster_list_L2[
ii][
jj].chovere_ = hcal_nrj / cluster_list_L2[
ii][
jj].cpt;
1028 for (
int ll = 0; ll < 3; ++ll) {
1029 ECAL_tower_L2Card[
ii][
jj][ll] =
1031 HCAL_tower_L2Card[
ii][
jj][ll] =
1033 iEta_tower_L2Card[
ii][
jj][ll] =
1035 iPhi_tower_L2Card[
ii][
jj][ll] =
1065 auto L1EGXtalClusters = std::make_unique<l1tp2::CaloCrystalClusterCollection>();
1066 auto L1EGammas = std::make_unique<l1t::EGammaBxCollection>();
1067 auto L1CaloTowers = std::make_unique<l1tp2::CaloTowerCollection>();
1073 for (
int jj = 0;
jj < 2; ++
jj) {
1074 if (energy_cluster_L2Card[
ii][
jj][ll] > 0.45) {
1076 energy_cluster_L2Card[
ii][
jj][ll],
1078 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1080 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1082 SimpleCaloHit centerhit;
1083 bool is_iso =
passes_iso(energy_cluster_L2Card[
ii][
jj][ll], isolation_cluster_L2Card[
ii][
jj][ll]);
1084 bool is_looseTkiso =
1086 bool is_ss = (showerShape_cluster_L2Card[
ii][
jj][ll] == 1);
1087 bool is_photon = (photonShowerShape_cluster_L2Card[
ii][
jj][ll] == 1) && is_ss && is_iso;
1088 bool is_looseTkss = (showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] == 1);
1091 energy_cluster_L2Card[
ii][
jj][ll],
1092 HE_cluster_L2Card[
ii][
jj][ll],
1093 isolation_cluster_L2Card[
ii][
jj][ll],
1099 energy_cluster_L2Card[
ii][
jj][ll],
1105 is_looseTkiso&& is_looseTkss,
1108 std::map<std::string, float>
params;
1109 params[
"standaloneWP_showerShape"] = is_ss;
1110 params[
"standaloneWP_isolation"] = is_iso;
1111 params[
"trkMatchWP_showerShape"] = is_looseTkss;
1112 params[
"trkMatchWP_isolation"] = is_looseTkiso;
1115 cluster.setExperimentalParams(
params);
1116 L1EGXtalClusters->push_back(cluster);
1118 int standaloneWP = (
int)(is_iso && is_ss);
1119 int looseL1TkMatchWP = (
int)(is_looseTkiso && is_looseTkss);
1120 int photonWP = (
int)(is_photon);
1123 L1EGammas->push_back(
1124 0,
l1t::EGamma(p4calibrated, p4calibrated.pt(), p4calibrated.eta(), p4calibrated.phi(),
quality, 1));
1142 static float constexpr towerEtaUpperUnitialized = -80;
1143 static float constexpr towerPhiUpperUnitialized = -90;
1144 if (l1CaloTower.
towerEta() < towerEtaUpperUnitialized && l1CaloTower.
towerPhi() < towerPhiUpperUnitialized) {
1152 for (
const auto& l1eg : *L1EGXtalClusters) {
1153 if (l1eg.experimentalParam(
"TTiEta") != l1CaloTower.
towerIEta())
1155 if (l1eg.experimentalParam(
"TTiPhi") != l1CaloTower.
towerIPhi())
1158 int n_L1eg = l1CaloTower.
nL1eg();
1162 if (l1CaloTower.
nL1eg() > 1)
1164 l1CaloTower.
setL1egTrkSS(l1eg.experimentalParam(
"trkMatchWP_showerShape"));
1165 l1CaloTower.
setL1egTrkIso(l1eg.experimentalParam(
"trkMatchWP_isolation"));
1170 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 getPhiMax_card(int card)
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_crystals_3towers
int getEtaMax_card(int card)
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.