|
[Rivet-svn] rivet: 2 new changesetsRivet Mercurial rivet at projects.hepforge.orgSat Aug 20 15:00:01 BST 2016
details: https://rivet.hepforge.org/hg/rivet/rev/fdfefe0eb17d branches: release-2-5-x changeset: 5417:fdfefe0eb17d user: Andy Buckley <andy at insectnation.org> date: Sat Aug 20 13:53:03 2016 +0100 description: Casts to avoid attempted min(int,size_t) details: https://rivet.hepforge.org/hg/rivet/rev/c9f90d382b03 branches: release-2-5-x changeset: 5418:c9f90d382b03 user: Andy Buckley <andy at insectnation.org> date: Sat Aug 20 14:13:48 2016 +0100 description: Adding filterBy methods for Particle and Jet which accept generic boolean functions as well as the Cut specialisation. diffs (truncated from 208 to 50 lines): --- a/ChangeLog Thu Aug 18 23:54:07 2016 +0100 +++ b/ChangeLog Sat Aug 20 14:13:48 2016 +0100 @@ -1,3 +1,8 @@ +2016-08-20 Andy Buckley <andy.buckley at cern.ch> + + * Adding filterBy methods for Particle and Jet which accept + generic boolean functions as well as the Cut specialisation. + 2016-08-18 Andy Buckley <andy.buckley at cern.ch> * Add a Jet::particles(Cut&) method, for inline filtering of jet constituents. --- a/include/Rivet/Tools/JetUtils.hh Thu Aug 18 23:54:07 2016 +0100 +++ b/include/Rivet/Tools/JetUtils.hh Sat Aug 20 14:13:48 2016 +0100 @@ -37,16 +37,42 @@ /// @name Unbound functions for filtering jets //@{ - /// Get a subset of the supplied jets that passes the supplied Cut - Jets filterBy(const Jets& jets, const Cut& c); + /// Filter a jet collection in-place to the subset that passes the supplied function + template <typename FN> + inline Jets& ifilterBy(Jets& jets, const FN& f) { + const auto newend = std::remove_if(jets.begin(), jets.end(), f); + jets.erase(newend, jets.end()); + return jets; + } - /// Filter a particle collection in-place to the subset that passes the supplied Cut + /// Get a subset of the supplied jets that passes the supplied function + template <typename FN> + inline Jets filterBy(const Jets& jets, const FN& f) { + Jets rtn = jets; + return ifilterBy(rtn, f); + } + + /// Filter a jet collection to the subset that passes the supplied function, into a new container + /// @note New container will be replaced, not appended to + template <typename FN> + inline Jets& filterBy(Jets& jets, const FN& f, Jets& out) { + out = filterBy(jets, f); + return out; + } + + + /// Filter a jet collection in-place to the subset that passes the supplied Cut Jets& ifilterBy(Jets& jets, const Cut& c); - /// Filter a particle collection to the subset that passes the supplied Cut, into a new container + /// Get a subset of the supplied jets that passes the supplied Cut + inline Jets filterBy(const Jets& jets, const Cut& c) {
More information about the Rivet-svn mailing list |