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

Integration of e/g CompositeID in 12.5.X #110

Merged
merged 70 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
c848045
starting point composite ID emulator
Jun 29, 2022
171cc91
cast floats to apfixed, run inference and compare output
Jun 29, 2022
ef982cf
add scheleton to plug in CompositeID
cerminar Jun 29, 2022
7edb2b7
incorporate compositeID as alternative to tkElectron, using skeleton …
Jul 27, 2022
4e7c57f
fix DR and add some verbosity
cerminar Aug 31, 2022
2e89963
equip to write decoded tracks to the event
cerminar Aug 3, 2021
55c4544
add calo coordinates to PFCandidates
cerminar Sep 15, 2021
5d19697
trying to move normalizations to different function
Aug 31, 2022
62d8ade
implement two BDT WPs
Aug 31, 2022
3ac8427
fixes
Aug 31, 2022
0d4e16d
Mapping of scores and WPs for consistent comparisons
Sep 1, 2022
108deea
trivialize the CompositeCandidate interface
cerminar Sep 16, 2022
e89f8fc
remove the cut on the CompositeID BDT and store the score in the TkEl…
cerminar Sep 16, 2022
98932ee
Remove pt10 cut from composite candidates
Sep 16, 2022
525233e
remove duplicated files
cerminar Oct 10, 2022
f8e4cea
remove duplicated files
cerminar Oct 10, 2022
42d7ce2
fix typo
cerminar Oct 10, 2022
32aa4c7
add missing headers
cerminar Oct 10, 2022
bbc27da
first implementation of the new data-formats for CompositeID input fe…
cerminar Oct 12, 2022
0b28796
reorder the code for adding the cluster-shape variables used by the c…
cerminar Nov 8, 2022
cd9bd45
temporary changes to run emulator from firmware testbench
cerminar Jan 27, 2023
0934ff3
make # of composite candidates per cluster configurabel
Nov 9, 2022
885ca19
add parameter for # of composite candidates per cluster
cerminar Nov 10, 2022
56ed6f7
change to new model with max tree depth of 4
Nov 10, 2022
8df4f6a
add variales for composite ID to HGCAL raw dataformat
Nov 23, 2022
c76cda6
Replace egamma BDT with model using no input scaling
Nov 21, 2022
b5ee230
Update egamma BDT to model trained on hw values. Use inversion fn fro…
Nov 22, 2022
47d4350
fix typo
cerminar Nov 23, 2022
5874bb5
switch to rounding for consisntency with HGC raw data format
cerminar Nov 24, 2022
c5b620f
fix assignment of cluster variables
cerminar Nov 24, 2022
1549f9f
add chi2 variables from track word, address some rounding issues in t…
cerminar Nov 25, 2022
3ed4d4f
mostly cosmetics
cerminar Nov 25, 2022
42dbbf2
move the chi2 back to be an emulator only quantity
cerminar Nov 25, 2022
0a2e3e9
fix constexpress
Nov 25, 2022
a45417a
code-format and remove unused parameters from CombinedID configuration
cerminar Nov 29, 2022
9b6c9f9
back to 1000 events
cerminar Nov 30, 2022
3096e6a
code-format
cerminar Dec 2, 2022
c9102cd
Drop includes not needed any more
cerminar Jan 31, 2023
4eba6d6
Event version is back to 12
cerminar Jan 31, 2023
a72fe0c
Introduce typedef for bdt features type + some std here and there
cerminar Jan 31, 2023
fad8b55
code format
cerminar Jan 31, 2023
dc0c262
undo changes to HGC ntuplizer
cerminar Feb 3, 2023
ccbf885
add slim version of packed Tk and Calo objs
cerminar Feb 15, 2023
aea1f6a
protect conversion for empy (0) words
cerminar Feb 21, 2023
466463b
Avoid code duplication or SLIM objects and other cosmetics
cerminar Mar 7, 2023
ac2694c
make unpacking of the addtional track variables configurable for barr…
cerminar Mar 8, 2023
d6a0d7e
Reinstate conifer runtime exception. Use cms::Exception in CMSSW cont…
thesps Mar 9, 2023
b84d29b
Merge pull request #13 from thesps/composite_eleid_125X_v0+cnf-fix
cerminar Mar 15, 2023
c7b819c
code format
cerminar Mar 15, 2023
e75fcf2
Handle BDT WPs and do some cosmetics
cerminar Mar 22, 2023
ac9470b
code format and fix python
cerminar Mar 22, 2023
c5e1296
cosmetics
cerminar Mar 27, 2023
8dfef6d
new model with srrtot rescaled, binned chi2 variables and without z0
Mar 28, 2023
c2ba610
Merge pull request #14 from Pmeiring/composite_eleid_125X_v0_newmodel
cerminar Mar 28, 2023
7cb2bd4
fix srr conversion back to float
cerminar Mar 28, 2023
b9e3ae9
Fix constexpr
cerminar Mar 28, 2023
feb0b83
code-format
cerminar Mar 28, 2023
4f0231c
Set working points. Don't transform WPs or BDT score
thesps Mar 29, 2023
64e9f43
Merge pull request #15 from thesps/composite_eleid_125X_v0_wps
cerminar Mar 29, 2023
fb34575
attempt to rounding problems in scaling srrtot
cerminar Mar 29, 2023
b3dde57
workaround to propagate BDT score to Layer2 objects
cerminar Mar 30, 2023
f64aac1
remove uneeded header
cerminar Mar 30, 2023
53081b5
make names of score variables more future proof
cerminar Mar 31, 2023
ce0ce6e
obsolete comment
cerminar Mar 31, 2023
73b2049
Fix type used in 1/pT
thesps Mar 31, 2023
8eaa9df
Merge pull request #16 from thesps/composite_eleid_125X_v0_wps
cerminar Mar 31, 2023
030489a
update the model: now built for using the HW input values
cerminar Apr 3, 2023
846567b
update tight WP
cerminar Apr 3, 2023
8d77d91
Update tight WP for 90%eff
cerminar Apr 3, 2023
f2aa770
Duplicate HGCAl TkeElectrons to run legacy Elliptic Algorithms for Ph…
cerminar Apr 4, 2023
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
4 changes: 3 additions & 1 deletion DataFormats/L1TCorrelator/interface/TkElectron.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ namespace l1t {

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

float idScore() const { return idScore_; }
// ---------- member functions ---------------------------

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

private:
edm::Ptr<L1TTTrackType> trkPtr_;
float trkzVtx_;
double trackCurvature_;
float idScore_;
};
} // namespace l1t
#endif
4 changes: 3 additions & 1 deletion DataFormats/L1TCorrelator/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
<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="7">
<version ClassVersion="7" checksum="3899336964"/>
<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
30 changes: 30 additions & 0 deletions DataFormats/L1TParticleFlow/interface/bit_encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,34 @@ inline void l1pf_pattern_unpack(const ap_uint<NB> data[], T objs[N]) {
}
}

template <unsigned int N, unsigned int OFFS = 0, typename T, int NB>
inline void l1pf_pattern_pack_slim(const T objs[N], ap_uint<NB> data[]) {
#ifdef __SYNTHESIS__
#pragma HLS inline
#pragma HLS inline region recursive
#endif
assert(T::BITWIDTH_SLIM <= NB);
for (unsigned int i = 0; i < N; ++i) {
#ifdef __SYNTHESIS__
#pragma HLS unroll
#endif
data[i + OFFS] = objs[i].pack_slim();
}
}

template <unsigned int N, unsigned int OFFS = 0, typename T, int NB>
inline void l1pf_pattern_unpack_slim(const ap_uint<NB> data[], T objs[N]) {
#ifdef __SYNTHESIS__
#pragma HLS inline
#pragma HLS inline region recursive
#endif
assert(T::BITWIDTH_SLIM <= NB);
for (unsigned int i = 0; i < N; ++i) {
#ifdef __SYNTHESIS__
#pragma HLS unroll
#endif
objs[i] = T::unpack(data[i + OFFS]);
}
}

#endif
17 changes: 17 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 - MEANZ_OFFSET(= 320 cm)
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,11 @@ namespace l1ct {
constexpr float Z0_LSB = 0.05;
constexpr float DXY_LSB = 0.05;
constexpr float PUPPIW_LSB = 1.0 / 256;
constexpr float MEANZ_OFFSET = 320.;
constexpr float SRRTOT_LSB = 0.0019531250; // pow(2, -9)
constexpr unsigned int SRRTOT_SCALE = 64; // pow(2, 6)
constexpr float HOE_LSB = 0.031250000; // pow(2, -5)

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 +175,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() / SRRTOT_SCALE; };
inline float floatMeanZ(meanz_t meanz) { return meanz + MEANZ_OFFSET; };
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 +208,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_SCALE / SRRTOT_LSB)); };
inline meanz_t makeMeanZ(float var) { return round(var - MEANZ_OFFSET); };
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 idScore;
bool read(std::fstream &from);
bool write(std::fstream &to) const;
void clear() {
EGIsoEleObj::clear();
srcCluster = nullptr;
srcTrack = nullptr;
sta_idx = -1;
idScore = -999;
clearIsoVars();
}

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

struct Event {
enum { VERSION = 11 };
enum { VERSION = 12 };
uint32_t run, lumi;
uint64_t event;
RawInputs raw;
Expand Down
Loading