|
[Rivet-svn] rivet: Use new std::function hashing approach in SmearedParticle...Rivet Mercurial rivet at projects.hepforge.orgSun Mar 27 21:45:01 BST 2016
details: https://rivet.hepforge.org/hg/rivet/rev/9ca382868844 branches: changeset: 5069:9ca382868844 user: Andy Buckley <andy at insectnation.org> date: Sun Mar 27 21:42:44 2016 +0100 description: Use new std::function hashing approach in SmearedParticles, too diffs (truncated from 78 to 50 lines): --- a/include/Rivet/Projections/SmearedJets.hh Sat Mar 26 22:53:23 2016 +0000 +++ b/include/Rivet/Projections/SmearedJets.hh Sun Mar 27 21:42:44 2016 +0100 @@ -144,7 +144,7 @@ /// Make a hash integer from the provided wrapped Jet -> Jet function size_t _mkhash(const std::function<Jet(const Jet&)>& fn) const { const size_t rtn = reinterpret_cast<size_t>(fn.target<Jet(*)(const Jet&)>()); - MSG_TRACE("J2D hash = " << rtn); + MSG_TRACE("J2J hash = " << rtn); return rtn; } --- a/include/Rivet/Projections/SmearedParticles.hh Sat Mar 26 22:53:23 2016 +0000 +++ b/include/Rivet/Projections/SmearedParticles.hh Sun Mar 27 21:42:44 2016 +0100 @@ -19,13 +19,24 @@ //@{ /// @brief Constructor with efficiency and smearing function args + template <typename P2DFN> + SmearedParticles(const ParticleFinder& pf, + const P2DFN& effFn, + const Cut& c=Cuts::open()) + : ParticleFinder(c), + _effFn(effFn), _smearFn(PARTICLE_SMEAR_IDENTITY) + { + setName("SmearedParticles"); + addProjection(pf, "TruthParticles"); + } + + + /// @brief Constructor with efficiency and smearing function args template <typename P2DFN, typename P2PFN> SmearedParticles(const ParticleFinder& pf, - const P2DFN& effFn, const P2PFN& smearFn=PARTICLE_SMEAR_IDENTITY, + const P2DFN& effFn, const P2PFN& smearFn, const Cut& c=Cuts::open()) : ParticleFinder(c), - _effFnHash(reinterpret_cast<size_t>(effFn)), - _smearFnHash(reinterpret_cast<size_t>(smearFn)), _effFn(effFn), _smearFn(smearFn) { setName("SmearedParticles"); @@ -44,7 +55,9 @@ /// Compare to another SmearedParticles int compare(const Projection& p) const { const SmearedParticles& other = dynamic_cast<const SmearedParticles&>(p); - return cmp(_effFnHash, other._effFnHash) || cmp(_smearFnHash, other._smearFnHash); + if (_mkhash(_effFn) == 0) return UNDEFINED; + if (_mkhash(_smearFn) == 0) return UNDEFINED; + return cmp(_mkhash(_effFn), _mkhash(other._effFn)) || cmp(_mkhash(_smearFn), _mkhash(other._smearFn)); }
More information about the Rivet-svn mailing list |