Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JEvtCategory.hh
Go to the documentation of this file.
1#ifndef __JAANET__JEVTCATEGORY__
2#define __JAANET__JEVTCATEGORY__
3
5
6#include "Jeep/JProperties.hh"
7
8#include "JLang/JClonable.hh"
9#include "JLang/JException.hh"
11
12#include "JAAnet/JHead.hh"
13
14
15/**
16 * \author bjung
17 */
18
19namespace JAANET {}
20namespace JPP { using namespace JAANET; }
21
22namespace JAANET {
23
25
26 using JLANG::JClonable;
28
29
30 /**
31 * Low-level interface for event categories.
32 */
33 struct JEvtCategory :
34 public JClonable <JEvtCategory>,
35 public JComparable<JEvtCategory>
36 {
37 /**
38 * Default constructor.
39 */
42 {}
43
44
45 /**
46 * Constructor.
47 *
48 * \param primaryType primary PDG type
49 */
53
54
55 /**
56 * Virtual destructor.
57 */
58 virtual ~JEvtCategory()
59 {}
60
61
62 /**
63 * Check if event category is valid.
64 *
65 * \return true if event category is valid; else false
66 */
67 virtual bool is_valid() const = 0;
68
69
70 /**
71 * Check validity.
72 */
73 inline void check_validity() const
74 {
75 using namespace JPP;
76
77 if (!is_valid()) {
78 THROW(JValueOutOfRange, "JEvtCategory::check_validity(): Invalid category " << *this);
79 }
80 }
81
82
83 /**
84 * Check whether given MC header matches with this event category.
85 *
86 * \param header MC header
87 * \return true if matching; else false
88 */
89 virtual bool match(const JHead& header) const = 0;
90
91
92 /**
93 * Check whether given event matches with this event category.
94 *
95 * \param event event
96 * \return true if matching; else false
97 */
98 virtual bool match(const Evt& event) const = 0;
99
100
101 /**
102 * Less-than method.
103 *
104 * \param category event category
105 * \return true if this event category is less than given event category; else false
106 */
107 virtual inline bool less(const JEvtCategory& category) const
108 {
109 return this->primaryType < category.getPrimaryType();
110 }
111
112
113 /**
114 * Get primary PDG type of this event category.
115 *
116 * \return primary PDG type
117 */
118 int getPrimaryType() const
119 {
120 return primaryType;
121 }
122
123
124 /**
125 * Get equation parameters.
126 *
127 * \return equation parameters
128 */
130 {
131 static JEquationParameters eqpars("=", ",", "./", "#");
132
133 return eqpars;
134 }
135
136
137 /**
138 * Set equation parameters.
139 *
140 * \param eqpars equation parameters
141 */
142 static inline void setEquationParameters(const JEquationParameters& eqpars)
143 {
144 getEquationParameters() = eqpars;
145 }
146
147
148 /**
149 * Get properties of this class.
150 *
151 * \param eqpars equation parameters
152 */
154 {
155 JProperties properties(eqpars,1);
156
157 properties.insert(gmake_property(primaryType));
158
159 return properties;
160 }
161
162
163 /**
164 * Get properties of this class.
165 *
166 * \param eqpars equation parameters
167 */
169 {
170 JProperties properties(eqpars,1);
171
172 properties.insert(gmake_property(primaryType));
173
174 return properties;
175 }
176
177
178 /**
179 * Read event category from input.
180 *
181 * \param in input stream
182 * \return input stream
183 */
184 virtual std::istream& read(std::istream& in)
185 {
186 using namespace JPP;
187
188 JStringStream is(in);
189
190 JProperties properties = getProperties();
191 is >> properties;
192
194
195 return in;
196 }
197
198
199 /**
200 * Write event category to output
201 *
202 *
203 * \param out output stream
204 * \return output stream
205 */
206 virtual std::ostream& write(std::ostream& out) const
207 {
208 return out << getProperties();
209 }
210
211
212 /**
213 * Read event category from input.
214 *
215 * \param in input stream
216 * \param object event category
217 * \return input stream
218 */
219 friend inline std::istream& operator>>(std::istream& in, JEvtCategory& object)
220 {
221 return object.read(in);
222 }
223
224
225 /**
226 * Write event category to output.
227 *
228 * \param out output stream
229 * \param object event category
230 * \return output stream
231 */
232 friend inline std::ostream& operator<<(std::ostream& out, const JEvtCategory& object)
233 {
234 return object.write(out);
235 }
236
237
238 protected:
239
240 int primaryType; //!< Event primary PDG type
241 };
242}
243
244#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Monte Carlo run header.
Definition JHead.hh:1236
Utility class to parse parameter values.
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
Exception for accessing a value in a collection that is outside of its range.
Extensions to Evt data format.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Low-level interface for event categories.
int primaryType
Event primary PDG type.
void check_validity() const
Check validity.
virtual std::istream & read(std::istream &in)
Read event category from input.
virtual JProperties getProperties(const JEquationParameters &eqpars=JEvtCategory::getEquationParameters())
Get properties of this class.
friend std::istream & operator>>(std::istream &in, JEvtCategory &object)
Read event category from input.
virtual JProperties getProperties(const JEquationParameters &eqpars=JEvtCategory::getEquationParameters()) const
Get properties of this class.
virtual std::ostream & write(std::ostream &out) const
Write event category to output.
friend std::ostream & operator<<(std::ostream &out, const JEvtCategory &object)
Write event category to output.
virtual bool match(const Evt &event) const =0
Check whether given event matches with this event category.
virtual ~JEvtCategory()
Virtual destructor.
virtual bool less(const JEvtCategory &category) const
Less-than method.
int getPrimaryType() const
Get primary PDG type of this event category.
virtual bool match(const JHead &header) const =0
Check whether given MC header matches with this event category.
JEvtCategory()
Default constructor.
static void setEquationParameters(const JEquationParameters &eqpars)
Set equation parameters.
virtual bool is_valid() const =0
Check if event category is valid.
static JEquationParameters & getEquationParameters()
Get equation parameters.
JEvtCategory(const int primaryType)
Constructor.
Template class for object cloning.
Definition JClonable.hh:59
Template definition of auxiliary base class for comparison of data structures.