10 #ifndef HEPMC3_FILTER_H
11 #define HEPMC3_FILTER_H
17 using Filter = std::function<bool(ConstGenParticlePtr)>;
21 inline std::vector<GenParticlePtr>
applyFilter(
const Filter &filter,
const std::vector<GenParticlePtr> &particles) {
22 std::vector<GenParticlePtr> result;
23 for(GenParticlePtr p: particles) {
24 if(filter(p)) result.push_back(p);
31 inline std::vector<ConstGenParticlePtr>
applyFilter(
const Filter &filter,
const std::vector<ConstGenParticlePtr> &particles) {
32 std::vector<ConstGenParticlePtr> result;
33 for(ConstGenParticlePtr p: particles) {
34 if(filter(p)) result.push_back(p);
47 return [lhs, rhs](ConstGenParticlePtr p)->
bool{
return lhs(p) && rhs(p); };
52 return [lhs, rhs](ConstGenParticlePtr p)->
bool{
return lhs(p) || rhs(p); };
57 return [rhs](ConstGenParticlePtr p)->
bool{
return ! (rhs(p));};
Filter operator&&(const Filter &lhs, const Filter &rhs)
The logical AND of two Filters is itself a Filter.
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.
std::function< bool(ConstGenParticlePtr)> Filter
type of Filter
Filter operator!(const Filter &rhs)
The negation of a Filter is itself a Filter.
bool ACCEPT_ALL(ConstGenParticlePtr dummy)
A Filter that will accept all particles This might be needed if a signature requires a default Filter...