#ifndef ROOT_TTreeFormula
#define ROOT_TTreeFormula
#ifndef ROOT_TFormula
#include "TFormula.h"
#endif
#ifndef ROOT_TLeaf
#include "TLeaf.h"
#endif
#ifndef ROOT_TObjArray
#include "TObjArray.h"
#endif
#include <string>
#include <vector>
#ifdef R__OLDHPACC
namespace std {
using ::string;
using ::vector;
}
#endif
const Int_t kMAXCODES = kMAXFOUND;
const Int_t kMAXFORMDIM = 5;
class TTree;
class TArrayI;
class TMethodCall;
class TLeafObject;
class TDataMember;
class TStreamerElement;
class TFormLeafInfoMultiVarDim;
class TFormLeafInfo;
class TBranchElement;
class TAxis;
class TTreeFormulaManager;
class TTreeFormula : public TFormula {
friend class TTreeFormulaManager;
protected:
enum {
kIsCharacter = BIT(12),
kMissingLeaf = BIT(15),
kIsInteger = BIT(17),
kNeedEntries = BIT(18)
};
enum {
kDirect, kDataMember, kMethod,
kIndexOfEntry, kEntries, kLength, kIteration, kLengthFunc, kSum, kEntryList,
kTreeMember,
kIndexOfLocalEntry,
kMin, kMax
};
enum {
kAlias = 200,
kAliasString = 201,
kAlternate = 202,
kAlternateString = 203,
kMinIf = 204,
kMaxIf = 205
};
TTree *fTree;
Short_t fCodes[kMAXCODES];
Int_t fNdata[kMAXCODES];
Int_t fNcodes;
Bool_t fHasCast;
Int_t fMultiplicity;
Int_t fNindex;
Int_t *fLookupType;
TObjArray fLeaves;
TObjArray fDataMembers;
TObjArray fMethods;
TObjArray fExternalCuts;
TObjArray fAliases;
TObjArray fLeafNames;
TObjArray fBranches;
Bool_t fQuickLoad;
Bool_t fNeedLoading;
Int_t fNdimensions[kMAXCODES];
Int_t fFixedSizes[kMAXCODES][kMAXFORMDIM];
UChar_t fHasMultipleVarDim[kMAXCODES];
Int_t fCumulSizes[kMAXCODES][kMAXFORMDIM];
Int_t fIndexes[kMAXCODES][kMAXFORMDIM];
TTreeFormula *fVarIndexes[kMAXCODES][kMAXFORMDIM];
TAxis *fAxis;
Bool_t fDidBooleanOptimization;
TTreeFormulaManager *fManager;
TList *fDimensionSetup;
std::vector<std::string> fAliasesUsed;
TTreeFormula(const char *name, const char *formula, TTree *tree, const std::vector<std::string>& aliases);
void Init(const char *name, const char *formula);
Bool_t BranchHasMethod(TLeaf* leaf, TBranch* branch, const char* method,const char* params, Long64_t readentry) const;
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 ¶n_level, TObjArray &castqueue, std::vector<std::string>& aliasUsed, Bool_t &useLeafCollectionObject, const char *fullExpression);
TLeaf* GetLeafWithDatamember(const char* topchoice, const char* nextchice, Long64_t readentry) const;
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, TFormLeafInfo *maininfo, Bool_t useCollectionObject);
Int_t RegisterDimensions(Int_t code, TLeaf *leaf);
Int_t RegisterDimensions(const char *size, Int_t code);
virtual Double_t GetValueFromMethod(Int_t i, TLeaf *leaf) const;
virtual void* GetValuePointerFromMethod(Int_t i, TLeaf *leaf) const;
Int_t GetRealInstance(Int_t instance, Int_t codeindex);
void LoadBranches();
Bool_t LoadCurrentDim();
void ResetDimensions();
virtual TClass* EvalClass(Int_t oper) const;
virtual Bool_t IsLeafInteger(Int_t code) const;
virtual Bool_t IsString(Int_t oper) const;
virtual Bool_t IsLeafString(Int_t code) const;
virtual Bool_t SwitchToFormLeafInfo(Int_t code);
virtual Bool_t StringToNumber(Int_t code);
void Convert(UInt_t fromVersion);
private:
TTreeFormula(const TTreeFormula&);
TTreeFormula& operator=(const TTreeFormula&);
public:
TTreeFormula();
TTreeFormula(const char *name,const char *formula, TTree *tree);
virtual ~TTreeFormula();
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 const char *EvalStringInstance(Int_t i=0);
virtual void* EvalObject(Int_t i=0);
TFormLeafInfo *GetLeafInfo(Int_t code) const;
TTreeFormulaManager*GetManager() const { return fManager; }
TMethodCall *GetMethodCall(Int_t code) const;
virtual Int_t GetMultiplicity() const {return fMultiplicity;}
virtual TLeaf *GetLeaf(Int_t n) const;
virtual Int_t GetNcodes() const {return fNcodes;}
virtual Int_t GetNdata();
virtual Bool_t IsInteger(Bool_t fast=kTRUE) const;
Bool_t IsQuickLoad() const { return fQuickLoad; }
virtual Bool_t IsString() const;
virtual Bool_t Notify() { UpdateFormulaLeaves(); return kTRUE; }
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 SetAxis(TAxis *axis=0);
void SetQuickLoad(Bool_t quick) { fQuickLoad = quick; }
virtual void SetTree(TTree *tree) {fTree = tree;}
virtual void ResetLoading();
virtual TTree* GetTree() const {return fTree;}
virtual void UpdateFormulaLeaves();
ClassDef(TTreeFormula,9)
};
#endif