Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JAANET::JEvtWeightFactorTFormula Class Referenceabstract

Base class implementation for reweighting factor for simulated events according to a specifiable ROOT TFormula. More...

#include <JEvtWeightFactorTFormula.hh>

Inheritance diagram for JAANET::JEvtWeightFactorTFormula:
JAANET::JEvtWeightFactor JLANG::JClonable< JClonable_t, JDerived_t >

Classes

struct  JEvtWeightFactorTFormulaExpression
 Auxiliary class for I/O of TFormula expression. More...
 
struct  JEvtWeightFactorTFormulaHelper
 Auxiliary class for I/O of TFormula-based event-weight factor. More...
 

Public Types

typedef JClonable< JClonable_t >::clone_type clone_type
 

Public Member Functions

 JEvtWeightFactorTFormula ()
 Default constructor.
 
 ~JEvtWeightFactorTFormula ()
 Virtual destructor.
 
void load (const char *const formula)
 Compile given formula.
 
void load ()
 Compile currently stored formula.
 
bool is_valid () const override
 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 from input.
 
virtual double getFactor (const Evt &evt) const =0
 Get event-weight factor of given event.
 
double operator() (const Evt &evt) const
 Get event-weight factor of given event.
 
void check_validity () const
 Check validity of this event-weight factor.
 
virtual std::ostream & write (std::ostream &out) const
 Write event-weight factor to output.
 
virtual clone_type clone () const override
 Get clone of this object.
 

Static Public Member Functions

static const std::string getFormulaKey ()
 Get formula keyword.
 
static const char *const getTypeKey ()
 Get type keyword.
 
static JEquationParametersgetEquationParameters ()
 Get equation parameters.
 
static void setEquationParameters (const JEquationParameters &eqpars)
 Set equation parameters.
 

Private Attributes

JLoadProperty< JEvtWeightFactorTFormula, JEvtWeightFactorTFormulaExpressionbuffer
 Formula expression.
 

Detailed Description

Base class implementation for reweighting factor for simulated events according to a specifiable ROOT TFormula.

Definition at line 37 of file JEvtWeightFactorTFormula.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

◆ JEvtWeightFactorTFormula()

JAANET::JEvtWeightFactorTFormula::JEvtWeightFactorTFormula ( )
inline

Default constructor.

Definition at line 46 of file JEvtWeightFactorTFormula.hh.

46 :
47 buffer(*this)
48 {}
JLoadProperty< JEvtWeightFactorTFormula, JEvtWeightFactorTFormulaExpression > buffer
Formula expression.

◆ ~JEvtWeightFactorTFormula()

JAANET::JEvtWeightFactorTFormula::~JEvtWeightFactorTFormula ( )
inline

Virtual destructor.

Definition at line 54 of file JEvtWeightFactorTFormula.hh.

55 {}

Member Function Documentation

◆ getFormulaKey()

static const std::string JAANET::JEvtWeightFactorTFormula::getFormulaKey ( )
inlinestatic

Get formula keyword.

Returns
formula keyword

Definition at line 63 of file JEvtWeightFactorTFormula.hh.

64 {
65 return "formula";
66 }

◆ load() [1/2]

void JAANET::JEvtWeightFactorTFormula::load ( const char *const formula)
inline

Compile given formula.

Parameters
formulaformula

Definition at line 74 of file JEvtWeightFactorTFormula.hh.

75 {
76 this->Clear();
77
78 if (this->Compile(formula)) {
79 THROW(JValueOutOfRange, "JEvtWeightFactorTFormula::load(): Could not compile formula: " << formula);
80 }
81 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

◆ load() [2/2]

void JAANET::JEvtWeightFactorTFormula::load ( )
inline

Compile currently stored formula.

Definition at line 87 of file JEvtWeightFactorTFormula.hh.

88 {
89 if (!buffer.empty()) {
90 load(buffer.c_str());
91 }
92 }
void load()
Compile currently stored formula.

◆ is_valid()

bool JAANET::JEvtWeightFactorTFormula::is_valid ( ) const
inlineoverridevirtual

Check whether this event-weight factor is valid.

Returns
true if valid; else false

Reimplemented from JAANET::JEvtWeightFactor.

Definition at line 100 of file JEvtWeightFactorTFormula.hh.

101 {
102 return this->IsValid();
103 }

◆ getProperties() [1/2]

JProperties JAANET::JEvtWeightFactorTFormula::getProperties ( const JEquationParameters & eqpars = JEvtWeightFactor::getEquationParameters())
inlinefinaloverridevirtual

Get properties of this class.

Parameters
eqparsequation parameters

Reimplemented from JAANET::JEvtWeightFactor.

Definition at line 111 of file JEvtWeightFactorTFormula.hh.

112 {
113 return JEvtWeightFactorTFormulaHelper(*this, eqpars);
114 }

◆ getProperties() [2/2]

JProperties JAANET::JEvtWeightFactorTFormula::getProperties ( const JEquationParameters & eqpars = JEvtWeightFactor::getEquationParameters()) const
inlinefinaloverridevirtual

Get properties of this class.

Parameters
eqparsequation parameters

Reimplemented from JAANET::JEvtWeightFactor.

Definition at line 122 of file JEvtWeightFactorTFormula.hh.

123 {
124 return JEvtWeightFactorTFormulaHelper(*this, eqpars);
125 }

◆ read()

std::istream & JAANET::JEvtWeightFactorTFormula::read ( std::istream & in)
inlinefinaloverridevirtual

Read event-weight factor from input.

Parameters
ininput stream
Returns
input stream

Reimplemented from JAANET::JEvtWeightFactor.

Definition at line 134 of file JEvtWeightFactorTFormula.hh.

135 {
136 using namespace std;
137
138 this->Clear();
139
140 streampos pos = in.tellg();
141
142 JProperties properties = getProperties();
143 in >> properties;
144
145 this->load();
146
147 in.clear(); // Rewind to read parameters
148 in.seekg(pos);
149
150 properties = getProperties();
151
152 in >> properties;
153
155
156 return in;
157 }
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
Utility class to parse parameter values.
void check_validity() const
Check validity of this event-weight factor.

◆ getTypeKey()

static const char *const JAANET::JEvtWeightFactor::getTypeKey ( )
inlinestaticinherited

Get type keyword.

Returns
type keyword

Definition at line 45 of file JEvtWeightFactor.hh.

46 {
47 return "type";
48 }

◆ getFactor()

virtual double JAANET::JEvtWeightFactor::getFactor ( const Evt & evt) const
pure virtualinherited

Get event-weight factor of given event.

Parameters
evtevent
Returns
event-weight factor

Implemented in JAANET::JDiffuseFlux.

◆ operator()()

double JAANET::JEvtWeightFactor::operator() ( const Evt & evt) const
inlineinherited

Get event-weight factor of given event.

Parameters
evtevent
Returns
event-weight factor

Definition at line 66 of file JEvtWeightFactor.hh.

67 {
68 return getFactor(evt);
69 }
virtual double getFactor(const Evt &evt) const =0
Get event-weight factor of given event.

◆ check_validity()

void JAANET::JEvtWeightFactor::check_validity ( ) const
inlineinherited

Check validity of this event-weight factor.

Definition at line 86 of file JEvtWeightFactor.hh.

87 {
88 using namespace JPP;
89
90 if (!is_valid()) {
91 THROW(JValueOutOfRange, "JEvtWeightFactor:check_validity(): Invalid event-weight factor " << *this);
92 }
93 }
Exception for accessing a value in a collection that is outside of its range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
virtual bool is_valid() const
Check whether this event-weight factor is valid.

◆ getEquationParameters()

static JEquationParameters & JAANET::JEvtWeightFactor::getEquationParameters ( )
inlinestaticinherited

Get equation parameters.

Returns
equation parameters

Definition at line 101 of file JEvtWeightFactor.hh.

102 {
103 static JEquationParameters equation("=", ",\n\r,", "./", "#");
104
105 return equation;
106 }
Simple data structure to support I/O of equations (see class JLANG::JEquation).

◆ setEquationParameters()

static void JAANET::JEvtWeightFactor::setEquationParameters ( const JEquationParameters & eqpars)
inlinestaticinherited

Set equation parameters.

Parameters
eqparsequation parameters

Definition at line 114 of file JEvtWeightFactor.hh.

115 {
116 getEquationParameters() = eqpars;
117 }
static JEquationParameters & getEquationParameters()
Get equation parameters.

◆ write()

virtual std::ostream & JAANET::JEvtWeightFactor::write ( std::ostream & out) const
inlinevirtualinherited

Write event-weight factor to output.

Parameters
outoutput stream
Returns
output stream

Definition at line 174 of file JEvtWeightFactor.hh.

175 {
176 return out << getProperties();
177 }
virtual JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters())
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

◆ buffer

JLoadProperty<JEvtWeightFactorTFormula, JEvtWeightFactorTFormulaExpression> JAANET::JEvtWeightFactorTFormula::buffer
private

Formula expression.

Definition at line 244 of file JEvtWeightFactorTFormula.hh.


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