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

[Phase-2 L1] Incorporate object threshold scalings, ID and isolation via dictionaries into the P2GT menu #46489

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

Conversation

artlbv
Copy link
Contributor

@artlbv artlbv commented Oct 23, 2024

PR description:

The idea of this PR is to allow for a more convenient organisation and book-keeping of the P2GT emulator menu configurations. Previously threshold changes due to object changes (so-called offline-online scalings) or ID/Iso WP changes had to be changed manually in every seed. With this PR dictionaries are introduced for common ID and Isolation Working Points as well as reading of the scalings (a MenuTools output) is implemented.

This addresses #46470 and was agreed to with the P2GT developer team @HaarigerHarald and @qvyz as presented here in slide 42.

FYI @VourMa @rovere @slaurila @RobertJWard @gpetruc

PR validation:

Tested to work with the standard recipe we (and HLT) are using in 1420pre1:

cmsDriver.py l1nanoPhase2 -s L1,L1TrackTrigger,L1P2GT,USER:PhysicsTools/L1Nano/l1tPh2Nano_cff.l1tPh2NanoTask --customise PhysicsTools/L1Nano/l1tPh2Nano_cff.addFullPh2L1Nano \                 
--conditions auto:phase2_realistic_T33 \
--geometry Extended2026D110 \
--era Phase2C17I13M9 \
--eventcontent NANOAOD \
--datatier GEN-SIM-DIGI-RAW-MINIAOD \
--customise SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,Configuration/DataProcessing/Utils.addMonitoring,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110 \
--filein /store/mc/Phase2Spring24DIGIRECOMiniAOD/TT_TuneCP5_14TeV-powheg-pythia8/GEN-SIM-DIGI-RAW-MINIAOD/PU200_AllTP_140X_mcRun4_realistic_v4-v1/2560000/11d1f6f0-5f03-421e-90c7-b5815197fc85.root \
--fileout file:output_Phase2_L1T.root \
--python_filename rerunL1_cfg.py \
--inputCommands="keep *, drop l1tPFJets_*_*_*, drop l1tTrackerMuons_l1tTkMuonsGmt*_*_HLT" \
--mc \
-n 1000 --nThreads 4

A simple check was comparing the edmConfigDump outputs pre and post PR as there the actual thresholds, ID and Isolation values are expanded into plaintext. The results seem reasonable.
Note that also the IDs used for TkMuons have changed since since the AR24 there are now 4 WPs (compared to 1 before).

We will check the agreement with the MenuTools once we get more stats processed (on small stats the agreement is rather good), but I would like to start the PR and the reviewing process, eventually soliciting feedback from our SW experts on these changes.

Note that the code function names in the menuConstants.py could be cleaned up etc, but the mechanism should the final one.

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 23, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

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

It involves the following packages:

  • L1Trigger/Phase2L1GT (upgrade, l1)

@Moanwar, @aloeliger, @cmsbuild, @epalencia, @srimanob, @subirsarkar can you please review it and eventually sign? Thanks.
@Martin-Grunewald, @missirol, @mmusich 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

@cmsbuild
Copy link
Contributor

@rovere
Copy link
Contributor

rovere commented Oct 24, 2024

The performance aligns with the measurements I did privately using only the fix for the DiTau52 path: +10% speed-up and a visible reduction of events triggering HLT Tau paths.

@mmusich
Copy link
Contributor

mmusich commented Oct 24, 2024

Indeed, putting here some details for the record as the PR test results, alas, are not forever.

Timing

CMSSW_14_2_X_2024-10-23-1100 CMSSW_14_2_X_2024-10-23-1100 + this PR
Screenshot from 2024-10-24 08-44-52 Screenshot from 2024-10-24 08-44-42

baseline: 5304.3 ms/ev | this PR: 4799.6 ms/ev | speedup gain -9.51%

Trigger Results

TriggerResults: found differences in 4 / 44 workflows

e.g. for workflow 29634.0

Found 10 matching events, out of which 6 have different HLT results

      Events    Accepted      Gained        Lost       Other  Trigger
          10           6           -          -1           -  pDoublePuppiJet112_112
          10           7           -          -2           -  pDoublePuppiTau52_52
          10           4           -          -2           -  pNNPuppiTauPuppiMet_55_190
          10           4          +1           -           -  pPuppiHT450
          10           5           -          -2           -  pSinglePuppiJet230
          10           0           -           -          ~2  HLT_AK4PFPuppiJet520
          10           0           -           -          ~1  HLT_PFPuppiHT1070
          10           1           -           -          ~1  HLT_DoublePFPuppiJets128_DoublePFPuppiBTagDeepCSV_2p4
          10           2           -           -          ~1  HLT_DoublePFPuppiJets128_DoublePFPuppiBTagDeepFlavour_2p4
          10           1           -           -          ~2  HLT_DoubleMediumChargedIsoPFTauHPS40_eta2p1
          10           3           -           -          ~2  HLT_DoubleMediumDeepTauPFTauHPS35_eta2p1

@mmusich
Copy link
Contributor

mmusich commented Oct 24, 2024

type bug-fix

Comment on lines +7 to +9
scalings_fname = environ["CMSSW_BASE"] + "/src/L1Trigger/Phase2L1GT/python/scalings_v44.json"
with open(scalings_fname, 'r') as file:
scalings = json.load(file)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you are necessarily guaranteed this is always going to exist (with a partial checkout of CMSSW for example where you are not working with these directories directly).

The JSON itself should be committed as a data file as it is not directly code.

I'm not sure if there is a FileInPath solution for inside a python configuration, but maybe one of the core people know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should it be the RELEASE_BASE then instead?

On the separation to cms-data: I think that given these constants are tied to the L1 menu, it would make sense to keep them together imo. Otherwise it might be hard to disentangle if changes are due to the menu config or constant changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if there is a FileInPath solution for inside a python configuration, but maybe one of the core people know.

there is pfnInPath.

Otherwise it might be hard to disentangle if changes are due to the menu config or constant changes.

I am not sure to see the issue. Can you elaborate?
Having said that, the main draw-back of storing the configuration in cms-data is that a configuration change will require a full release as opposed to a patch-release. Having said that it's not clear to me what's the long term strategy for storing the phase-2 L1T menu, so it's hard to say if that is going to be an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mmusich do you mean using this for example?

Comment on lines +32 to +88
objectIDs = {
"L1nnPuppiTau": {
"default": {
"qual" : 225
}
},
"L1tkPhoton":{
"Iso": {
"qual": {
"barrel": 0b0010,
"endcap": 0b0100,
},
"iso": {
"barrel": 0.25,
"endcap": 0.205,
}
}
},
"L1tkElectron":{
"Iso": {
# "qual": {
# "barrel": 0b0010,
# "endcap": 0b0010,
# },
"iso": {
"barrel": 0.13,
"endcap": 0.28,
}
},
"NoIso": {
"qual": {
"barrel": 0b0010,
"endcap": 0b0010,
},
},
"NoIsoLowPt": {
"qual": {
"barrel": 0b0010,
"endcap": 0b0000,
},
}
},
"L1gmtTkMuon":{
"VLoose": {
"qual": 0b0001,
},
"Loose": {
"qual": 0b0010,
},
"Medium": {
"qual": 0b0100,
},
"Tight": {
"qual": 0b1000,
},
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are already storing menu constants in JSON, could this also be added to the JSON?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. though it would be a separate JSON, as the one with scalings is generated from the MenuTools.

@gpetruc
Copy link
Contributor

gpetruc commented Oct 29, 2024 via email

@aloeliger
Copy link
Contributor

@artlbv what is that status of this PR?

Choose a reason for hiding this comment

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

Personally I'm not a big fan of adding a new file type. Also considering that the contents of that json is a perfectly valid python dict.

Choose a reason for hiding this comment

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

@artlbv Additional remark after discussion with Hannes, could we maybe sync up the object naming convention? It's super confusing for anyone reading the menu if in one place the object is called L1TrackJet and in another the collection is referred to as CL2JetsSC4 for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. do you mean we should just save the JSON with .py as extension?
  2. I agree and was planning to remap the object names in the JSON – will push this for this PR

Choose a reason for hiding this comment

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

  1. Well you need a variable to assign the constant but other than that yes. Now, I understand that you had some automation with the json export in mind, but do you see the scales changing that often?
  2. Great!

Choose a reason for hiding this comment

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

While at it we have some documentation in: https://github.com/cms-sw/cmssw/blob/master/L1Trigger/Phase2L1GT/README.md

Could you also add some documentation about the usage of scales when writing a menu?

else:
return max(0, new_thr)

def getObjectThrs(thr, obj, id):

Choose a reason for hiding this comment

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

@artlbv We think it would be better to explicitly write out the all thresholds instead of using this function that either returns a cms.double or cms.vdouble and hides what the regions actually mean. Hence we'd prefer

regionsMinPt = cms.vdouble(off2onl(52, "L1nnPuppiTau", "default", "barrel"), off2onl(52, "L1nnPuppiTau", "default", "endcap"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is too long and redundant imo (what if the off. threshold is mistyped in one of the regions?).
a compromise could be to list the regions as another argument, i.e.:

regionsMinPt  = getObjectThrs(17, "L1nnPuppiTau", "default", ["barrel","endcap"])

how about this?

Choose a reason for hiding this comment

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

Looks good to me as well, since one can at least guess that this might return a cms.vdouble.

@artlbv
Copy link
Contributor Author

artlbv commented Nov 19, 2024

@artlbv what is that status of this PR?

there were some more pending checks before finishing this PR (+feedback from the P2GT that just came): see this JIRA ticket
– check discrepancies with MenuTools when both use TkPhotons (no standalone EG)
– decide what to do with the dynamic ID of the low pt Muons

I'm not sure how urgent these checks are wrt to merging this PR into master tbh.
@rovere @VourMa do you prefer the PR to go in as is or rather to have the above discrepancies sorted out before?

@HaarigerHarald
Copy link

HaarigerHarald commented Nov 19, 2024

@artlbv what is that status of this PR?

there were some more pending checks before finishing this PR (+feedback from the P2GT that just came): see this JIRA ticket – check discrepancies with MenuTools when both use TkPhotons (no standalone EG) – decide what to do with the dynamic ID of the low pt Muons

I'm not sure how urgent these checks are wrt to merging this PR into master tbh. @rovere @VourMa do you prefer the PR to go in as is or rather to have the above discrepancies sorted out before?

The muon quality was already updated as part of #45606. I ran over 10000 ttbar pre and post change to ensure that both cuts are equivalent. They might have diverged since though I did not check this.

@artlbv
Copy link
Contributor Author

artlbv commented Nov 20, 2024

The muon quality was already updated as part of #45606. I ran over 10000 ttbar pre and post change to ensure that both cuts are equivalent. They might have diverged since though I did not check this.

This is another thing. The dynamic ID I refer to is something implemented in the MenuTools, but not possible in the GT.
We need a DPG decision on this @slaurila @folguera

@VourMa
Copy link
Contributor

VourMa commented Nov 20, 2024

@rovere @VourMa do you prefer the PR to go in as is or rather to have the above discrepancies sorted out before?

From my side, I think it's better to finalize this PR, as it takes care of the most important issues we have been seeing. Then, we can follow up with the remaining fixes in a separate PR, especially because I understand that, for these extra fixes, there may not be an immediate solution.

@cmsbuild
Copy link
Contributor

Milestone for this pull request has been moved to CMSSW_15_0_X. Please open a backport if it should also go in to CMSSW_14_2_X.

@cmsbuild cmsbuild modified the milestones: CMSSW_14_2_X, CMSSW_15_0_X Nov 22, 2024
@mmusich
Copy link
Contributor

mmusich commented Dec 17, 2024

From my side, I think it's better to finalize this PR, as it takes care of the most important issues we have been seeing. Then, we can follow up with the remaining fixes in a separate PR, especially because I understand that, for these extra fixes, there may not be an immediate solution.

we just got reminded that currently we can't get sound estimates on the timing increase due to new path additions (e.g. in #46924). Can someone update on the foreseen trajectory for this PR from the L1 side @artlbv @cms-sw/l1-l2 ?

@mmusich
Copy link
Contributor

mmusich commented Dec 17, 2024

@cmsbuild, please test

@cmsbuild
Copy link
Contributor

+1

Size: This PR adds an extra 12KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-d2424a/43505/summary.html
COMMIT: e2e4b6c
CMSSW: CMSSW_15_0_X_2024-12-17-1100/el8_amd64_gcc12
Additional Tests: HLT_P2_TIMING
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/46489/43505/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially removed 1 lines from the logs
  • Reco comparison results: 120 differences found in the comparisons
  • DQMHistoTests: Total files compared: 46
  • DQMHistoTests: Total histograms compared: 3510017
  • DQMHistoTests: Total failures: 373
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3509624
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 45 files compared)
  • Checked 202 log files, 172 edm output root files, 46 DQM output files
  • TriggerResults: found differences in 4 / 44 workflows

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.

8 participants