10#ifndef HEPMC3_FILTER_H
11#define HEPMC3_FILTER_H
19using Filter = std::function<bool(ConstGenParticlePtr)>;
23inline std::vector<GenParticlePtr>
applyFilter(
const Filter &filter,
const std::vector<GenParticlePtr> &particles) {
24 std::vector<GenParticlePtr> result;
25 for (GenParticlePtr p: particles) {
26 if (filter(p)) result.push_back(p);
33inline std::vector<ConstGenParticlePtr>
applyFilter(
const Filter &filter,
const std::vector<ConstGenParticlePtr> &particles) {
34 std::vector<ConstGenParticlePtr> result;
35 for (ConstGenParticlePtr p: particles) {
36 if (filter(p)) result.push_back(p);
49 return [lhs, rhs](ConstGenParticlePtr p)->
bool{
return lhs(p) && rhs(p); };
54 return [lhs, rhs](ConstGenParticlePtr p)->
bool{
return lhs(p) || rhs(p); };
59 return [rhs](ConstGenParticlePtr p)->
bool{
return !(rhs(p));};
Definition of class GenParticle.
std::vector< GenParticlePtr > applyFilter(const Filter &filter, const std::vector< GenParticlePtr > &particles)
Apply a Filter to a list of GenParticles Returns a vector of GenParticles that satisfy the Filter.
Filter operator||(const Filter &lhs, const Filter &rhs)
The logical OR of two Filters is itself a Filter.
Filter operator!(const Filter &rhs)
The negation of a Filter is itself a Filter.
std::function< bool(ConstGenParticlePtr)> Filter
type of Filter
Filter operator&&(const Filter &lhs, const Filter &rhs)
The logical AND of two Filters is itself a Filter.
bool ACCEPT_ALL(ConstGenParticlePtr)
A Filter that will accept all particles This might be needed if a signature requires a default Filter...