Jpp 19.3.0-rc.3
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 "JSystem/JStat.hh"
13
14#include "JAAnet/JHead.hh"
15
16
17/**
18 * \author bjung
19 */
20
21namespace JAANET {}
22namespace JPP { using namespace JAANET; }
23
24namespace JAANET {
25
27
28 using JLANG::JClonable;
30
31
32 /**
33 * Low-level interface for event categories.
34 */
35 struct JEvtCategory :
36 public JClonable <JEvtCategory>,
37 public JComparable<JEvtCategory>
38 {
39 /**
40 * Default constructor.
41 */
44 {}
45
46
47 /**
48 * Constructor.
49 *
50 * \param primaryType primary PDG type
51 */
55
56
57 /**
58 * Virtual destructor.
59 */
60 virtual ~JEvtCategory()
61 {}
62
63
64 /**
65 * Check if event category is valid.
66 *
67 * \return true if event category is valid; else false
68 */
69 virtual bool is_valid() const = 0;
70
71
72 /**
73 * Check validity.
74 */
75 inline void check_validity() const
76 {
77 using namespace JPP;
78
79 if (!is_valid()) {
80 THROW(JValueOutOfRange, "JEvtCategory::check_validity(): Invalid category " << *this);
81 }
82 }
83
84
85 /**
86 * Check whether given MC header matches with this event category.
87 *
88 * \param header MC header
89 * \return true if matching; else false
90 */
91 virtual bool match(const JHead& header) const = 0;
92
93
94 /**
95 * Check whether given event matches with this event category.
96 *
97 * \param event event
98 * \return true if matching; else false
99 */
100 virtual bool match(const Evt& event) const = 0;
101
102
103 /**
104 * Less-than method.
105 *
106 * \param category event category
107 * \return true if this event category is less than given event category; else false
108 */
109 virtual inline bool less(const JEvtCategory& category) const
110 {
111 return this->primaryType < category.getPrimaryType();
112 }
113
114
115 /**
116 * Get primary PDG type of this event category.
117 *
118 * \return primary PDG type
119 */
120 int getPrimaryType() const
121 {
122 return primaryType;
123 }
124
125
126 /**
127 * Get equation parameters.
128 *
129 * \return equation parameters
130 */
132 {
133 static JEquationParameters eqpars("=", ",", "./", "#");
134
135 return eqpars;
136 }
137
138
139 /**
140 * Set equation parameters.
141 *
142 * \param eqpars equation parameters
143 */
144 static inline void setEquationParameters(const JEquationParameters& eqpars)
145 {
146 getEquationParameters() = eqpars;
147 }
148
149
150 /**
151 * Get properties of this class.
152 *
153 * \param eqpars equation parameters
154 */
156 {
157 JProperties properties(eqpars,1);
158
159 properties.insert(gmake_property(primaryType));
160
161 return properties;
162 }
163
164
165 /**
166 * Get properties of this class.
167 *
168 * \param eqpars equation parameters
169 */
171 {
172 JProperties properties(eqpars,1);
173
174 properties.insert(gmake_property(primaryType));
175
176 return properties;
177 }
178
179
180 /**
181 * Read event category from input.
182 *
183 * \param in input stream
184 * \return input stream
185 */
186 virtual std::istream& read(std::istream& in)
187 {
188 using namespace std;
189 using namespace JPP;
190
191 JStringStream is(in);
192
193 if (getFileStatus(is.str().c_str())) {
194 is.load();
195 }
196
197 JProperties properties = getProperties();
198 is >> properties;
199
201
202 return in;
203 }
204
205
206 /**
207 * Write event category to output
208 *
209 *
210 * \param out output stream
211 * \return output stream
212 */
213 virtual std::ostream& write(std::ostream& out) const
214 {
215 return out << getProperties();
216 }
217
218
219 /**
220 * Read event category from input.
221 *
222 * \param in input stream
223 * \param object event category
224 * \return input stream
225 */
226 friend inline std::istream& operator>>(std::istream& in, JEvtCategory& object)
227 {
228 return object.read(in);
229 }
230
231
232 /**
233 * Write event category to output.
234 *
235 * \param out output stream
236 * \param object event category
237 * \return output stream
238 */
239 friend inline std::ostream& operator<<(std::ostream& out, const JEvtCategory& object)
240 {
241 return object.write(out);
242 }
243
244
245 protected:
246
247 int primaryType; //!< Event primary PDG type
248 };
249}
250
251#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
File status.
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.
void load()
Load data from file with name corresponding to current contents.
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.