Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Phase-2 L1T 14_0_X] small fixes for RCT cluster emulation #43989

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ namespace p2eg {
static constexpr float c0_ss = 0.94, c1_ss = 0.052, c2_ss = 0.044; // passes_ss
static constexpr float d0 = 0.96, d1 = 0.0003; // passes_photon
static constexpr float e0_looseTkss = 0.944, e1_looseTkss = 0.65, e2_looseTkss = 0.4; // passes_looseTkss
static constexpr float loose_ss_offset = 0.89; // loosen ss requirement in two eta bins
static constexpr float eta0_loose_ss = 0.4, eta1_loose_ss = 0.5, eta2_loose_ss = 0.75, eta3_loose_ss = 0.85;
static constexpr float high_pt_threshold = 130.; // apply iso and ss requirements below this threshold
static constexpr float cut_500_MeV = 0.5;

static constexpr float ECAL_LSB = 0.5; // to convert from int to float (GeV) multiply by LSB
Expand Down Expand Up @@ -91,14 +94,6 @@ namespace p2eg {

static constexpr int N_GCTTOWERS_CLUSTER_ISO_ONESIDE = 5; // window size of isolation sum (5x5 in towers)

/*
* Convert HCAL ET to ECAL ET convention
*/
inline ap_uint<12> convertHcalETtoEcalET(ap_uint<12> HCAL) {
float hcalEtAsFloat = HCAL * HCAL_LSB;
return (ap_uint<12>(hcalEtAsFloat / ECAL_LSB));
}

//////////////////////////////////////////////////////////////////////////
// RCT: indexing helper functions
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -773,7 +768,8 @@ namespace p2eg {
int clusterRegionIdx = 0) {
data = (clusterEnergy) | (((ap_uint<32>)towerEta) << 12) | (((ap_uint<32>)towerPhi) << 17) |
(((ap_uint<32>)clusterEta) << 19) | (((ap_uint<32>)clusterPhi) << 22) | (((ap_uint<32>)satur) << 25);
regionIdx = clusterRegionIdx, et5x5 = clusterEt5x5;
regionIdx = clusterRegionIdx;
et5x5 = clusterEt5x5;
et2x5 = clusterEt2x5;
brems = clusterBrems;
calib = clusterCalib;
Expand Down Expand Up @@ -907,7 +903,7 @@ namespace p2eg {
/*******************************************************************/
inline bool passes_iso(float pt, float iso) {
bool is_iso = true;
if (pt > 130)
if (pt > high_pt_threshold)
is_iso = true;
else if (pt < slideIsoPtThreshold) {
if (!((a0_80 - a1_80 * pt) > iso))
Expand All @@ -921,26 +917,32 @@ namespace p2eg {

inline bool passes_looseTkiso(float pt, float iso) {
bool is_iso;
if (pt > 130)
if (pt > high_pt_threshold)
is_iso = true;
else
is_iso = (b0 + b1 * std::exp(-b2 * pt) > iso);
return is_iso;
}

inline bool passes_ss(float pt, float ss) {
inline bool passes_ss(float pt, float eta, float ss) {
bool is_ss;
if (pt > 130)
if (pt > high_pt_threshold)
is_ss = true;
else if ((abs(eta) > eta0_loose_ss && abs(eta) < eta1_loose_ss) ||
(abs(eta) > eta2_loose_ss && abs(eta) < eta3_loose_ss)) // temporary adjustment
is_ss = ((loose_ss_offset + c1_ss * std::exp(-c2_ss * pt)) <= ss);
else
is_ss = ((c0_ss + c1_ss * std::exp(-c2_ss * pt)) <= ss);
return is_ss;
}

inline bool passes_looseTkss(float pt, float ss) {
inline bool passes_looseTkss(float pt, float eta, float ss) {
bool is_ss;
if (pt > 130)
if (pt > high_pt_threshold)
is_ss = true;
else if ((abs(eta) > eta0_loose_ss && abs(eta) < eta1_loose_ss) ||
(abs(eta) > eta2_loose_ss && abs(eta) < eta3_loose_ss)) // temporary adjustment
is_ss = ((loose_ss_offset - e1_looseTkss * std::exp(-e2_looseTkss * pt)) <= ss);
else
is_ss = ((e0_looseTkss - e1_looseTkss * std::exp(-e2_looseTkss * pt)) <= ss);
return is_ss;
Expand Down
15 changes: 4 additions & 11 deletions L1Trigger/L1CaloTrigger/interface/Phase2L1GCT.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,15 @@ inline void p2eg::doProximityAndBremsStitching(const p2eg::RCTcard_t (&inputCard
}

// Next, check for brems correction: clusters need to be next to each other in TOWERS only (not crystals) across an RCT card boundary.
// And the sub-leading cluster must have a significant (>10%) energy of the larger cluster, in order for them to be combined.
if (towerPhi1 == topTowerPhi) {
if (towerPhi2 == botTowerPhi) {
if ((dPhi <= 5) && (dEta < 2)) {
if (one > two) {
if (two >
(0.10 * one)) { // Only stitch if the sub-leading cluster has a significant amount of energy
outputCards[i].RCTtoGCTfiber[j].RCTclusters[k].et = one + two;
outputCards[i + 1].RCTtoGCTfiber[j1].RCTclusters[k1].et = 0;
}
outputCards[i].RCTtoGCTfiber[j].RCTclusters[k].et = one + two;
outputCards[i + 1].RCTtoGCTfiber[j1].RCTclusters[k1].et = 0;
} else {
if (one >
(0.10 * two)) { // Only stitch if the sub-leading cluster has a significant amount of energy
outputCards[i].RCTtoGCTfiber[j].RCTclusters[k].et = 0;
outputCards[i + 1].RCTtoGCTfiber[j1].RCTclusters[k1].et = one + two;
}
outputCards[i].RCTtoGCTfiber[j].RCTclusters[k].et = 0;
outputCards[i + 1].RCTtoGCTfiber[j1].RCTclusters[k1].et = one + two;
}
}
}
Expand Down
18 changes: 11 additions & 7 deletions L1Trigger/L1CaloTrigger/interface/Phase2L1RCT.h
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ inline void p2eg::getECALTowersEt(p2eg::crystal tempX[p2eg::CRYSTAL_IN_ETA][p2eg
int index = j + 4 * i;
towerEt[index] = 0;
for (int k = 0; k < 5; k++) {
towerEt[index] += (towerEtN[i][j][k] >> 2);
towerEt[index] += towerEtN[i][j][k];
}
}
}
Expand Down Expand Up @@ -1223,7 +1223,7 @@ inline p2eg::clusterInfo p2eg::getBremsValuesPos(p2eg::crystal tempX[p2eg::CRYST
for (int i = 0; i < 3; i++) {
eta_slice[i] = phi0eta[i] + phi1eta[i] + phi2eta[i] + phi3eta[i] + phi4eta[i];
}
cluster_tmp.energy = (eta_slice[0] + eta_slice[1] + eta_slice[2]) >> 2;
cluster_tmp.energy = (eta_slice[0] + eta_slice[1] + eta_slice[2]);

return cluster_tmp;
}
Expand Down Expand Up @@ -1298,7 +1298,7 @@ inline p2eg::clusterInfo p2eg::getBremsValuesNeg(p2eg::crystal tempX[p2eg::CRYST
for (int i = 0; i < 3; i++) {
eta_slice[i] = phi0eta[i] + phi1eta[i] + phi2eta[i] + phi3eta[i] + phi4eta[i];
}
cluster_tmp.energy = (eta_slice[0] + eta_slice[1] + eta_slice[2]) >> 2;
cluster_tmp.energy = (eta_slice[0] + eta_slice[1] + eta_slice[2]);

return cluster_tmp;
}
Expand Down Expand Up @@ -1389,7 +1389,7 @@ inline p2eg::clusterInfo p2eg::getClusterValues(p2eg::crystal tempX[p2eg::CRYSTA
eta_slice[i] = phi0eta[i] + phi1eta[i] + phi2eta[i] + phi3eta[i] + phi4eta[i];
}

cluster_tmp.energy = (eta_slice[1] + eta_slice[2] + eta_slice[3]) >> 2;
cluster_tmp.energy = (eta_slice[1] + eta_slice[2] + eta_slice[3]);

// Get the energy totals in the 5x5 and also in two 2x5
et5x5Tot = (eta_slice[0] + eta_slice[1] + eta_slice[2] + eta_slice[3] + eta_slice[4]);
Expand All @@ -1401,8 +1401,8 @@ inline p2eg::clusterInfo p2eg::getClusterValues(p2eg::crystal tempX[p2eg::CRYSTA
else
etSum2x5 = et2x5_2Tot;

cluster_tmp.et5x5 = et5x5Tot >> 2;
cluster_tmp.et2x5 = etSum2x5 >> 2;
cluster_tmp.et5x5 = et5x5Tot;
cluster_tmp.et2x5 = etSum2x5;

return cluster_tmp;
}
Expand Down Expand Up @@ -1503,7 +1503,7 @@ inline void p2eg::stitchClusterOverRegionBoundary(std::vector<Cluster>& cluster_
dPhi = (phi1 > phi2) ? (phi1 - phi2) : (phi2 - phi1);

if (dPhi < 2) {
ap_uint<15> totalEnergy = c1.clusterEnergy() + c2.clusterEnergy();
ap_uint<12> totalEnergy = c1.clusterEnergy() + c2.clusterEnergy();
ap_uint<15> totalEt2x5 = c1.uint_et2x5() + c2.uint_et2x5();
ap_uint<15> totalEt5x5 = c1.uint_et5x5() + c2.uint_et5x5();

Expand All @@ -1521,6 +1521,7 @@ inline void p2eg::stitchClusterOverRegionBoundary(std::vector<Cluster>& cluster_
totalEt5x5,
totalEt2x5,
c1.getBrems(),
c1.getCalib(),
c1.getIsSS(),
c1.getIsLooseTkss(),
rct_is_iso,
Expand All @@ -1535,6 +1536,7 @@ inline void p2eg::stitchClusterOverRegionBoundary(std::vector<Cluster>& cluster_
0,
0,
0,
1.0,
false,
false,
rct_is_iso,
Expand All @@ -1553,6 +1555,7 @@ inline void p2eg::stitchClusterOverRegionBoundary(std::vector<Cluster>& cluster_
0,
0,
0,
1.0,
false,
false,
rct_is_iso,
Expand All @@ -1567,6 +1570,7 @@ inline void p2eg::stitchClusterOverRegionBoundary(std::vector<Cluster>& cluster_
totalEt5x5,
totalEt2x5,
c2.getBrems(),
c2.getCalib(),
c2.getIsSS(),
c2.getIsLooseTkss(),
rct_is_iso,
Expand Down
19 changes: 9 additions & 10 deletions L1Trigger/L1CaloTrigger/plugins/Phase2L1CaloEGammaEmulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ void Phase2L1CaloEGammaEmulator::produce(edm::Event& iEvent, const edm::EventSet
ehit.setId(hit.id());
ehit.setPosition(GlobalVector(cell->getPosition().x(), cell->getPosition().y(), cell->getPosition().z()));
ehit.setEnergy(et);
ehit.setEt_uint((ap_uint<10>)hit.encodedEt()); // also save the uint Et
ehit.setEt_uint(
(ap_uint<10>)hit.encodedEt() >>
2); // also save the uint Et, this is to convert between 0.125 (in MC production) and 0.5 (in firmware based code)
ehit.setPt();
ecalhits.push_back(ehit);
}
Expand Down Expand Up @@ -332,9 +334,8 @@ void Phase2L1CaloEGammaEmulator::produce(edm::Event& iEvent, const edm::EventSet

// Iteratively find four clusters and remove them from 'temporary' as we go, and fill cluster_list
for (int c = 0; c < p2eg::N_CLUSTERS_PER_REGION; c++) {
p2eg::Cluster newCluster = p2eg::getClusterFromRegion3x4(
temporary); // remove cluster from 'temporary', adjust for LSB 0.5 at GCT in getClusterValues
newCluster.setRegionIdx(idxRegion); // add the region number
p2eg::Cluster newCluster = p2eg::getClusterFromRegion3x4(temporary); // remove cluster from 'temporary'
newCluster.setRegionIdx(idxRegion); // add the region number
if (newCluster.clusterEnergy() > 0) {
// do not push back 0-energy clusters
cluster_list[cc].push_back(newCluster);
Expand All @@ -343,7 +344,7 @@ void Phase2L1CaloEGammaEmulator::produce(edm::Event& iEvent, const edm::EventSet

// Create towers using remaining ECAL energy, and the HCAL towers were already calculated in towersEtHCAL[12]
ap_uint<12> towerEtECAL[12];
p2eg::getECALTowersEt(temporary, towerEtECAL); // adjust for LSB 0.5 at GCT
p2eg::getECALTowersEt(temporary, towerEtECAL);

// Fill towerHCALCard and towerECALCard arrays
for (int i = 0; i < 12; i++) {
Expand Down Expand Up @@ -418,8 +419,8 @@ void Phase2L1CaloEGammaEmulator::produce(edm::Event& iEvent, const edm::EventSet
// Cluster shower shape flags
//-------------------------------------------//
for (auto& c : cluster_list_merged[cc]) {
c.is_ss = p2eg::passes_ss(c.getPt(), (c.getEt2x5() / c.getEt5x5()));
c.is_looseTkss = p2eg::passes_looseTkss(c.getPt(), (c.getEt2x5() / c.getEt5x5()));
c.is_ss = p2eg::passes_ss(c.getPt(), c.realEta(cc), (c.getEt2x5() / c.getEt5x5()));
c.is_looseTkss = p2eg::passes_looseTkss(c.getPt(), c.realEta(cc), (c.getEt2x5() / c.getEt5x5()));
}

//-------------------------------------------//
Expand Down Expand Up @@ -483,9 +484,7 @@ void Phase2L1CaloEGammaEmulator::produce(edm::Event& iEvent, const edm::EventSet
for (int jj = 0; jj < p2eg::n_towers_cardPhi; ++jj) { // 4 towers per card in phi

l1tp2::CaloTower l1CaloTower;
// Divide by 8.0 to get ET as float (GeV)
l1CaloTower.setEcalTowerEt(towerECALCard[ii][jj][cc].et() * p2eg::ECAL_LSB);
// HCAL TPGs encoded ET: multiply by the LSB (0.5) to convert to GeV
l1CaloTower.setHcalTowerEt(towerHCALCard[ii][jj][cc].et() * p2eg::HCAL_LSB);
int absToweriEta = p2eg::getAbsID_iEta_fromFirmwareCardTowerLink(cc, ii, jj);
int absToweriPhi = p2eg::getAbsID_iPhi_fromFirmwareCardTowerLink(cc, ii, jj);
Expand Down Expand Up @@ -526,7 +525,7 @@ void Phase2L1CaloEGammaEmulator::produce(edm::Event& iEvent, const edm::EventSet
p2eg::tower_t t0_ecal = towerECALCard[iTower][iLink][rcc];
p2eg::tower_t t0_hcal = towerHCALCard[iTower][iLink][rcc];
p2eg::RCTtower_t t;
t.et = t0_ecal.et() + p2eg::convertHcalETtoEcalET(t0_hcal.et());
t.et = t0_ecal.et() + t0_hcal.et();
t.hoe = t0_ecal.hoe();
// Not needed for GCT firmware but will be written into GCT CMSSW outputs : 12 bits each
t.ecalEt = t0_ecal.et();
Expand Down