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

Restructure CTL1 input handling #129

Draft
wants to merge 40 commits into
base: L1PF_14_2_X
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
86346a0
Initial prototype to integrate the new multiclass model
cerminar Apr 4, 2024
43d2e3d
skeleton for hgc multiclass id integration
Apr 30, 2024
ce46e0c
update multiclass BDT WP & reorganize conifer model diretory
May 2, 2024
ded7b44
Clean up conifer directory
May 6, 2024
6eb55a7
Read BDT path correctly
May 6, 2024
cad5651
fix PU rejection bug with multi classifier
May 10, 2024
72878fa
Bug fix for BDT score not being applied
Jun 3, 2024
8fb65ed
Simpler way to debug the cluster & it connection of BDT scores
Jun 3, 2024
57617d9
clean up code
Jun 3, 2024
0dbf52e
Update model with meanz offset & confier header fix & offline-softmax
Aug 26, 2024
548c6f1
Switch to emulated crystal clusters and store digitized version in PF…
cerminar May 23, 2024
0fc656f
Address empty hwQual in CrystalClusters
cerminar May 23, 2024
0508634
fix conversion to 64bits
cerminar Aug 26, 2024
b69309a
Integrate hgcId & track truth matching on v9
Aug 26, 2024
3f32485
compatiable with track truth matching
Aug 26, 2024
da02f7b
Skeleton of barrel TkEleComposite ID
cerminar Aug 27, 2024
91e5cee
Complete first working version
cerminar Aug 28, 2024
0c3edf3
reduce verbosiry
cerminar Aug 28, 2024
9165ad4
Address tight WP assignment
cerminar Aug 28, 2024
7897185
Fix pt frac
cerminar Aug 28, 2024
632bdca
Fix track pt cut and elliptic matching for new EB model
cerminar Aug 29, 2024
4366b05
New model for the endcap
cerminar Aug 29, 2024
bcd7903
Fix digi object for selected clusters
cerminar Sep 12, 2024
7ff3f67
Fix nput features and precision for new TKEle EB model
cerminar Sep 12, 2024
caa1c22
roll back to Peter's composite ID in HGCal
cerminar Sep 18, 2024
c425b11
v9 + GCT + EBcomposite + EEmulticlass_tinymodel
Sep 26, 2024
c673f00
update HGC model to have pTbinned WP
Oct 8, 2024
7c19bba
set photon WP to false and fix the quality for collection before sele…
cerminar Nov 11, 2024
026e1d7
Fist step towards removing input conversion to PFCluster.
cerminar Nov 14, 2024
aa5a59d
Initial implementation of HGC cluster encoding/decoding
cerminar Nov 27, 2024
c235628
Add scheleton of multiclass model for evaluation while decoding clusters
cerminar Nov 27, 2024
88cb0df
Some cleanup and code formatting
cerminar Nov 28, 2024
8d0610b
Cleanup hgcal packing/unpacking, get a working python config
cerminar Nov 29, 2024
ef6ff0e
Move emulator objects sources to L1Candidate + code format
cerminar Dec 9, 2024
1a752d2
Refactoring the reference handling
cerminar Dec 9, 2024
160e065
Consistent naming for EG models
cerminar Dec 11, 2024
0eb5916
Restructure model configuration and handling
cerminar Dec 11, 2024
3512a4b
Remove duplicated code for tk to clusrter linking
cerminar Dec 11, 2024
89c9e8e
Remove redundant conifer header
cerminar Dec 11, 2024
4e20c8d
Add chi2 to Tk format for PF and start adding ID prob to calo clusters
cerminar Dec 12, 2024
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
11 changes: 6 additions & 5 deletions DataFormats/L1TParticleFlow/interface/PFCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#define DataFormats_L1TParticleFlow_PFCandidate_h

#include <vector>
#include "DataFormats/L1Trigger/interface/L1Candidate.h"
#include "DataFormats/L1TMuonPhase2/interface/SAMuon.h"
#include "DataFormats/L1TParticleFlow/interface/PFCluster.h"
#include "DataFormats/L1TParticleFlow/interface/PFTrack.h"
#include "DataFormats/L1Trigger/interface/RegionalOutput.h"

Expand All @@ -13,6 +11,7 @@ namespace l1t {
class PFCandidate : public L1Candidate {
public:
typedef l1t::SAMuonRef MuonRef;
typedef edm::Ptr<l1t::L1Candidate> L1CandPtr;
enum ParticleType { ChargedHadron = 0, Electron = 1, NeutralHadron = 2, Photon = 3, Muon = 4 };

PFCandidate() {}
Expand All @@ -37,8 +36,9 @@ namespace l1t {
const PFTrackRef& pfTrack() const { return trackRef_; }
void setPFTrack(const PFTrackRef& ref) { trackRef_ = ref; }

const PFClusterRef& pfCluster() const { return clusterRef_; }
void setPFCluster(const PFClusterRef& ref) { clusterRef_ = ref; }
const L1CandPtr& caloPtr() const { return caloPtr_; }
void setCaloPtr(const L1CandPtr& ptr) { caloPtr_ = ptr; }
// FIXME: need to provide backward compatibility to get Ptr out of the PFCluster ref

const MuonRef& muon() const { return muonRef_; }
void setMuon(const MuonRef& ref) { muonRef_ = ref; }
Expand Down Expand Up @@ -71,7 +71,8 @@ namespace l1t {
void setEncodedPuppi64(uint64_t encodedPuppi64) { encodedPuppi64_ = encodedPuppi64; }

private:
PFClusterRef clusterRef_;

L1CandPtr caloPtr_;
PFTrackRef trackRef_;
MuonRef muonRef_;
float dxy_, puppiWeight_, caloEta_, caloPhi_;
Expand Down
28 changes: 27 additions & 1 deletion DataFormats/L1TParticleFlow/interface/PFCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ namespace l1t {
hOverE_(hOverE),
ptError_(ptError),
absZBarycenter_(absZBarycenter),
sigmaRR_(sigmaRR) {
sigmaRR_(sigmaRR),
puIdScore_(0),
emIdScore_(0),
piIdScore_(0),
digiData_(0) // FIXME: is this still needed? Most likely not!
{
setPdgId(isEM ? 22 : 130); // photon : non-photon(K0)
}
PFCluster(
Expand Down Expand Up @@ -76,12 +81,33 @@ namespace l1t {
float egVsPUMVAOut() const { return egVsPUMVAOut_; }
void setEgVsPUMVAOut(float egVsPUMVAOut) { egVsPUMVAOut_ = egVsPUMVAOut; }

void setPuIDScore(float score) { puIdScore_ = score; }
float puIDScore() const { return puIdScore_; }

void setEmIDScore(float score) { emIdScore_ = score; }
float emIDScore() const { return emIdScore_; }

void setPiIDScore(float score) { piIdScore_ = score; }
float piIDScore() const { return piIdScore_; }

// Kyungmin
void setRho(float rho) { rho_ = rho; } // FIXME: is this still needed?
float getRho() const { return rho_; }

uint64_t digiWord() const { return digiData_; }
void setDigiWord(uint64_t data) {
digiData_ = data;
}

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

ConstituentsAndFractions constituents_;
uint64_t digiData_;
};

typedef std::vector<l1t::PFCluster> PFClusterCollection;
Expand Down
5 changes: 5 additions & 0 deletions DataFormats/L1TParticleFlow/interface/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ namespace l1ct {
typedef ap_uint<4> redChi2Bin_t;
typedef ap_fixed<10, 1, AP_RND_CONV, AP_SAT> id_score_t; // ID score to be between -1 (background) and 1 (signal)
typedef ap_ufixed<10, 1, AP_RND, AP_SAT> b_tag_score_t; // result_t from the NN is still apx_fixed<16,6>
//FIXME: no optimization for now
typedef ap_ufixed<8, 1, AP_RND_CONV, AP_SAT> id_prob_t; // ID prob between 0 and 1 (signal)



// 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 @@ -176,6 +180,7 @@ namespace l1ct {
inline float floatMeanZ(meanz_t meanz) { return meanz + MEANZ_OFFSET; };
inline float floatHoe(hoe_t hoe) { return hoe.to_float(); };
inline float floatIDScore(id_score_t score) { return score.to_float(); };
inline float floatIDProb(id_prob_t prob) { return prob.to_float(); };
inline float floatBtagScore(b_tag_score_t b_tag_score) { return b_tag_score.to_float(); }

inline pt_t makePt(int pt) { return ap_ufixed<16, 14>(pt) >> 2; }
Expand Down
20 changes: 10 additions & 10 deletions DataFormats/L1TParticleFlow/interface/layer1_emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

namespace l1t {
class PFTrack;
class PFCluster;
class PFCandidate;
class L1Candidate;
class SAMuon;
} // namespace l1t

namespace l1ct {

struct HadCaloObjEmu : public HadCaloObj {
const l1t::PFCluster *src = nullptr;
const l1t::L1Candidate *src = nullptr;
bool read(std::fstream &from);
bool write(std::fstream &to) const;
void clear() {
Expand All @@ -29,7 +29,7 @@ namespace l1ct {
};

struct EmCaloObjEmu : public EmCaloObj {
const l1t::PFCluster *src = nullptr;
const l1t::L1Candidate *src = nullptr;
bool read(std::fstream &from);
bool write(std::fstream &to) const;
void clear() {
Expand Down Expand Up @@ -69,7 +69,7 @@ namespace l1ct {
};

struct PFChargedObjEmu : public PFChargedObj {
const l1t::PFCluster *srcCluster = nullptr;
const l1t::L1Candidate *srcCluster = nullptr;
const l1t::PFTrack *srcTrack = nullptr;
const l1t::SAMuon *srcMu = nullptr;
const l1t::PFCandidate *srcCand = nullptr;
Expand All @@ -85,7 +85,7 @@ namespace l1ct {
};

struct PFNeutralObjEmu : public PFNeutralObj {
const l1t::PFCluster *srcCluster = nullptr;
const l1t::L1Candidate *srcCluster = nullptr;
const l1t::PFCandidate *srcCand = nullptr;
bool read(std::fstream &from);
bool write(std::fstream &to) const;
Expand All @@ -112,7 +112,7 @@ namespace l1ct {
};

struct PuppiObjEmu : public PuppiObj {
const l1t::PFCluster *srcCluster = nullptr;
const l1t::L1Candidate *srcCluster = nullptr;
const l1t::PFTrack *srcTrack = nullptr;
const l1t::SAMuon *srcMu = nullptr;
const l1t::PFCandidate *srcCand = nullptr;
Expand Down Expand Up @@ -149,15 +149,15 @@ namespace l1ct {
};

struct EGObjEmu : public EGIsoObj {
const l1t::PFCluster *srcCluster = nullptr;
const l1t::L1Candidate *srcCluster = nullptr;
void clear() {
srcCluster = nullptr;
EGIsoObj::clear();
}
};

struct EGIsoObjEmu : public EGIsoObj {
const l1t::PFCluster *srcCluster;
const l1t::L1Candidate *srcCluster;

// NOTE: we use an index to the persistable RefPtr when we reshuffle collections
// this way we avoid complex object in the object interface which needs to be used in standalone programs
Expand Down Expand Up @@ -193,7 +193,7 @@ namespace l1ct {
};

struct EGIsoEleObjEmu : public EGIsoEleObj {
const l1t::PFCluster *srcCluster = nullptr;
const l1t::L1Candidate *srcCluster = nullptr;
const l1t::PFTrack *srcTrack = nullptr;

// NOTE: we use an index to the persistable RefPtr when we reshuffle collections
Expand Down Expand Up @@ -337,7 +337,7 @@ namespace l1ct {
};

struct Event {
enum { VERSION = 13 };
enum { VERSION = 14 };
uint32_t run, lumi;
uint64_t event;
RawInputs raw;
Expand Down
46 changes: 34 additions & 12 deletions DataFormats/L1TParticleFlow/interface/layer1_objs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ namespace l1ct {
srrtot_t hwSrrTot;
meanz_t hwMeanZ;
hoe_t hwHoe;
id_prob_t hwPiID;
id_prob_t hwEgID;

// NOTE: empty objects will have hwPiID = 0, hwEmID = 0, hwPuID = 1
id_prob_t hwPuID() const { return id_prob_t(1) - hwPiID - hwEgID; }

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

inline bool operator>(const HadCaloObj &other) const { return hwPt > other.hwPt; }
Expand All @@ -33,6 +38,8 @@ namespace l1ct {
hwSrrTot = 0;
hwMeanZ = 0;
hwHoe = 0;
hwPiID = 0;
hwEgID = 0;
}

int intPt() const { return Scales::intPt(hwPt); }
Expand All @@ -46,6 +53,9 @@ namespace l1ct {
float floatSrrTot() const { return Scales::floatSrrTot(hwSrrTot); };
float floatMeanZ() const { return Scales::floatMeanZ(hwMeanZ); };
float floatHoe() const { return Scales::floatHoe(hwHoe); };
float floatPiID() const { return Scales::floatIDProb(hwPiID); };
float floatEmID() const { return Scales::floatIDProb(hwEmID); };
float floatPuID() const { return Scales::floatIDProb(hwPuID()); };

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

Expand Down Expand Up @@ -94,10 +104,13 @@ namespace l1ct {
srrtot_t hwSrrTot;
meanz_t hwMeanZ;
hoe_t hwHoe;
id_prob_t hwPiID;
id_prob_t hwEgID;


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

inline bool operator>(const EmCaloObj &other) const { return hwPt > other.hwPt; }
Expand All @@ -112,8 +125,13 @@ namespace l1ct {
hwSrrTot = 0;
hwMeanZ = 0;
hwHoe = 0;
hwPiID = 0;
hwEgID = 0;
}

// NOTE: empty objects will have hwPiID = 0, hwEgID = 0, hwPuID = 1
id_prob_t hwPuID() const { return id_prob_t(1) - hwPiID - hwEgID; }

int intPt() const { return Scales::intPt(hwPt); }
int intPtErr() const { return Scales::intPt(hwPtErr); }
int intEta() const { return hwEta.to_int(); }
Expand All @@ -125,6 +143,9 @@ namespace l1ct {
float floatSrrTot() const { return Scales::floatSrrTot(hwSrrTot); };
float floatMeanZ() const { return Scales::floatMeanZ(hwMeanZ); };
float floatHoe() const { return Scales::floatHoe(hwHoe); };
float floatPiID() const { return Scales::floatIDProb(hwPiID); };
float floatEmID() const { return Scales::floatIDProb(hwEmID); };
float floatPuID() const { return Scales::floatIDProb(hwPuID()); };

static const int BITWIDTH_SLIM = pt_t::width + eta_t::width + phi_t::width + pt_t::width + emid_t::width;

Expand Down Expand Up @@ -172,11 +193,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
redChi2Bin_t hwRedChi2RZ; // 4 bits
//FIXME: 3 bits would be enough
redChi2Bin_t hwRedChi2Bend; // 4 bits
stub_t hwStubs;

enum TkQuality { PFLOOSE = 1, PFTIGHT = 2 };
bool isPFLoose() const { return hwQuality[0]; }
Expand Down Expand Up @@ -204,10 +225,10 @@ namespace l1ct {
hwDxy = 0;
hwCharge = false;
hwQuality = 0;
hwStubs = 0;
hwRedChi2RZ = 0;
hwRedChi2RPhi = 0;
hwRedChi2RZ = 0;
hwRedChi2Bend = 0;
hwStubs = 0;
}

int intPt() const { return Scales::intPt(hwPt); }
Expand All @@ -227,10 +248,10 @@ namespace l1ct {
float floatDxy() const { return Scales::floatDxy(hwDxy); }

static const int BITWIDTH_SLIM = 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 + redChi2Bin_t::width;

static const int BITWIDTH =
BITWIDTH_SLIM + stub_t::width + redChi2Bin_t::width + redChi2Bin_t::width + redChi2Bin_t::width;
BITWIDTH_SLIM + redChi2Bin_t::width + redChi2Bin_t::width + stub_t::width;

inline ap_uint<BITWIDTH> pack() const {
ap_uint<BITWIDTH> ret;
Expand All @@ -244,10 +265,11 @@ 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, hwRedChi2RZ);
pack_into_bits(ret, start, hwRedChi2Bend);
pack_into_bits(ret, start, hwStubs);

return ret;
}
inline static TkObj unpack(const ap_uint<BITWIDTH> &src) {
Expand All @@ -262,10 +284,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.hwRedChi2RZ);
unpack_from_bits(src, start, ret.hwRedChi2Bend);
unpack_from_bits(src, start, ret.hwStubs);
return ret;
}
inline ap_uint<BITWIDTH_SLIM> pack_slim() const { return pack()(BITWIDTH_SLIM - 1, 0); }
Expand Down
6 changes: 5 additions & 1 deletion DataFormats/L1TParticleFlow/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<lcgdict>

<class name="l1t::PFCluster" ClassVersion="4">
<class name="l1t::PFCluster" ClassVersion="8">
<version ClassVersion="8" checksum="469821397"/>
<version ClassVersion="7" checksum="1901656035"/>
<version ClassVersion="6" checksum="439598246"/>
<version ClassVersion="5" checksum="3527085893"/>
<version ClassVersion="4" checksum="3917005656"/>
<version ClassVersion="3" checksum="1668592434"/>
</class>
Expand Down
Loading