Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6d56501
starting point composite ID emulator
Jun 29, 2022
1664f0e
cast floats to apfixed, run inference and compare output
Jun 29, 2022
c959fb5
add scheleton to plug in CompositeID
cerminar Jun 29, 2022
808b13e
incorporate compositeID as alternative to tkElectron, using skeleton …
Jul 27, 2022
2f52af5
fix DR and add some verbosity
cerminar Aug 31, 2022
19f2526
equip to write decoded tracks to the event
cerminar Aug 3, 2021
201cb52
add calo coordinates to PFCandidates
cerminar Sep 15, 2021
fd68c4b
trying to move normalizations to different function
Aug 31, 2022
ea1f03a
implement two BDT WPs
Aug 31, 2022
0120200
fixes
Aug 31, 2022
8445954
Mapping of scores and WPs for consistent comparisons
Sep 1, 2022
df466e8
trivialize the CompositeCandidate interface
cerminar Sep 16, 2022
de2a730
remove the cut on the CompositeID BDT and store the score in the TkEl…
cerminar Sep 16, 2022
3dfe89f
Remove pt10 cut from composite candidates
Sep 16, 2022
839921f
remove duplicated files
cerminar Oct 10, 2022
9c38bb7
remove duplicated files
cerminar Oct 10, 2022
2695a0e
fix typo
cerminar Oct 10, 2022
c938910
add missing headers
cerminar Oct 10, 2022
9ebd3ef
first implementation of the new data-formats for CompositeID input fe…
cerminar Oct 12, 2022
a873d19
temporary changes to run emulator from firmware testbench
Oct 12, 2022
44966d9
fix conflict
Oct 12, 2022
d22df66
Merge pull request #10 from Pmeiring/compositeID_emulator_reorg
cerminar Oct 13, 2022
ff004f2
reorder the code for adding the cluster-shape variables used by the c…
cerminar Nov 8, 2022
3819a93
Merge branch 'compositeID_emulator_reorg' of https://github.com/cermi…
cerminar Nov 8, 2022
21c13f2
make # of composite candidates per cluster configurabel
Nov 9, 2022
1a49435
add parameter for # of composite candidates per cluster
cerminar Nov 10, 2022
795dd71
change to new model with max tree depth of 4
Nov 10, 2022
0435970
Merge pull request #11 from Pmeiring/compositeID_emulator_reorg_newmodel
cerminar Nov 11, 2022
b420b2a
Replace egamma BDT with model using no input scaling
Nov 21, 2022
b0d2467
Update egamma BDT to model trained on hw values. Use inversion fn fro…
Nov 22, 2022
1531733
add variales for composite ID to HGCAL raw dataformat
Nov 23, 2022
1a8a52a
Merge pull request #12 from thesps/egcid-newmodel
cerminar Nov 23, 2022
aab53d3
fix typo
cerminar Nov 23, 2022
ae29ed6
switch to rounding for consisntency with HGC raw data format
cerminar Nov 24, 2022
e0e7b09
fix assignment of cluster variables
cerminar Nov 24, 2022
10f1db3
add chi2 variables from track word, address some rounding issues in t…
cerminar Nov 25, 2022
61e17df
mostly cosmetics
cerminar Nov 25, 2022
7118835
fix constexpress
Nov 25, 2022
47a1020
move the chi2 back to be an emulator only quantity
cerminar Nov 25, 2022
d867bcb
Merge branch 'compositeID_emulator_reorg' of https://github.com/cermi…
cerminar Nov 25, 2022
5774ec6
code-format and remove unused parameters from CombinedID configuration
cerminar Nov 29, 2022
f729072
back to 1000 events
cerminar Nov 30, 2022
a1a5edd
Merge branch 'L1PF_12_3_X' of github.com:p2l1pfp/cmssw into composite…
cerminar Dec 2, 2022
f3dc21d
code-format
cerminar Dec 2, 2022
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
5 changes: 4 additions & 1 deletion DataFormats/L1TCorrelator/interface/TkElectron.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ namespace l1t {

float trkzVtx() const { return trkzVtx_; }
double trackCurvature() const { return trackCurvature_; }

float compositeBdtScore() const { return compositeBdtScore_; }
// ---------- member functions ---------------------------

void setTrkzVtx(float TrkzVtx) { trkzVtx_ = TrkzVtx; }
void setTrackCurvature(double trackCurvature) { trackCurvature_ = trackCurvature; }
void setCompositeBdtScore(float score) { compositeBdtScore_ = score; }


private:
edm::Ptr<L1TTTrackType> trkPtr_;
float trkzVtx_;
double trackCurvature_;
float compositeBdtScore_;
};
} // namespace l1t
#endif
3 changes: 2 additions & 1 deletion DataFormats/L1TCorrelator/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
<class name="edm::Wrapper<std::vector<l1t::L1CaloTkTau> >"/>
<class name="edm::Ref<std::vector<l1t::L1CaloTkTau>,l1t::L1CaloTkTau,edm::refhelper::FindUsingAdvance<std::vector<l1t::L1CaloTkTau>,l1t::L1CaloTkTau> >"/>

<class name="l1t::TkElectron" ClassVersion="5">
<class name="l1t::TkElectron" ClassVersion="6">
<version ClassVersion="6" checksum="1759715068"/>
<version ClassVersion="5" checksum="965807884"/>
<version ClassVersion="4" checksum="3922083203"/>
<version ClassVersion="3" checksum="3970647299"/>
Expand Down
6 changes: 5 additions & 1 deletion DataFormats/L1TParticleFlow/interface/PFCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ namespace l1t {

void setZ0(float z0) { setVertex(reco::Particle::Point(0, 0, z0)); }
void setDxy(float dxy) { dxy_ = dxy; }
void setCaloEta(float caloeta) { caloEta_ = caloeta; }
void setCaloPhi(float calophi) { caloPhi_ = calophi; }

float z0() const { return vz(); }
float dxy() const { return dxy_; }
float caloEta() const { return caloEta_; }
float caloPhi() const { return caloPhi_; }

int16_t hwZ0() const { return hwZ0_; }
int16_t hwDxy() const { return hwDxy_; }
Expand All @@ -70,7 +74,7 @@ namespace l1t {
PFClusterRef clusterRef_;
PFTrackRef trackRef_;
MuonRef muonRef_;
float dxy_, puppiWeight_;
float dxy_, puppiWeight_, caloEta_, caloPhi_;

int16_t hwZ0_, hwDxy_;
uint16_t hwTkQuality_, hwPuppiWeight_, hwEmID_;
Expand Down
17 changes: 15 additions & 2 deletions DataFormats/L1TParticleFlow/interface/PFCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ namespace l1t {
float ptError = 0,
int hwpt = 0,
int hweta = 0,
int hwphi = 0)
int hwphi = 0,
float absZBarycenter = 0.,
float sigmaRR = 0.)
: L1Candidate(PolarLorentzVector(pt, eta, phi, 0), hwpt, hweta, hwphi, /*hwQuality=*/isEM ? 1 : 0),
hOverE_(hOverE),
ptError_(ptError) {
ptError_(ptError),
absZBarycenter_(absZBarycenter),
sigmaRR_(sigmaRR) {
setPdgId(isEM ? 22 : 130); // photon : non-photon(K0)
}
PFCluster(
Expand All @@ -37,6 +41,12 @@ namespace l1t {
float hOverE() const { return hOverE_; }
void setHOverE(float hOverE) { hOverE_ = hOverE; }

void setSigmaRR(float sigmaRR) { sigmaRR_ = sigmaRR; }
float absZBarycenter() const { return absZBarycenter_; }

void setAbsZBarycenter(float absZBarycenter) { absZBarycenter_ = absZBarycenter; }
float sigmaRR() const { return sigmaRR_; }

float emEt() const {
if (hOverE_ == -1)
return 0;
Expand Down Expand Up @@ -68,6 +78,9 @@ namespace l1t {

private:
float hOverE_, ptError_, egVsPionMVAOut_, egVsPUMVAOut_;
// HGC dedicated quantities (0ed by default)
float absZBarycenter_, sigmaRR_;

ConstituentsAndFractions constituents_;
};

Expand Down
16 changes: 16 additions & 0 deletions DataFormats/L1TParticleFlow/interface/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ namespace l1ct {
typedef ap_uint<10> em2calo_dr_t;
typedef ap_uint<13> tk2calo_dq_t;
typedef ap_uint<4> egquality_t;
typedef ap_uint<3> stub_t;
typedef ap_ufixed<10, 1, AP_TRN, AP_SAT> srrtot_t;
typedef ap_uint<8> meanz_t; // mean - SCALE_MEANZ = 320
typedef ap_ufixed<10, 5, AP_TRN, AP_SAT> hoe_t;
typedef ap_uint<4> redChi2Bin_t;

// FIXME: adjust range 10-11bits -> 1/4 - 1/2TeV is probably more than enough for all reasonable use cases
typedef ap_ufixed<11, 9, AP_TRN, AP_SAT> iso_t;

Expand Down Expand Up @@ -149,6 +155,10 @@ namespace l1ct {
constexpr float Z0_LSB = 0.05;
constexpr float DXY_LSB = 0.05;
constexpr float PUPPIW_LSB = 1.0 / 256;
constexpr float MEANZ_SCALE = 320.;
constexpr float SRRTOT_LSB = 0.0019531250;
constexpr float HOE_LSB = 0.031250000;

inline float floatPt(pt_t pt) { return pt.to_float(); }
inline float floatPt(dpt_t pt) { return pt.to_float(); }
inline float floatPt(pt2_t pt2) { return pt2.to_float(); }
Expand All @@ -164,6 +174,9 @@ namespace l1ct {
inline float floatDxy(dxy_t dxy) { return dxy.to_float() * DXY_LSB; }
inline float floatPuppiW(puppiWgt_t puppiw) { return puppiw.to_float() * PUPPIW_LSB; }
inline float floatIso(iso_t iso) { return iso.to_float(); }
inline float floatSrrTot(srrtot_t srrtot) { return srrtot.to_float(); };
inline float floatMeanZ(meanz_t meanz) { return meanz + MEANZ_SCALE; };
inline float floatHoe(hoe_t hoe) { return hoe.to_float(); };

inline pt_t makePt(int pt) { return ap_ufixed<16, 14>(pt) >> 2; }
inline dpt_t makeDPt(int dpt) { return ap_fixed<18, 16>(dpt) >> 2; }
Expand Down Expand Up @@ -194,6 +207,9 @@ namespace l1ct {
inline iso_t makeIso(float iso) { return iso_t(0.25 * round(iso * 4)); }

inline int makeDR2FromFloatDR(float dr) { return ceil(dr * dr / ETAPHI_LSB / ETAPHI_LSB); }
inline srrtot_t makeSrrTot(float var) { return srrtot_t(SRRTOT_LSB * round(var / SRRTOT_LSB)); };
inline meanz_t makeMeanZ(float var) { return round(var - MEANZ_SCALE); };
inline hoe_t makeHoe(float var) { return hoe_t(HOE_LSB * round(var / HOE_LSB)); };

inline float maxAbsEta() { return ((1 << (eta_t::width - 1)) - 1) * ETAPHI_LSB; }
inline float maxAbsPhi() { return ((1 << (phi_t::width - 1)) - 1) * ETAPHI_LSB; }
Expand Down
7 changes: 4 additions & 3 deletions DataFormats/L1TParticleFlow/interface/layer1_emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace l1ct {
};

struct TkObjEmu : public TkObj {
uint16_t hwChi2, hwStubs;
uint16_t hwChi2;
float simPt, simCaloEta, simCaloPhi, simVtxEta, simVtxPhi, simZ0, simD0;
const l1t::PFTrack *src;
bool read(std::fstream &from);
Expand All @@ -48,7 +48,6 @@ namespace l1ct {
TkObj::clear();
src = nullptr;
hwChi2 = 0;
hwStubs = 0;
simPt = 0;
simCaloEta = 0;
simCaloPhi = 0;
Expand Down Expand Up @@ -196,13 +195,15 @@ namespace l1ct {
const l1t::PFTrack *srcTrack;
// we use an index to the standalone object needed to retrieve a Ref when putting
int sta_idx;
float bdtScore;
bool read(std::fstream &from);
bool write(std::fstream &to) const;
void clear() {
EGIsoEleObj::clear();
srcCluster = nullptr;
srcTrack = nullptr;
sta_idx = -1;
bdtScore = -999;
clearIsoVars();
}

Expand Down Expand Up @@ -334,7 +335,7 @@ namespace l1ct {
};

struct Event {
enum { VERSION = 11 };
enum { VERSION = 13 };
uint32_t run, lumi;
uint64_t event;
RawInputs raw;
Expand Down
64 changes: 58 additions & 6 deletions DataFormats/L1TParticleFlow/interface/layer1_objs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ namespace l1ct {
phi_t hwPhi; // relative to the region center, at calo
pt_t hwEmPt;
emid_t hwEmID;
srrtot_t hwSrrTot;
meanz_t hwMeanZ;
hoe_t hwHoe;

inline bool operator==(const HadCaloObj &other) const {
return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwEmPt == other.hwEmPt &&
hwEmID == other.hwEmID;
hwEmID == other.hwEmID && hwSrrTot == other.hwSrrTot && hwMeanZ == other.hwMeanZ && hwHoe == other.hwHoe;
}

inline bool operator>(const HadCaloObj &other) const { return hwPt > other.hwPt; }
Expand All @@ -27,6 +30,9 @@ namespace l1ct {
hwPhi = 0;
hwEmPt = 0;
hwEmID = 0;
hwSrrTot = 0;
hwMeanZ = 0;
hwHoe = 0;
}

int intPt() const { return Scales::intPt(hwPt); }
Expand All @@ -37,10 +43,14 @@ namespace l1ct {
float floatEmPt() const { return Scales::floatPt(hwEmPt); }
float floatEta() const { return Scales::floatEta(hwEta); }
float floatPhi() const { return Scales::floatPhi(hwPhi); }
float floatSrrTot() const { return Scales::floatSrrTot(hwSrrTot); };
float floatMeanZ() const { return Scales::floatMeanZ(hwMeanZ); };
float floatHoe() const { return Scales::floatHoe(hwHoe); };

bool hwIsEM() const { return hwEmID != 0; }

static const int BITWIDTH = pt_t::width + eta_t::width + phi_t::width + pt_t::width + emid_t::width;
static const int BITWIDTH = pt_t::width + eta_t::width + phi_t::width + pt_t::width + emid_t::width +
srrtot_t::width + meanz_t::width + hoe_t::width;
inline ap_uint<BITWIDTH> pack() const {
ap_uint<BITWIDTH> ret;
unsigned int start = 0;
Expand All @@ -49,6 +59,9 @@ namespace l1ct {
pack_into_bits(ret, start, hwPhi);
pack_into_bits(ret, start, hwEmPt);
pack_into_bits(ret, start, hwEmID);
pack_into_bits(ret, start, hwSrrTot);
pack_into_bits(ret, start, hwMeanZ);
pack_into_bits(ret, start, hwHoe);
return ret;
}
inline static HadCaloObj unpack(const ap_uint<BITWIDTH> &src) {
Expand All @@ -59,6 +72,9 @@ namespace l1ct {
unpack_from_bits(src, start, ret.hwPhi);
unpack_from_bits(src, start, ret.hwEmPt);
unpack_from_bits(src, start, ret.hwEmID);
unpack_from_bits(src, start, ret.hwSrrTot);
unpack_from_bits(src, start, ret.hwMeanZ);
unpack_from_bits(src, start, ret.hwHoe);
return ret;
}
};
Expand All @@ -70,10 +86,13 @@ namespace l1ct {
eta_t hwEta; // relative to the region center, at calo
phi_t hwPhi; // relative to the region center, at calo
emid_t hwEmID;
srrtot_t hwSrrTot;
meanz_t hwMeanZ;
hoe_t hwHoe;

inline bool operator==(const EmCaloObj &other) const {
return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwPtErr == other.hwPtErr &&
hwEmID == other.hwEmID;
hwEmID == other.hwEmID && hwSrrTot == other.hwSrrTot && hwMeanZ == other.hwMeanZ && hwHoe == other.hwHoe;
}

inline bool operator>(const EmCaloObj &other) const { return hwPt > other.hwPt; }
Expand All @@ -85,6 +104,9 @@ namespace l1ct {
hwEta = 0;
hwPhi = 0;
hwEmID = 0;
hwSrrTot = 0;
hwMeanZ = 0;
hwHoe = 0;
}

int intPt() const { return Scales::intPt(hwPt); }
Expand All @@ -95,8 +117,12 @@ namespace l1ct {
float floatPtErr() const { return Scales::floatPt(hwPtErr); }
float floatEta() const { return Scales::floatEta(hwEta); }
float floatPhi() const { return Scales::floatPhi(hwPhi); }
float floatSrrTot() const { return Scales::floatSrrTot(hwSrrTot); };
float floatMeanZ() const { return Scales::floatMeanZ(hwMeanZ); };
float floatHoe() const { return Scales::floatHoe(hwHoe); };

static const int BITWIDTH = pt_t::width + eta_t::width + phi_t::width + pt_t::width + emid_t::width;
static const int BITWIDTH = pt_t::width + eta_t::width + phi_t::width + pt_t::width + emid_t::width +
srrtot_t::width + meanz_t::width + hoe_t::width;
inline ap_uint<BITWIDTH> pack() const {
ap_uint<BITWIDTH> ret;
unsigned int start = 0;
Expand All @@ -105,6 +131,9 @@ namespace l1ct {
pack_into_bits(ret, start, hwPhi);
pack_into_bits(ret, start, hwPtErr);
pack_into_bits(ret, start, hwEmID);
pack_into_bits(ret, start, hwSrrTot);
pack_into_bits(ret, start, hwMeanZ);
pack_into_bits(ret, start, hwHoe);
return ret;
}
inline static EmCaloObj unpack(const ap_uint<BITWIDTH> &src) {
Expand All @@ -115,6 +144,10 @@ namespace l1ct {
unpack_from_bits(src, start, ret.hwPhi);
unpack_from_bits(src, start, ret.hwPtErr);
unpack_from_bits(src, start, ret.hwEmID);
unpack_from_bits(src, start, ret.hwSrrTot);
unpack_from_bits(src, start, ret.hwMeanZ);
unpack_from_bits(src, start, ret.hwHoe);

return ret;
}
};
Expand All @@ -130,6 +163,11 @@ namespace l1ct {
z0_t hwZ0;
dxy_t hwDxy;
tkquality_t hwQuality;
stub_t hwStubs;
redChi2Bin_t hwRedChi2RZ; // 4 bits
redChi2Bin_t hwRedChi2RPhi; // 4 bits
//FIXME: is this actually filled? 3 bits would be enough
redChi2Bin_t hwRedChi2Bend; // 4 bits

enum TkQuality { PFLOOSE = 1, PFTIGHT = 2 };
bool isPFLoose() const { return hwQuality[0]; }
Expand All @@ -140,7 +178,8 @@ namespace l1ct {
inline bool operator==(const TkObj &other) const {
return hwPt == other.hwPt && hwEta == other.hwEta && hwPhi == other.hwPhi && hwDEta == other.hwDEta &&
hwDPhi == other.hwDPhi && hwZ0 == other.hwZ0 && hwDxy == other.hwDxy && hwCharge == other.hwCharge &&
hwQuality == other.hwQuality;
hwQuality == other.hwQuality && hwStubs == other.hwStubs && hwRedChi2RZ == other.hwRedChi2RZ &&
hwRedChi2RPhi == other.hwRedChi2RPhi && hwRedChi2Bend == other.hwRedChi2Bend;
}

inline bool operator>(const TkObj &other) const { return hwPt > other.hwPt; }
Expand All @@ -156,6 +195,10 @@ namespace l1ct {
hwDxy = 0;
hwCharge = false;
hwQuality = 0;
hwStubs = 0;
hwRedChi2RZ = 0;
hwRedChi2RPhi = 0;
hwRedChi2Bend = 0;
}

int intPt() const { return Scales::intPt(hwPt); }
Expand All @@ -175,7 +218,8 @@ namespace l1ct {
float floatDxy() const { return Scales::floatDxy(hwDxy); }

static const int BITWIDTH = pt_t::width + eta_t::width + phi_t::width + tkdeta_t::width + tkdphi_t::width + 1 +
z0_t::width + dxy_t::width + tkquality_t::width;
z0_t::width + dxy_t::width + tkquality_t::width + stub_t::width + redChi2Bin_t::width +
redChi2Bin_t::width + redChi2Bin_t::width;
inline ap_uint<BITWIDTH> pack() const {
ap_uint<BITWIDTH> ret;
unsigned int start = 0;
Expand All @@ -188,6 +232,10 @@ namespace l1ct {
pack_into_bits(ret, start, hwZ0);
pack_into_bits(ret, start, hwDxy);
pack_into_bits(ret, start, hwQuality);
pack_into_bits(ret, start, hwStubs);
pack_into_bits(ret, start, hwRedChi2RZ);
pack_into_bits(ret, start, hwRedChi2RPhi);
pack_into_bits(ret, start, hwRedChi2Bend);
return ret;
}
inline static TkObj unpack(const ap_uint<BITWIDTH> &src) {
Expand All @@ -202,6 +250,10 @@ namespace l1ct {
unpack_from_bits(src, start, ret.hwZ0);
unpack_from_bits(src, start, ret.hwDxy);
unpack_from_bits(src, start, ret.hwQuality);
unpack_from_bits(src, start, ret.hwStubs);
unpack_from_bits(src, start, ret.hwRedChi2RZ);
unpack_from_bits(src, start, ret.hwRedChi2RPhi);
unpack_from_bits(src, start, ret.hwRedChi2Bend);
return ret;
}
};
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/L1TParticleFlow/src/PFCandidate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ l1t::PFCandidate::PFCandidate(
: L1Candidate(p, hwpt, hweta, hwphi, /*hwQuality=*/int(kind)),
dxy_(0),
puppiWeight_(puppiWeight),
caloEta_(0),
caloPhi_(0),
hwZ0_(0),
hwDxy_(0),
hwTkQuality_(0),
Expand Down
7 changes: 4 additions & 3 deletions DataFormats/L1TParticleFlow/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<lcgdict>

<class name="l1t::PFCluster" ClassVersion="3">
<class name="l1t::PFCluster" ClassVersion="4">
<version ClassVersion="4" checksum="3917005656"/>
<version ClassVersion="3" checksum="1668592434"/>
</class>
<class name="l1t::PFClusterCollection"/>
Expand All @@ -19,7 +20,8 @@
<class name="edm::RefVector<l1t::PFTrackCollection>" />
<class name="std::vector<edm::Ref<l1t::PFTrackCollection> >" />

<class name="l1t::PFCandidate" ClassVersion="6">
<class name="l1t::PFCandidate" ClassVersion="7">
<version ClassVersion="7" checksum="2118795037"/>
<version ClassVersion="6" checksum="2195440462"/>
<version ClassVersion="5" checksum="3777180193"/>
<version ClassVersion="4" checksum="3798885201"/>
Expand Down Expand Up @@ -67,4 +69,3 @@
<class name="std::vector<edm::Ref<l1t::HPSPFTauCollection> >" />

</lcgdict>

Loading