Logo ROOT  
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 #include "TVirtualTreePlayer.h"
31 
32 #include "TSelectorDraw.h"
33 #include "TTree.h"
34 
35 class TVirtualIndex;
36 
38 
39 private:
40  TTreePlayer(const TTreePlayer &) = delete;
41  TTreePlayer& operator=(const TTreePlayer &) = delete;
42 
43 protected:
44  TTree *fTree; //! Pointer to current Tree
45  Bool_t fScanRedirect; // Switch to redirect TTree::Scan output to a file
46  const char *fScanFileName; // Name of the file where Scan is redirected
47  Int_t fDimension; // Dimension of the current expression
48  Long64_t fSelectedRows; // Number of selected entries
49  TH1 *fHistogram; //! Pointer to histogram used for the projection
50  TSelectorDraw *fSelector; //! Pointer to current selector
51  TSelector *fSelectorFromFile;//! Pointer to a user defined selector created by this TTreePlayer object
52  TClass *fSelectorClass; //! Pointer to the actual class of the TSelectorFromFile
53  TList *fInput; //! input list to the selector
54  TList *fFormulaList; //! Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
55  TSelector *fSelectorUpdate; //! Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves function
56 
57 protected:
58  const char *GetNameByIndex(TString &varexp, Int_t *index,Int_t colindex);
60 
61 public:
62  TTreePlayer();
63  virtual ~TTreePlayer();
64  virtual TVirtualIndex *BuildIndex(const TTree *T, const char *majorname, const char *minorname);
65  virtual TTree *CopyTree(const char *selection, Option_t *option
66  ,Long64_t nentries, Long64_t firstentry);
67  virtual Long64_t DrawScript(const char* wrapperPrefix,
68  const char *macrofilename, const char *cutfilename,
69  Option_t *option, Long64_t nentries, Long64_t firstentry);
70  virtual Long64_t DrawSelect(const char *varexp, const char *selection, Option_t *option
71  ,Long64_t nentries, Long64_t firstentry);
72  virtual Int_t Fit(const char *formula ,const char *varexp, const char *selection,Option_t *option ,
73  Option_t *goption ,Long64_t nentries, Long64_t firstentry);
74  virtual Int_t GetDimension() const {return fDimension;}
75  TH1 *GetHistogram() const {return fHistogram;}
76  virtual Long64_t GetEntries(const char *selection);
77  virtual Long64_t GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const;
78  virtual Int_t GetNfill() const {return fSelector->GetNfill();}
79  const char *GetScanFileName() const {return fScanFileName;}
80  TTreeFormula *GetSelect() const {return fSelector->GetSelect();}
81  virtual Long64_t GetSelectedRows() const {return fSelectedRows;}
82  virtual TSelector *GetSelector() const {return fSelector;}
83  virtual TSelector *GetSelectorFromFile() const {return fSelectorFromFile;}
84  // See TSelectorDraw::GetVar
85  TTreeFormula *GetVar(Int_t i) const {return fSelector->GetVar(i);};
86  // See TSelectorDraw::GetVar
87  TTreeFormula *GetVar1() const {return fSelector->GetVar1();}
88  // See TSelectorDraw::GetVar
89  TTreeFormula *GetVar2() const {return fSelector->GetVar2();}
90  // See TSelectorDraw::GetVar
91  TTreeFormula *GetVar3() const {return fSelector->GetVar3();}
92  // See TSelectorDraw::GetVar
93  TTreeFormula *GetVar4() const {return fSelector->GetVar4();}
94  // See TSelectorDraw::GetVal
95  virtual Double_t *GetVal(Int_t i) const {return fSelector->GetVal(i);};
96  // See TSelectorDraw::GetVal
97  virtual Double_t *GetV1() const {return fSelector->GetV1();}
98  // See TSelectorDraw::GetVal
99  virtual Double_t *GetV2() const {return fSelector->GetV2();}
100  // See TSelectorDraw::GetVal
101  virtual Double_t *GetV3() const {return fSelector->GetV3();}
102  // See TSelectorDraw::GetVal
103  virtual Double_t *GetV4() const {return fSelector->GetV4();}
104  virtual Double_t *GetW() const {return fSelector->GetW();}
105  virtual Int_t MakeClass(const char *classname, Option_t *option);
106  virtual Int_t MakeCode(const char *filename);
107  virtual Int_t MakeProxy(const char *classname,
108  const char *macrofilename = 0, const char *cutfilename = 0,
109  const char *option = 0, Int_t maxUnrolling = 3);
110  virtual Int_t MakeReader(const char *classname, Option_t *option);
111  TPrincipal *Principal(const char *varexp, const char *selection, Option_t *option
112  ,Long64_t nentries, Long64_t firstentry);
113  virtual Long64_t Process(const char *filename,Option_t *option, Long64_t nentries, Long64_t firstentry);
114  virtual Long64_t Process(TSelector *selector,Option_t *option, Long64_t nentries, Long64_t firstentry);
115  virtual void RecursiveRemove(TObject *obj);
116  virtual Long64_t Scan(const char *varexp, const char *selection, Option_t *option
117  ,Long64_t nentries, Long64_t firstentry);
119  virtual TSQLResult *Query(const char *varexp, const char *selection, Option_t *option
120  ,Long64_t nentries, Long64_t firstentry);
121  virtual void SetEstimate(Long64_t n);
123  void SetScanFileName(const char *name) {fScanFileName=name;}
124  virtual void SetTree(TTree *t) {fTree = t;}
125  virtual void StartViewer(Int_t ww, Int_t wh);
126  virtual Int_t UnbinnedFit(const char *formula ,const char *varexp, const char *selection,Option_t *option
127  ,Long64_t nentries, Long64_t firstentry);
128  virtual void UpdateFormulaLeaves();
129 
130  ClassDef(TTreePlayer,3); //Manager class to play with TTrees
131 };
132 
133 #endif
n
const Int_t n
Definition: legend1.C:16
TSelectorDraw::GetV1
virtual Double_t * GetV1() const
Definition: TSelectorDraw.h:102
TTreePlayer::operator=
TTreePlayer & operator=(const TTreePlayer &)=delete
TSelector
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:31
TTreePlayer::Scan
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.
Definition: TTreePlayer.cxx:2425
TTreePlayer::Fit
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.
Definition: TTreePlayer.cxx:559
Option_t
const char Option_t
Definition: RtypesCore.h:66
TTreePlayer::fTree
TTree * fTree
Definition: TTreePlayer.h:44
TVirtualIndex
Abstract interface for Tree Index.
Definition: TVirtualIndex.h:30
TTreePlayer::fSelector
TSelectorDraw * fSelector
Pointer to histogram used for the projection.
Definition: TTreePlayer.h:50
TTreePlayer::Query
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.
Definition: TTreePlayer.cxx:2804
TTreePlayer::GetNameByIndex
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...
Definition: TTreePlayer.cxx:622
TTreePlayer::DrawSelect
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.
Definition: TTreePlayer.cxx:337
TVirtualTreePlayer.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TSelectorDraw::GetSelect
TTreeFormula * GetSelect() const
Definition: TSelectorDraw.h:88
TTree
A TTree represents a columnar dataset.
Definition: TTree.h:79
TTreePlayer::ScanRedirected
Bool_t ScanRedirected()
Definition: TTreePlayer.h:118
TSelectorDraw::GetW
virtual Double_t * GetW() const
Definition: TSelectorDraw.h:109
Int_t
int Int_t
Definition: RtypesCore.h:45
TSelectorDraw::GetVar3
TTreeFormula * GetVar3() const
Definition: TSelectorDraw.h:97
TTreePlayer::GetSelect
TTreeFormula * GetSelect() const
Definition: TTreePlayer.h:80
TSelectorDraw::GetNfill
virtual Int_t GetNfill() const
Definition: TSelectorDraw.h:86
nentries
int nentries
Definition: THbookFile.cxx:91
TTreePlayer::Process
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.
Definition: TTreePlayer.cxx:2185
TTree.h
TString
Basic string class.
Definition: TString.h:136
TTreePlayer::SetEstimate
virtual void SetEstimate(Long64_t n)
Set number of entries to estimate variable limits.
Definition: TTreePlayer.cxx:2937
TTreePlayer::GetDimension
virtual Int_t GetDimension() const
Definition: TTreePlayer.h:74
TTreePlayer::MakeReader
virtual Int_t MakeReader(const char *classname, Option_t *option)
Generate skeleton selector class for this tree.
Definition: TTreePlayer.cxx:1973
TTreePlayer::Principal
TPrincipal * Principal(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry)
Interface to the Principal Components Analysis class.
Definition: TTreePlayer.cxx:2003
bool
TSelectorDraw::GetVar
TTreeFormula * GetVar(Int_t i) const
Return the TTreeFormula corresponding to the i-th component of the request formula (where the compone...
Definition: TSelectorDraw.cxx:1081
TSQLResult
Definition: TSQLResult.h:32
TTreePlayer::GetSelectedRows
virtual Long64_t GetSelectedRows() const
Definition: TTreePlayer.h:81
TTreePlayer::fSelectorClass
TClass * fSelectorClass
Pointer to a user defined selector created by this TTreePlayer object.
Definition: TTreePlayer.h:52
TTreePlayer::DrawScript
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.
Definition: TTreePlayer.cxx:293
TTreePlayer::fScanFileName
const char * fScanFileName
Definition: TTreePlayer.h:46
TTreePlayer::MakeProxy
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.
Definition: TTreePlayer.cxx:1913
TTreePlayer::UpdateFormulaLeaves
virtual void UpdateFormulaLeaves()
this function is called by TChain::LoadTree when a new Tree is loaded.
Definition: TTreePlayer.cxx:3132
TTreePlayer
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition: TTreePlayer.h:37
TTreePlayer::SetTree
virtual void SetTree(TTree *t)
Definition: TTreePlayer.h:124
TTreePlayer::GetHistogram
TH1 * GetHistogram() const
Definition: TTreePlayer.h:75
TTreePlayer::MakeCode
virtual Int_t MakeCode(const char *filename)
Generate skeleton function for this Tree.
Definition: TTreePlayer.cxx:1548
TTreePlayer::fSelectorFromFile
TSelector * fSelectorFromFile
Pointer to current selector.
Definition: TTreePlayer.h:51
TTreePlayer::GetVar
TTreeFormula * GetVar(Int_t i) const
Definition: TTreePlayer.h:85
TTreePlayer::GetVar1
TTreeFormula * GetVar1() const
Definition: TTreePlayer.h:87
TTreePlayer::SetScanRedirect
void SetScanRedirect(Bool_t on=kFALSE)
Definition: TTreePlayer.h:122
TTreePlayer::CopyTree
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.
Definition: TTreePlayer.cxx:185
TTreePlayer::GetSelector
virtual TSelector * GetSelector() const
Definition: TTreePlayer.h:82
TTreePlayer::fInput
TList * fInput
Pointer to the actual class of the TSelectorFromFile.
Definition: TTreePlayer.h:53
TTreePlayer::GetV2
virtual Double_t * GetV2() const
Definition: TTreePlayer.h:99
TTreePlayer::StartViewer
virtual void StartViewer(Int_t ww, Int_t wh)
Start the TTreeViewer on this TTree.
Definition: TTreePlayer.cxx:2948
TTreePlayer::GetVar4
TTreeFormula * GetVar4() const
Definition: TTreePlayer.h:93
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TTreePlayer::UnbinnedFit
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.
Definition: TTreePlayer.cxx:3035
TVirtualTreePlayer
Abstract base class defining the interface for the plugins that implement Draw, Scan,...
Definition: TVirtualTreePlayer.h:38
TPrincipal
Principal Components Analysis (PCA)
Definition: TPrincipal.h:21
TTreePlayer::fHistogram
TH1 * fHistogram
Definition: TTreePlayer.h:49
TTreeFormula
Used to pass a selection expression to the Tree drawing routine.
Definition: TTreeFormula.h:58
TTreePlayer::fDimension
Int_t fDimension
Definition: TTreePlayer.h:47
TTreePlayer::~TTreePlayer
virtual ~TTreePlayer()
Tree destructor.
Definition: TTreePlayer.cxx:126
TTreePlayer::GetV3
virtual Double_t * GetV3() const
Definition: TTreePlayer.h:101
TTreePlayer::GetScanFileName
const char * GetScanFileName() const
Definition: TTreePlayer.h:79
TTreePlayer::TTreePlayer
TTreePlayer()
Default Tree constructor.
Definition: TTreePlayer.cxx:97
TTreePlayer::GetW
virtual Double_t * GetW() const
Definition: TTreePlayer.h:104
TSelectorDraw::GetVar4
TTreeFormula * GetVar4() const
Definition: TSelectorDraw.h:99
TTreePlayer::GetVal
virtual Double_t * GetVal(Int_t i) const
Definition: TTreePlayer.h:95
TSelectorDraw::GetVar1
TTreeFormula * GetVar1() const
Definition: TSelectorDraw.h:93
TTreePlayer::fSelectorUpdate
TSelector * fSelectorUpdate
Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
Definition: TTreePlayer.h:55
TTreePlayer::GetNfill
virtual Int_t GetNfill() const
Definition: TTreePlayer.h:78
TTreePlayer::BuildIndex
virtual TVirtualIndex * BuildIndex(const TTree *T, const char *majorname, const char *minorname)
Build the index for the tree (see TTree::BuildIndex)
Definition: TTreePlayer.cxx:140
TTreePlayer::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
cleanup pointers in the player pointing to obj
Definition: TTreePlayer.cxx:2339
Double_t
double Double_t
Definition: RtypesCore.h:59
TSelectorDraw.h
TTreePlayer::GetV4
virtual Double_t * GetV4() const
Definition: TTreePlayer.h:103
TSelectorDraw::GetVal
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 ...
Definition: TSelectorDraw.cxx:1069
TTreePlayer::GetEntries
virtual Long64_t GetEntries(const char *selection)
Return the number of entries matching the selection.
Definition: TTreePlayer.cxx:589
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TSelectorDraw::GetV2
virtual Double_t * GetV2() const
Definition: TSelectorDraw.h:104
TSelectorDraw::GetV4
virtual Double_t * GetV4() const
Definition: TSelectorDraw.h:108
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TTreePlayer::GetV1
virtual Double_t * GetV1() const
Definition: TTreePlayer.h:97
TTreePlayer::fSelectedRows
Long64_t fSelectedRows
Definition: TTreePlayer.h:48
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:34
TSelectorDraw::GetV3
virtual Double_t * GetV3() const
Definition: TSelectorDraw.h:106
TTreePlayer::GetVar3
TTreeFormula * GetVar3() const
Definition: TTreePlayer.h:91
TTreePlayer::fFormulaList
TList * fFormulaList
input list to the selector
Definition: TTreePlayer.h:54
TTreePlayer::DeleteSelectorFromFile
void DeleteSelectorFromFile()
Delete any selector created by this object.
Definition: TTreePlayer.cxx:250
TTreePlayer::TTreePlayer
TTreePlayer(const TTreePlayer &)=delete
TSelectorDraw::GetVar2
TTreeFormula * GetVar2() const
Definition: TSelectorDraw.h:95
TTreePlayer::GetVar2
TTreeFormula * GetVar2() const
Definition: TTreePlayer.h:89
TTreePlayer::fScanRedirect
Bool_t fScanRedirect
Pointer to current Tree.
Definition: TTreePlayer.h:45
TTreePlayer::SetScanFileName
void SetScanFileName(const char *name)
Definition: TTreePlayer.h:123
TTreePlayer::MakeClass
virtual Int_t MakeClass(const char *classname, Option_t *option)
Generate skeleton analysis class for this Tree.
Definition: TTreePlayer.cxx:718
TTreePlayer::GetEntriesToProcess
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...
Definition: TTreePlayer.cxx:602
TTreePlayer::GetSelectorFromFile
virtual TSelector * GetSelectorFromFile() const
Definition: TTreePlayer.h:83
TList
A doubly linked list.
Definition: TList.h:44
TSelectorDraw
A specialized TSelector for TTree::Draw.
Definition: TSelectorDraw.h:33
int