Skip to content

[L1T] PR containing simulation and emulation related to jet mass reconstruction (Phase-2) #47792

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

lrobertshaw
Copy link

PR description:

Added logic for calculating jet mass in simulation where no approximations are made. Also added logic for firmware emulation which is bit-accurate to firmware implementation and makes a number of approximations for firmware efficiency. To integrate this work with the various taggers, a number of changes were made to the datatypes which the jet mass is read out to.

PR validation:

Resolution plots produced and compared with existing algorithms which already calculate mass (AK8) to check that the mass is similar. Simulation and emulation checked to match up well. Emulator and firmware match validated by GitLab CI pipelines in CMS-cactus repository and via running tests locally.

Commits squashed into one for the PR, below are all commit messages:

  • Adding another commit to squash ahead of PR
  • Squashing 38 previous commits relating to jet mass ahead of opening pull request
  • added logic for calculating jet mass and added this mass to the jet mass value, values printed to screen to ensure they are being set but currently mass not present in ntuples - default value of 0 present
  • changes for calculating jet mass in SW imp
  • Added code to use external seeds for SW implementation
  • removed printing for debug info
  • modified SC jet emulator header file to support jet mass inside l1ct jet type, then changed jet producer plugin to fill the EDM jet with this mass and also changed jet emulator src code makeJet_HW function so it calculates something, though its not correctly the jet mass
  • added mass calculation to emulator following same method as firmware imp, but without LUTs
  • pt_t doesnt have good enough precision for squared values - changed to use floats for now
  • converted eta/phi to from global to relative for jet mass calculation
  • changed emulator imp to use fixed types which give same precision as float with as few bits as possible
  • changed code to use LUTs as implemented in firmware instead of using cpp math functions
  • added code to sort and truncate constituents before passing to jet mass function, uses identical types to firmware
  • introduced preprocessing steps to jet mass function to replicate the format that constituents are received as in firmware
  • Fix eta/phi fiducial check for charged PUPPI candidates
  • Replace the isFiducial(hwEta, hwPhi) call for charged PUPPI candidates to use hwVtxEta and hwVtxPhi instead of hwEta and hwPhi.
  • modified datatypes and methods to handle jet mass
  • Use seed passed in to makeJet_HW as starting point for jet axis.
  • fixes after rebase
  • Cleaning up code and synchronising with p2l1pfp CMSSW fork
  • restored L1CaloTrigger package
  • added SC8 sim jets to the emulator chain
  • fixed a bug with calculating sim jet mass
  • cleaned up how LUTs are produced and synchronised with how it is done in firmware
  • removed old commented out code
  • added floatMass method to gt namespace
  • code-format and code-checks stylistic modifications
  • Fix handling of phi wrap around.
  • changed gt jet equality operator to also check mass
  • populate edmJet using GT jet mass
  • changes for testing using mass2
  • Put jet mass on second jet word. Add helper function for unpacking two-word jets.
  • made changes to use second word to store jet mass squared, instead of first word for jet mass
  • just code-checks and code-formats changes
  • store unsorted parts not truncated, sorted sparse parts as causes segfault
  • trying to fix seg fault
  • increasing bit width to allow for second word in l1ct::jets
  • fixed bug with LUTs due to compiler dependent rounding vs truncation order
  • Set mass to 17 bits and replace b tag score so that the CT jet is 64 bits.
  • code-checks and code-format
  • added sc8 corrected just to python config
  • Define separate GT Jet format for wide cone jets.
  • removed old commented out code

Adding another commit to squash ahead of PR

Squashing 38 previous commits relating to jet mass ahead of opening pull request

added logic for calculating jet mass and added this mass to the jet mass value, values printed to screen to ensure they are being set but currently mass not present in ntuples - default value of 0 present

changes for calculating jet mass in SW imp

Added code to use external seeds for SW implementation

removed printing for debug info

modified SC jet emulator header file to support jet mass inside l1ct jet type, then changed jet producer plugin to fill the EDM jet with this mass and also changed jet emulator src code makeJet_HW function so it calculates something, though its not correctly the jet mass

added mass calculation to emulator following same method as firmware imp, but without LUTs

pt_t doesnt have good enough precision for squared values - changed to use floats for now

converted eta/phi to from global to relative for jet mass calculation

changed emulator imp to use fixed types which give same precision as float with as few bits as possible

changed code to use LUTs as implemented in firmware instead of using cpp math functions

added code to sort and truncate constituents before passing to jet mass function, uses identical types to firmware

introduced preprocessing steps to jet mass function to replicate the format that constituents are received as in firmware

Fix eta/phi fiducial check for charged PUPPI candidates

Replace the isFiducial(hwEta, hwPhi) call for charged PUPPI candidates to use hwVtxEta and hwVtxPhi instead of hwEta and hwPhi.

modified datatypes and methods to handle jet mass

Use seed passed in to makeJet_HW as starting point for jet axis.

fixes after rebase

Cleaning up code and synchronising with p2l1pfp CMSSW fork

restored L1CaloTrigger package

added SC8 sim jets to the emulator chain

fixed a bug with calculating sim jet mass

cleaned up how LUTs are produced and synchronised with how it is done in firmware

removed old commented out code

added floatMass method to gt namespace

code-format and code-checks stylistic modifications

Fix handling of phi wrap around.

changed gt jet equality operator to also check mass

populate edmJet using GT jet mass

changes for testing using mass2

Put jet mass on second jet word.  Add helper function for unpacking two-word jets.

made changes to use second word to store jet mass squared, instead of first word for jet mass

just code-checks and code-formats changes

store unsorted parts not truncated, sorted sparse parts as causes segfault

trying to fix seg fault

increasing bit width to allow for second word in l1ct::jets

fixed bug with LUTs due to compiler dependent rounding vs truncation order

Set mass to 17 bits and replace b tag score so that the CT jet is 64 bits.

code-checks and code-format

added sc8 corrected just to python config

Define separate GT Jet format for wide cone jets.

removed old commented out code
@cmsbuild cmsbuild changed the base branch from CMSSW_15_1_X to master April 4, 2025 09:32
@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

@lrobertshaw, CMSSW_15_1_X branch is closed for direct updates. cms-bot is going to move this PR to master branch.
In future, please use cmssw master branch to submit your changes.

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47792/44372

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47792/44373

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

A new Pull Request was created by @lrobertshaw for master.

It involves the following packages:

  • DataFormats/L1TParticleFlow (l1, upgrade)
  • L1Trigger/Configuration (l1)
  • L1Trigger/Phase2L1ParticleFlow (l1, upgrade)

@BenjaminRS, @Moanwar, @cmsbuild, @quinnanm, @srimanob, @subirsarkar can you please review it and eventually sign? Thanks.
@Martin-Grunewald, @missirol, @mmusich, @rovere this is something you requested to watch as well.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.

cms-bot commands are listed here

@BenjaminRS
Copy link
Contributor

test parameters:

  • workflow = 29634.78
  • relvals_opt = --what cleanedupgrade,standard,highstats,pileup,generator,extendedgen,production,identity,ged,machine,premix,nano,gpu,2017,2026

@BenjaminRS
Copy link
Contributor

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

-1

Failed Tests: RelVals
Size: This PR adds an extra 52KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-56a96b/45385/summary.html
COMMIT: f224be0
CMSSW: CMSSW_15_1_X_2025-04-03-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/47792/45385/install.sh to create a dev area with all the needed externals and cmssw changes.

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

Pull request #47792 was updated. @BenjaminRS, @Moanwar, @cmsbuild, @quinnanm, @srimanob, @subirsarkar can you please check and sign again.

@BenjaminRS
Copy link
Contributor

BenjaminRS commented Apr 4, 2025

please test

Copy link
Contributor

@thesps thesps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few small comments, this mostly looks good to me

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 4, 2025

+1

Size: This PR adds an extra 16KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-56a96b/45387/summary.html
COMMIT: 9db1d48
CMSSW: CMSSW_15_1_X_2025-04-04-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/47792/45387/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 8, 2025

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47792/44414

Code check has found code style and quality issues which could be resolved by applying following patch(s)

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 8, 2025

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-47792/44415

@cmsbuild
Copy link
Contributor

cmsbuild commented Apr 8, 2025

Pull request #47792 was updated. @BenjaminRS, @Moanwar, @cmsbuild, @quinnanm, @srimanob, @subirsarkar can you please check and sign again.

Copy link
Contributor

@BenjaminRS BenjaminRS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR: I have a few comments which I have added to the relevant lines

b_tag_score_t hwBtagScore;
// b_tag_score_t hwBtagScore;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really remove the btag score now from the jets? If so then you can remove the commented out lines here and throughout

Comment on lines -151 to +176
#endif
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to have a empty line at the end of file

@@ -1,6 +1,8 @@
#ifndef L1Trigger_Phase2L1ParticleFlow_L1SeedConePFJetEmulator_h
#define L1Trigger_Phase2L1ParticleFlow_L1SeedConePFJetEmulator_h

#define NCONSTITSFW 32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here as to what this is please? (I assume it is the maximum number of constituents?)

@@ -136,23 +158,28 @@ l1t::PFJet L1SeedConePFJetProducer::makeJet_SW(const std::vector<edm::Ptr<l1t::P
return jet;
}

// std::vector<l1t::PFJet>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

@@ -229,4 +265,4 @@ void L1SeedConePFJetProducer::fillDescriptions(edm::ConfigurationDescriptions& d
descriptions.addWithDefaultLabel(desc);
}

DEFINE_FWK_MODULE(L1SeedConePFJetProducer);
DEFINE_FWK_MODULE(L1SeedConePFJetProducer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add empty line at end of file

L1SCJetEmu emulator;
edm::EDGetTokenT<std::vector<l1t::PFCandidate>> l1PFToken;
l1tpf::corrector corrector;

std::vector<l1t::PFJet> processEvent_SW(std::vector<edm::Ptr<l1t::PFCandidate>>& parts) const;
std::vector<l1t::PFJet> processEvent_SW(std::vector<edm::Ptr<l1t::PFCandidate>>& work) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be parts in order to be consistent with

l1t::PFJet makeJet_SW(const std::vector<edm::Ptr<l1t::PFCandidate>>& parts,
and
l1t::PFJet L1SeedConePFJetProducer::makeJet_SW(const std::vector<edm::Ptr<l1t::PFCandidate>>& parts,

@@ -110,15 +180,20 @@ std::vector<L1SCJetEmu::Jet> L1SCJetEmu::emulateEvent(std::vector<Particle>& par
});
if (debug_) {
dbgCout() << "Seed: " << seed.hwPt << ", " << seed.hwEta << ", " << seed.hwPhi << std::endl;
std::cout << "N particles : " << particlesInCone.size() << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be dbgCout() instead of std::cout?

work.end());
}
return jets;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add empty line at end of file

l1t::PFCandidate seed = *parts.at(0);
l1t::PFJet L1SeedConePFJetProducer::makeJet_SW(const std::vector<edm::Ptr<l1t::PFCandidate>>& parts,
const edm::Ptr<l1t::PFCandidate>& seed) const {
// l1t::PFCandidate seed = *parts.at(0);
Copy link
Contributor

@quinnanm quinnanm Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this comment be deleted? (L104)

unsigned nJets;
bool HW;
bool debug;
bool doCorrections;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it necessary to get rid of the consts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants