11 #ifndef HEPMC3_FEATURE_H 12 #define HEPMC3_FEATURE_H 58 template<
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;};
161 template<
typename Feature_type,
typename Dummy =
void>
204 template<
typename Feature_type>
205 class Feature<Feature_type, typename
std::enable_if<std::is_integral<Feature_type>::value, void>::type> :
public GenericFeature<Feature_type> {
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 );
274 template<
typename Feature_type>
275 class 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 );
322 template<
typename Feature_type>
Feature< Feature_type > abs() const
abs function
Feature< Feature_type > abs() const
Abs function.
GenericFeature(Evaluator_type functor)
Hide the constructor so no one can use GenericFeature directly.
Definition of class GenParticle.
Filter operator>(Feature_type value) const
greater than operator
virtual Filter operator!=(Feature_type value) const
inequality operator
Feature(Evaluator_type functor)
Feature.
GenericFeature defines the Feature interface GenericFeature is not intended to be used directly...
Defines Filter operations for combingin Filters.
Feature(Evaluator_type functor)
Feature.
Feature< Feature_type > abs() const
abs function
Feature_type operator()(ConstGenParticlePtr input) const
access the underlying feature value
Filter operator<(Feature_type value) const
less than operator
Filter operator>=(Feature_type value) const
greater than or equals operator
std::function< bool(ConstGenParticlePtr)> Filter
type of Filter
Expose GenericFeature interface to derived Feature class.
Feature(const Feature ©)
Feature.
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
Feature(const Feature ©)
Copy.
Filter operator<=(Feature_type value) const
less than or equals operator
std::function< int(ConstGenParticlePtr)> Evaluator_type
evaluator type
Feature(Evaluator_type functor)
Feature.
GenericFeature(const GenericFeature ©)
Hide the copy constructor.
virtual Filter operator==(Feature_type value) const
equality operator
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...
Feature(const Feature ©)
Copy.