Logo ROOT   6.08/07
Reference Guide
TTreePlayer.h
Go to the documentation of this file.
1 // @(#)root/treeplayer:$Id$
2 // Author: Rene Brun 12/01/96
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTreePlayer
13 #define ROOT_TTreePlayer
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TTreePlayer //
19 // //
20 // A TTree object is a list of TBranch. //
21 // To Create a TTree object one must: //
22 // - Create the TTree header via the TTree constructor //
23 // - Call the TBranch constructor for every branch. //
24 // //
25 // To Fill this object, use member function Fill with no parameters. //
26 // The Fill function loops on all defined TBranch. //
27 // //
28 //////////////////////////////////////////////////////////////////////////
29 
30 #ifndef ROOT_TTree
31 #include "TTree.h"
32 #endif
33 #ifndef ROOT_TSelectorDraw
34 #include "TSelectorDraw.h"
35 #endif
36 #ifndef ROOT_TVirtualTreePlayer
37 #include "TVirtualTreePlayer.h"
38 #endif
39 
40 
41 class TVirtualIndex;
42 
44 
45 private:
46  TTreePlayer(const TTreePlayer &);
48 
49 protected:
50  TTree *fTree; //! Pointer to current Tree
51  Bool_t fScanRedirect; // Switch to redirect TTree::Scan output to a file
52  const char *fScanFileName; // Name of the file where Scan is redirected
53  Int_t fDimension; // Dimension of the current expression
54  Long64_t fSelectedRows; // Number of selected entries
55  TH1 *fHistogram; //! Pointer to histogram used for the projection
56  TSelectorDraw *fSelector; //! Pointer to current selector
57  TSelector *fSelectorFromFile;//! Pointer to a user defined selector created by this TTreePlayer object
58  TClass *fSelectorClass; //! Pointer to the actual class of the TSelectorFromFile
59  TList *fInput; //! input list to the selector
60  TList *fFormulaList; //! Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
61  TSelector *fSelectorUpdate; //! Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves function
62 
63 protected:
64  const char *GetNameByIndex(TString &varexp, Int_t *index,Int_t colindex);
65  void TakeAction(Int_t nfill, Int_t &npoints, Int_t &action, TObject *obj, Option_t *option);
66  void TakeEstimate(Int_t nfill, Int_t &npoints, Int_t action, TObject *obj, Option_t *option);
68 
69 public:
70  TTreePlayer();
71  virtual ~TTreePlayer();
72  virtual TVirtualIndex *BuildIndex(const TTree *T, const char *majorname, const char *minorname);
73  virtual TTree *CopyTree(const char *selection, Option_t *option
74  ,Long64_t nentries, Long64_t firstentry);
75  virtual Long64_t DrawScript(const char* wrapperPrefix,
76  const char *macrofilename, const char *cutfilename,
77  Option_t *option, Long64_t nentries, Long64_t firstentry);
78  virtual Long64_t DrawSelect(const char *varexp, const char *selection, Option_t *option
79  ,Long64_t nentries, Long64_t firstentry);
80  virtual Int_t Fit(const char *formula ,const char *varexp, const char *selection,Option_t *option ,
81  Option_t *goption ,Long64_t nentries, Long64_t firstentry);
82  virtual Int_t GetDimension() const {return fDimension;}
83  TH1 *GetHistogram() const {return fHistogram;}
84  virtual Long64_t GetEntries(const char *selection);
85  virtual Long64_t GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const;
86  virtual Int_t GetNfill() const {return fSelector->GetNfill();}
87  const char *GetScanFileName() const {return fScanFileName;}
88  TTreeFormula *GetSelect() const {return fSelector->GetSelect();}
89  virtual Long64_t GetSelectedRows() const {return fSelectedRows;}
90  TSelector *GetSelector() const {return fSelector;}
92  // See TSelectorDraw::GetVar
93  TTreeFormula *GetVar(Int_t i) const {return fSelector->GetVar(i);};
94  // See TSelectorDraw::GetVar
95  TTreeFormula *GetVar1() const {return fSelector->GetVar1();}
96  // See TSelectorDraw::GetVar
97  TTreeFormula *GetVar2() const {return fSelector->GetVar2();}
98  // See TSelectorDraw::GetVar
99  TTreeFormula *GetVar3() const {return fSelector->GetVar3();}
100  // See TSelectorDraw::GetVar
101  TTreeFormula *GetVar4() const {return fSelector->GetVar4();}
102  // See TSelectorDraw::GetVal
103  virtual Double_t *GetVal(Int_t i) const {return fSelector->GetVal(i);};
104  // See TSelectorDraw::GetVal
105  virtual Double_t *GetV1() const {return fSelector->GetV1();}
106  // See TSelectorDraw::GetVal
107  virtual Double_t *GetV2() const {return fSelector->GetV2();}
108  // See TSelectorDraw::GetVal
109  virtual Double_t *GetV3() const {return fSelector->GetV3();}
110  // See TSelectorDraw::GetVal
111  virtual Double_t *GetV4() const {return fSelector->GetV4();}
112  virtual Double_t *GetW() const {return fSelector->GetW();}
113  virtual Int_t MakeClass(const char *classname, Option_t *option);
114  virtual Int_t MakeCode(const char *filename);
115  virtual Int_t MakeProxy(const char *classname,
116  const char *macrofilename = 0, const char *cutfilename = 0,
117  const char *option = 0, Int_t maxUnrolling = 3);
118  virtual Int_t MakeReader(const char *classname, Option_t *option);
119  TPrincipal *Principal(const char *varexp, const char *selection, Option_t *option
120  ,Long64_t nentries, Long64_t firstentry);
121  virtual Long64_t Process(const char *filename,Option_t *option, Long64_t nentries, Long64_t firstentry);
122  virtual Long64_t Process(TSelector *selector,Option_t *option, Long64_t nentries, Long64_t firstentry);
123  virtual void RecursiveRemove(TObject *obj);
124  virtual Long64_t Scan(const char *varexp, const char *selection, Option_t *option
125  ,Long64_t nentries, Long64_t firstentry);
127  virtual TSQLResult *Query(const char *varexp, const char *selection, Option_t *option
128  ,Long64_t nentries, Long64_t firstentry);
129  virtual void SetEstimate(Long64_t n);
130  void SetScanRedirect(Bool_t on=kFALSE) {fScanRedirect = on;}
131  void SetScanFileName(const char *name) {fScanFileName=name;}
132  virtual void SetTree(TTree *t) {fTree = t;}
133  virtual void StartViewer(Int_t ww, Int_t wh);
134  virtual Int_t UnbinnedFit(const char *formula ,const char *varexp, const char *selection,Option_t *option
135  ,Long64_t nentries, Long64_t firstentry);
136  virtual void UpdateFormulaLeaves();
137 
138  ClassDef(TTreePlayer,3); //Manager class to play with TTrees
139 };
140 
141 #endif
void DeleteSelectorFromFile()
Delete any selector created by this object.
Principal Components Analysis (PCA)
Definition: TPrincipal.h:28
void SetScanFileName(const char *name)
Definition: TTreePlayer.h:131
virtual Long64_t GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const
return the number of entries to be processed this function checks that nentries is not bigger than th...
TTreeFormula * GetVar(Int_t i) const
Return the TTreeFormula corresponding to the i-th component of the request formula (where the compone...
long long Long64_t
Definition: RtypesCore.h:69
TTree * fTree
Definition: TTreePlayer.h:50
Abstract interface for Tree Index.
Definition: TVirtualIndex.h:31
virtual Double_t * GetVal(Int_t i) const
Return the last values corresponding to the i-th component of the formula being processed (where the ...
virtual Double_t * GetV2() const
TSelectorDraw * fSelector
Pointer to histogram used for the projection.
Definition: TTreePlayer.h:56
const char * GetNameByIndex(TString &varexp, Int_t *index, Int_t colindex)
Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves funct...
const char Option_t
Definition: RtypesCore.h:62
double T(double x)
Definition: ChebyshevPol.h:34
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Long64_t Scan(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Loop on Tree and print entries passing selection.
virtual void SetTree(TTree *t)
Definition: TTreePlayer.h:132
virtual Double_t * GetV4() const
TTreeFormula * GetSelect() const
Definition: TTreePlayer.h:88
virtual Int_t GetDimension() const
Definition: TTreePlayer.h:82
TPrincipal * Principal(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Interface to the Principal Components Analysis class.
virtual Long64_t DrawSelect(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Draw expression varexp for specified entries that matches the selection.
virtual Long64_t DrawScript(const char *wrapperPrefix, const char *macrofilename, const char *cutfilename, Option_t *option, Long64_t nentries, Long64_t firstentry)
Draw the result of a C++ script.
virtual Double_t * GetV3() const
TTreeFormula * GetVar4() const
Definition: TSelectorDraw.h:99
virtual TTree * CopyTree(const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Copy a Tree with selection, make a clone of this Tree header, then copy the selected entries...
void SetScanRedirect(Bool_t on=kFALSE)
Definition: TTreePlayer.h:130
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t ScanRedirected()
Definition: TTreePlayer.h:126
virtual Long64_t Process(const char *filename, Option_t *option, Long64_t nentries, Long64_t firstentry)
Process this tree executing the TSelector code in the specified filename.
TTreeFormula * GetVar2() const
Definition: TSelectorDraw.h:95
virtual Double_t * GetV2() const
Definition: TTreePlayer.h:107
TSelector * GetSelector() const
Definition: TTreePlayer.h:90
TSelector * fSelectorFromFile
Pointer to current selector.
Definition: TTreePlayer.h:57
void TakeEstimate(Int_t nfill, Int_t &npoints, Int_t action, TObject *obj, Option_t *option)
TTreeFormula * GetVar1() const
Definition: TTreePlayer.h:95
Used to pass a selection expression to the Tree drawing routine.
Definition: TTreeFormula.h:64
virtual ~TTreePlayer()
Tree destructor.
virtual void UpdateFormulaLeaves()
this function is called by TChain::LoadTree when a new Tree is loaded.
A doubly linked list.
Definition: TList.h:47
virtual void StartViewer(Int_t ww, Int_t wh)
Start the TTreeViewer on this TTree.
virtual Double_t * GetW() const
Definition: TTreePlayer.h:112
virtual Int_t UnbinnedFit(const char *formula, const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Unbinned fit of one or more variable(s) from a Tree.
virtual void SetEstimate(Long64_t n)
Set number of entries to estimate variable limits.
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:88
virtual Double_t * GetW() const
virtual Int_t MakeReader(const char *classname, Option_t *option)
Generate skeleton selector class for this tree.
virtual Double_t * GetV1() const
virtual Long64_t GetSelectedRows() const
Definition: TTreePlayer.h:89
virtual Int_t GetNfill() const
Definition: TTreePlayer.h:86
TClass * fSelectorClass
Pointer to a user defined selector created by this TTreePlayer object.
Definition: TTreePlayer.h:58
const char * fScanFileName
Definition: TTreePlayer.h:52
virtual Int_t MakeProxy(const char *classname, const char *macrofilename=0, const char *cutfilename=0, const char *option=0, Int_t maxUnrolling=3)
Generate a skeleton analysis class for this Tree using TBranchProxy.
Int_t fDimension
Definition: TTreePlayer.h:53
virtual Double_t * GetV3() const
Definition: TTreePlayer.h:109
TList * fInput
Pointer to the actual class of the TSelectorFromFile.
Definition: TTreePlayer.h:59
virtual Double_t * GetV4() const
Definition: TTreePlayer.h:111
TTreePlayer & operator=(const TTreePlayer &)
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TH1 * GetHistogram() const
Definition: TTreePlayer.h:83
virtual Int_t MakeCode(const char *filename)
Generate skeleton function for this Tree.
TSelector * GetSelectorFromFile() const
Definition: TTreePlayer.h:91
TTreeFormula * GetVar(Int_t i) const
Definition: TTreePlayer.h:93
virtual Double_t * GetV1() const
Definition: TTreePlayer.h:105
A specialized TSelector for TTree::Draw.
Definition: TSelectorDraw.h:33
TTreeFormula * GetVar4() const
Definition: TTreePlayer.h:101
double Double_t
Definition: RtypesCore.h:55
TSelector * fSelectorUpdate
Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
Definition: TTreePlayer.h:61
Bool_t fScanRedirect
Pointer to current Tree.
Definition: TTreePlayer.h:51
TH1 * fHistogram
Definition: TTreePlayer.h:55
int nentries
Definition: THbookFile.cxx:89
virtual Int_t GetNfill() const
Definition: TSelectorDraw.h:86
The TH1 histogram class.
Definition: TH1.h:80
TTreeFormula * GetVar3() const
Definition: TSelectorDraw.h:97
virtual void RecursiveRemove(TObject *obj)
cleanup pointers in the player pointing to obj
const char * GetScanFileName() const
Definition: TTreePlayer.h:87
TTreePlayer()
Default Tree constructor.
Definition: TTreePlayer.cxx:97
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Double_t * GetVal(Int_t i) const
Definition: TTreePlayer.h:103
virtual Long64_t GetEntries(const char *selection)
Return the number of entries matching the selection.
Abstract base class defining the interface for the plugins that implement Draw, Scan, Process, MakeProxy, etc.
void TakeAction(Int_t nfill, Int_t &npoints, Int_t &action, TObject *obj, Option_t *option)
Long64_t fSelectedRows
Definition: TTreePlayer.h:54
virtual TVirtualIndex * BuildIndex(const TTree *T, const char *majorname, const char *minorname)
Build the index for the tree (see TTree::BuildIndex)
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TTreeFormula * GetVar3() const
Definition: TTreePlayer.h:99
TList * fFormulaList
input list to the selector
Definition: TTreePlayer.h:60
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition: TTreePlayer.h:43
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
virtual Int_t Fit(const char *formula, const char *varexp, const char *selection, Option_t *option, Option_t *goption, Long64_t nentries, Long64_t firstentry)
Fit a projected item(s) from a Tree.
TTreeFormula * GetVar2() const
Definition: TTreePlayer.h:97
const Int_t n
Definition: legend1.C:16
virtual Int_t MakeClass(const char *classname, Option_t *option)
Generate skeleton analysis class for this Tree.
char name[80]
Definition: TGX11.cxx:109
TTreeFormula * GetVar1() const
Definition: TSelectorDraw.h:93
virtual TSQLResult * Query(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Loop on Tree and return TSQLResult object containing entries passing selection.