![]() |
|
|||
File indexing completed on 2025-04-02 08:47:06
0001 /** 0002 \file 0003 Declaration of class Smear::FormulaString. 0004 0005 \author Michael Savastio 0006 \date 2011-08-19 0007 \copyright 2011 Brookhaven National Lab 0008 */ 0009 0010 #ifndef INCLUDE_EICSMEAR_SMEAR_FORMULASTRING_H_ 0011 #define INCLUDE_EICSMEAR_SMEAR_FORMULASTRING_H_ 0012 0013 #include <string> 0014 #include <vector> 0015 0016 #include <TObject.h> 0017 0018 #include "eicsmear/smear/Smear.h" // For KinType enum 0019 0020 class TFormula; 0021 0022 namespace Smear { 0023 0024 /** 0025 A formula described by a string with up to four variables. 0026 */ 0027 class FormulaString : public TObject { 0028 public: 0029 /** 0030 Destructor. 0031 */ 0032 virtual ~FormulaString(); 0033 0034 /** 0035 Default construtor. 0036 Only present to meet ROOT requirements for objects to have a default 0037 constructor. 0038 Always evaluates to zero. 0039 */ 0040 FormulaString(); 0041 0042 /** 0043 Initialise with a string describing the formula. 0044 Formula syntax is as for ROOT::TFormula. 0045 Valid variable names are: 0046 <ul> 0047 <li>"E"</li> 0048 <li>"P"</li> 0049 <li>"theta"</li> 0050 <li>"phi"</li> 0051 <li>"pZ"</li> 0052 <li>"pT"</li> 0053 </ul> 0054 Variable names ARE case sensitive. 0055 Energy (momentum) are in GeV(/c), angles are in radians. 0056 e.g. for the function p/sin(theta) 0057 Smear::FormulaString("P/sin(theta)"); 0058 */ 0059 explicit FormulaString(const std::string&); 0060 0061 /** 0062 Evaluate the formula with the provided arguments. 0063 Arguments should be listed in the order they were 0064 named in the constructor string. 0065 e.g. if the input function was "P/sin(theta)" pass a vector with 0066 element 0 == 0.5 and element 1 == 3 to evaluate at P == 0.5 and 0067 theta == 3. 0068 */ 0069 virtual double Eval(const std::vector<double>&) const; 0070 0071 /** 0072 Returns a vector of Smear::KinType corresponding to the variables 0073 named in the constructor string. 0074 e.g. If initialised with "P/sin(theta)", would result in a vector with 0075 two elements: kP, kTheta. 0076 */ 0077 virtual std::vector<Smear::KinType> Variables() const; 0078 0079 /** 0080 Returns the processed formula string with variables substituted. 0081 */ 0082 virtual std::string GetString() const; 0083 0084 /** 0085 Returns the unprocessed input formula string. 0086 */ 0087 virtual std::string GetInputString() const; 0088 0089 /** 0090 Returns the name corresponding the a Smear::KinType. 0091 */ 0092 static std::string GetKinName(KinType); 0093 0094 /** 0095 Returns the KinType corresponding to the variable name, 0096 or kInvalidKinType if the name is invalid. 0097 */ 0098 static KinType GetKinType(const std::string&); 0099 0100 protected: 0101 /** 0102 Process the input string, containing "P", "theta" etc into a version 0103 with "x", "y", "z", "t" substituted, compatible with TFormula. 0104 */ 0105 std::string Parse(const std::string&); 0106 0107 TFormula* mFormula; 0108 std::string mInput; ///< Original formula (before parsing) 0109 std::vector<Smear::KinType> mVariables; 0110 0111 ClassDef(Smear::FormulaString, 1) 0112 }; 0113 0114 } // namespace Smear 0115 0116 #endif // INCLUDE_EICSMEAR_SMEAR_FORMULASTRING_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |