Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JEvtWeightFactor.hh
Go to the documentation of this file.
1#ifndef __JAANET__JEVTWEIGHTFACTOR__
2#define __JAANET__JEVTWEIGHTFACTOR__
3
5
7
8#include "Jeep/JProperties.hh"
9
10#include "JLang/JClonable.hh"
11
12
13/**
14 * \author bjung
15 */
16
17namespace JAANET {}
18namespace JPP { using namespace JAANET; }
19
20namespace JAANET {
21
22 using JLANG::JClonable;
23
24
25 /**
26 * Abstract base class for specifiable event-weight factors.
27 */
29 public JClonable<JEvtWeightFactor>
30 {
31 /**
32 * Virtual destructor.
33 */
35 {}
36
37
38 /**
39 * Get type keyword.
40 *
41 * \return type keyword
42 */
43 static const char* const getTypeKey()
44 {
45 return "type";
46 }
47
48
49 /**
50 * Get event-weight factor of given event.
51 *
52 * \param evt event
53 * \return event-weight factor
54 */
55 virtual double getFactor(const Evt& evt) const = 0;
56
57
58 /**
59 * Get event-weight factor of given event.
60 *
61 * \param evt event
62 * \return event-weight factor
63 */
64 double operator()(const Evt& evt) const
65 {
66 return getFactor(evt);
67 }
68
69
70 /**
71 * Check whether this event-weight factor is valid.
72 *
73 * \return true if valid; else false
74 */
75 virtual bool is_valid() const
76 {
77 return true;
78 }
79
80
81 /**
82 * Check validity of this event-weight factor.
83 */
84 void check_validity() const
85 {
86 using namespace JPP;
87
88 if (!is_valid()) {
89 THROW(JValueOutOfRange, "JEvtWeightFactor:check_validity(): Invalid event-weight factor " << *this);
90 }
91 }
92
93
94 /**
95 * Get equation parameters.
96 *
97 * \return equation parameters
98 */
100 {
101 static JEquationParameters equation("=", ",\n\r,", "./", "#");
102
103 return equation;
104 }
105
106
107 /**
108 * Set equation parameters.
109 *
110 * \param eqpars equation parameters
111 */
112 static inline void setEquationParameters(const JEquationParameters& eqpars)
113 {
114 getEquationParameters() = eqpars;
115 }
116
117
118 /**
119 * Get properties of this class.
120 *
121 * \param eqpars equation parameters
122 */
124 {
125 return JProperties(eqpars,1);
126 }
127
128
129 /**
130 * Get properties of this class.
131 *
132 * \param eqpars equation parameters
133 */
135 {
136 return JProperties(eqpars,1);
137 }
138
139
140 /**
141 * Read event-weight factor from input.
142 *
143 * \param in input stream
144 * \return input stream
145 */
146 virtual std::istream& read(std::istream& in)
147 {
148 using namespace std;
149 using namespace JPP;
150
151 JStringStream is(in);
152
153 JProperties properties = getProperties();
154 is >> properties;
155
157
158 return in;
159 }
160
161
162 /**
163 * Write event-weight factor to output
164 *
165 * \param out output stream
166 * \return output stream
167 */
168 virtual std::ostream& write(std::ostream& out) const
169 {
170 return out << getProperties();
171 }
172
173
174 /**
175 * Read event category from input.
176 *
177 * \param in input stream
178 * \param object event category
179 * \return input stream
180 */
181 friend inline std::istream& operator>>(std::istream& in, JEvtWeightFactor& object)
182 {
183 return object.read(in);
184 }
185
186
187 /**
188 * Write event category to output.
189 *
190 * \param out output stream
191 * \param object event category
192 * \return output stream
193 */
194 friend inline std::ostream& operator<<(std::ostream& out, const JEvtWeightFactor& object)
195 {
196 return object.write(out);
197 }
198 };
199}
200
201#endif
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Utility class to parse parameter values.
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
Abstract base class for specifiable event-weight factors.
static void setEquationParameters(const JEquationParameters &eqpars)
Set equation parameters.
virtual JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const
Get properties of this class.
friend std::ostream & operator<<(std::ostream &out, const JEvtWeightFactor &object)
Write event category to output.
double operator()(const Evt &evt) const
Get event-weight factor of given event.
virtual ~JEvtWeightFactor()
Virtual destructor.
virtual JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters())
Get properties of this class.
virtual std::ostream & write(std::ostream &out) const
Write event-weight factor to output.
static const char *const getTypeKey()
Get type keyword.
virtual bool is_valid() const
Check whether this event-weight factor is valid.
void check_validity() const
Check validity of this event-weight factor.
virtual std::istream & read(std::istream &in)
Read event-weight factor from input.
friend std::istream & operator>>(std::istream &in, JEvtWeightFactor &object)
Read event category from input.
static JEquationParameters & getEquationParameters()
Get equation parameters.
virtual double getFactor(const Evt &evt) const =0
Get event-weight factor of given event.
Template class for object cloning.
Definition JClonable.hh:59