File indexing completed on 2025-01-18 10:01:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef HEPMC3_SELECTOR_H
0011 #define HEPMC3_SELECTOR_H
0012
0013 #include <string>
0014 #include <memory>
0015 #include "HepMC3/Filter.h"
0016 #include "HepMC3/Feature.h"
0017 #include "HepMC3/AttributeFeature.h"
0018
0019 namespace HepMC3 {
0020
0021 template<typename T>
0022 class SelectorWrapper;
0023
0024 class Selector;
0025
0026 using ConstSelectorPtr = std::shared_ptr<const Selector>;
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 class Selector {
0058 public:
0059
0060 virtual ~Selector() {};
0061
0062 virtual Filter operator > (int value) const = 0;
0063 virtual Filter operator > (double value) const = 0;
0064
0065 virtual Filter operator >= (int value) const = 0;
0066 virtual Filter operator >= (double value) const = 0;
0067
0068 virtual Filter operator < (int value) const = 0;
0069 virtual Filter operator < (double value) const = 0;
0070
0071 virtual Filter operator <= (int value) const = 0;
0072 virtual Filter operator <= (double value) const = 0;
0073
0074 virtual Filter operator == (int value) const = 0;
0075 virtual Filter operator == (double value) const = 0;
0076
0077 virtual Filter operator != (int value) const = 0;
0078 virtual Filter operator != (double value) const = 0;
0079
0080 virtual ConstSelectorPtr abs() const = 0;
0081 static AttributeFeature ATTRIBUTE(const std::string &name);
0082 };
0083
0084 template<typename Feature_type>
0085 class SelectorWrapper : public Selector {
0086 public:
0087
0088 SelectorWrapper(typename Feature<Feature_type>::Evaluator_type functor): m_internal(functor) {}
0089
0090
0091 Filter operator > (int value) const override {
0092 return m_internal > value;
0093 }
0094
0095
0096 Filter operator > (double value) const override {
0097 return m_internal > value;
0098 }
0099
0100
0101 Filter operator >= (int value) const override {
0102 return m_internal >= value;
0103 }
0104
0105
0106 Filter operator >= (double value) const override {
0107 return m_internal >= value;
0108 }
0109
0110
0111 Filter operator < (int value) const override {
0112 return m_internal < value;
0113 }
0114
0115
0116 Filter operator < (double value) const override {
0117 return m_internal < value;
0118 }
0119
0120
0121 Filter operator <= (int value) const override {
0122 return m_internal <= value;
0123 }
0124
0125
0126 Filter operator <= (double value) const override {
0127 return m_internal <= value;
0128 }
0129
0130
0131 Filter operator == (int value) const override {
0132 return m_internal == value;
0133 }
0134
0135
0136 Filter operator == (double value) const override {
0137 return m_internal == value;
0138 }
0139
0140
0141 Filter operator != (int value) const override {
0142 return m_internal != value;
0143 }
0144
0145
0146 Filter operator != (double value) const override {
0147 return m_internal != value;
0148 }
0149
0150
0151 ConstSelectorPtr abs() const override {
0152 SelectorWrapper<Feature_type> *copy = new SelectorWrapper<Feature_type>(*this);
0153 copy->m_internal = m_internal.abs();
0154 return ConstSelectorPtr(copy);
0155 }
0156
0157 private:
0158 Feature<Feature_type> m_internal;
0159 };
0160
0161 ConstSelectorPtr abs(const Selector &input);
0162
0163 #if defined(WIN32) && !defined(HEPMC3search_NO_StandardSelector_EXPORTS)
0164 #ifdef HepMC3search_EXPORTS
0165 #define HEPMC3search_StandardSelector_EXPORT_API __declspec(dllexport)
0166 #else
0167 #define HEPMC3search_StandardSelector_EXPORT_API __declspec(dllimport)
0168 #endif
0169 #else
0170 #define HEPMC3search_StandardSelector_EXPORT_API
0171 #endif
0172
0173
0174 class StandardSelector: public Selector {
0175 public:
0176 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<int> STATUS;
0177 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<int> PDG_ID;
0178 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<double> PT;
0179 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<double> ENERGY;
0180 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<double> RAPIDITY;
0181 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<double> ETA;
0182 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<double> PHI;
0183 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<double> ET;
0184 HEPMC3search_StandardSelector_EXPORT_API static const SelectorWrapper<double> MASS;
0185 };
0186
0187 }
0188 #endif