10 #ifndef HEPMC3_FILTER_H 11 #define HEPMC3_FILTER_H 17 using Filter = std::function<bool(ConstGenParticlePtr)>;
21 inline vector<GenParticlePtr>
applyFilter(
const Filter &filter,
const vector<GenParticlePtr> &particles){
22 vector<GenParticlePtr> result;
23 for(GenParticlePtr p: particles){
24 if(filter(p)) result.push_back(p);
31 inline vector<ConstGenParticlePtr>
applyFilter(
const Filter &filter,
const vector<ConstGenParticlePtr> &particles){
32 vector<ConstGenParticlePtr> result;
33 for(ConstGenParticlePtr p: particles){
34 if(filter(p)) result.push_back(p);
46 inline Filter
operator && (
const Filter & lhs,
const Filter &rhs){
47 return [lhs, rhs](ConstGenParticlePtr p)->
bool{
return lhs(p) && rhs(p); };
51 inline Filter
operator || (
const Filter & lhs,
const Filter &rhs){
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.
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.
bool ACCEPT_ALL(ConstGenParticlePtr dummy)
A Filter that will accept all particles This might be needed if a signature requires a default Filter...
vector< GenParticlePtr > applyFilter(const Filter &filter, const vector< GenParticlePtr > &particles)
Apply a Filter to a list of GenParticles Returns a vector of GenParticles that satisfy the Filter.