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;};
169template<
typename Feature_type,
typename Dummy =
void>
198 Evaluator_type absfunctor = [functor](ConstGenParticlePtr p)->Feature_type{return ::abs((*functor)(p));};
218template<
typename Feature_type>
219class Feature<Feature_type, typename std::enable_if<std::is_integral<Feature_type>::value, void>::type> :
public GenericFeature<Feature_type> {
249 Evaluator_type absfunctor = [functor](ConstGenParticlePtr p)->Feature_type{return ::abs((*functor)(p));};
256 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) > value;};
262 return [value, functor](ConstGenParticlePtr input)->
bool{
return (*functor)(input) < value;};
268 return [value, functor](ConstGenParticlePtr input)->
bool{
269 Feature_type local = (*functor)(input);
270 return std::abs(local - value) < std::numeric_limits<double>::epsilon();
282 return !( (*this) == value );
295template<
typename Feature_type>
296class Feature<Feature_type, typename std::enable_if<std::is_floating_point<Feature_type>::value, void>::type> :
public GenericFeature<Feature_type> {
325 Evaluator_type absfunctor = [functor](ConstGenParticlePtr p)->Feature_type{
return std::abs((*functor)(p));};
331 return [value, functor](ConstGenParticlePtr input)->
bool{
332 Feature_type local = (*functor)(input);
333 return std::less_equal<Feature_type>{}(fabs(local - value) , std::numeric_limits<Feature_type>::epsilon());
338 return !( (*this) == value );
351template<
typename Feature_type>
Defines Filter operations for combingin Filters.
Definition of class GenParticle.
Feature & operator=(const Feature &)=default
=
Feature< Feature_type > abs() const
abs function
Feature(Evaluator_type functor)
Feature.
Feature & operator=(Feature &&)=default
=
Feature(Feature &&)=default
Move constructor.
Feature(const Feature ©)
Copy.
Feature & operator=(const Feature &)=default
=
Feature< Feature_type > abs() const
abs function
Feature(Evaluator_type functor)
Feature.
Feature & operator=(Feature &&)=default
=
Feature(Feature &&)=default
Move constructor.
Feature(const Feature ©)
Feature.
Expose GenericFeature interface to derived Feature class.
Feature & operator=(const Feature &)=default
=
Feature< Feature_type > abs() const
Abs function.
Feature(Evaluator_type functor)
Feature.
Feature & operator=(Feature &&)=default
=
Feature(Feature &&)=default
Move constructor.
Feature(const Feature ©)
Copy.
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 ...
Filter operator>=(Feature_type value) const
greater than or equals operator
GenericFeature & operator=(const GenericFeature &)=default
=
std::function< Feature_type(ConstGenParticlePtr)> Evaluator_type
evaluator type
virtual Filter operator!=(Feature_type value) const
inequality operator
GenericFeature(GenericFeature &&)=default
Move constructor.
GenericFeature(const GenericFeature ©)
Hide the copy constructor.
GenericFeature & operator=(GenericFeature &&)=default
=
std::shared_ptr< Evaluator_type > EvaluatorPtr
shared pointer for evaluator type
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,...