HepMC3 event record library: GenericFeature< Feature_type > Class Template Reference

HepMC3 event record library

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
GenericFeature< Feature_type > Class Template Reference

## Detailed Description

template<typename Feature_type>
class HepMC3::GenericFeature< Feature_type >

GenericFeature defines the Feature interface GenericFeature is not intended to be used directly. The derived Feature class and its specialisations should be used.

A Feature wraps a function object that can extract a generic Feature_type from a ConstGenParticlePtr. Usually the Feature_type would be something like int (e.g. status) or double (e.g. pT), but it could in principle be any attribute of a particle so long as there are well defined <, <=, >, >=, == and != operators for that attribute, as well as an abs function.

Once a Feature is defined, you can obtain Filters that select Particles according to that Feature by e.g. Feature<int> status([](ConstGenParticlePtr p)->int{return p->status();}); bool is_stable = (status == 1)(p); Filter is_beam = (status == 4); bool beam = is_beam(p);

An abs function is also defined, so abs(Feature) works as you'd expect, e.g. Feature<double> rapidity([](ConstGenParticlePtr p)->double{return p->momentum().rap();}); Filter rapCut = abs(rapidity) < 2.5;

Please also see the Selector interface, which defines an abstract interface to Feature that is free of the template params and also includes some standard Features such as

Selector::STATUS; Selector::PDG_ID; Selector::PT; Selector::RAPIDITY;

Definition at line 59 of file Feature.h.

`#include <Feature.h>`

Inheritance diagram for GenericFeature< Feature_type >:
[legend]
Collaboration diagram for GenericFeature< Feature_type >:
[legend]

## Public Types
using | Evaluator_type = std::function<Feature_type(ConstGenParticlePtr)>
| evaluator type
using | EvaluatorPtr = std::shared_ptr<Evaluator_type>
| shared pointer for evaluator type

## Public Member Functions
Feature_type | operator() (ConstGenParticlePtr input) const
| access the underlying feature value
Filter | operator> (Feature_type value) const
| greater than operator
Filter | operator< (Feature_type value) const
| less than operator
Filter | operator>= (Feature_type value) const
| greater than or equals operator
Filter | operator<= (Feature_type value) const
| less than or equals operator
virtual Filter | operator== (Feature_type value) const
| equality operator
virtual Filter | operator!= (Feature_type value) const
| inequality operator

## Protected Member Functions
| GenericFeature (Evaluator_type functor)
| Hide the constructor so no one can use GenericFeature directly.
| GenericFeature (const GenericFeature &copy)
| Hide the copy constructor.
| GenericFeature (GenericFeature &&)=default
| Move constructor.
GenericFeature & | operator= (const GenericFeature &)=default
| =
GenericFeature & | operator= (GenericFeature &&)=default
| =

## Protected Attributes
EvaluatorPtr | m_internal
| internal copy of func for evaluation on the heap so will persist in resulting Filters even if parent Feature object was destroyed

## Member Typedef Documentation

## ◆ Evaluator_type

template<typename Feature_type>

using Evaluator_type = std::function<Feature_type(ConstGenParticlePtr)>

evaluator type

Definition at line 62 of file Feature.h.

## ◆ EvaluatorPtr

template<typename Feature_type>

using EvaluatorPtr = std::shared_ptr<Evaluator_type>

shared pointer for evaluator type

Definition at line 64 of file Feature.h.

## Constructor & Destructor Documentation

## ◆ GenericFeature() [1/3]

template<typename Feature_type>

GenericFeature | ( | Evaluator_type | functor | ) |
| inlineprotected

Hide the constructor so no one can use GenericFeature directly.

Definition at line 114 of file Feature.h.

References m_internal.

## ◆ GenericFeature() [2/3]

template<typename Feature_type>

GenericFeature | ( | const GenericFeature< Feature_type > & | copy | ) |
| inlineprotected

Hide the copy constructor.

Definition at line 117 of file Feature.h.

References GenericFeature(), and m_internal.

## ◆ GenericFeature() [3/3]

template<typename Feature_type>

GenericFeature | ( | GenericFeature< Feature_type > && |  | ) |
| protecteddefault

Move constructor.

References GenericFeature().

## Member Function Documentation

## ◆ operator!=()

template<typename Feature_type>

virtual Filter operator!= | ( | Feature_type | value | ) | const
| inlinevirtual

inequality operator

Returns
  Filter function

Reimplemented in Feature< Feature_type, typename std::enable_if< std::is_floating_point< Feature_type >::value, void >::type >.

Definition at line 107 of file Feature.h.

References m_internal.

## ◆ operator()()

template<typename Feature_type>

Feature_type operator() | ( | ConstGenParticlePtr | input | ) | const
| inline

access the underlying feature value

Definition at line 67 of file Feature.h.

References m_internal.

## ◆ operator<()

template<typename Feature_type>

Filter operator< | ( | Feature_type | value | ) | const
| inline

less than operator

Returns
  Filter function

Definition at line 79 of file Feature.h.

References m_internal.

## ◆ operator<=()

template<typename Feature_type>

Filter operator<= | ( | Feature_type | value | ) | const
| inline

less than or equals operator

Returns
  Filter function

Definition at line 93 of file Feature.h.

References m_internal.

## ◆ operator=() [1/2]

template<typename Feature_type>

GenericFeature & operator= | ( | const GenericFeature< Feature_type > & |  | ) |
| protecteddefault

=

References GenericFeature().

## ◆ operator=() [2/2]

template<typename Feature_type>

GenericFeature & operator= | ( | GenericFeature< Feature_type > && |  | ) |
| protecteddefault

=

References GenericFeature().

## ◆ operator==()

template<typename Feature_type>

virtual Filter operator== | ( | Feature_type | value | ) | const
| inlinevirtual

equality operator

Returns
  Filter function

Reimplemented in Feature< Feature_type, typename std::enable_if< std::is_floating_point< Feature_type >::value, void >::type >.

Definition at line 100 of file Feature.h.

References m_internal.

## ◆ operator>()

template<typename Feature_type>

Filter operator> | ( | Feature_type | value | ) | const
| inline

greater than operator

Returns
  Filter function

Definition at line 73 of file Feature.h.

References m_internal.

## ◆ operator>=()

template<typename Feature_type>

Filter operator>= | ( | Feature_type | value | ) | const
| inline

greater than or equals operator

Returns
  Filter function

Definition at line 86 of file Feature.h.

References m_internal.

## Field Documentation

## ◆ m_internal

template<typename Feature_type>

EvaluatorPtr m_internal
| protected

internal copy of func for evaluation on the heap so will persist in resulting Filters even if parent Feature object was destroyed

Definition at line 130 of file Feature.h.

The documentation for this class was generated from the following file:

- Feature.h