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

Refactor tau cluster variable computation #24382

Merged

Conversation

mbluj
Copy link
Contributor

@mbluj mbluj commented Aug 24, 2018

Refactor tau cluster variable computation: put MVA calculation for pat::Taus into non-class method.

Description from developer (Jan Steggemann @steggema):
With the MVA calculation a non-class method, it can directly be used from FWlite so that the tau MVA isolation can also be evaluated from FWlite. Code to do this will be merged separately via Heppy. This is meant to be a preceding PR that factors out code that affects Taus, and in particular code run in the Tau RECO sequence. No changes of any tau reco quantities are expected.

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

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

It involves the following packages:

RecoTauTag/RecoTau

@perrotta, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks.
@davidlange6, @slava77, @fabiocos you are the release manager for this.

cms-bot commands are listed here

@perrotta
Copy link
Contributor

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Aug 24, 2018

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/30036/console Started: 2018/08/24 13:05

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

Comparison job queued.

@cmsbuild
Copy link
Contributor

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-24382/30036/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 31
  • DQMHistoTests: Total histograms compared: 2987459
  • DQMHistoTests: Total failures: 2
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2987267
  • DQMHistoTests: Total skipped: 190
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 30 files compared)
  • Checked 129 log files, 14 edm output root files, 31 DQM output files

}
return n_photons;
}
namespace reco { namespace tau { namespace mva {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, this is a new namespace.
Is it really needed and are the methods MVA-specific?
We have reco::tau:disc and reco::tau::helpers, which could be used instead.
IMHO, reco::tau is enough.

}
namespace reco { namespace tau { namespace mva {
/// return chi2 of the leading track ==> deprecated? <==
float tau_leadTrackChi2(const reco::PFTau& tau);
Copy link
Contributor

Choose a reason for hiding this comment

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

is the tau_ prefix needed for the methods? everything is in the tau namespace. So, perhaps no prefix is OK.
I see that some of the methods do not have a tau_ prefix.

}
return 0.;
}
float pt_weighted_dx(const pat::Tau& tau, int mode, int var, int decaymode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

the implementation is identical to pt_weighted_dx(const PFTau& tau. It looks like a good candidate for a template

Copy link
Contributor

Choose a reason for hiding this comment

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

here is one option
2169a12

is this really unreadable?
I think that the danger of missing an update in either of the two duplicated places is worse than slight increase in complexity.

/// return sum of pt weighted values of dr relative to tau candidate for all pf photon candidates,
/// which are associated to signal
float tau_pt_weighted_dr_signal(const reco::PFTau& tau, int dm);
float tau_pt_weighted_dr_signal(const pat::Tau& tau, int dm);
Copy link
Contributor

Choose a reason for hiding this comment

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

these could stay inlined (perhaps with an explicit inline qualifier).
Same for tau_pt_weighted_deta_strip, tau_pt_weighted_dphi_strip, and tau_pt_weighted_dr_iso.

}
};
enum { kOldDMwoLT, kOldDMwLT, kNewDMwoLT, kNewDMwLT, kDBoldDMwLT, kDBnewDMwLT, kPWoldDMwLT, kPWnewDMwLT, kDBoldDMwLTwGJ, kDBnewDMwLTwGJ };
bool fillMVAInputs(float* mvaInput, const pat::Tau& tau, int mvaOpt, const std::string nameCharged, const std::string nameNeutral, const std::string namePu, const std::string nameOutside, const std::string nameFootprint);
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a newline for readability.
const std::string&


// --- The following 5 variables differ slightly between AOD & MiniAOD
// because they are recomputed using packedCandidates saved in the tau
float nPhoton = (float)reco::tau::mva::tau_n_photons_total(tau);
Copy link
Contributor

Choose a reason for hiding this comment

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

the extra cast on the rhs is not needed

return false;
}

}}} // namespaces
Copy link
Contributor

Choose a reason for hiding this comment

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

please terminate the file with a newline

@@ -161,7 +161,6 @@ class PFRecoTauDiscriminationByMVAIsolationRun2 : public PFTauDiscriminationProd
std::unique_ptr<PFTauDiscriminator> category_output_;
Copy link
Contributor

Choose a reason for hiding this comment

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

the enums defined on L141 are now somewhat redundant with what's defined in the included PFRecoTauClusterVariables.h.
There is no obvious conflict here due to still fully localized use of these values in mvaOpt_.
So, cleanup is not required, but could still be better.

float HcalEnInSignalPFCands = 0;
typedef std::vector <reco::PFCandidatePtr>::iterator constituents_iterator;
for(constituents_iterator it=constsignal.begin(); it != constsignal.end(); ++it) {
reco::PFCandidatePtr & icand = *it;
Copy link
Contributor

Choose a reason for hiding this comment

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

some modernization of the code can be done, since we have an opportunity with this refactoring:

  • range for loops for (auto const& icand : constsignal)

Making the local variable names conform to the CMS style of starting with lower case for locals and data members/methods would be nice as well.

return n_photons;
}

bool fillMVAInputs(float* mvaInput, const pat::Tau& tau, int mvaOpt, const std::string nameCharged, const std::string nameNeutral, const std::string namePu, const std::string nameOutside, const std::string nameFootprint)
Copy link
Contributor

Choose a reason for hiding this comment

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

should I take this replacement of the implementation of PATTauDiscriminationByMVAIsolationRun2 as a move to the new standard single supported MVA?
If the other variants are expected to remain supported, then a simple fillMVAInputs method name here is not enough. In this case please make a distinction with some specification in the function name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are a bit confused by the comment: PATTauDiscriminationByMVAIsolationRun2 plugin is the single implementation of MVA-based isolation tau-Ids with the fillMVAInputs method having itself all the different MVAIso variants included. Could you please clarify what you exactly mean?

Regardless, we can rename the method to fillIsoMVARun2Inputs (Iso and Run2 added) to better distinguish from other possible MVA-based tau-ids, e.g. anti electron ones, which could in principle use the cluster variables.

Copy link
Contributor

Choose a reason for hiding this comment

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

currently there are different tau MVAs in the release. So, it seems unnatural to single out one and fill it with a generically named function.
To me this either means that this PR is the first step to eliminate/subsume other MVA filling implementations or the method is named improperly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'm still confused - the method as implemented works for all tau MVAs by means of the "mvaOpt" argument.

Concerning dropping the possibility to recalculate previous versions of the MVA from the tau code, I'm in principle in favour of this since it will make the code simpler, but it's not the focus of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, thank you for clarification.

Just for notice, there are the following MVA-based tau-Ids and related plugins:

  • MVA-based isolation:
    • PFRecoTauDiscriminationByMVAIsolation2.cc for Run-1
    • PFRecoTauDiscriminationByMVAIsolationRun2.cc for Run-2 with its counterpart for pat::Taus called PATTauDiscriminationByMVAIsolationRun2.cc
  • e->tauh fakes veto:
    • PFRecoTauDiscriminationAgainstElectronMVA5.cc for Run-1
    • PFRecoTauDiscriminationAgainstElectronMVA6.cc for Run-2 with its counterpart for pat::Taus called PATTauDiscriminationAgainstElectronMVA6.cc
  • mu->tauh fakes veto:
    • PFRecoTauDiscriminationAgainstMuonMVA.cc

The old Run-1 plugins can be removed at some point, but it is beyond a scope of this PR.

To avoid confusion we will also rename the method to fillIsoMVARun2Inputs to indicate that it is used for this particular MVA-based tau-Id.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2018

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2018

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2018

Pull request #24382 was updated. @perrotta, @cmsbuild, @slava77 can you please check and sign again.

@slava77
Copy link
Contributor

slava77 commented Sep 3, 2018

@cmsbuild please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2018

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/30226/console Started: 2018/09/03 17:55

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2018

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 3, 2018

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-24382/30226/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 32
  • DQMHistoTests: Total histograms compared: 3143879
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3143681
  • DQMHistoTests: Total skipped: 197
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 31 files compared)
  • Checked 133 log files, 14 edm output root files, 32 DQM output files

@slava77
Copy link
Contributor

slava77 commented Sep 4, 2018

+1

for #24382 79da684

  • code changes are in line with the PR description and the follow up review.
  • jenkins tests pass and comparisons with the baseline show no differences

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 4, 2018

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar, @fabiocos (and backports should be raised in the release meeting by the corresponding L2)

@fabiocos
Copy link
Contributor

fabiocos commented Sep 6, 2018

+1

@cmsbuild cmsbuild merged commit e123fa2 into cms-sw:master Sep 6, 2018
@mbluj mbluj deleted the CMSSW_10_3_X_tau_pog_TauClusterVarRefactor branch October 10, 2023 10:05
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

6 participants