added sign form parX for the FUNCTION block.
This commit is contained in:
@ -93,6 +93,24 @@ PFunction::~PFunction()
|
|||||||
CleanupFuncEvalTree();
|
CleanupFuncEvalTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// InitNode (protected)
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* \param node
|
||||||
|
*/
|
||||||
|
void PFunction::InitNode(PFuncTreeNode &node)
|
||||||
|
{
|
||||||
|
node.fID = 0;
|
||||||
|
node.fOperatorTag = 0;
|
||||||
|
node.fFunctionTag = 0;
|
||||||
|
node.fIvalue = 0;
|
||||||
|
node.fSign = false;
|
||||||
|
node.fDvalue = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
// SetFuncNo (protected)
|
// SetFuncNo (protected)
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
@ -135,6 +153,7 @@ Bool_t PFunction::SetFuncNo()
|
|||||||
*/
|
*/
|
||||||
Bool_t PFunction::GenerateFuncEvalTree()
|
Bool_t PFunction::GenerateFuncEvalTree()
|
||||||
{
|
{
|
||||||
|
InitNode(fFunc);
|
||||||
FillFuncEvalTree(fInfo.trees.begin(), fFunc);
|
FillFuncEvalTree(fInfo.trees.begin(), fFunc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -155,6 +174,8 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node)
|
|||||||
string str;
|
string str;
|
||||||
PFuncTreeNode child;
|
PFuncTreeNode child;
|
||||||
|
|
||||||
|
InitNode(child);
|
||||||
|
|
||||||
if (i->value.id() == PFunctionGrammar::realID) { // handle number
|
if (i->value.id() == PFunctionGrammar::realID) { // handle number
|
||||||
str = string(i->value.begin(), i->value.end()); // get string
|
str = string(i->value.begin(), i->value.end()); // get string
|
||||||
status = sscanf(str.c_str(), "%lf", &dvalue); // convert string to Double_t
|
status = sscanf(str.c_str(), "%lf", &dvalue); // convert string to Double_t
|
||||||
@ -169,7 +190,12 @@ void PFunction::FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node)
|
|||||||
node.fDvalue = 0.0135538817; // keep the value
|
node.fDvalue = 0.0135538817; // keep the value
|
||||||
} else if (i->value.id() == PFunctionGrammar::parameterID) { // handle parameter number
|
} else if (i->value.id() == PFunctionGrammar::parameterID) { // handle parameter number
|
||||||
str = string(i->value.begin(), i->value.end()); // get string
|
str = string(i->value.begin(), i->value.end()); // get string
|
||||||
status = sscanf(str.c_str(), "PAR%d", &ivalue); // convert string to parameter number
|
if (strstr(str.c_str(), "-")) {
|
||||||
|
node.fSign = true;
|
||||||
|
status = sscanf(str.c_str(), "-PAR%d", &ivalue); // convert string to parameter number
|
||||||
|
} else {
|
||||||
|
status = sscanf(str.c_str(), "PAR%d", &ivalue); // convert string to parameter number
|
||||||
|
}
|
||||||
node.fID = PFunctionGrammar::parameterID; // keep the ID
|
node.fID = PFunctionGrammar::parameterID; // keep the ID
|
||||||
node.fIvalue = ivalue; // keep the value
|
node.fIvalue = ivalue; // keep the value
|
||||||
// cout << endl << ">> parameterID: value = " << ivalue;
|
// cout << endl << ">> parameterID: value = " << ivalue;
|
||||||
@ -373,7 +399,12 @@ Double_t PFunction::EvalNode(PFuncTreeNode &node)
|
|||||||
} else if (node.fID == PFunctionGrammar::constGammaMuID) {
|
} else if (node.fID == PFunctionGrammar::constGammaMuID) {
|
||||||
return node.fDvalue;
|
return node.fDvalue;
|
||||||
} else if (node.fID == PFunctionGrammar::parameterID) {
|
} else if (node.fID == PFunctionGrammar::parameterID) {
|
||||||
return fParam[node.fIvalue-1];
|
Double_t dval;
|
||||||
|
if (node.fSign)
|
||||||
|
dval = -fParam[node.fIvalue-1];
|
||||||
|
else
|
||||||
|
dval = fParam[node.fIvalue-1];
|
||||||
|
return dval;
|
||||||
} else if (node.fID == PFunctionGrammar::mapID) {
|
} else if (node.fID == PFunctionGrammar::mapID) {
|
||||||
if (fMap[node.fIvalue-1] == 0) // map == 0
|
if (fMap[node.fIvalue-1] == 0) // map == 0
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
@ -76,6 +76,7 @@ typedef struct func_tree_node {
|
|||||||
Int_t fOperatorTag; ///< tag for '+', '-', '*', '/'
|
Int_t fOperatorTag; ///< tag for '+', '-', '*', '/'
|
||||||
Int_t fFunctionTag; ///< tag got "cos", "sin", ...
|
Int_t fFunctionTag; ///< tag got "cos", "sin", ...
|
||||||
Int_t fIvalue; ///< for parameter numbers and maps
|
Int_t fIvalue; ///< for parameter numbers and maps
|
||||||
|
Bool_t fSign; ///< for sign, true means '-', false '+'
|
||||||
Double_t fDvalue; ///< for numbers
|
Double_t fDvalue; ///< for numbers
|
||||||
vector<func_tree_node> children; ///< holding sub-tree
|
vector<func_tree_node> children; ///< holding sub-tree
|
||||||
} PFuncTreeNode;
|
} PFuncTreeNode;
|
||||||
@ -95,6 +96,7 @@ class PFunction {
|
|||||||
virtual TString* GetFuncString() { return &fFuncString; }
|
virtual TString* GetFuncString() { return &fFuncString; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void InitNode(PFuncTreeNode &node);
|
||||||
virtual Bool_t SetFuncNo();
|
virtual Bool_t SetFuncNo();
|
||||||
|
|
||||||
virtual Bool_t FindAndCheckMapAndParamRange(PFuncTreeNode &node, UInt_t mapSize, UInt_t paramSize);
|
virtual Bool_t FindAndCheckMapAndParamRange(PFuncTreeNode &node, UInt_t mapSize, UInt_t paramSize);
|
||||||
|
@ -85,7 +85,8 @@ struct PFunctionGrammar : public grammar<PFunctionGrammar>
|
|||||||
|
|
||||||
fun_label = leaf_node_d[ ( lexeme_d[ "FUN" >> +digit_p ] ) ];
|
fun_label = leaf_node_d[ ( lexeme_d[ "FUN" >> +digit_p ] ) ];
|
||||||
|
|
||||||
parameter = leaf_node_d[ ( lexeme_d[ "PAR" >> +digit_p ] ) ];
|
parameter = leaf_node_d[ ( lexeme_d[ "PAR" >> +digit_p ] ) |
|
||||||
|
( lexeme_d[ "-PAR" >> +digit_p ] ) ];
|
||||||
|
|
||||||
map = leaf_node_d[ ( lexeme_d[ "MAP" >> +digit_p ] ) ];
|
map = leaf_node_d[ ( lexeme_d[ "MAP" >> +digit_p ] ) ];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user