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
Refactor tau cluster variable computation #24382
Conversation
…t::Taus into non-class method
Refactor tau cluster variable computation
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-24382/6151 |
please test |
The tests are being triggered in jenkins. |
+1 The following merge commits were also included on top of IB + this PR after doing git cms-merge-topic: |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
} | ||
return n_photons; | ||
} | ||
namespace reco { namespace tau { namespace mva { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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_; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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-1PFRecoTauDiscriminationByMVAIsolationRun2.cc
for Run-2 with its counterpart forpat::Taus
calledPATTauDiscriminationByMVAIsolationRun2.cc
- e->tauh fakes veto:
PFRecoTauDiscriminationAgainstElectronMVA5.cc
for Run-1PFRecoTauDiscriminationAgainstElectronMVA6.cc
for Run-2 with its counterpart forpat::Taus
calledPATTauDiscriminationAgainstElectronMVA6.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.
Address code review comments, including modernisation of code
The code-checks are being triggered in jenkins. |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-24382/6279 |
@cmsbuild please test |
The tests are being triggered in jenkins. |
+1 The following merge commits were also included on top of IB + this PR after doing git cms-merge-topic: |
Comparison job queued. |
Comparison is ready Comparison Summary:
|
+1 for #24382 79da684
|
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) |
+1 |
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.