|
[Rivet-svn] rivet: Copy & paste error fixes in implementation of BoolJetAND, ...Rivet Mercurial rivet at projects.hepforge.orgThu Feb 22 16:15:02 GMT 2018
details: https://rivet.hepforge.org/hg/rivet/rev/39000fa9739e branches: release-2-6-x changeset: 6244:39000fa9739e user: Andy Buckley <andy at insectnation.org> date: Thu Feb 22 16:09:31 2018 +0000 description: Copy & paste error fixes in implementation of BoolJetAND,OR,NOT. Adding boolean operator syntactic sugar for composition of bool functors. diffs (truncated from 128 to 50 lines): --- a/ChangeLog Tue Feb 20 11:38:51 2018 +0000 +++ b/ChangeLog Thu Feb 22 16:09:31 2018 +0000 @@ -1,3 +1,9 @@ +2018-02-22 Andy Buckley <andy.buckley at cern.ch> + + * Adding boolean operator syntactic sugar for composition of bool functors. + + * Copy & paste error fixes in implementation of BoolJetAND,OR,NOT. + 2018-02-01 Andy Buckley <andy.buckley at cern.ch> * Make the project() and compare() methods of projections public. --- a/include/Rivet/Tools/JetUtils.hh Tue Feb 20 11:38:51 2018 +0000 +++ b/include/Rivet/Tools/JetUtils.hh Thu Feb 22 16:09:31 2018 +0000 @@ -48,34 +48,51 @@ virtual bool operator()(const Jet& p) const = 0; }; + + /// Functor for and-combination of selector logic struct BoolJetAND : public BoolJetFunctor { - BoolJetAND(const std::vector<ParticleSelector>& sels) : selectors(sels) {} - BoolJetAND(const ParticleSelector& a, const ParticleSelector& b) : selectors({a,b}) {} - BoolJetAND(const ParticleSelector& a, const ParticleSelector& b, const ParticleSelector& c) : selectors({a,b,c}) {} - bool operator()(const Particle& p) const { - for (const ParticleSelector& sel : selectors) if (!sel(p)) return false; + BoolJetAND(const std::vector<JetSelector>& sels) : selectors(sels) {} + BoolJetAND(const JetSelector& a, const JetSelector& b) : selectors({a,b}) {} + BoolJetAND(const JetSelector& a, const JetSelector& b, const JetSelector& c) : selectors({a,b,c}) {} + bool operator()(const Jet& j) const { + for (const JetSelector& sel : selectors) if (!sel(j)) return false; return true; } - std::vector<ParticleSelector> selectors; + std::vector<JetSelector> selectors; }; + /// Operator syntactic sugar for AND construction + inline BoolJetAND operator && (const JetSelector& a, const JetSelector& b) { + return BoolJetAND(a, b); + } + + /// Functor for or-combination of selector logic struct BoolJetOR : public BoolJetFunctor { - BoolJetOR(const std::vector<ParticleSelector>& sels) : selectors(sels) {} - BoolJetOR(const ParticleSelector& a, const ParticleSelector& b) : selectors({a,b}) {} - BoolJetOR(const ParticleSelector& a, const ParticleSelector& b, const ParticleSelector& c) : selectors({a,b,c}) {} - bool operator()(const Particle& p) const { - for (const ParticleSelector& sel : selectors) if (sel(p)) return true; + BoolJetOR(const std::vector<JetSelector>& sels) : selectors(sels) {}
More information about the Rivet-svn mailing list |