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] calibrated GCT calo jets and taus #43746

Merged
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
108 changes: 83 additions & 25 deletions L1Trigger/L1CaloTrigger/interface/Phase2L1CaloEGammaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace p2eg {
static constexpr float e0_looseTkss = 0.944, e1_looseTkss = 0.65, e2_looseTkss = 0.4; // passes_looseTkss
static constexpr float cut_500_MeV = 0.5;

static constexpr float ECAL_LSB = 0.125; // to convert from int to float (GeV) multiply by LSB
static constexpr float ECAL_LSB = 0.5; // to convert from int to float (GeV) multiply by LSB
static constexpr float HCAL_LSB = 0.5;

static constexpr int N_CLUSTERS_PER_REGION = 4; // number of clusters per ECAL region
Expand Down Expand Up @@ -434,10 +434,22 @@ namespace p2eg {

class towerHCAL {
private:
ap_uint<10> et = 0;
ap_uint<6> fb = 0;
ap_uint<10> et;
ap_uint<6> fb;

public:
// constructor
towerHCAL() {
et = 0;
fb = 0;
};

// copy constructor
towerHCAL(const towerHCAL& other) {
et = other.et;
fb = other.fb;
};

// set members
inline void zeroOut() {
et = 0;
Expand Down Expand Up @@ -474,12 +486,6 @@ namespace p2eg {
};
};

// overload operator= to use copy constructor
towers3x4 operator=(const towers3x4& other) {
const towers3x4& newRegion(other);
return newRegion;
};

// set members
inline void zeroOut() {
for (int i = 0; i < TOWER_IN_ETA; i++) {
Expand Down Expand Up @@ -591,9 +597,22 @@ namespace p2eg {
*/
class crystalMax {
public:
ap_uint<10> energy = 0;
uint8_t phiMax = 0;
uint8_t etaMax = 0;
ap_uint<10> energy;
uint8_t phiMax;
uint8_t etaMax;

crystalMax() {
energy = 0;
phiMax = 0;
etaMax = 0;
}

crystalMax& operator=(const crystalMax& rhs) {
energy = rhs.energy;
phiMax = rhs.phiMax;
etaMax = rhs.etaMax;
return *this;
}
};

class ecaltp_t {
Expand Down Expand Up @@ -667,9 +686,14 @@ namespace p2eg {

class tower_t {
public:
ap_uint<16> data = 0;
ap_uint<16> data;

tower_t() { data = 0; }
tower_t& operator=(const tower_t& rhs) {
data = rhs.data;
return *this;
}

tower_t() = default;
tower_t(ap_uint<12> et, ap_uint<4> hoe) { data = (et) | (((ap_uint<16>)hoe) << 12); }

ap_uint<12> et() { return (data & 0xFFF); }
Expand All @@ -685,7 +709,7 @@ namespace p2eg {
float newEt = getEt() * factor;

// Convert the new pT to an unsigned int (16 bits so we can take the logical OR with the bit mask later)
ap_uint<16> newEt_uint = (ap_uint<16>)(int)(newEt * 8.0);
ap_uint<16> newEt_uint = (ap_uint<16>)(int)(newEt / ECAL_LSB);
// Make sure the first four bits are zero
newEt_uint = (newEt_uint & 0x0FFF);

Expand All @@ -697,9 +721,7 @@ namespace p2eg {
/*
* For towers: Calculate H/E ratio given the ECAL and HCAL energies and modify the hoe() value.
*/
void getHoverE(ap_uint<12> ECAL, ap_uint<12> HCAL_inHcalConvention) {
// Convert HCAL ET to ECAL ET convention
ap_uint<12> HCAL = convertHcalETtoEcalET(HCAL_inHcalConvention);
void addHoverEToTower(ap_uint<12> ECAL, ap_uint<12> HCAL) {
ap_uint<4> hoeOut;
ap_uint<1> hoeLSB = 0;
ap_uint<4> hoe = 0;
Expand Down Expand Up @@ -741,13 +763,34 @@ namespace p2eg {

class clusterInfo {
public:
ap_uint<10> seedEnergy = 0;
ap_uint<15> energy = 0;
ap_uint<15> et5x5 = 0;
ap_uint<15> et2x5 = 0;
ap_uint<5> phiMax = 0;
ap_uint<5> etaMax = 0;
ap_uint<2> brems = 0;
ap_uint<10> seedEnergy;
ap_uint<15> energy;
ap_uint<15> et5x5;
ap_uint<15> et2x5;
ap_uint<5> phiMax;
ap_uint<5> etaMax;
ap_uint<2> brems;

clusterInfo() {
seedEnergy = 0;
energy = 0;
et5x5 = 0;
et2x5 = 0;
phiMax = 0;
etaMax = 0;
brems = 0;
}

clusterInfo& operator=(const clusterInfo& rhs) {
seedEnergy = rhs.seedEnergy;
energy = rhs.energy;
et5x5 = rhs.et5x5;
et2x5 = rhs.et2x5;
phiMax = rhs.phiMax;
etaMax = rhs.etaMax;
brems = rhs.brems;
return *this;
}
};

//--------------------------------------------------------//
Expand Down Expand Up @@ -808,6 +851,20 @@ namespace p2eg {
is_looseTkiso = cluster_is_looseTkiso;
}

Cluster& operator=(const Cluster& rhs) {
data = rhs.data;
regionIdx = rhs.regionIdx;
calib = rhs.calib;
brems = rhs.brems;
et5x5 = rhs.et5x5;
et2x5 = rhs.et2x5;
is_ss = rhs.is_ss;
is_looseTkss = rhs.is_looseTkss;
is_iso = rhs.is_iso;
is_looseTkiso = rhs.is_looseTkiso;
return *this;
}

void setRegionIdx(int regIdx) { regionIdx = regIdx; } // Newly added

ap_uint<12> clusterEnergy() const { return (data & 0xFFF); }
Expand Down Expand Up @@ -1438,6 +1495,7 @@ namespace p2eg {
l1tp2::CaloTower l1CaloTower;
// Store total Et (HCAL+ECAL) in the ECAL Et member
l1CaloTower.setEcalTowerEt(totalEtFloat());
l1CaloTower.setHcalTowerEt(ecalEtFloat());
int global_tower_iEta = globalToweriEtaFromGCTcardiEta(gctCard_tower_iEta);
int global_tower_iPhi = globalToweriPhiFromGCTcardiPhi(nGCTCard, gctCard_tower_iPhi);
l1CaloTower.setTowerIEta(global_tower_iEta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ namespace gctobj {
jet_tmp.tauEt = 0.;
}
jet_tmp.etaCenter = jet.etaCenter; // this is the ET weighted eta centre of the ST
jet_tmp.phiCenter = jet.phiCenter; // this is the ET weighted eta centre of the ST
jet_tmp.phiCenter = jet.phiCenter; // this is the ET weighted phi centre of the ST
jet_tmp.etaMax = jet.etaMax; // this is the leading tower eta in the ST
jet_tmp.phiMax = jet.phiMax; // this is the leading tower phi in the ST
return jet_tmp;
Expand Down
5 changes: 4 additions & 1 deletion L1Trigger/L1CaloTrigger/interface/Phase2L1GCT.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ inline p2eg::GCTinternal_t p2eg::getClustersTowers(const p2eg::GCTcard_t& GCTcar
*/
inline p2eg::GCTintTowers_t p2eg::getFullTowers(const p2eg::GCTinternal_t& GCTinternal) {
p2eg::GCTintTowers_t GCTintTowers;

// Positive eta
for (int i = 0; i < p2eg::N_GCTPOSITIVE_FIBERS; i = i + 4) {
for (int i1 = 0; i1 < 4; i1++) {
Expand All @@ -249,6 +248,8 @@ inline p2eg::GCTintTowers_t p2eg::getFullTowers(const p2eg::GCTinternal_t& GCTin
ap_uint<15> eta = p2eg::N_GCTETA / 2 + k;
GCTintTowers.GCTtower[eta][phi].et = GCTinternal.GCTCorrfiber[phi].GCTtowers[k].et;
GCTintTowers.GCTtower[eta][phi].hoe = GCTinternal.GCTCorrfiber[phi].GCTtowers[k].hoe;
GCTintTowers.GCTtower[eta][phi].ecalEt = GCTinternal.GCTCorrfiber[phi].GCTtowers[k].ecalEt;
GCTintTowers.GCTtower[eta][phi].hcalEt = GCTinternal.GCTCorrfiber[phi].GCTtowers[k].hcalEt;
for (int ic1 = 0; ic1 < 4; ic1++) {
for (int jc = 0; jc < p2eg::N_GCTCLUSTERS_FIBER; jc++) {
ap_uint<15> eta1 = p2eg::N_GCTETA / 2 + GCTinternal.GCTCorrfiber[i + ic1].GCTclusters[jc].towEta;
Expand All @@ -271,6 +272,8 @@ inline p2eg::GCTintTowers_t p2eg::getFullTowers(const p2eg::GCTinternal_t& GCTin
ap_uint<15> phi = i + i1 - p2eg::N_GCTPOSITIVE_FIBERS;
GCTintTowers.GCTtower[eta][phi].et = GCTinternal.GCTCorrfiber[i + i1].GCTtowers[k].et;
GCTintTowers.GCTtower[eta][phi].hoe = GCTinternal.GCTCorrfiber[i + i1].GCTtowers[k].hoe;
GCTintTowers.GCTtower[eta][phi].ecalEt = GCTinternal.GCTCorrfiber[i + i1].GCTtowers[k].ecalEt;
GCTintTowers.GCTtower[eta][phi].hcalEt = GCTinternal.GCTCorrfiber[i + i1].GCTtowers[k].hcalEt;
for (int ic1 = 0; ic1 < 4; ic1++) {
for (int jc = 0; jc < p2eg::N_GCTCLUSTERS_FIBER; jc++) {
ap_uint<15> eta1 = p2eg::N_GCTETA / 2 - 1 - GCTinternal.GCTCorrfiber[i + ic1].GCTclusters[jc].towEta;
Expand Down
33 changes: 15 additions & 18 deletions L1Trigger/L1CaloTrigger/interface/Phase2L1RCT.h
Original file line number Diff line number Diff line change
Expand Up @@ -1036,18 +1036,15 @@ inline void p2eg::getECALTowersEt(p2eg::crystal tempX[p2eg::CRYSTAL_IN_ETA][p2eg
}
}

towerEt[0] = towerEtN[0][0][0] + towerEtN[0][0][1] + towerEtN[0][0][2] + towerEtN[0][0][3] + towerEtN[0][0][4];
towerEt[1] = towerEtN[0][1][0] + towerEtN[0][1][1] + towerEtN[0][1][2] + towerEtN[0][1][3] + towerEtN[0][1][4];
towerEt[2] = towerEtN[0][2][0] + towerEtN[0][2][1] + towerEtN[0][2][2] + towerEtN[0][2][3] + towerEtN[0][2][4];
towerEt[3] = towerEtN[0][3][0] + towerEtN[0][3][1] + towerEtN[0][3][2] + towerEtN[0][3][3] + towerEtN[0][3][4];
towerEt[4] = towerEtN[1][0][0] + towerEtN[1][0][1] + towerEtN[1][0][2] + towerEtN[1][0][3] + towerEtN[1][0][4];
towerEt[5] = towerEtN[1][1][0] + towerEtN[1][1][1] + towerEtN[1][1][2] + towerEtN[1][1][3] + towerEtN[1][1][4];
towerEt[6] = towerEtN[1][2][0] + towerEtN[1][2][1] + towerEtN[1][2][2] + towerEtN[1][2][3] + towerEtN[1][2][4];
towerEt[7] = towerEtN[1][3][0] + towerEtN[1][3][1] + towerEtN[1][3][2] + towerEtN[1][3][3] + towerEtN[1][3][4];
towerEt[8] = towerEtN[2][0][0] + towerEtN[2][0][1] + towerEtN[2][0][2] + towerEtN[2][0][3] + towerEtN[2][0][4];
towerEt[9] = towerEtN[2][1][0] + towerEtN[2][1][1] + towerEtN[2][1][2] + towerEtN[2][1][3] + towerEtN[2][1][4];
towerEt[10] = towerEtN[2][2][0] + towerEtN[2][2][1] + towerEtN[2][2][2] + towerEtN[2][2][3] + towerEtN[2][2][4];
towerEt[11] = towerEtN[2][3][0] + towerEtN[2][3][1] + towerEtN[2][3][2] + towerEtN[2][3][3] + towerEtN[2][3][4];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
int index = j + 4 * i;
towerEt[index] = 0;
for (int k = 0; k < 5; k++) {
towerEt[index] += (towerEtN[i][j][k] >> 2);
}
}
}

ap_uint<12> totalEt;
for (int i = 0; i < 12; i++) {
Expand Down Expand Up @@ -1226,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]);
cluster_tmp.energy = (eta_slice[0] + eta_slice[1] + eta_slice[2]) >> 2;

return cluster_tmp;
}
Expand Down Expand Up @@ -1301,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]);
cluster_tmp.energy = (eta_slice[0] + eta_slice[1] + eta_slice[2]) >> 2;

return cluster_tmp;
}
Expand Down Expand Up @@ -1392,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]);
cluster_tmp.energy = (eta_slice[1] + eta_slice[2] + eta_slice[3]) >> 2;

// 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 @@ -1404,8 +1401,8 @@ inline p2eg::clusterInfo p2eg::getClusterValues(p2eg::crystal tempX[p2eg::CRYSTA
else
etSum2x5 = et2x5_2Tot;

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

return cluster_tmp;
}
Expand All @@ -1427,7 +1424,7 @@ inline p2eg::Cluster p2eg::getClusterFromRegion3x4(p2eg::crystal temp[p2eg::CRYS

cluster_tmp = p2eg::getClusterPosition(ecalRegion);

float seedEnergyFloat = cluster_tmp.seedEnergy / 8.0;
float seedEnergyFloat = cluster_tmp.seedEnergy * ECAL_LSB;

// Do not make cluster if seed is less than 1.0 GeV
if (seedEnergyFloat < 1.0) {
Expand Down
13 changes: 7 additions & 6 deletions L1Trigger/L1CaloTrigger/plugins/Phase2L1CaloEGammaEmulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ void Phase2L1CaloEGammaEmulator::produce(edm::Event& iEvent, const edm::EventSet
for (const auto& hit : *pcalohits.product()) {
if (hit.encodedEt() > 0) // hit.encodedEt() returns an int corresponding to 2x the crystal Et
{
// Et is 10 bit, by keeping the ADC saturation Et at 120 GeV it means that you have to divide by 8
float et = hit.encodedEt() * p2eg::ECAL_LSB;
// Et is 10 bit, by keeping the ADC saturation Et at 120 GeV it means that you have to multiply by 0.125 (input LSB)
float et = hit.encodedEt() * 0.125;
if (et < p2eg::cut_500_MeV) {
continue; // Reject hits with < 500 MeV ET
}
Expand Down Expand Up @@ -332,8 +332,9 @@ 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'
newCluster.setRegionIdx(idxRegion); // add the region number
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
if (newCluster.clusterEnergy() > 0) {
// do not push back 0-energy clusters
cluster_list[cc].push_back(newCluster);
Expand All @@ -342,7 +343,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);
p2eg::getECALTowersEt(temporary, towerEtECAL); // adjust for LSB 0.5 at GCT

// Fill towerHCALCard and towerECALCard arrays
for (int i = 0; i < 12; i++) {
Expand Down Expand Up @@ -440,7 +441,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
ap_uint<12> ecalEt = towerECALCard[ii][jj][cc].et();
ap_uint<12> hcalEt = towerHCALCard[ii][jj][cc].et();
towerECALCard[ii][jj][cc].getHoverE(ecalEt, hcalEt);
towerECALCard[ii][jj][cc].addHoverEToTower(ecalEt, hcalEt);
}
}

Expand Down
Loading