Jpp 19.3.0-rc.4
the software that should make you happy
Loading...
Searching...
No Matches
JAANET::JEvtWeightFactorProduct Struct Reference

Class for product of event-weight factors. More...

#include <JEvtWeightFactorProduct.hh>

Inheritance diagram for JAANET::JEvtWeightFactorProduct:
std::vector< JEvtWeightFactorHelper > JLANG::JClonable< JClonable_t, JDerived_t >

Classes

struct  JEvtWeightFactorProductHelper
 Auxiliary class for I/O of product of event-weight factors. More...
 

Public Types

typedef JClonable< JClonable_t >::clone_type clone_type
 

Public Member Functions

 JEvtWeightFactorProduct ()
 Default constructor.
 
 JEvtWeightFactorProduct (const JOscProbHelper &oscProb)
 Constructor.
 
 JEvtWeightFactorProduct (const JOscProbHelper &oscProb, const JEvtWeightFactorHelper &factor)
 Constructor.
 
template<class ... Args>
 JEvtWeightFactorProduct (const JOscProbHelper &oscProb, const JEvtWeightFactorHelper &factor, const Args &...args)
 Constructor.
 
 JEvtWeightFactorProduct (const JEvtWeightFactorHelper &factor)
 Constructor.
 
template<class ... Args>
 JEvtWeightFactorProduct (const JEvtWeightFactorHelper &factor, const Args &...args)
 Constructor.
 
void push_back (const JEvtWeightFactorHelper &factor)
 Put event-weight factor.
 
template<class ... Args>
void push_back (const JEvtWeightFactorHelper &factor, const Args &...args)
 Put event-weight factor.
 
JEvtWeightFactorProductjoin (const JEvtWeightFactorProduct &product)
 Join this product of event-weight factors with a given product of event-weight factors.
 
const JOscProbHelpergetOscProb () const
 Get oscillation probability calculator.
 
size_t setOscProb (const JOscProbHelper &oscProb)
 Set oscillation probability calculator for all compatible event weight factors.
 
double getFactor (const Evt &evt) const override final
 Get multiplication factor of given event.
 
bool is_valid () const override final
 Check whether this event-weight factor is valid.
 
JProperties getProperties (const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
 Get properties of this class.
 
JProperties getProperties (const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) const override final
 Get properties of this class.
 
std::istream & read (std::istream &in) override final
 Read event-weight factor product from stream.
 
std::ostream & write (std::ostream &out) const override final
 Write event-weight factor to output.
 
virtual clone_type clone () const override
 Get clone of this object.
 

Private Attributes

JOscProbHelper oscProb
 Oscillation probability calculator.
 

Detailed Description

Class for product of event-weight factors.

The input syntax follows the following scheme:

[oscillation probabilities configuration] <factor>+,

in which:

  • oscillation probabilities configuration refers to an optional specification of the oscillation parameters, which can be given according to one of the following formats:
    1. <oscprob_file>,
    2. oscprob=<oscprob_file>,
    3. <oscprob_key>=<oscprob_value>[<end of line> <oscprob_key>=<oscprob_value>]+ or
    4. oscprob.<oscprob_key>=<oscprob_value>[<end of line> oscprob.<oscprob_key>=<oscprob_value>]+, where:
    • oscprob_key refers to an oscillation probability calculator configuration key;
    • oscprob_value to an oscillation probability calculator configuration value and
    • oscprob_file to an oscillation probability calculator configuration file with key-value pairs,
  • factor refers to a weighting factor, which needs to be specified according to the following format:
    1. <factor identifier> [<factor arguments> [ & <factor identifier> [<factor arguments] ]+ ];, where:
    • factor identifier refers to an event-weight factor identifier (c.f. JAANET::JEvtWeighFactorDictionary::factors); and
    • factor arguments to the list of arguments for the corresponding event-weight factor,
  • multiple weighting factors can be combined into one when specified as a group separated by the '&' character.

Definition at line 64 of file JEvtWeightFactorProduct.hh.

Member Typedef Documentation

◆ clone_type

template<class JClonable_t , class JDerived_t >
JClonable<JClonable_t>::clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone_type
inherited

Definition at line 61 of file JClonable.hh.

Constructor & Destructor Documentation

◆ JEvtWeightFactorProduct() [1/6]

JAANET::JEvtWeightFactorProduct::JEvtWeightFactorProduct ( )
inline

Default constructor.

Definition at line 71 of file JEvtWeightFactorProduct.hh.

71 :
72 oscProb()
73 {}
JOscProbHelper oscProb
Oscillation probability calculator.

◆ JEvtWeightFactorProduct() [2/6]

JAANET::JEvtWeightFactorProduct::JEvtWeightFactorProduct ( const JOscProbHelper & oscProb)
inline

Constructor.

Parameters
oscProboscillation probability calculator

Definition at line 81 of file JEvtWeightFactorProduct.hh.

81 :
83 {}

◆ JEvtWeightFactorProduct() [3/6]

JAANET::JEvtWeightFactorProduct::JEvtWeightFactorProduct ( const JOscProbHelper & oscProb,
const JEvtWeightFactorHelper & factor )
inline

Constructor.

Parameters
oscProboscillation probability calculator
factorevent-weight factor

Definition at line 92 of file JEvtWeightFactorProduct.hh.

93 :
95 {
96 this->push_back(factor);
97 }
void push_back(const JEvtWeightFactorHelper &factor)
Put event-weight factor.

◆ JEvtWeightFactorProduct() [4/6]

template<class ... Args>
JAANET::JEvtWeightFactorProduct::JEvtWeightFactorProduct ( const JOscProbHelper & oscProb,
const JEvtWeightFactorHelper & factor,
const Args &... args )
inline

Constructor.

Parameters
oscProboscillation probability calculator
factorevent-weight factor
argsremaining event-weight factors

Definition at line 108 of file JEvtWeightFactorProduct.hh.

110 :
112 {
113 this->push_back(factor, args...);
114 }

◆ JEvtWeightFactorProduct() [5/6]

JAANET::JEvtWeightFactorProduct::JEvtWeightFactorProduct ( const JEvtWeightFactorHelper & factor)
inline

Constructor.

Parameters
factorevent-weight factor

Definition at line 123 of file JEvtWeightFactorProduct.hh.

123 :
124 oscProb()
125 {
126 this->push_back(factor);
127 }

◆ JEvtWeightFactorProduct() [6/6]

template<class ... Args>
JAANET::JEvtWeightFactorProduct::JEvtWeightFactorProduct ( const JEvtWeightFactorHelper & factor,
const Args &... args )
inline

Constructor.

Parameters
factorevent-weight factor
argsremaining event-weight factors

Definition at line 137 of file JEvtWeightFactorProduct.hh.

138 :
139 oscProb()
140 {
141 this->push_back(factor, args...);
142 }

Member Function Documentation

◆ push_back() [1/2]

void JAANET::JEvtWeightFactorProduct::push_back ( const JEvtWeightFactorHelper & factor)
inline

Put event-weight factor.

Parameters
factorevent-weight factor

Definition at line 150 of file JEvtWeightFactorProduct.hh.

151 {
152 const JEvtWeightFactorProduct* p = dynamic_cast<const JEvtWeightFactorProduct*>(factor.get());
153
154 if (p != NULL) {
155 this->insert(this->end(), p->begin(), p->end());
156 } else {
158 }
159 }

◆ push_back() [2/2]

template<class ... Args>
void JAANET::JEvtWeightFactorProduct::push_back ( const JEvtWeightFactorHelper & factor,
const Args &... args )
inline

Put event-weight factor.

Parameters
factorevent-weight factor
argsremaining event-weight factors

Definition at line 169 of file JEvtWeightFactorProduct.hh.

171 {
172 push_back(factor);
173 push_back(args...);
174 }

◆ join()

JEvtWeightFactorProduct & JAANET::JEvtWeightFactorProduct::join ( const JEvtWeightFactorProduct & product)
inline

Join this product of event-weight factors with a given product of event-weight factors.

Parameters
productproduct of event-weight factors
Returns
joined product of event-weight factors

Definition at line 183 of file JEvtWeightFactorProduct.hh.

184 {
185 this->insert(this->end(), product.begin(), product.end());
186
187 return (*this);
188 }

◆ getOscProb()

const JOscProbHelper & JAANET::JEvtWeightFactorProduct::getOscProb ( ) const
inline

Get oscillation probability calculator.

Returns
oscillation probability calculator

Definition at line 196 of file JEvtWeightFactorProduct.hh.

197 {
198 return oscProb;
199 }

◆ setOscProb()

size_t JAANET::JEvtWeightFactorProduct::setOscProb ( const JOscProbHelper & oscProb)
inline

Set oscillation probability calculator for all compatible event weight factors.

Parameters
oscProboscillation probability calculator
Returns
number of modified event weighters

Definition at line 208 of file JEvtWeightFactorProduct.hh.

209 {
210 using namespace JPP;
211
212 if (oscProb) {
213
214 size_t n = 0;
215
216 this->oscProb = oscProb;
217
218 for (iterator i = this->begin(); i != this->end(); ++i) {
219
220 JEvtWeightFactorHelper& factor = *i;
221
222 if (!factor) { continue; }
223
224 JOscFlux* p = dynamic_cast<JOscFlux*>(factor.get());
225
226 if (p != NULL) {
227
229 ++n;
230
231 } else {
232
233 JOscProbHelper* q = dynamic_cast<JOscProbHelper*>(factor.get());
234
235 if (q != NULL) {
236 *q = oscProb;
237 ++n;
238 }
239 }
240 }
241
242 return n;
243
244 } else {
245
246 THROW(JNullPointerException, "JEvtWeightFactorProduct::setOscProb(): Given oscillation probability function is invalid.");
247 }
248 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for null pointer operation.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition JPolint.hh:791
Helper class for event-weight factor.
Implementation of oscillated neutrino flux.
Definition JOscFlux.hh:44
void setOscProb(const JOscProbHelper oscProb)
Set oscillation probability calculator.
Definition JOscFlux.hh:76
Helper class for oscillation probability calculators.

◆ getFactor()

double JAANET::JEvtWeightFactorProduct::getFactor ( const Evt & evt) const
inlinefinaloverride

Get multiplication factor of given event.

Parameters
evtevent
Returns
multiplication factor

Definition at line 257 of file JEvtWeightFactorProduct.hh.

258 {
259 using namespace std;
260
261 double factor = 1.0;
262
263 for (vector<JEvtWeightFactorHelper>::const_iterator i = this->cbegin(); i != this->cend(); ++i) {
264 factor *= i->getFactor(evt);
265 }
266
267 return factor;
268 }

◆ is_valid()

bool JAANET::JEvtWeightFactorProduct::is_valid ( ) const
inlinefinaloverride

Check whether this event-weight factor is valid.

Returns
true if valid; else false

Definition at line 276 of file JEvtWeightFactorProduct.hh.

277 {
278 for (const_iterator i = this->cbegin(); i != this->cend(); ++i) {
279 if (!(i->is_valid())) { return false; }
280 }
281
282 return true;
283 }

◆ getProperties() [1/2]

JProperties JAANET::JEvtWeightFactorProduct::getProperties ( const JEquationParameters & eqpars = JEvtWeightFactor::getEquationParameters())
inlinefinaloverride

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 291 of file JEvtWeightFactorProduct.hh.

292 {
293 return JEvtWeightFactorProductHelper(*this, eqpars);
294 }

◆ getProperties() [2/2]

JProperties JAANET::JEvtWeightFactorProduct::getProperties ( const JEquationParameters & eqpars = JEvtWeightFactor::getEquationParameters()) const
inlinefinaloverride

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 302 of file JEvtWeightFactorProduct.hh.

303 {
304 return JEvtWeightFactorProductHelper(*this, eqpars);
305 }

◆ read()

std::istream & JAANET::JEvtWeightFactorProduct::read ( std::istream & in)
inlinefinaloverride

Read event-weight factor product from stream.

Parameters
ininput stream
Returns
input stream

Definition at line 314 of file JEvtWeightFactorProduct.hh.

315 {
316 using namespace std;
317 using namespace JPP;
318
319 static const JEvtWeightFactorDictionary dictionary(oscProb);
320
321 JStringStream is(in);
322
323 if (getFileStatus(is.str().c_str())) {
324 is.load();
325 }
326
327 // Read event weight factors
328
329 for (JToken<'&'> token; is >> token; ) {
330
331 int factorID = 0;
332
333 istringstream iss(token);
334
335 const streampos poss = iss.tellg();
336
337 if (!(iss >> factorID)) { // Check if token corresponds to oscillation parameter set
338
339 iss.clear();
340 iss.seekg(poss);
341
342 iss >> oscProb;
343
344 if (fail(iss)) {
345 continue;
346 }
347 }
348
349 const JEvtWeightFactorHelper helper = dictionary[factorID];
350
351 JEvtWeightFactor& factor = helper.getFactor();
352
353 iss >> factor;
354
355 push_back(helper);
356 }
357
358 return in;
359 }
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
Wrapper class around string.
Definition JToken.hh:26
bool fail(std::istream &in)
Check for stream state.
Definition JParser.hh:98
JEvtWeightFactor & getFactor() const
Get reference to event-weight factor.

◆ write()

std::ostream & JAANET::JEvtWeightFactorProduct::write ( std::ostream & out) const
inlinefinaloverride

Write event-weight factor to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 368 of file JEvtWeightFactorProduct.hh.

369 {
370 return out << getProperties(JEquationParameters("=", "\n", "./", "#"));
371 }
Simple data structure to support I/O of equations (see class JLANG::JEquation).
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.

◆ clone()

template<class JClonable_t , class JDerived_t >
virtual clone_type JLANG::JClonable< JClonable_t, JDerived_t >::clone ( ) const
inlineoverridevirtualinherited

Member Data Documentation

◆ oscProb

JOscProbHelper JAANET::JEvtWeightFactorProduct::oscProb
private

Oscillation probability calculator.

Definition at line 413 of file JEvtWeightFactorProduct.hh.


The documentation for this struct was generated from the following file: