eic-smear  1.0.3
A collection of ROOT classes for Monte Carlo events and a fast-smearing code simulating detector effects for the Electron-Ion Collider task force
Smear::FormulaString Class Reference

A formula described by a string with up to four variables. More...

#include <FormulaString.h>

Inheritance diagram for Smear::FormulaString:

Public Member Functions

virtual ~FormulaString ()
 Destructor. More...
 
 FormulaString ()
 Default construtor. More...
 
 FormulaString (const std::string &)
 Initialise with a string describing the formula. More...
 
virtual double Eval (const std::vector< double > &) const
 Evaluate the formula with the provided arguments. More...
 
virtual std::vector< Smear::KinTypeVariables () const
 Returns a vector of Smear::KinType corresponding to the variables named in the constructor string. More...
 
virtual std::string GetString () const
 Returns the processed formula string with variables substituted. More...
 
virtual std::string GetInputString () const
 Returns the unprocessed input formula string. More...
 

Static Public Member Functions

static std::string GetKinName (KinType)
 Returns the name corresponding the a Smear::KinType. More...
 
static KinType GetKinType (const std::string &)
 Returns the KinType corresponding to the variable name, or kInvalidKinType if the name is invalid. More...
 

Protected Member Functions

std::string Parse (const std::string &)
 Process the input string, containing "P", "theta" etc into a version with "x", "y", "z", "t" substituted, compatible with TFormula. More...
 

Protected Attributes

TFormula * mFormula
 
std::string mInput
 Original formula (before parsing) More...
 
std::vector< Smear::KinTypemVariables
 

Detailed Description

A formula described by a string with up to four variables.

Definition at line 27 of file FormulaString.h.

Constructor & Destructor Documentation

◆ ~FormulaString()

Smear::FormulaString::~FormulaString ( )
virtual

Destructor.

Definition at line 68 of file FormulaString.cxx.

◆ FormulaString() [1/2]

Smear::FormulaString::FormulaString ( )

Default construtor.

Only present to meet ROOT requirements for objects to have a default constructor. Always evaluates to zero.

Definition at line 75 of file FormulaString.cxx.

◆ FormulaString() [2/2]

Smear::FormulaString::FormulaString ( const std::string &  formula)
explicit

Initialise with a string describing the formula.

Formula syntax is as for ROOT::TFormula. Valid variable names are:

  • "E"
  • "P"
  • "theta"
  • "phi"
  • "pZ"
  • "pT"

Variable names ARE case sensitive. Energy (momentum) are in GeV(/c), angles are in radians. e.g. for the function p/sin(theta) Smear::FormulaString("P/sin(theta)");

Definition at line 79 of file FormulaString.cxx.

Member Function Documentation

◆ Eval()

double Smear::FormulaString::Eval ( const std::vector< double > &  args) const
virtual

Evaluate the formula with the provided arguments.

Arguments should be listed in the order they were named in the constructor string. e.g. if the input function was "P/sin(theta)" pass a vector with element 0 == 0.5 and element 1 == 3 to evaluate at P == 0.5 and theta == 3.

Definition at line 86 of file FormulaString.cxx.

◆ GetInputString()

std::string Smear::FormulaString::GetInputString ( ) const
virtual

Returns the unprocessed input formula string.

Definition at line 141 of file FormulaString.cxx.

◆ GetKinName()

std::string Smear::FormulaString::GetKinName ( KinType  type)
static

Returns the name corresponding the a Smear::KinType.

Definition at line 153 of file FormulaString.cxx.

◆ GetKinType()

KinType Smear::FormulaString::GetKinType ( const std::string &  name)
static

Returns the KinType corresponding to the variable name, or kInvalidKinType if the name is invalid.

Definition at line 145 of file FormulaString.cxx.

◆ GetString()

std::string Smear::FormulaString::GetString ( ) const
virtual

Returns the processed formula string with variables substituted.

Definition at line 133 of file FormulaString.cxx.

◆ Parse()

std::string Smear::FormulaString::Parse ( const std::string &  formula)
protected

Process the input string, containing "P", "theta" etc into a version with "x", "y", "z", "t" substituted, compatible with TFormula.

Definition at line 102 of file FormulaString.cxx.

◆ Variables()

std::vector< KinType > Smear::FormulaString::Variables ( ) const
virtual

Returns a vector of Smear::KinType corresponding to the variables named in the constructor string.

e.g. If initialised with "P/sin(theta)", would result in a vector with two elements: kP, kTheta.

Definition at line 98 of file FormulaString.cxx.

Member Data Documentation

◆ mFormula

TFormula* Smear::FormulaString::mFormula
protected

Definition at line 107 of file FormulaString.h.

◆ mInput

std::string Smear::FormulaString::mInput
protected

Original formula (before parsing)

Definition at line 108 of file FormulaString.h.

◆ mVariables

std::vector<Smear::KinType> Smear::FormulaString::mVariables
protected

Definition at line 109 of file FormulaString.h.


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