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

deprecate integer types for L1T and HLT prescales in HLTConfigData and its clients #39220

Merged
merged 1 commit into from Sep 20, 2022

Conversation

missirol
Copy link
Contributor

@missirol missirol commented Aug 26, 2022

PR description:

#32741 introduced the use fractional L1T prescales [1], as well as support for them in HLT utilities [2].

[1] Here, "fractional" means a number corresponding to N / 100, where N is non-negative integer.
[2] This mainly concerns HLTConfigProvider and HLTPrescaleProvider, which are used by many modules downstream of HLT to access the values of both L1T and HLT prescales.

On the other hand, the default template arguments of some methods in [2] still lead to using integers for both L1T and HLT prescales. This can lead to silent truncation of non-integer L1T prescales in client code (in principle, this would also apply to HLT prescales, but non-integer HLT prescales have never been used, to my knowledge; conversely, fractional L1T prescales have been used to take data since a while now).

This PR (1) deprecates the use of types other than double and FractionalPrescale for accessing L1T and HLT prescales via HLTConfigProvider and HLTPrescaleProvider, and (2) updates client code in CMSSW. Concerning user code outside CMSSW, (1) will prevent it from compiling if it tries to access L1T or HLT prescales with deprecated types (the solution is to specify the appropriate types as template arguments).

Edit: this PR was originally dropping support for integers in HLT utilities only for L1T prescales, and this was later extended to HLT prescales as well, with the idea of 'breaking' user code only once for both, in view of the possibility that HLT might use non-integer prescales in the future. See for further details.

This PR is alternative to #39094.

Kindly asking @Sam-Harper and @fwyzard to review.

Note : this PR only takes care of code accessing L1T prescales via HLTPrescaleProvider. Clients accessing L1T prescales in other ways [a,b,c] are not affected (for better or worse) by this PR.

[a] code accessing L1T prescales directly via L1GtUtils (Stage-1 L1T, pre-2016; only supporting int for L1T prescale values)
[b] code accessing L1T prescales directly via L1TGlobalUtil (Stage-1 L1T, 2016-now; only supporting double for L1T prescale values since #32741)
[c] code accessing prescales via PackedTriggerPrescales (e.g. int ps = (PackedTriggerPrescales).getPrescaleForName will continue to silently truncate values).

PR validation:

scram build runtests and runTheMatrix.py -l 11634.0 passed.

If this PR is a backport, please specify the original PR and why you need to backport that PR. If this PR will be backported, please specify to which release cycle the backport is meant for:

Not sure about backports. In my understanding, client code touched by this PR is accessing L1T prescales in 2022 Data incorrectly, truncating those values to integers, so there might be reasons to backport this to 12_5_X, or even 12_4_X. Aside from DQM (and code outside CMSSW), the main downstream effect might be on MINIAOD, because of the update in PATTriggerProducer and DataFormats/PatCandidates.

@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-39220/31842

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @missirol (Marino Missiroli) for master.

It involves the following packages:

  • Calibration/HcalCalibAlgos (alca)
  • Calibration/IsolatedParticles (alca)
  • CommonTools/TriggerUtils (hlt, l1)
  • DQMOffline/Trigger (dqm)
  • DataFormats/PatCandidates (reconstruction)
  • HLTrigger/HLTcore (hlt)
  • PhysicsTools/Heppy (analysis)
  • PhysicsTools/PatAlgos (reconstruction)

@malbouis, @tvami, @yuanchao, @pmandrik, @rekovic, @epalencia, @mandrenguyen, @emanueleusai, @ahmad3213, @saumyaphor4252, @cmsbuild, @missirol, @ChrisMisan, @jfernan2, @clacaputo, @Martin-Grunewald, @jpata, @francescobrivio, @micsucmed, @cecilecaillol, @rvenditti can you please review it and eventually sign? Thanks.
@rappoccio, @gouskos, @hatakeyamak, @emilbols, @Martin-Grunewald, @bsunanda, @mbluj, @ahinzmann, @demuller, @seemasharmafnal, @mmarionncern, @silviodonato, @jhgoh, @jdolen, @HuguesBrun, @azotz, @cericeci, @fwyzard, @trocino, @rociovilar, @sscruz, @rovere, @jdamgov, @nhanvtran, @gkasieczka, @tocheng, @schoef, @mmusich, @mtosi, @andrzejnovak, @AlexDeMoor, @Fedespring, @JyothsnaKomaragiri, @gpetruc, @mariadalfonso this is something you requested to watch as well.
@perrotta, @dpiparo, @qliphy, @rappoccio you are the release manager for this.

cms-bot commands are listed here

@missirol
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-8aa7bf/27131/summary.html
COMMIT: 165b65b
CMSSW: CMSSW_12_5_X_2022-08-25-2300/el8_amd64_gcc10
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/39220/27131/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 2 differences found in the comparisons
  • DQMHistoTests: Total files compared: 51
  • DQMHistoTests: Total histograms compared: 3695708
  • DQMHistoTests: Total failures: 19
  • DQMHistoTests: Total nulls: 1
  • DQMHistoTests: Total successes: 3695666
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.004 KiB( 50 files compared)
  • DQMHistoSizes: changed ( 312.0 ): 0.004 KiB MessageLogger/Warnings
  • Checked 212 log files, 49 edm output root files, 51 DQM output files
  • TriggerResults: no differences found

@ChrisMisan
Copy link
Contributor

test parameters:

  • workflows=11634.0

@ChrisMisan
Copy link
Contributor

please test workflow 11634.0

@missirol
Copy link
Contributor Author

please abort

Wf 11634.0 runs by default in PR tests, and already passed in the first round of tests (see above).

@missirol
Copy link
Contributor Author

test parameters:

Copy link
Contributor

@ChrisMisan ChrisMisan left a comment

Choose a reason for hiding this comment

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

@missirol I think it should be considered to implement a separate object for constructions like pair of vector of pairs of... It'd make the code far more clear and it'd also tackle the issue of abused auto statement.

@@ -199,7 +199,7 @@ class IsoTrig : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::Share
math::XYZPoint leadPV_;

std::map<unsigned int, unsigned int> trigList_;
std::map<unsigned int, const std::pair<int, int>> trigPreList_;
std::map<unsigned int, const std::pair<double, int>> trigPreList_;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be unordered_map

std::map<unsigned int, unsigned int>::iterator itr;
std::map<unsigned int, const std::pair<int, int>>::iterator itrPre;
std::map<unsigned int, const std::pair<double, int>>::iterator itrPre;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be unordered_map

@@ -788,13 +788,12 @@ void PATTriggerProducer::produce(Event& iEvent, const EventSetup& iSetup) {
const edm::TriggerNames& names = iEvent.triggerNames(*handleTriggerResults);
//std::cout << "Run " << iEvent.id().run() << ", LS " << iEvent.id().luminosityBlock() << ": pset " << set << 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.

Is this needed?

auto l1HLTPSFrac = hltPSProvider_.prescaleValues<FractionalPrescale>(iEvent, iSetup, hltPath_);
auto l1HLTPSDoubleFrac = hltPSProvider_.prescaleValues<double, FractionalPrescale>(iEvent, iSetup, hltPath_);

auto l1HLTDetailPSDouble = hltPSProvider_.prescaleValuesInDetail<double>(iEvent, iSetup, hltPath_);
auto l1HLTDetailPSInt = hltPSProvider_.prescaleValuesInDetail<int>(iEvent, iSetup, hltPath_);
auto l1HLTDetailPSInt = hltPSProvider_.prescaleValuesInDetail<double, int>(iEvent, iSetup, hltPath_);
auto l1HLTDetailPSFrac = hltPSProvider_.prescaleValuesInDetail<FractionalPrescale>(iEvent, iSetup, hltPath_);

std::cout << "---------Begin Event--------" << 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.

Please consider changing couts to logging system.

Copy link
Contributor

Choose a reason for hiding this comment

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

so I disagree with this comment and I will explain my reasoning.

The HLTPrescaleExample module is clearly a test/example module which will never ever run in normal CMSSW jobs as it doesnt do anything.

Its purpose is to help users hence the simplicity.

Even though I have 15 years on CMSSW, I still find configuring the message logger properly a bit of trial and error. Perhaps this is just me but perhaps not. But I figure my target audience, a new grad student has no hope.

If this was to run other than test/example, I would fully agree with changing it but given its purpose is a simple example to try and quickly help users who dont want to waste time dealing with the message logger, I would have left it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can revert this change. Regarding the cfg file, what would you prefer? (keep its update or not, use it or not as a unit test)

Copy link
Contributor

Choose a reason for hiding this comment

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

ah yes you are now using it as a unit test which means it probably should be message logger. Anyways thought I would explain why it was done with couts in the first place.

The issue that it would be very nice that this example prints out some output so we would need to configure the example properly configure the message logger.

I envisioned the user running it as a test and then having the prescales dump to screen which I think is usually useful for learning and getting a feel if its working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. Indeed, I didn't touch it initially, then I updated it such that cmsRun hltPrescaleExample_cfg.py (which is all the unit test is) gives the full printout, a la cout. I leave it as is, unless you let me know otherwise.

@missirol
Copy link
Contributor Author

please test

Refreshing the tests before signing for HLT.

@cms-sw/xpog-l2 , do you have any comments on this PR?

@vlimant
Copy link
Contributor

vlimant commented Sep 19, 2022

integration test under consideration https://gitlab.cern.ch/cms-nanoAOD/nanoAOD-integration/-/issues/190

@cmsbuild
Copy link
Contributor

+1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-8aa7bf/27642/summary.html
COMMIT: 9d3f0c1
CMSSW: CMSSW_12_6_X_2022-09-18-2300/el8_amd64_gcc10
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/39220/27642/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • No significant changes to the logs found
  • Reco comparison results: 1 differences found in the comparisons
  • DQMHistoTests: Total files compared: 51
  • DQMHistoTests: Total histograms compared: 3621956
  • DQMHistoTests: Total failures: 5
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3621929
  • DQMHistoTests: Total skipped: 22
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 50 files compared)
  • Checked 212 log files, 49 edm output root files, 51 DQM output files
  • TriggerResults: no differences found

@missirol
Copy link
Contributor Author

+hlt

@vlimant
Copy link
Contributor

vlimant commented Sep 19, 2022

+1

@mandrenguyen
Copy link
Contributor

Hi @missirol
I understand fractional prescales are planned for the ion running. Can you backport to 12_5_X please?
FYI @FHead @denerslemos

@tvami
Copy link
Contributor

tvami commented Sep 19, 2022

@tvami
Copy link
Contributor

tvami commented Sep 19, 2022

@cms-sw/orp-l2 I understand analysis signature does not exists, so this is essentially fully signed

@missirol
Copy link
Contributor Author

missirol commented Sep 19, 2022

I understand fractional prescales are planned for the ion running. Can you backport to 12_5_X please?

@mandrenguyen

A last-minute backport of a big PR is exactly what I was trying to avoid, thus the comments in #39220 (comment) and #39220 (comment), specifically

A bi-product of this PR is a bugfix to MINIAOD, which has so far mistakenly saved L1T prescales as integers, even though in Run 3 L1T prescales can actually have non-integer values. This might call for a full, or partial, backport of this PR to earlier release cycles, but that is the left to the judgement of MINIAOD experts.

Later today, I will have to check if a backport is trivial, or requires more work, assuming ORP is okay with it.

@missirol missirol changed the title deprecate integer types for L1T and HLT prescales in HLTConfigProvider and its clients deprecate integer types for L1T and HLT prescales in HLTConfigData and its clients Sep 19, 2022
@missirol
Copy link
Contributor Author

type bugfix

A bi-product of this PR is a bugfix to MINIAOD in the handling of L1T prescales.

Based on #39220 (comment), a backport to 12_5_X is opened in #39446.

Copy link
Contributor

@perrotta perrotta left a comment

Choose a reason for hiding this comment

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

All comments are basically the same: as you moved prescales to non-integer tyoes, did you check that rounding approximations did not spoil the effect of the checks for equality to exaclty "1"?

@@ -235,11 +235,8 @@ void EwkMuLumiMonitorDQM::analyze(const Event& ev, const EventSetup&) {
bool prescaled = false;
const unsigned int prescaleSize = hltConfigProvider_.prescaleSize();
for (unsigned int ps = 0; ps < prescaleSize; ps++) {
const unsigned int prescaleValue = hltConfigProvider_.prescaleValue(ps, trig);
if (prescaleValue != 1)
if (hltConfigProvider_.prescaleValue<double>(ps, trig) != 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't you affected by possible rounding effects of the double quantity here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const std::pair<int, int> prescales(hltPrescaleProvider_.prescaleValues(iEvent, iSetup, *iHLT));
if (prescales.first * prescales.second == 1)
auto const prescales = hltPrescaleProvider_.prescaleValues<double>(iEvent, iSetup, *iHLT);
if (prescales.first == 1 and prescales.second == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ok with rounding effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #39220 (comment). Here, I changed the check to "HLT==1 and L1T==1", instead of doing a floating-point operation ("HLT * L1T").

@@ -139,7 +139,7 @@ void TriggerMatchProducer<object>::produce(edm::Event& event, const edm::EventSe

if (TString(*iHLT).Contains(TRegexp(hltTag_))) {
triggerInMenu[*iHLT] = true;
if (hltPrescaleProvider_.prescaleValue(event, eventSetup, *iHLT) == 1)
if (hltPrescaleProvider_.prescaleValue<double>(event, eventSetup, *iHLT) == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ok with rounding effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To the best of my knowledge, yes, in short because that double is not the result of floating-point operation.

This call goes back to HLTConfigData::prescaleValue<T>, where we have the implicit conversion of HLTPrescaleTable::prescale (unsigned int) into T (which must be double or FractionalPrescale). So, we are reading an int as a double, not calculating this double with a floating-point operation (in that case, the complication of rounding effects would apply, afaiu).

The unit test in HLTrigger/HLTcore/test/test_catch2_HLTConfigData.cc was extended exactly to gain some confidence in this respect, comparing double, or FractionalPrescale, to unsigned int for the values of a dummy PS table.

++iSeed) {
int l1 = (hltPrescale_->prescaleValuesInDetail(iEvent, iSetup, hltpath1)).first.at(iSeed).second;
for (size_t iSeed = 0; iSeed < prescales_num.first.size(); ++iSeed) {
auto l1 = prescales_num.first.at(iSeed).second;
if (l1 < 1)
continue;
if (l1 == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ok with rounding effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -108,7 +108,7 @@ void TriggerCandProducer<object>::produce(edm::Event& event, const edm::EventSet
for (std::vector<edm::InputTag>::const_iterator iMyHLT = hltTags_.begin(); iMyHLT != hltTags_.end(); ++iMyHLT) {
if ((*iMyHLT).label() == *iHLT) {
triggerInMenu[(*iMyHLT).label()] = true;
if (hltPrescaleProvider_.prescaleValue(event, eventSetup, *iHLT) == 1)
if (hltPrescaleProvider_.prescaleValue<double>(event, eventSetup, *iHLT) == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ok with rounding effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -411,7 +411,7 @@ void EopElecTreeWriter::analyze(const edm::Event& iEvent, const edm::EventSetup&

const unsigned int prescaleSize = hltConfig_.prescaleSize();
for (unsigned int ps = 0; ps < prescaleSize; ps++) {
const unsigned int prescaleValue = hltConfig_.prescaleValue(ps, triggerName);
auto const prescaleValue = hltConfig_.prescaleValue<double>(ps, triggerName);
if (prescaleValue != 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ok with rounding effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -45,33 +42,14 @@ namespace heppy {
}
bool outcome = true;
for (std::vector<unsigned int>::const_iterator it = indices_.begin(), ed = indices_.end(); it != ed; ++it) {
if (result.getPrescaleForIndex(*it) != 1) {
if (result.getPrescaleForIndex<double>(*it) != 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ok with rounding effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -558,7 +558,7 @@ void PATTriggerProducer::produce(Event& iEvent, const EventSetup& iSetup) {
if (hltConfig.prescaleSize() > 0) {
if (hltPrescaleProvider_.prescaleSet(iEvent, iSetup) != -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ok with rounding effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prescaleSet is the index of the PS column, and it remains an int, so no issue.

@perrotta
Copy link
Contributor

+1

@perrotta
Copy link
Contributor

merge

@cmsbuild cmsbuild merged commit 44a3367 into cms-sw:master Sep 20, 2022
@missirol missirol deleted the devel_nonIntTriggerPrescales branch September 20, 2022 14:13
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.

None yet