Jpp test-rotations-old
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.

Input syntax as follows:

      <oscprob_key>=<oscprob_value>[,<oscprob_key>=<oscprob_value>]...

      oscprob.<oscprob_key>=<oscprob_value>[,oscprob.<oscprob_key>=<oscprob_value>]...

      oscprob=<oscprob_file>

      <oscprob_file>

      <factor identifier> [<factor arguments> [& <factor identifier> [<factor arguments]]...];

where

  • <oscprob_key> refers to an oscillation probability calculator configuration key;
  • <oscprob_value> to an oscillation probability calculator configuration value;
  • <oscprob_file> to an oscillation probability calculator configuration file;
  • <factor identifier> 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

Definition at line 61 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 68 of file JEvtWeightFactorProduct.hh.

68 :
69 oscProb()
70 {}
JOscProbHelper oscProb
Oscillation probability calculator.

◆ JEvtWeightFactorProduct() [2/6]

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

Constructor.

Parameters
oscProboscillation probability calculator

Definition at line 78 of file JEvtWeightFactorProduct.hh.

78 :
80 {}

◆ JEvtWeightFactorProduct() [3/6]

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

Constructor.

Parameters
oscProboscillation probability calculator
factorevent-weight factor

Definition at line 89 of file JEvtWeightFactorProduct.hh.

90 :
92 {
93 this->push_back(factor);
94 }
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 105 of file JEvtWeightFactorProduct.hh.

107 :
109 {
110 this->push_back(factor, args...);
111 }

◆ JEvtWeightFactorProduct() [5/6]

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

Constructor.

Parameters
factorevent-weight factor

Definition at line 120 of file JEvtWeightFactorProduct.hh.

120 :
121 oscProb()
122 {
123 this->push_back(factor);
124 }

◆ 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 134 of file JEvtWeightFactorProduct.hh.

135 :
136 oscProb()
137 {
138 this->push_back(factor, args...);
139 }

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 147 of file JEvtWeightFactorProduct.hh.

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

◆ 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 166 of file JEvtWeightFactorProduct.hh.

168 {
169 push_back(factor);
170 push_back(args...);
171 }

◆ 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 180 of file JEvtWeightFactorProduct.hh.

181 {
182 this->insert(this->end(), product.begin(), product.end());
183
184 return (*this);
185 }

◆ getOscProb()

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

Get oscillation probability calculator.

Returns
oscillation probability calculator

Definition at line 193 of file JEvtWeightFactorProduct.hh.

194 {
195 return oscProb;
196 }

◆ 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 205 of file JEvtWeightFactorProduct.hh.

206 {
207 using namespace JPP;
208
209 if (oscProb) {
210
211 size_t n = 0;
212
213 this->oscProb = oscProb;
214
215 for (iterator i = this->begin(); i != this->end(); ++i) {
216
217 JEvtWeightFactorHelper& factor = *i;
218
219 if (!factor) { continue; }
220
221 JOscFlux* p = dynamic_cast<JOscFlux*>(factor.get());
222
223 if (p != NULL) {
224
226 ++n;
227
228 } else {
229
230 JOscProbHelper* q = dynamic_cast<JOscProbHelper*>(factor.get());
231
232 if (q != NULL) {
233 *q = oscProb;
234 ++n;
235 }
236 }
237 }
238
239 return n;
240
241 } else {
242
243 THROW(JNullPointerException, "JEvtWeightFactorProduct::setOscProb(): Given oscillation probability function is invalid.");
244 }
245 }
#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 254 of file JEvtWeightFactorProduct.hh.

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

◆ 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 273 of file JEvtWeightFactorProduct.hh.

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

◆ getProperties() [1/2]

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

Get properties of this class.

Parameters
eqparsequation parameters

Definition at line 288 of file JEvtWeightFactorProduct.hh.

289 {
290 return JEvtWeightFactorProductHelper(*this, eqpars);
291 }

◆ 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 299 of file JEvtWeightFactorProduct.hh.

300 {
301 return JEvtWeightFactorProductHelper(*this, eqpars);
302 }

◆ 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 311 of file JEvtWeightFactorProduct.hh.

312 {
313 using namespace std;
314 using namespace JPP;
315
316 static const JEvtWeightFactorDictionary dictionary(oscProb);
317
318 streampos pos = in.tellg();
319
320 // Optional loading of data from file
321
322 std::string buffer;
323 in >> buffer;
324
325 if (getFileStatus(buffer.c_str())) {
326
327 ifstream ifs(buffer.c_str());
328
329 read(ifs);
330
331 ifs.close();
332
333 return in;
334
335 } else {
336
337 in.clear();
338 in.seekg(pos);
339 }
340
341 // Read optional oscillation probability calculator configuration
342
343 in >> oscProb;
344
345 if (fail(in)) {
346
347 in.clear();
348 in.seekg(pos);
349 }
350
351 // Read event weight factors
352
353 for (JToken<'&'> token; in >> token; ) {
354
355 int factorID = 0;
356
357 istringstream iss(token);
358
359 if (!(iss >> factorID)) { continue; }
360
361 const JEvtWeightFactorHelper helper(dictionary.at(factorID).getFactor());
362
363 JEvtWeightFactor& factor = helper.getFactor();
364
365 iss >> factor;
366
367 push_back(helper);
368 }
369
370 return in;
371 }
Wrapper class around string.
Definition JToken.hh:26
bool fail(std::istream &in)
Check for stream state.
Definition JParser.hh:98
std::istream & read(std::istream &in) override final
Read event-weight factor product from stream.

◆ 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 380 of file JEvtWeightFactorProduct.hh.

381 {
382 return out << getProperties(JEquationParameters("=", "\n", "./", "#"));
383 }
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 425 of file JEvtWeightFactorProduct.hh.


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