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
[10_6_X] improving performance of PuppiProducer #31290
Merged
cmsbuild
merged 2 commits into
cms-sw:CMSSW_10_6_X
from
missirol:devel_106X_puppi_speedup5
Sep 4, 2020
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
#ifndef CommonTools_PileupAlgos_PuppiCandidate | ||
#define CommonTools_PileupAlgos_PuppiCandidate | ||
#ifndef CommonTools_PileupAlgos_PuppiCandidate_h | ||
#define CommonTools_PileupAlgos_PuppiCandidate_h | ||
|
||
#include "fastjet/PseudoJet.hh" | ||
|
||
// Extension of fastjet::PseudoJet that caches eta and some other info | ||
// Puppi uses register to decide between NHs, PV CHs, and PU CHs. | ||
class PuppiCandidate : public fastjet::PseudoJet { | ||
public: | ||
using fastjet::PseudoJet::PseudoJet; | ||
double pseudorapidity() const { _ensure_valid_eta(); return _eta; } | ||
double eta() const { return pseudorapidity(); } | ||
void _ensure_valid_eta() const { if(_eta==fastjet::pseudojet_invalid_rap) _eta = fastjet::PseudoJet::pseudorapidity(); } | ||
void set_info(int puppi_register) { _puppi_register = puppi_register; } | ||
inline int puppi_register() const { return _puppi_register; } | ||
private: | ||
// variable names in fastjet style | ||
mutable double _eta = fastjet::pseudojet_invalid_rap; | ||
int _puppi_register; | ||
struct PuppiCandidate { | ||
double pt{0}; | ||
double eta{0}; | ||
double phi{0}; | ||
double m{0}; | ||
double rapidity{0}; | ||
double px{0}; | ||
double py{0}; | ||
double pz{0}; | ||
double e{0}; | ||
int id{0}; | ||
int puppi_register{0}; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 master version uses
and getsDefaultWgtIfApplyCHS
in the second conditional instead ofand iConstits[i0].puppi_register != 0
. Are these equivalent? If yes, a redefinition ofgetsDefaultWgtIfApplyCHS
may be in order.If no, please elaborate
(in this case, the separate definition of
getsDefaultWgtIfApplyCHS
seems unnecessary because it is not reused anywhere else).also a linebreak at/after
or
would be niceThere 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.
In practice, I think the condition
id == 1 or id == 2
corresponds toregister != 0
(looking at howpuppi_register
is filled here), but in principle the two things can differ (or at least, I wanted to make no assumptions).The logic behind how these changes are implemented is the following:
goodVar
needs to be calculated when the final weight of the candidate is non-trivial (this is the first condition, which corresponds to the logical NOT of these two cases), or when thegoodVar
of a given candidate is needed internally byPuppiAlgo::add
, here; in10_6_X
, the latter condition translates to(.. < etaMaxExtrap) and puppi_register != 0
, while in11_X_Y
the criterion is(.. < etaMaxExtrap) and (id == 1 or id == 2)
(see here).So, the logic is the same here and in the original PR; the end result looks different just as a consequence of the fact that the
Puppi{Container,Algo}
implementation is different in the two releases.I added a commit to remove the temporary variable
getsDefaultWgtIfApplyCHS
, which was indeed only used once, and took the opportunity to add the linebreak.