11#ifndef HEPMC3_FEATURE_H
12#define HEPMC3_FEATURE_H
58template<
typename Feature_type>
67 Feature_type
operator()(ConstGenParticlePtr input)
const {
75 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) > value;};
81 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) < value;};
88 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) >= value;};
95 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) <= value;};
102 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) == value;};
109 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) != value;};
161template<
typename Feature_type,
typename Dummy =
void>
184 Evaluator_type absfunctor = [functor](ConstGenParticlePtr p)->Feature_type{return ::abs((*functor)(p));};
204template<
typename Feature_type>
205class Feature<Feature_type, typename std::enable_if<std::is_integral<Feature_type>::value, void>::type> :
public GenericFeature<Feature_type> {
228 Evaluator_type absfunctor = [functor](ConstGenParticlePtr p)->Feature_type{return ::abs((*functor)(p));};
235 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) > value;};
241 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) < value;};
247 return [value, functor](ConstGenParticlePtr input)->
bool{
248 Feature_type local = (*functor)(input);
249 return std::abs(local - value) < std::numeric_limits<double>::epsilon();
261 return !( (*this) == value );
274template<
typename Feature_type>
275class Feature<Feature_type, typename std::enable_if<std::is_floating_point<Feature_type>::value, void>::type> :
public GenericFeature<Feature_type> {
296 Evaluator_type absfunctor = [functor](ConstGenParticlePtr p)->Feature_type{
return std::abs((*functor)(p));};
302 return [value, functor](ConstGenParticlePtr input)->
bool{
303 Feature_type local = (*functor)(input);
304 return std::less_equal<Feature_type>{}(fabs(local - value) , std::numeric_limits<Feature_type>::epsilon());
309 return !( (*this) == value );
322template<
typename Feature_type>
Defines Filter operations for combingin Filters.
Definition of class GenParticle.
Feature< Feature_type > abs() const
abs function
Feature(Evaluator_type functor)
Feature.
Feature(const Feature ©)
Copy.
Feature< Feature_type > abs() const
abs function
Feature(Evaluator_type functor)
Feature.
Feature(const Feature ©)
Feature.
Expose GenericFeature interface to derived Feature class.
Feature< Feature_type > abs() const
Abs function.
Feature(Evaluator_type functor)
Feature.
Feature(const Feature ©)
Copy.
GenericFeature defines the Feature interface GenericFeature is not intended to be used directly....
Filter operator>(Feature_type value) const
greater than operator
Filter operator<(Feature_type value) const
less than operator
EvaluatorPtr m_internal
internal copy of func for evaluation on the heap so will persist in resulting Filters even if parent ...
std::shared_ptr< Evaluator_type > EvaluatorPtr
shared pointer for evaluator type
Filter operator>=(Feature_type value) const
greater than or equals operator
std::function< Feature_type(ConstGenParticlePtr)> Evaluator_type
evaluator type
virtual Filter operator!=(Feature_type value) const
inequality operator
GenericFeature(const GenericFeature ©)
Hide the copy constructor.
Feature_type operator()(ConstGenParticlePtr input) const
access the underlying feature value
virtual Filter operator==(Feature_type value) const
equality operator
Filter operator<=(Feature_type value) const
less than or equals operator
GenericFeature(Evaluator_type functor)
Hide the constructor so no one can use GenericFeature directly.
std::function< bool(ConstGenParticlePtr)> Filter
type of Filter
Feature< Feature_type > abs(const Feature< Feature_type > &input)
Obtain the absolute value of a Feature. This works as you'd expect. If foo is a valid Feature,...