Functions can now not only operate on parameters and maps but also on meta information
obtained from the data files. Currently the following meta information can be accessed if available: field in (G): B or b energy in (keV): En or en temperature in (K): since some data files contain a vector of temperature, they have to be accessed with an index, like T0 or t0, etc.
This commit is contained in:
@ -44,6 +44,7 @@
|
||||
|
||||
#include <TString.h>
|
||||
|
||||
#include "PMusr.h"
|
||||
#include "PFunctionGrammar.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -79,7 +80,7 @@ typedef struct func_tree_node {
|
||||
Int_t fOperatorTag; ///< tag for '+', '-', '*', '/'
|
||||
Int_t fFunctionTag; ///< tag got "cos", "sin", ...
|
||||
Int_t fIvalue; ///< for parameter numbers and maps
|
||||
Bool_t fSign; ///< for sign, true means '-', false '+'
|
||||
Bool_t fSign; ///< for sign, true means '-', false '+'
|
||||
Double_t fDvalue; ///< for numbers
|
||||
std::vector<func_tree_node> children; ///< holding sub-tree
|
||||
} PFuncTreeNode;
|
||||
@ -96,7 +97,7 @@ class PFunction {
|
||||
virtual Bool_t IsValid() { return fValid; }
|
||||
virtual Int_t GetFuncNo() { return fFuncNo; }
|
||||
virtual Bool_t CheckMapAndParamRange(UInt_t mapSize, UInt_t paramSize);
|
||||
virtual Double_t Eval(std::vector<Double_t> param);
|
||||
virtual Double_t Eval(std::vector<Double_t> param, PMetaData metaData);
|
||||
virtual void SetMap(std::vector<Int_t> map) { fMap = map; }
|
||||
|
||||
virtual TString* GetFuncString() { return &fFuncString; }
|
||||
@ -124,6 +125,8 @@ class PFunction {
|
||||
virtual void EvalTreeForString(tree_parse_info<> info);
|
||||
virtual void EvalTreeForStringExpression(iter_t const& i);
|
||||
TString fFuncString; ///< clear text representation of the function
|
||||
|
||||
PMetaData fMetaData; ///< keeps meta data from data files (field, energy, temperature, ...)
|
||||
};
|
||||
|
||||
#endif // _PFUNCTION_H_
|
||||
|
@ -57,15 +57,18 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
|
||||
static const int realID = 1;
|
||||
static const int constPiID = 2;
|
||||
static const int constGammaMuID = 3;
|
||||
static const int funLabelID = 4;
|
||||
static const int parameterID = 5;
|
||||
static const int mapID = 6;
|
||||
static const int functionID = 7;
|
||||
static const int powerID = 8;
|
||||
static const int factorID = 9;
|
||||
static const int termID = 10;
|
||||
static const int expressionID = 11;
|
||||
static const int assignmentID = 12;
|
||||
static const int constFieldID = 4;
|
||||
static const int constEnergyID = 5;
|
||||
static const int constTempID = 6;
|
||||
static const int funLabelID = 7;
|
||||
static const int parameterID = 8;
|
||||
static const int mapID = 9;
|
||||
static const int functionID = 10;
|
||||
static const int powerID = 11;
|
||||
static const int factorID = 12;
|
||||
static const int termID = 13;
|
||||
static const int expressionID = 14;
|
||||
static const int assignmentID = 15;
|
||||
|
||||
template <typename ScannerT>
|
||||
struct definition
|
||||
@ -79,6 +82,12 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
|
||||
|
||||
const_gamma_mu = leaf_node_d[ str_p("GAMMA_MU") ];
|
||||
|
||||
const_field = leaf_node_d[ str_p("B") ];
|
||||
|
||||
const_energy = leaf_node_d[ str_p("EN") ];
|
||||
|
||||
const_temp = leaf_node_d[ ( lexeme_d[ "T" >> +digit_p ] ) ];
|
||||
|
||||
fun_label = leaf_node_d[ ( lexeme_d[ "FUN" >> +digit_p ] ) ];
|
||||
|
||||
parameter = leaf_node_d[ ( lexeme_d[ "PAR" >> +digit_p ] ) |
|
||||
@ -110,6 +119,9 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
|
||||
factor = real
|
||||
| const_pi
|
||||
| const_gamma_mu
|
||||
| const_field
|
||||
| const_energy
|
||||
| const_temp
|
||||
| parameter
|
||||
| map
|
||||
| function
|
||||
@ -134,6 +146,9 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
|
||||
BOOST_SPIRIT_DEBUG_RULE(real);
|
||||
BOOST_SPIRIT_DEBUG_RULE(const_pi);
|
||||
BOOST_SPIRIT_DEBUG_RULE(const_gamma_mu);
|
||||
BOOST_SPIRIT_DEBUG_RULE(const_field);
|
||||
BOOST_SPIRIT_DEBUG_RULE(const_energy);
|
||||
BOOST_SPIRIT_DEBUG_RULE(const_temp);
|
||||
BOOST_SPIRIT_DEBUG_RULE(fun_label);
|
||||
BOOST_SPIRIT_DEBUG_RULE(parameter);
|
||||
BOOST_SPIRIT_DEBUG_RULE(map);
|
||||
@ -154,6 +169,9 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
|
||||
rule<ScannerT, parser_context<>, parser_tag<mapID> > map;
|
||||
rule<ScannerT, parser_context<>, parser_tag<parameterID> > parameter;
|
||||
rule<ScannerT, parser_context<>, parser_tag<funLabelID> > fun_label;
|
||||
rule<ScannerT, parser_context<>, parser_tag<constTempID> > const_temp;
|
||||
rule<ScannerT, parser_context<>, parser_tag<constEnergyID> > const_energy;
|
||||
rule<ScannerT, parser_context<>, parser_tag<constFieldID> > const_field;
|
||||
rule<ScannerT, parser_context<>, parser_tag<constGammaMuID> > const_gamma_mu;
|
||||
rule<ScannerT, parser_context<>, parser_tag<constPiID> > const_pi;
|
||||
rule<ScannerT, parser_context<>, parser_tag<realID> > real;
|
||||
|
@ -51,7 +51,7 @@ class PFunctionHandler
|
||||
virtual Bool_t IsValid() { return fValid; }
|
||||
virtual Bool_t DoParse();
|
||||
virtual Bool_t CheckMapAndParamRange(UInt_t mapSize, UInt_t paramSize);
|
||||
virtual double Eval(Int_t funNo, std::vector<Int_t> map, std::vector<double> param);
|
||||
virtual double Eval(Int_t funNo, std::vector<Int_t> map, std::vector<double> param, PMetaData metaData);
|
||||
virtual Int_t GetFuncNo(UInt_t idx);
|
||||
virtual Int_t GetFuncIndex(Int_t funcNo);
|
||||
virtual UInt_t GetNoOfFuncs() { return fFuncs.size(); }
|
||||
|
@ -93,9 +93,8 @@ class PMsrHandler
|
||||
virtual UInt_t GetFuncIndex(Int_t funNo) { return fFuncHandler->GetFuncIndex(funNo); }
|
||||
virtual Bool_t CheckMapAndParamRange(UInt_t mapSize, UInt_t paramSize)
|
||||
{ return fFuncHandler->CheckMapAndParamRange(mapSize, paramSize); }
|
||||
virtual Double_t EvalFunc(UInt_t i, std::vector<Int_t> map, std::vector<Double_t> param)
|
||||
{ return fFuncHandler->Eval(i,map,param); }
|
||||
|
||||
virtual Double_t EvalFunc(UInt_t i, std::vector<Int_t> map, std::vector<Double_t> param, PMetaData metaData)
|
||||
{ return fFuncHandler->Eval(i, map, param, metaData); }
|
||||
virtual UInt_t GetNoOfFitParameters(UInt_t idx);
|
||||
virtual Int_t ParameterInUse(UInt_t paramNo);
|
||||
virtual Bool_t CheckRunBlockIntegrity();
|
||||
|
@ -212,6 +212,16 @@ typedef std::vector<TString> PStringVector;
|
||||
*/
|
||||
enum EPMusrHandleTag { kEmpty, kFit, kView };
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>keep a couple of meta data for the FUNCTIONS.
|
||||
*/
|
||||
struct PMetaData {
|
||||
Double_t fField; ///< field in (G)
|
||||
Double_t fEnergy; ///< energy in (keV)
|
||||
PDoubleVector fTemp; ///< temperature(s) in (K)
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------
|
||||
/**
|
||||
* <p>Handles the data which will be fitted, i.e. packed, background corrected, ...
|
||||
|
@ -73,8 +73,7 @@ class PRunBase
|
||||
|
||||
PRunData fData; ///< data to be fitted, viewed, i.e. binned data
|
||||
Double_t fTimeResolution; ///< time resolution in (us)
|
||||
Double_t fField; ///< field from the meta-data of the data file
|
||||
PDoubleVector fTemp; ///< temperature(s) from the meta-data of the data file : first = temp, second = std. dev. of the temperature
|
||||
PMetaData fMetaData; ///< keeps the meta data from the data file like field, temperature, energy, ...
|
||||
PDoubleVector fT0s; ///< all t0 bins of a run! The derived classes will handle it.
|
||||
std::vector<PDoubleVector> fAddT0s; ///< all t0 bins of all addrun's of a run! The derived classes will handle it.
|
||||
|
||||
|
Reference in New Issue
Block a user