HepMC event record
include/HepMC/Search/FilterBase.h
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014 The HepMC collaboration (see AUTHORS for details)
5 //
6 #ifndef HEPMC_SEARCH_FILTERBASE_H
7 #define HEPMC_SEARCH_FILTERBASE_H
8 /**
9  * @file FilterBase.h
10  * @brief Definition of \b class FilterBase
11  *
12  * @class HepMC::FilterBase
13  * @brief Base class for Filter class
14  *
15  * Objects of this class cannot be directly created by user.
16  * See @ref search_engine for details on how this class is used.
17  *
18  * @ingroup search_engine
19  *
20  */
21 
22 namespace HepMC {
23 
24 class Filter;
25 
26 class FilterBase {
27 //
28 // Enums
29 //
30 protected:
31 
32 /** @brief List of filter parameter types */
34  INTEGER_PARAM,
35  BOOL_PARAM,
36  ATTRIBUTE_PARAM
37 };
38 
39 /** @brief List of filters with integer parameter */
41  STATUS,
42  PDG_ID,
43  ABS_PDG_ID
44 };
45 
46 /** @brief List of filters with boolean parameter */
48  HAS_END_VERTEX,
49  HAS_PRODUCTION_VERTEX,
50  HAS_SAME_PDG_ID_DAUGHTER,
51  IS_STABLE,
52  IS_BEAM
53 };
54 
55 /** @brief List of filters with attribute parameter */
57  ATTRIBUTE_EXISTS,
58  ATTRIBUTE_IS_EQUAL
59 };
60 
61 /** @brief List of operators on filter values */
63  EQUAL,
64  GREATER,
65  GREATER_OR_EQUAL,
66  LESS,
67  LESS_OR_EQUAL,
68  NOT_EQUAL
69 };
70 
71 //
72 // Const initializers
73 //
74 public:
75  static const FilterBase init_status() { return FilterBase(STATUS); } //!< init static const STATUS
76  static const FilterBase init_pdg_id() { return FilterBase(PDG_ID); } //!< init static const PDG_ID
77  static const FilterBase init_abs_pdg_id() { return FilterBase(ABS_PDG_ID); } //!< init static const ABS_PDG_ID
78 
79  static const Filter init_has_end_vertex(); //!< init static const HAS_END_VERTEX
80  static const Filter init_has_production_vertex(); //!< init static const HAS_PRODUCTION_VERTEX
81  static const Filter init_has_same_pdg_id_daughter(); //!< init static const HAS_SAME_PDG_ID_DAUGHTER
82  static const Filter init_is_stable(); //!< init static const IS_STABLE
83  static const Filter init_is_beam(); //!< init static const IS_BEAM
84 
85 //
86 // Constructors
87 //
88 protected:
89 
90  /** @brief Integer-type internal constructor
91  *
92  * Used by static const initializers to define filters.
93  */
95 
96  /** @brief Boolean-type internal constructor
97  *
98  * Used by static const initializers to define filters.
99  */
101 
102  /** @brief Attribute-type internal constructor
103  *
104  * Used by attribute initializers to define filters.
105  */
107 
108 //
109 // Functions
110 //
111 public:
112  Filter operator==(int value) const; //!< Create integer filter with operator ==
113  Filter operator!=(int value) const; //!< Create integer filter with operator !=
114  Filter operator> (int value) const; //!< Create integer filter with operator >
115  Filter operator>=(int value) const; //!< Create integer filter with operator >=
116  Filter operator< (int value) const; //!< Create integer filter with operator <
117  Filter operator<=(int value) const; //!< Create integer filter with operator <=
118 
119 //
120 // Fields
121 //
122 protected:
123  FilterParamType m_value_type; //!< Parameter type
124 
125  union {
126  FilterAttributeParam m_attribute; //!< Attribute value (if attribute parameter type)
127  FilterIntegerParam m_int; //!< Integer value (if integer parameter type)
128  FilterBoolParam m_bool; //!< Boolean value (if boolean parameter type)
129  };
130 };
131 
132 static const FilterBase STATUS = FilterBase::init_status(); //!< Filter base for filtering GenParticle::status()
133 static const FilterBase PDG_ID = FilterBase::init_pdg_id(); //!< Filter base for filtering GenParticle::pid()
134 static const FilterBase ABS_PDG_ID = FilterBase::init_abs_pdg_id(); //!< Filter base for filtering abs( GenParticle::pid() )
135 
136 } // namespace HepMC
137 
138 #endif
static const Filter init_has_production_vertex()
init static const HAS_PRODUCTION_VERTEX
Definition: FilterBase.cc:26
FilterBase(FilterAttributeParam p)
Attribute-type internal constructor.
static const FilterBase init_pdg_id()
init static const PDG_ID
FilterParamType m_value_type
Parameter type.
FilterBoolParam m_bool
Boolean value (if boolean parameter type)
FilterBoolParam
List of filters with boolean parameter.
Filter operator>(int value) const
Create integer filter with operator >
Definition: FilterBase.cc:19
Class used to define filters for search engine.
FilterIntegerParam
List of filters with integer parameter.
Filter operator==(int value) const
Create integer filter with operator ==.
Definition: FilterBase.cc:17
FilterParamType
List of filter parameter types.
static const FilterBase init_abs_pdg_id()
init static const ABS_PDG_ID
static const Filter init_is_stable()
init static const IS_STABLE
Definition: FilterBase.cc:28
static const Filter init_is_beam()
init static const IS_BEAM
Definition: FilterBase.cc:29
FilterAttributeParam m_attribute
Attribute value (if attribute parameter type)
Filter operator>=(int value) const
Create integer filter with operator >=.
Definition: FilterBase.cc:20
FilterIntegerParam m_int
Integer value (if integer parameter type)
FilterBase(FilterBoolParam p)
Boolean-type internal constructor.
static const FilterBase init_status()
init static const STATUS
static const FilterBase PDG_ID
Filter base for filtering GenParticle::pid()
static const Filter init_has_end_vertex()
init static const HAS_END_VERTEX
Definition: FilterBase.cc:25
FilterOperator
List of operators on filter values.
FilterBase(FilterIntegerParam p)
Integer-type internal constructor.
Filter operator<=(int value) const
Create integer filter with operator <=.
Definition: FilterBase.cc:22
Filter operator<(int value) const
Create integer filter with operator <.
Definition: FilterBase.cc:21
Definition of template class SmartPointer.
static const FilterBase STATUS
Filter base for filtering GenParticle::status()
static const FilterBase ABS_PDG_ID
Filter base for filtering abs( GenParticle::pid() )
static const Filter init_has_same_pdg_id_daughter()
init static const HAS_SAME_PDG_ID_DAUGHTER
Definition: FilterBase.cc:27
Filter operator!=(int value) const
Create integer filter with operator !=.
Definition: FilterBase.cc:18
FilterAttributeParam
List of filters with attribute parameter.