Skip to content
Open
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
7 changes: 4 additions & 3 deletions DPGAnalysis/Phase2L1TNanoAOD/python/l1tPh2Nanotables_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,13 @@
)

sc8JetTable = pfJetTable.clone(
src = 'l1tSC8PFL1PuppiCorrectedEmulator',
src = cms.InputTag('l1tSC82ProngJetProducer', 'l1tSC82ProngJets'),
name = "L1puppiJetSC8",
doc = "SeededCone 0.8 Puppi jet, origin: Correlator",
variables = cms.PSet(
pfJetTable.variables.clone(),
mass = Var("mass", float)
mass = Var("mass", float),
nprongTagScore = Var('getTagScore("nprong")', float)
)
)

Expand Down Expand Up @@ -580,7 +581,7 @@
# ## jets
sc4JetTable,
sc8JetTable,
sc4ExtJetTable,
sc4ExtJetTable,
sc4NGJetTable,
histoJetTable,
caloJetTable,
Expand Down
7 changes: 7 additions & 0 deletions DataFormats/L1TCalorimeterPhase2/interface/CaloPFCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,35 @@ namespace l1tp2 {
CaloPFCluster()
: l1t::L1Candidate(),
clusterEt_(0.),
ecalEt_(0.),
clusterIEta_(-99),
clusterIPhi_(-99),
clusterEta_(-99.),
clusterPhi_(-99.) {}

CaloPFCluster(const PolarLorentzVector& p4,
float clusterEt,
float ecalEt,
int clusterIEta,
int clusterIPhi,
float clusterEta,
float clusterPhi)
: l1t::L1Candidate(p4),
clusterEt_(clusterEt),
ecalEt_(ecalEt),
clusterIEta_(clusterIEta),
clusterIPhi_(clusterIPhi),
clusterEta_(clusterEta),
clusterPhi_(clusterPhi) {}

inline float clusterEt() const { return clusterEt_; };
inline float ecalEt() const { return ecalEt_; };
inline int clusterIEta() const { return clusterIEta_; };
inline int clusterIPhi() const { return clusterIPhi_; };
inline float clusterEta() const { return clusterEta_; };
inline float clusterPhi() const { return clusterPhi_; };
void setClusterEt(float clusterEtIn) { clusterEt_ = clusterEtIn; };
void setEcalEt(float ecalEtIn) { ecalEt_ = ecalEtIn; };
void setClusterIEta(int clusterIEtaIn) { clusterIEta_ = clusterIEtaIn; };
void setClusterIPhi(int clusterIPhiIn) { clusterIPhi_ = clusterIPhiIn; };
void setClusterEta(float clusterEtaIn) { clusterEta_ = clusterEtaIn; };
Expand All @@ -46,6 +51,8 @@ namespace l1tp2 {
private:
// ET
float clusterEt_;
// ECAL ET
float ecalEt_;
// GCT ieta
int clusterIEta_;
// GCT iphi
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef DataFormats_L1TCalorimeterPhase2_DigitizedCaloToCorrelatorTM18_h
#define DataFormats_L1TCalorimeterPhase2_DigitizedCaloToCorrelatorTM18_h

#include <ap_int.h>
#include <variant>
#include <vector>
#include "DataFormats/L1TCalorimeterPhase2/interface/GCTEmDigiCluster.h"
#include "DataFormats/L1TCalorimeterPhase2/interface/GCTHadDigiCluster.h"

namespace l1tp2 {

typedef std::variant<std::monostate, l1tp2::GCTEmDigiCluster, l1tp2::GCTHadDigiCluster> GCTDigiCluster;
typedef std::vector<l1tp2::GCTDigiCluster> GCTDigiClusterLink;

class DigitizedCaloToCorrelatorTM18 {
private:
// Data (to remove)
ap_uint<64> CardData[162];

GCTDigiClusterLink CardLink;

public:
DigitizedCaloToCorrelatorTM18() {
for (int i = 0; i < 162; i++) {
CardData[i] = 0;
}
}
DigitizedCaloToCorrelatorTM18(ap_uint<64> data[162], GCTDigiClusterLink link) {
for (int i = 0; i < 162; i++) {
CardData[i] = data[i];
}
CardLink = link;
}

const ap_uint<64>* dataCard() const { return CardData; }
const GCTDigiClusterLink& linkCard() const { return CardLink; }
};

// Collection typedef
// this represents both the EM and PF clusters from a single GCT card in one link
typedef std::vector<l1tp2::DigitizedCaloToCorrelatorTM18> DigitizedCaloToCorrelatorCollectionTM18;

} // namespace l1tp2

#endif
148 changes: 44 additions & 104 deletions DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterCorrelator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,16 @@ namespace l1tp2 {
static constexpr float ETA_RANGE_ONE_SIDE = 1.4841; // barrel goes from (-1.4841, +1.4841)
static constexpr float LSB_ETA = ((2 * ETA_RANGE_ONE_SIDE) / (n_towers_eta * n_crystals_in_tower)); // (2.8 / 170)
static constexpr float LSB_PHI = ((2 * M_PI) / (3 * n_towers_phi * n_crystals_in_tower)); // (2 pi * 360)
static constexpr float PHI_RANGE_PER_SLR_DEGREES = 120;

static constexpr unsigned int n_bits_pt = 12; // 12 bits allocated for pt
static constexpr unsigned int n_bits_unused_start = 63; // unused bits start at bit 63

// "top" of the correlator card #0 in GCT coordinates is iPhi tower index 24
static constexpr int correlatorCard0_tower_iphi_offset = 24;
static constexpr int correlatorCard0_tower_iphi_offset = 68;
// same but for correlator cards #1 and 2 (cards wrap around phi = 180 degrees):
static constexpr int correlatorCard1_tower_iphi_offset = 48;
static constexpr int correlatorCard2_tower_iphi_offset = 0;

// Private member functions to perform digitization
ap_uint<12> digitizePt(float pt_f) {
float maxPt_f = (std::pow(2, n_bits_pt) - 1) * LSB_PT;
// If pT exceeds the maximum (extremely unlikely), saturate the value
if (pt_f >= maxPt_f) {
return (ap_uint<12>)0xFFF;
}

return (ap_uint<12>)(pt_f / LSB_PT);
}

ap_uint<8> digitizeIEtaCr(unsigned int iEtaCr) { return (ap_uint<8>)iEtaCr; }

ap_uint<7> digitizeIPhiCr(unsigned int iPhiCr) { return (ap_uint<7>)iPhiCr; }

// To-do: HoE is not defined for clusters
ap_uint<4> digitizeHoE(unsigned int hoe) { return (ap_uint<4>)hoe; }
ap_uint<2> digitizeHoeFlag(unsigned int hoeFlag) { return (ap_uint<2>)hoeFlag; }

ap_uint<3> digitizeIso(unsigned int iso) { return (ap_uint<3>)iso; }
ap_uint<2> digitizeIsoFlag(unsigned int isoFlag) { return (ap_uint<2>)isoFlag; }

// To-do: fb: no information yet
ap_uint<6> digitizeFb(unsigned int fb) { return (ap_uint<6>)fb; }

// To-do: timing: no information yet
ap_uint<5> digitizeTiming(unsigned int timing) { return (ap_uint<5>)timing; }

// Shape: shower shape working point
ap_uint<2> digitizeShapeFlag(unsigned int shapeFlag) { return (ap_uint<2>)shapeFlag; }

// TO-DO: Brems: was brems applied (NOT STORED YET IN GCT)
ap_uint<2> digitizeBrems(unsigned int brems) { return (ap_uint<2>)brems; }
static constexpr int correlatorCard1_tower_iphi_offset = 20;
static constexpr int correlatorCard2_tower_iphi_offset = 44;

public:
DigitizedClusterCorrelator() { clusterData = 0x0; }
Expand All @@ -71,45 +38,20 @@ namespace l1tp2 {

// Constructor from digitized inputs
DigitizedClusterCorrelator(ap_uint<12> pt,
ap_uint<8> etaCr,
ap_uint<7> phiCr,
ap_uint<4> hoe,
ap_uint<2> hoeFlag,
ap_uint<3> iso,
ap_uint<2> isoFlag,
ap_uint<6> fb,
ap_uint<7> eta,
ap_int<7> phi,
ap_uint<6> hoe,
ap_uint<6> iso,
ap_uint<6> shape,
ap_uint<3> wp,
ap_uint<5> timing,
ap_uint<2> shapeFlag,
ap_uint<2> brems,
int iGCTCard,
bool fullydigitizedInputs) {
(void)fullydigitizedInputs;
clusterData = ((ap_uint<64>)pt) | (((ap_uint<64>)etaCr) << 12) | (((ap_uint<64>)phiCr) << 20) |
(((ap_uint<64>)hoe) << 27) | (((ap_uint<64>)hoeFlag) << 31) | (((ap_uint<64>)iso) << 36) |
(((ap_uint<64>)isoFlag) << 38) | (((ap_uint<64>)fb) << 44) | (((ap_uint<64>)timing) << 49) |
(((ap_uint<64>)shapeFlag << 51)) | (((ap_uint<64>)brems << 53));
idxGCTCard = iGCTCard;
}

// Constructor from float inputs
DigitizedClusterCorrelator(float pt_f,
unsigned int iEtaCr,
unsigned int iPhiCr,
unsigned int hoe,
unsigned int hoeFlag,
unsigned int iso,
unsigned int isoFlag,
unsigned int fb,
unsigned int timing,
unsigned int shapeFlag,
unsigned int brems,
ap_uint<10> spare,
int iGCTCard) {
clusterData = (((ap_uint<64>)digitizePt(pt_f)) | ((ap_uint<64>)digitizeIEtaCr(iEtaCr) << 12) |
((ap_uint<64>)digitizeIPhiCr(iPhiCr) << 20) | ((ap_uint<64>)digitizeHoE(hoe) << 27) |
((ap_uint<64>)digitizeHoeFlag(hoeFlag) << 31) | ((ap_uint<64>)digitizeIso(iso) << 36) |
((ap_uint<64>)digitizeIsoFlag(isoFlag) << 38) | ((ap_uint<64>)digitizeFb(fb) << 44) |
((ap_uint<64>)digitizeTiming(timing) << 49) | ((ap_uint<64>)digitizeShapeFlag(shapeFlag) << 51) |
((ap_uint<64>)digitizeBrems(brems) << 53));
clusterData = ((ap_uint<64>)pt) | (((ap_uint<64>)eta) << 12) | (((ap_uint<64>)(phi & 0x7F)) << 19) |
(((ap_uint<64>)hoe) << 26) | (((ap_uint<64>)iso) << 32) | (((ap_uint<64>)shape) << 38) |
(((ap_uint<64>)wp) << 44) | (((ap_uint<64>)timing) << 47) | (((ap_uint<64>)brems) << 52) |
(((ap_uint<64>)spare) << 54);
idxGCTCard = iGCTCard;
}

Expand All @@ -121,49 +63,39 @@ namespace l1tp2 {
float ptFloat() const { return (pt() * ptLSB()); }

// crystal eta in the correlator region (LSB: 2.8/170)
ap_uint<8> eta() const { return ((clusterData >> 12) & 0xFF); } // (eight 1's) 0b11111111 = 0xFF
ap_uint<7> eta() const { return ((clusterData >> 12) & 0x7F); } // (seven 1's) 0b11111111 = 0x7F

// crystal phi in the correlator region (LSB: 2pi/360)
ap_uint<7> phi() const { return ((clusterData >> 20) & 0x7F); } // (seven 1's) 0b1111111 = 0x7F
ap_int<7> phi() const { return ((clusterData >> 19) & 0x7F); }

// HoE value and flag: not defined yet in the emulator
ap_uint<4> hoe() const { return ((clusterData >> 27) & 0xF); } // (four 1's) 0b1111 = 0xF
ap_uint<2> hoeFlag() const { return ((clusterData >> 31) & 0x3); } // (two 1's) 0b11 = 0x3
ap_uint<6> hoe() const { return ((clusterData >> 26) & 0x3F); }

// Raw isolation sum: not saved in the emulator
ap_uint<3> iso() const { return ((clusterData >> 36) & 0x7); }
ap_uint<6> iso() const { return ((clusterData >> 32) & 0x3F); } // raw isolation sum

// iso flag: two bits, least significant bit is the standalone WP (true or false), second bit is the looseTk WP (true or false)
// e.g. 0b01 : standalone iso flag passed, loose Tk iso flag did not pass
ap_uint<2> isoFlags() const { return ((clusterData >> 38) & 0x3); } // (two 1's) 0b11 = 0x3
bool passes_iso() const { return (isoFlags() & 0x1); } // standalone iso WP
bool passes_looseTkiso() const { return (isoFlags() & 0x2); } // loose Tk iso WP
ap_uint<6> shape() const { return ((clusterData >> 38) & 0x3F); } // et2x5/et5x5

// fb and timing: not saved in the current emulator
ap_uint<6> fb() const { return ((clusterData >> 44) & 0x3F); }
ap_uint<5> timing() const { return ((clusterData >> 49) & 0x1F); }
ap_uint<3> wp() const { return ((clusterData >> 44) & 0x7); } // encoded standaloneWP, looseL1TkMatchWP, photonWP

// shower shape shape flag: two bits, least significant bit is the standalone WP, second bit is the looseTk WP
// e.g. 0b01 : standalone shower shape flag passed, loose Tk shower shape flag did not pass
ap_uint<2> shapeFlags() const { return ((clusterData >> 51) & 0x3); }

bool passes_ss() const { return (shapeFlags() & 0x1); } // standalone shower shape WP
bool passes_looseTkss() const { return (shapeFlags() & 0x2); } // loose Tk shower shape WP
// timing: not saved in the current emulator
ap_uint<5> timing() const { return ((clusterData >> 47) & 0x1F); }

// brems: not saved in the current emulator
ap_uint<2> brems() const { return ((clusterData >> 53) & 0x3); }
ap_uint<2> brems() const { return ((clusterData >> 52) & 0x3); }

ap_uint<10> spare() const { return ((clusterData >> 54) & 0x3FF); }

// which GCT card (0, 1, or 2)
unsigned int cardNumber() const { return idxGCTCard; }

const int unusedBitsStart() const { return n_bits_unused_start; }

// Other checks
bool passNullBitsCheck(void) const { return ((data() >> unusedBitsStart()) == 0x0); }

// Get real eta (does not depend on card number). crystal iEta = 0 starts at real eta -1.4841.
// Get real eta (does not depend on card number)
// LSB_ETA/2 is to add half a crystal width to get the center of the crystal in eta
float realEta() const { return (float)((-1 * ETA_RANGE_ONE_SIDE) + (eta() * LSB_ETA) + (LSB_ETA / 2)); }
float realEta() const {
float tmpeta = (eta() * LSB_ETA) + (LSB_ETA / 2);
if ((spare() & 0x4) == 0)
tmpeta = -((eta() * LSB_ETA) + (LSB_ETA / 2));
return tmpeta;
}

// Get real phi (uses card number).
float realPhi() const {
Expand All @@ -176,10 +108,18 @@ namespace l1tp2 {
} else if (cardNumber() == 2) {
offset_tower = correlatorCard2_tower_iphi_offset;
}
int thisPhi = (phi() + (offset_tower * n_crystals_in_tower));
// crystal iPhi = 0 starts at real phi = -180 degrees

int tmpphi = (phi() + PHI_RANGE_PER_SLR_DEGREES / 4);
bool wrapped = !((spare() & 0x2) == 0);
if (wrapped) {
tmpphi += PHI_RANGE_PER_SLR_DEGREES / 2;
}
int thisPhi = (tmpphi + (offset_tower * n_crystals_in_tower));
if (thisPhi > 180)
thisPhi -= 360; // range between -180 to 180 degrees

// LSB_PHI/2 is to add half a crystal width to get the center of the crystal in phi
return (float)((-1 * M_PI) + (thisPhi * LSB_PHI) + (LSB_PHI / 2));
return (float)((thisPhi * LSB_PHI) + (LSB_PHI / 2));
}
};

Expand Down
Loading