library: libTreePlayer
#include "TTreeFormula.h"

TTreeFormula


class description - source file - inheritance tree (.pdf)

class TTreeFormula : public TFormula

Inheritance Chart:
TObject
<-
TNamed
<-
TFormula
<-
TTreeFormula
    private:
TTreeFormula(const TTreeFormula&) TTreeFormula& operator=(const TTreeFormula&) protected:
TTreeFormula(const char* name, const char* formula, TTree* tree, const vector<string>& aliases) Bool_t BranchHasMethod(TLeaf* leaf, TBranch* branch, const char* method, const char* params, Long64_t readentry) const virtual void Convert(UInt_t fromVersion) Int_t DefineAlternate(const char* expression) void DefineDimensions(Int_t code, Int_t size, TFormLeafInfoMultiVarDim* info, Int_t& virt_dim) Int_t FindLeafForExpression(const char* expression, TLeaf*& leaf, TString& leftover, Bool_t& final, UInt_t& paran_level, TObjArray& castqueue, vector<std::string>& aliasUsed, Bool_t& useLeafCollectionObject, const char* fullExpression) TLeaf* GetLeafWithDatamember(const char* topchoice, const char* nextchice, Long64_t readentry) const Int_t GetRealInstance(Int_t instance, Int_t codeindex) virtual Double_t GetValueFromMethod(Int_t i, TLeaf* leaf) const virtual void* GetValuePointerFromMethod(Int_t i, TLeaf* leaf) const void Init(const char* name, const char* formula) virtual Bool_t IsLeafInteger(Int_t code) const virtual Bool_t IsLeafString(Int_t code) const virtual Bool_t IsString(Int_t oper) const void LoadBranches() Bool_t LoadCurrentDim() Int_t ParseWithLeaf(TLeaf* leaf, const char* expression, Bool_t final, UInt_t paran_level, TObjArray& castqueue, Bool_t useLeafCollectionObject, const char* fullExpression) Int_t RegisterDimensions(Int_t code, Int_t size, TFormLeafInfoMultiVarDim* multidim = 0) Int_t RegisterDimensions(Int_t code, TBranchElement* branch) Int_t RegisterDimensions(Int_t code, TFormLeafInfo* info, Bool_t useCollectionObject) Int_t RegisterDimensions(Int_t code, TLeaf* leaf) Int_t RegisterDimensions(const char* size, Int_t code) void ResetDimensions() public:
TTreeFormula() TTreeFormula(const char* name, const char* formula, TTree* tree) virtual ~TTreeFormula() static TClass* Class() virtual Int_t DefinedVariable(TString& variable, Int_t& action) virtual TClass* EvalClass() const virtual Double_t EvalInstance(Int_t i = 0, const char** stringStack = "0") virtual void* EvalObject(Int_t i = 0) virtual const char* EvalStringInstance(Int_t i = 0) const virtual TLeaf* GetLeaf(Int_t n) const TFormLeafInfo* GetLeafInfo(Int_t code) const TTreeFormulaManager* GetManager() const TMethodCall* GetMethodCall(Int_t code) const virtual Int_t GetMultiplicity() const virtual Int_t GetNcodes() const virtual Int_t GetNdata() virtual TTree* GetTree() const virtual TClass* IsA() const virtual Bool_t IsInteger() const Bool_t IsQuickLoad() const virtual Bool_t IsString() const virtual Bool_t Notify() virtual char* PrintValue(Int_t mode = 0) const virtual char* PrintValue(Int_t mode, Int_t instance, const char* decform = "9.9") const virtual void ResetLoading() virtual void SetAxis(TAxis* axis = 0) void SetQuickLoad(Bool_t quick) virtual void SetTree(TTree* tree) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b) virtual void UpdateFormulaLeaves()

Data Members


    protected:
TTree* fTree ! pointer to Tree Short_t fCodes[500] List of leaf numbers referenced in formula Int_t fNdata[500] ! This caches the physical number of element in the leaf or datamember. Int_t fNcodes Number of leaves referenced in formula Bool_t fHasCast Record whether the formula contain a cast operation or not Int_t fMultiplicity Indicator of the variability of the formula Int_t fNindex Size of fIndex Int_t* fLookupType [fNindex] array indicating how each leaf should be looked-up TObjArray fLeaves ! List of leaf used in this formula. TObjArray fDataMembers ! List of leaf data members TObjArray fMethods ! List of leaf method calls TObjArray fAliases ! List of TTreeFormula for each alias used. TObjArray fLeafNames List of TNamed describing leaves TObjArray fBranches ! List of branches to read. Similar to fLeaces but duplicates are zeroed out. Bool_t fQuickLoad ! If true, branch GetEntry is only called when the entry number changes. Bool_t fNeedLoading ! If true, the current entry has not been loaded yet. Int_t fNdimensions[500] Number of array dimensions in each leaf Int_t fFixedSizes[500][5] Physical sizes of lower dimensions for each leaf UChar_t fHasMultipleVarDim[500] True if the corresponding variable is an array with more than one variable dimension. Int_t fCumulSizes[500][5] Accumulated sizes of lower dimensions for each leaf after variable dimensions has been calculated Int_t fIndexes[500][5] Index of array selected by user for each leaf TTreeFormula* fVarIndexes[500][5] Pointer to a variable index. TList* fDimensionSetup ! list of dimension setups, for delayed creation of the dimension information. vector<std::string> fAliasesUsed ! List of aliases used during the parsing of the expression. TAxis* fAxis ! pointer to histogram axis if this is a string Bool_t fDidBooleanOptimization ! True if we executed one boolean optimization since the last time instance number 0 was evaluated TTreeFormulaManager* fManager ! The dimension coordinator. public:
static const enum TTreeFormula:: kIsCharacter static const enum TTreeFormula:: kMissingLeaf static const enum TTreeFormula:: kDirect static const enum TTreeFormula:: kDataMember static const enum TTreeFormula:: kMethod static const enum TTreeFormula:: kIndexOfEntry static const enum TTreeFormula:: kEntries static const enum TTreeFormula:: kLength static const enum TTreeFormula:: kIteration static const enum TTreeFormula:: kLengthFunc static const enum TTreeFormula:: kSum static const enum TTreeFormula:: kAlias static const enum TTreeFormula:: kAliasString static const enum TTreeFormula:: kAlternate static const enum TTreeFormula:: kAlternateString

Class Description

 TTreeFormula now relies on a variety of TFormLeafInfo classes to handle the
 reading of the information.  Here is the list of theses classes:
   TFormLeafInfo
   TFormLeafInfoDirect
   TFormLeafInfoNumerical
   TFormLeafInfoClones
   TFormLeafInfoCollection
   TFormLeafInfoPointer
   TFormLeafInfoMethod
   TFormLeafInfoMultiVarDim
   TFormLeafInfoMultiVarDimDirect
   TFormLeafInfoCast

 The following method are available from the TFormLeafInfo interface:

  AddOffset(Int_t offset, TStreamerElement* element)
  GetCounterValue(TLeaf* leaf) : return the size of the array pointed to.
  GetObjectAddress(TLeafElement* leaf) : Returns the the location of the object pointed to.
  GetMultiplicity() : Returns info on the variability of the number of elements
  GetNdata(TLeaf* leaf) : Returns the number of elements
  GetNdata() : Used by GetNdata(TLeaf* leaf)
  GetValue(TLeaf *leaf, Int_t instance = 0) : Return the value
  GetValuePointer(TLeaf *leaf, Int_t instance = 0) : Returns the address of the value
  GetLocalValuePointer(TLeaf *leaf, Int_t instance = 0) : Returns the address of the value of 'this' LeafInfo
  IsString()
  ReadValue(char *where, Int_t instance = 0) : Internal function to interpret the location 'where'
  Update() : react to the possible loading of a shared library.



TTreeFormula(): TFormula(), fQuickLoad(kFALSE), fNeedLoading(kTRUE), fDidBooleanOptimization(kFALSE)
*-*-*-*-*-*-*-*-*-*-*Tree Formula default constructor*-*-*-*-*-*-*-*-*-*
*-*                  ================================

TTreeFormula(const char *name,const char *expression, TTree *tree) :TFormula(), fTree(tree), fQuickLoad(kFALSE), fNeedLoading(kTRUE), fDidBooleanOptimization(kFALSE)
 Normal TTree Formula Constuctor

TTreeFormula(const char *name,const char *expression, TTree *tree, const std::vector<std::string>& aliases) :TFormula(), fTree(tree), fQuickLoad(kFALSE), fNeedLoading(kTRUE), fAliasesUsed(aliases), fDidBooleanOptimization(kFALSE)
 Constructor used during the expansion of an alias

void Init(const char*name, const char* expression)
 Initialiation called from the constructors.

~TTreeFormula()
*-*-*-*-*-*-*-*-*-*-*Tree Formula default destructor*-*-*-*-*-*-*-*-*-*-*
*-*                  =================================

void DefineDimensions(Int_t code, Int_t size, TFormLeafInfoMultiVarDim * info, Int_t& virt_dim)
 This method is used internally to decode the dimensions of the variables

Int_t RegisterDimensions(const char *info, Int_t code)
 This method is used internally to decode the dimensions of the variables

Int_t RegisterDimensions(Int_t code, Int_t size, TFormLeafInfoMultiVarDim * multidim)
 This method stores the dimension information for later usage.

Int_t RegisterDimensions(Int_t code, TFormLeafInfo *leafinfo, Bool_t useCollectionObject)
 This method is used internally to decode the dimensions of the variables

Int_t RegisterDimensions(Int_t code, TBranchElement *branch)
 This method is used internally to decode the dimensions of the variables

Int_t RegisterDimensions(Int_t code, TLeaf *leaf)
 This method is used internally to decode the dimensions of the variables

Int_t DefineAlternate(const char *expression)
 This method check for treat the case where expression contains $Atl and load up
 both fAliases and fExpr.
 We return
   -1 in case of failure
   0 in case we did not find $Alt
   the action number in case of success.

Int_t ParseWithLeaf(TLeaf *leaf, const char *subExpression, Bool_t final, UInt_t paran_level, TObjArray &castqueue, Bool_t useLeafCollectionObject, const char* fullExpression)
 Decompose 'expression' as pointing to something inside the leaf
 Returns:
   -2  Error: some information is missing (message already printed)
   -1  Error: Syntax is incorrect (message already printed)
    0
    >0 the value returns is the action code.

Int_t FindLeafForExpression(const char* expression, TLeaf *&leaf, TString &leftover, Bool_t &final, UInt_t &paran_level, TObjArray &castqueue, std::vector<std::string>& aliasUsed, Bool_t &useLeafCollectionObject, const char *fullExpression)
 Look for the leaf corresponding to the start of expression.
 It returns the corresponding leaf if any.
 It also modify the following arguments:
   leftover: contain from expression that was not used to determine the leaf
   final:
   paran_level: number of un-matched open parenthesis
   cast_queue: list of cast to be done
   aliases: list of aliases used

Int_t DefinedVariable(TString &name, Int_t &action)
*-*-*-*-*-*Check if name is in the list of Tree/Branch leaves*-*-*-*-*
*-*        ==================================================

   This member function redefines the function in TFormula
   If a leaf has a name corresponding to the argument name, then
   returns a new code.
   A TTreeFormula may contain more than one variable.
   For each variable referenced, the pointers to the corresponding
   branch and leaf is stored in the object arrays fBranches and fLeaves.

   name can be :
      - Leaf_Name (simple variable or data member of a ClonesArray)
      - Branch_Name.Leaf_Name
      - Branch_Name.Method_Name
      - Leaf_Name[index]
      - Branch_Name.Leaf_Name[index]
      - Branch_Name.Leaf_Name[index1]
      - Branch_Name.Leaf_Name[][index2]
      - Branch_Name.Leaf_Name[index1][index2]
   New additions:
      - Branch_Name.Leaf_Name[OtherLeaf_Name]
      - Branch_Name.Datamember_Name
      - '.' can be replaced by '->'
   and
      - Branch_Name[index1].Leaf_Name[index2]
      - Leaf_name[index].Action().OtherAction(param)
      - Leaf_name[index].Action()[val].OtherAction(param)

   The expected returns values are
     -2 :  the name has been recognized but won't be usable
     -1 :  the name has not been recognized
    >=0 :  the name has been recognized, return the internal code for this name.


TLeaf* GetLeafWithDatamember(const char* topchoice, const char* nextchoice, Long64_t readentry) const

Bool_t BranchHasMethod(TLeaf* leafcur, TBranch * branch, const char* method, const char* params, Long64_t readentry) const
 Return the leaf (if any) of the tree with contains an object of a class
 having a method which has the name provided in the argument.

Int_t GetRealInstance(Int_t instance, Int_t codeindex)

TClass* EvalClass() const
*-*-*-*-*-*-*-*-*-*-*Evaluate the class of this treeformula*-*-*-*-*-*-*-*-*-*
*-*                  ======================================

  If the 'value' of this formula is a simple pointer to an object,
  this function returns the TClass corresponding to its type.

void* EvalObject(int instance)
*-*-*-*-*-*-*-*-*-*-*Evaluate this treeformula*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                  =========================

  Return the address of the object pointed to by the formula.
  Return 0 if the formula is not a single object
  The object type can be retrieved using by call EvalClass();

const char* EvalStringInstance(Int_t instance)

Double_t EvalInstance(Int_t instance, const char *stringStackArg[])
*-*-*-*-*-*-*-*-*-*-*Evaluate this treeformula*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                  =========================


TFormLeafInfo* GetLeafInfo(Int_t code) const
*-*-*-*-*-*-*-*Return DataMember corresponding to code*-*-*-*-*-*
*-*            =======================================

  function called by TLeafObject::GetValue
  with the value of fLookupType computed in TTreeFormula::DefinedVariable

TLeaf* GetLeaf(Int_t n) const
*-*-*-*-*-*-*-*Return leaf corresponding to serial number n*-*-*-*-*-*
*-*            ============================================


TMethodCall* GetMethodCall(Int_t code) const
*-*-*-*-*-*-*-*Return methodcall corresponding to code*-*-*-*-*-*
*-*            =======================================

  function called by TLeafObject::GetValue
  with the value of fLookupType computed in TTreeFormula::DefinedVariable

Int_t GetNdata()
*-*-*-*-*-*-*-*Return number of available instances in the formula-*-*-*-*-*-*
*-*            ===================================================


Double_t GetValueFromMethod(Int_t i, TLeaf *leaf) const
*-*-*-*-*-*-*-*Return result of a leafobject method*-*-*-*-*-*-*-*
*-*            ====================================


void* GetValuePointerFromMethod(Int_t i, TLeaf *leaf) const
*-*-*-*-*-*-*-*Return result of a leafobject method*-*-*-*-*-*-*-*
*-*            ====================================


Bool_t IsInteger() const
 return TRUE if the formula corresponds to one single Tree leaf
 and this leaf is short, int or unsigned short, int
 When a leaf is of type integer, the generated histogram is forced
 to have an integer bin width

Bool_t IsLeafInteger(Int_t code) const
 return TRUE if the leaf corresponding to code is short, int or unsigned
 short, int When a leaf is of type integer, the generated histogram is
 forced to have an integer bin width

Bool_t IsString() const
 return TRUE if the formula is a string

Bool_t IsString(Int_t oper) const
 (fOper[i]>=105000 && fOper[i]<110000) || fOper[i] == kStrings)

Bool_t IsLeafString(Int_t code) const
 return TRUE if the leaf or data member corresponding to code is a string

char* PrintValue(Int_t mode) const
*-*-*-*-*-*-*-*Return value of variable as a string*-*-*-*-*-*-*-*
*-*            ====================================

      mode = -2 : Print line with ***
      mode = -1 : Print column names
      mode = 0  : Print column values

char* PrintValue(Int_t mode, Int_t instance, const char *decform) const
*-*-*-*-*-*-*-*Return value of variable as a string*-*-*-*-*-*-*-*
*-*            ====================================

      mode = -2 : Print line with ***
      mode = -1 : Print column names
      mode = 0  : Print column values

void ResetLoading()

void SetAxis(TAxis *axis)

void Streamer(TBuffer &R__b)
 Stream an object of class TTreeFormula.

void UpdateFormulaLeaves()
 this function is called TTreePlayer::UpdateFormulaLeaves, itself
 called by TChain::LoadTree when a new Tree is loaded.
 Because Trees in a TChain may have a different list of leaves, one
 must update the leaves numbers in the TTreeFormula used by the TreePlayer.

void ResetDimensions()
 Populate the TTreeFormulaManager with the dimension information.

void LoadBranches()
 Make sure that all the branches have been loaded properly.

Bool_t LoadCurrentDim()

void Convert(UInt_t oldversion)
 Convert the fOper of a TTTreeFormula version fromVersion to the current in memory version



Inline Functions


               TTreeFormula& operator=(const TTreeFormula&)
                TTreeFormula TTreeFormula(const char* name, const char* formula, TTree* tree)
        TTreeFormulaManager* GetManager() const
                       Int_t GetMultiplicity() const
                       Int_t GetNcodes() const
                      Bool_t IsQuickLoad() const
                      Bool_t Notify()
                        void SetQuickLoad(Bool_t quick)
                        void SetTree(TTree* tree)
                      TTree* GetTree() const
                     TClass* Class()
                     TClass* IsA() const
                        void ShowMembers(TMemberInspector& insp, char* parent)
                        void StreamerNVirtual(TBuffer& b)


Author: Rene Brun 19/01/96
Last update: root/treeplayer:$Name: $:$Id: TTreeFormula.cxx,v 1.182 2005/08/29 12:05:56 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.