83 static constexpr
float b0 = 0.38,
b1 = 1.9,
b2 = 0.05;
85 static constexpr
float d0 = 0.96,
d1 = 0.0003;
128 int phiID = int((phi +
M_PI) / size_cell);
140 int phiID = int((phi +
M_PI) / size_cell);
166 float phi = (
id * size_cell) -
M_PI + 0.5 * size_cell;
298 inline float pt()
const {
return pt_; };
320 static constexpr
int PI = 180;
324 while (result <= -PI)
345 calib_(iConfig.getParameter<edm::
ParameterSet>(
"calib")),
348 produces<l1tp2::CaloCrystalClusterCollection>();
349 produces<BXVector<l1t::EGamma> >();
350 produces<l1tp2::CaloTowerCollection>(
"L1CaloTowerCollection");
376 std::vector<SimpleCaloHit> ecalhits;
378 for (
const auto&
hit : *pcalohits.product()) {
379 if (
hit.encodedEt() > 0)
382 float et =
hit.encodedEt() / 8.;
393 ecalhits.push_back(ehit);
398 std::vector<SimpleCaloHit> hcalhits;
401 for (
const auto&
hit : *hbhecoll.product()) {
402 float et = decoder.hcaletValue(
hit.
id(),
hit.t0());
406 LogError(
"L1EGCrystalClusterEmulatorProducer")
407 <<
" -- Hcal hit DetID not present in HCAL Geom: " <<
hit.
id() << std::endl;
411 const std::vector<HcalDetId>& hcId = theTrigTowerGeometry.
detIds(
hit.
id());
413 LogError(
"L1EGCrystalClusterEmulatorProducer")
414 <<
"Cannot find any HCalDetId corresponding to " <<
hit.
id() << std::endl;
418 if (hcId[0].subdetId() > 1)
421 for (
const auto& hcId_i : hcId) {
422 if (hcId_i.subdetId() > 1)
428 hcal_tp_position = tmpVector;
437 hcalhits.push_back(hhit);
463 ECAL_tower_L1Card[
ii][
jj][ll] = 0;
464 HCAL_tower_L1Card[
ii][
jj][ll] = 0;
465 iPhi_tower_L1Card[
ii][
jj][ll] = -999;
466 iEta_tower_L1Card[
ii][
jj][ll] = -999;
473 energy_cluster_L1Card[
ii][
jj][ll] = 0;
474 brem_cluster_L1Card[
ii][
jj][ll] = 0;
475 towerID_cluster_L1Card[
ii][
jj][ll] = 0;
476 crystalID_cluster_L1Card[
ii][
jj][ll] = 0;
490 bool build_cluster =
true;
494 build_cluster =
false;
497 for (
const auto&
hit : ecalhits) {
505 !
hit.used() &&
hit.pt() >= 1.0 &&
hit.pt() > centerhit.
pt())
509 build_cluster =
true;
516 if (build_cluster && nclusters > 0 && nclusters <=
n_clusters_max) {
537 for (
auto&
hit : ecalhits) {
544 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
545 rightlobe +=
hit.pt();
547 if (
abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
548 leftlobe +=
hit.pt();
550 if (
abs(
hit.dieta(centerhit)) <= 2 &&
abs(
hit.diphi(centerhit)) <= 2) {
551 e5x5 +=
hit.energy();
554 if ((
hit.dieta(centerhit) == 1
or hit.dieta(centerhit) == 0) &&
555 (
hit.diphi(centerhit) == 1
or hit.diphi(centerhit) == 0)) {
556 e2x2_1 +=
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_2 +=
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_3 +=
hit.energy();
569 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
570 (
hit.diphi(centerhit) == 0
or hit.diphi(centerhit) == -1)) {
571 e2x2_4 +=
hit.energy();
574 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == 1) &&
abs(
hit.diphi(centerhit)) <= 2) {
575 e2x5_1 +=
hit.energy();
578 if ((
hit.dieta(centerhit) == 0
or hit.dieta(centerhit) == -1) &&
abs(
hit.diphi(centerhit)) <= 2) {
579 e2x5_2 +=
hit.energy();
587 abs(
hit.dieta(centerhit)) <= 1 &&
abs(
hit.diphi(centerhit)) <= 2 &&
597 if (
do_brem && (rightlobe > 0.10 * mc1.
cpt or leftlobe > 0.10 * mc1.
cpt)) {
598 for (
auto&
hit : ecalhits) {
606 if (rightlobe > 0.10 * mc1.
cpt && (leftlobe < 0.10 * mc1.cpt or rightlobe > leftlobe) &&
607 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) > 2 &&
hit.diphi(centerhit) <= 7) {
612 if (leftlobe > 0.10 * mc1.
cpt && (rightlobe < 0.10 * mc1.cpt or leftlobe >= rightlobe) &&
613 abs(
hit.dieta(centerhit)) <= 1 &&
hit.diphi(centerhit) < -2 &&
hit.diphi(centerhit) >= -7) {
624 if (e2x2_2 > mc1.
c2x2_)
626 if (e2x2_3 > mc1.
c2x2_)
628 if (e2x2_4 > mc1.
c2x2_)
636 cluster_list[cc].push_back(mc1);
643 for (
unsigned int jj = 0;
jj < unsigned(cluster_list[cc].
size()); ++
jj) {
644 for (
unsigned int kk =
jj + 1;
kk < unsigned(cluster_list[cc].
size()); ++
kk) {
645 if (
std::abs(cluster_list[cc][
jj].ceta_ - cluster_list[cc][
kk].ceta_) < 2 &&
646 std::abs(cluster_list[cc][
jj].cphi_ - cluster_list[cc][
kk].cphi_) < 2) {
647 if (cluster_list[cc][
kk].cpt > cluster_list[cc][
jj].cpt) {
648 cluster_list[cc][
kk].cpt += cluster_list[cc][
jj].cpt;
649 cluster_list[cc][
kk].c5x5_ += cluster_list[cc][
jj].c5x5_;
650 cluster_list[cc][
kk].c2x5_ += cluster_list[cc][
jj].c2x5_;
651 cluster_list[cc][
jj].cpt = 0;
652 cluster_list[cc][
jj].c5x5_ = 0;
653 cluster_list[cc][
jj].c2x5_ = 0;
654 cluster_list[cc][
jj].c2x2_ = 0;
656 cluster_list[cc][
jj].cpt += cluster_list[cc][
kk].cpt;
657 cluster_list[cc][
jj].c5x5_ += cluster_list[cc][
kk].c5x5_;
658 cluster_list[cc][
jj].c2x5_ += cluster_list[cc][
kk].c2x5_;
659 cluster_list[cc][
kk].cpt = 0;
660 cluster_list[cc][
kk].c2x2_ = 0;
661 cluster_list[cc][
kk].c2x5_ = 0;
662 cluster_list[cc][
kk].c5x5_ = 0;
666 if (cluster_list[cc][
jj].cpt > 0) {
667 cluster_list[cc][
jj].cpt =
668 cluster_list[cc][
jj].cpt *
671 cluster_list_merged[cc].push_back(cluster_list[cc][
jj]);
683 getTowerID(cluster_list_merged[cc][
jj].ceta_, cluster_list_merged[cc][
jj].cphi_);
687 cluster_list_merged[cc][
jj].c2x5_ / cluster_list_merged[cc][
jj].c5x5_))
692 cluster_list_merged[cc][
jj].c2x5_ / cluster_list_merged[cc][
jj].c5x5_))
697 cluster_list_merged[cc][
jj].c2x2_ / cluster_list_merged[cc][
jj].c2x5_))
704 for (
const auto&
hit : ecalhits) {
723 static constexpr
float tower_width = 0.0873;
728 (
ii + 0.5) * tower_width;
738 for (
const auto&
hit : hcalhits) {
747 HCAL_tower_L1Card[
jj][
ii][cc] +=
hit.pt();
758 for (
unsigned int kk = n_clusters_4link;
kk < cluster_list_merged[cc].size(); ++
kk) {
759 if (cluster_list_merged[cc][
kk].cpt > 0) {
761 [
getTower_etaID(cluster_list_merged[cc][
kk].ceta_)][cc] += cluster_list_merged[cc][
kk].cpt;
790 HCAL_tower_L2Card[
ii][
jj][ll] = 0;
791 ECAL_tower_L2Card[
ii][
jj][ll] = 0;
792 iEta_tower_L2Card[
ii][
jj][ll] = 0;
793 iPhi_tower_L2Card[
ii][
jj][ll] = 0;
800 energy_cluster_L2Card[
ii][
jj][ll] = 0;
801 brem_cluster_L2Card[
ii][
jj][ll] = 0;
802 towerID_cluster_L2Card[
ii][
jj][ll] = 0;
803 crystalID_cluster_L2Card[
ii][
jj][ll] = 0;
804 isolation_cluster_L2Card[
ii][
jj][ll] = 0;
805 HE_cluster_L2Card[
ii][
jj][ll] = 0;
806 photonShowerShape_cluster_L2Card[
ii][
jj][ll] = 0;
807 showerShape_cluster_L2Card[
ii][
jj][ll] = 0;
808 showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] = 0;
819 int card_left = 2 *
ii +
jj;
820 int card_right = 2 *
ii + jj + 2;
857 int card_left = 2 *
ii +
jj;
858 int card_right = 2 *
ii + jj + 2;
909 int card_bottom = 2 *
ii;
910 int card_top = 2 *
ii + 1;
950 cluster_list_L2[
ii].push_back(mc1);
960 if (cluster_list_L2[
ii][
jj].cpt > 0) {
963 cluster_list_L2[
ii][
jj].cpt = 0;
964 cluster_list_L2[
ii][
jj].ctowerid_ = 0;
965 cluster_list_L2[
ii][
jj].ccrystalid_ = 0;
972 for (
unsigned int jj = 0;
jj < 8 &&
jj < cluster_list_L2[
ii].size(); ++
jj) {
975 float hcal_nrj = 0.0;
979 for (
unsigned int jjj = 0; jjj < 8 && jjj < cluster_list_L2[iii].size(); ++jjj) {
980 if (!(iii ==
ii && jjj ==
jj)) {
983 if (
abs(cluster2_eta - cluster_etaOfTower_fullDetector) <= 2 &&
984 (
abs(cluster2_phi - cluster_phiOfTower_fullDetector) <= 2
or
985 abs(cluster2_phi -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
986 isolation += cluster_list_L2[iii][jjj].cpt;
998 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
999 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or
1000 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1002 if (!((cluster_phiOfTower_fullDetector == 0 && phiOftower_fullDetector == 71)
or
1003 (cluster_phiOfTower_fullDetector == 23 && phiOftower_fullDetector == 26)
or
1004 (cluster_phiOfTower_fullDetector == 24 && phiOftower_fullDetector == 21)
or
1005 (cluster_phiOfTower_fullDetector == 47 && phiOftower_fullDetector == 50)
or
1006 (cluster_phiOfTower_fullDetector == 48 && phiOftower_fullDetector == 45)
or
1007 (cluster_phiOfTower_fullDetector == 71 && phiOftower_fullDetector == 2))) {
1008 isolation += ECAL_tower_L1Card[ll][mm][
kk];
1014 if (
abs(etaOftower_fullDetector - cluster_etaOfTower_fullDetector) <= 2 &&
1015 (
abs(phiOftower_fullDetector - cluster_phiOfTower_fullDetector) <= 2
or
1016 abs(phiOftower_fullDetector -
n_towers_Phi - cluster_phiOfTower_fullDetector) <= 2)) {
1017 hcal_nrj += HCAL_tower_L1Card[ll][mm][
kk];
1022 cluster_list_L2[
ii][
jj].ciso_ = ((
isolation) * (25.0 / ntowers)) / cluster_list_L2[
ii][
jj].cpt;
1023 cluster_list_L2[
ii][
jj].chovere_ = hcal_nrj / cluster_list_L2[
ii][
jj].cpt;
1031 for (
int ll = 0; ll < 3; ++ll) {
1032 ECAL_tower_L2Card[
ii][
jj][ll] =
1034 HCAL_tower_L2Card[
ii][
jj][ll] =
1036 iEta_tower_L2Card[
ii][
jj][ll] =
1038 iPhi_tower_L2Card[
ii][
jj][ll] =
1048 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].ccrystalid_;
1050 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].ctowerid_;
1052 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].cpt;
1054 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].cbrem_;
1056 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].ciso_;
1058 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].chovere_;
1060 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].cshowershape_;
1062 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].cshowershapeloosetk_;
1064 [
ii / n_clusters_4link] = cluster_list_L2[
ii][
jj].cphotonshowershape_;
1068 auto L1EGXtalClusters = std::make_unique<l1tp2::CaloCrystalClusterCollection>();
1069 auto L1EGammas = std::make_unique<l1t::EGammaBxCollection>();
1070 auto L1CaloTowers = std::make_unique<l1tp2::CaloTowerCollection>();
1076 for (
int jj = 0;
jj < 2; ++
jj) {
1077 if (energy_cluster_L2Card[
ii][
jj][ll] > 0.45) {
1079 energy_cluster_L2Card[
ii][
jj][ll],
1081 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1083 ii, ll, towerID_cluster_L2Card[
ii][
jj][ll], crystalID_cluster_L2Card[
ii][
jj][ll]),
1086 bool is_iso =
passes_iso(energy_cluster_L2Card[
ii][
jj][ll], isolation_cluster_L2Card[
ii][
jj][ll]);
1087 bool is_looseTkiso =
1089 bool is_ss = (showerShape_cluster_L2Card[
ii][
jj][ll] == 1);
1090 bool is_photon = (photonShowerShape_cluster_L2Card[
ii][
jj][ll] == 1) && is_ss && is_iso;
1091 bool is_looseTkss = (showerShapeLooseTk_cluster_L2Card[
ii][
jj][ll] == 1);
1094 energy_cluster_L2Card[
ii][
jj][ll],
1095 HE_cluster_L2Card[
ii][
jj][ll],
1096 isolation_cluster_L2Card[
ii][
jj][ll],
1099 float(brem_cluster_L2Card[
ii][
jj][ll]),
1102 energy_cluster_L2Card[
ii][
jj][ll],
1108 is_looseTkiso&& is_looseTkss,
1111 std::map<std::string, float>
params;
1112 params[
"standaloneWP_showerShape"] = is_ss;
1113 params[
"standaloneWP_isolation"] = is_iso;
1114 params[
"trkMatchWP_showerShape"] = is_looseTkss;
1115 params[
"trkMatchWP_isolation"] = is_looseTkiso;
1118 cluster.setExperimentalParams(params);
1119 L1EGXtalClusters->push_back(cluster);
1121 int standaloneWP = (int)(is_iso && is_ss);
1122 int looseL1TkMatchWP = (int)(is_looseTkiso && is_looseTkss);
1123 int photonWP = (int)(is_photon);
1126 L1EGammas->push_back(
1127 0,
l1t::EGamma(p4calibrated, p4calibrated.pt(), p4calibrated.eta(), p4calibrated.phi(),
quality, 1));
1145 static float constexpr towerEtaUpperUnitialized = -80;
1146 static float constexpr towerPhiUpperUnitialized = -90;
1147 if (l1CaloTower.
towerEta() < towerEtaUpperUnitialized && l1CaloTower.
towerPhi() < towerPhiUpperUnitialized) {
1155 for (
const auto& l1eg : *L1EGXtalClusters) {
1156 if (l1eg.experimentalParam(
"TTiEta") != l1CaloTower.
towerIEta())
1158 if (l1eg.experimentalParam(
"TTiPhi") != l1CaloTower.
towerIPhi())
1161 int n_L1eg = l1CaloTower.
nL1eg();
1165 if (l1CaloTower.
nL1eg() > 1)
1167 l1CaloTower.
setL1egTrkSS(l1eg.experimentalParam(
"trkMatchWP_showerShape"));
1168 l1CaloTower.
setL1egTrkIso(l1eg.experimentalParam(
"trkMatchWP_isolation"));
1173 L1CaloTowers->push_back(l1CaloTower);
1180 iEvent.
put(
std::move(L1CaloTowers),
"L1CaloTowerCollection");
1212 bool is_ss = (pss >
d0 -
d1 *
pt);
void setId(const EBDetId &id)
static constexpr int n_links_GCTcard
constexpr double deltaPhi(double phi1, double phi2)
int getCrystal_etaID(float eta)
static constexpr float e2_looseTkss
l1tp2::ParametricCalibration calib_
edm::EDGetTokenT< edm::SortedCollection< HcalTriggerPrimitiveDigi > > hcalTPToken_
int getCrystal_phiID(float phi)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool passes_looseTkiso(float pt, float iso)
int getTower_phiID(int cluster_phiID)
std::pair< ALIstring, ALIstring > pss
static constexpr int toweriEta_fromAbsoluteID_shift
static constexpr int toweriPhi_fromAbsoluteID_shift_upperHalf
static constexpr int n_towers_halfPhi
static constexpr float cut_500_MeV
int getPhiMin_card(int card)
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryTag_
void setEcalTowerEt(float et)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
uint32_t const *__restrict__ Quality * quality
Sin< T >::type sin(const T &t)
static constexpr float ECAL_eta_range
bool passes_iso(float pt, float iso)
static constexpr float c2_ss
void setTowerIPhi(int iPhi)
void setIsEndcapHit(bool isEC)
Geom::Phi< T > phi() 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)
float get_calibrate(float uncorr)
Exp< T >::type exp(const T &t)
static constexpr int n_eta_bins
const HcalTopology * hcTopology_
bool operator==(SimpleCaloHit &other) const
Log< level::Error, false > LogError
int convert_L2toL1_card(int card, int link)
static constexpr int n_borders_eta
static constexpr float a1_80
int getEtaMin_card(int card)
void setL1egTrkIso(int trkIso)
void produce(edm::Event &, const edm::EventSetup &) override
static constexpr int toweriPhi_fromAbsoluteID_shift_lowerHalf
const GlobalVector & position() const
static constexpr int n_clusters_max
float getTowerEta_fromAbsoluteID(int id)
static constexpr int n_crystals_towerPhi
Geom::Theta< T > theta() const
int iphi() const
get the crystal iphi
bool getData(T &iHolder) const
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)
L1EGCrystalClusterEmulatorProducer(const edm::ParameterSet &)
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
static constexpr float a0_80
float distanceTo(SimpleCaloHit &other) const
bool passes_ss(float pt, float ss)
static constexpr bool do_brem
void setPosition(const GlobalVector &pos)
float getTowerPhi_fromAbsoluteID(int id)
bool passes_photon(float pt, float pss)
Abs< T >::type abs(const T &t)
int diphi(SimpleCaloHit &other) const
static constexpr int n_towers_per_link
void setL1egTrkSS(int trkSS)
int ieta() const
get the crystal ieta
edm::EDGetTokenT< EcalEBTrigPrimDigiCollection > ecalTPEBToken_
static constexpr float plateau_ss
static constexpr int n_clusters_link
void setIsBarrel(bool isBarrel)
float dphi(SimpleCaloHit &other) const
static constexpr float half_crystal_size
int dieta(SimpleCaloHit &other) const
int convert_L2toL1_tower(int tower)
void setTowerEta(float eta)
static constexpr float c1_ss
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
static constexpr float d0
int getTower_etaID(int cluster_etaID)
int convert_L2toL1_link(int link)
static constexpr float slideIsoPtThreshold
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.
static constexpr float a0
static constexpr float e0_looseTkss
void setL1egTowerEt(float et)
float deta(SimpleCaloHit &other) const
static constexpr int n_borders_phi
static constexpr int n_crystals_towerEta
const CaloSubdetectorGeometry * ebGeometry
bool passes_looseTkss(float pt, float ss)
float l1egTowerEt() const
static constexpr int n_GCTcards
static constexpr int n_towers_Phi
static constexpr float b2
static constexpr float b0
float getPhi_fromL2LinkCardTowerCrystal(int link, int card, int tower, int crystal)
void setIdHcal(const HcalDetId &idhcal)
~L1EGCrystalClusterEmulatorProducer() override
const EBDetId & id() const
static constexpr float d1
int getCrystalIDInTower(int etaID, int phiID)
static constexpr int n_towers_Eta
static constexpr float c0_ss
void setL1egStandaloneSS(int staSS)
void setUsed(bool isUsed)
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
const CaloSubdetectorGeometry * hbGeometry
static constexpr float b1
Global3DVector GlobalVector
static constexpr float e1_looseTkss
edm::ESGetToken< CaloTPGTranscoder, CaloTPGRecord > decoderTag_
bool validHT(const HcalTrigTowerDetId &id) const
std::vector< HcalDetId > detIds(const HcalTrigTowerDetId &) const
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.