Jpp master_rocky-44-g75b7c4f75
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  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 compile (const char *const formula)
 Compile given formula.
 
void compile ()
 Compile currently stored formula.
 
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.
 
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::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.
 

Protected Member Functions

TFormula & getFormula ()
 Retrieve TFormula.
 
const TFormula & getFormula () const
 Retrieve TFormula.
 

Detailed Description

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

Definition at line 33 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 42 of file JEvtWeightFactorTFormula.hh.

43 {}

◆ ~JEvtWeightFactorTFormula()

JAANET::JEvtWeightFactorTFormula::~JEvtWeightFactorTFormula ( )
inline

Virtual destructor.

Definition at line 49 of file JEvtWeightFactorTFormula.hh.

50 {}

Member Function Documentation

◆ getFormulaKey()

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

Get formula keyword.

Returns
formula keyword

Definition at line 58 of file JEvtWeightFactorTFormula.hh.

59 {
60 return "formula";
61 }

◆ compile() [1/2]

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

Compile given formula.

Parameters
formulaformula

Definition at line 69 of file JEvtWeightFactorTFormula.hh.

70 {
71 this->Clear();
72
73 if (this->Compile(formula)) {
74 THROW(JValueOutOfRange, "JEvtWeightFactorTFormula::compile(): Could not compile formula: " << formula);
75 }
76
77 this->check_validity();
78 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
void check_validity() const
Check validity of this event-weight factor.

◆ compile() [2/2]

void JAANET::JEvtWeightFactorTFormula::compile ( )
inline

Compile currently stored formula.

Definition at line 84 of file JEvtWeightFactorTFormula.hh.

85 {
86 compile(this->GetExpFormula());
87 }
void compile()
Compile currently stored formula.

◆ 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 95 of file JEvtWeightFactorTFormula.hh.

96 {
97 return JEvtWeightFactorTFormulaHelper(*this, eqpars);
98 }

◆ 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 106 of file JEvtWeightFactorTFormula.hh.

107 {
108 return JEvtWeightFactorTFormulaHelper(*this, eqpars);
109 }

◆ 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 118 of file JEvtWeightFactorTFormula.hh.

119 {
120 using namespace std;
121
122 this->Clear();
123
124 streampos pos = in.tellg();
125
126 JProperties properties = getProperties();
127 in >> properties;
128
129 this->compile();
130
131 in.clear(); // Rewind to read parameters
132 in.seekg(pos);
133
134 properties = getProperties();
135 in >> properties;
136
137 return in;
138 }
JProperties getProperties(const JEquationParameters &eqpars=JEvtWeightFactor::getEquationParameters()) override final
Get properties of this class.
Utility class to parse parameter values.

◆ getFormula() [1/2]

TFormula & JAANET::JEvtWeightFactorTFormula::getFormula ( )
inlineprotected

Retrieve TFormula.

Returns
TFormula

Definition at line 148 of file JEvtWeightFactorTFormula.hh.

149 {
150 return static_cast<TFormula&>(*this);
151 }

◆ getFormula() [2/2]

const TFormula & JAANET::JEvtWeightFactorTFormula::getFormula ( ) const
inlineprotected

Retrieve TFormula.

Returns
TFormula

Definition at line 159 of file JEvtWeightFactorTFormula.hh.

160 {
161 return static_cast<const TFormula&>(*this);
162 }

◆ 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.

◆ is_valid()

virtual bool JAANET::JEvtWeightFactor::is_valid ( ) const
inlinevirtualinherited

Check whether this event-weight factor is valid.

Returns
true if valid; else false

Definition at line 77 of file JEvtWeightFactor.hh.

78 {
79 return true;
80 }

◆ 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("=", ",", "./", "#");
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

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