Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
35class TVirtualIndex;
36
38
39private:
40 TTreePlayer(const TTreePlayer &) = delete;
41 TTreePlayer& operator=(const TTreePlayer &) = delete;
42
43protected:
44 TTree *fTree; ///<! Pointer to current Tree
45 bool 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
57protected:
58 const char *GetNameByIndex(TString &varexp, Int_t *index,Int_t colindex);
60
61public:
63 ~TTreePlayer() override;
64 TVirtualIndex *BuildIndex(const TTree *T, const char *majorname, const char *minorname) override;
65 TTree *CopyTree(const char *selection, Option_t *option
66 ,Long64_t nentries, Long64_t firstentry) override;
67 Long64_t DrawScript(const char* wrapperPrefix,
68 const char *macrofilename, const char *cutfilename,
69 Option_t *option, Long64_t nentries, Long64_t firstentry) override;
70 Long64_t DrawSelect(const char *varexp, const char *selection, Option_t *option
71 ,Long64_t nentries, Long64_t firstentry) override;
72 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) override;
74 Int_t GetDimension() const override {return fDimension;}
75 TH1 *GetHistogram() const override {return fHistogram;}
76 Long64_t GetEntries(const char *selection) override;
77 virtual Long64_t GetEntriesToProcess(Long64_t firstentry, Long64_t nentries) const;
78 Int_t GetNfill() const override {return fSelector->GetNfill();}
79 const char *GetScanFileName() const {return fScanFileName;}
80 TTreeFormula *GetSelect() const override {return fSelector->GetSelect();}
81 Long64_t GetSelectedRows() const override {return fSelectedRows;}
82 TSelector *GetSelector() const override {return fSelector;}
84 /// See TSelectorDraw::GetVar
85 TTreeFormula *GetVar(Int_t i) const override {return fSelector->GetVar(i);};
86 /// See TSelectorDraw::GetVar
87 TTreeFormula *GetVar1() const override {return fSelector->GetVar1();}
88 /// See TSelectorDraw::GetVar
89 TTreeFormula *GetVar2() const override {return fSelector->GetVar2();}
90 /// See TSelectorDraw::GetVar
91 TTreeFormula *GetVar3() const override {return fSelector->GetVar3();}
92 /// See TSelectorDraw::GetVar
93 TTreeFormula *GetVar4() const override {return fSelector->GetVar4();}
94 /// See TSelectorDraw::GetVal
95 Double_t *GetVal(Int_t i) const override {return fSelector->GetVal(i);};
96 /// See TSelectorDraw::GetVal
97 Double_t *GetV1() const override {return fSelector->GetV1();}
98 /// See TSelectorDraw::GetVal
99 Double_t *GetV2() const override {return fSelector->GetV2();}
100 /// See TSelectorDraw::GetVal
101 Double_t *GetV3() const override {return fSelector->GetV3();}
102 /// See TSelectorDraw::GetVal
103 Double_t *GetV4() const override {return fSelector->GetV4();}
104 Double_t *GetW() const override {return fSelector->GetW();}
105 Int_t MakeClass(const char *classname, Option_t *option) override;
106 Int_t MakeCode(const char *filename) override;
107 Int_t MakeProxy(const char *classname,
108 const char *macrofilename = nullptr, const char *cutfilename = nullptr,
109 const char *option = nullptr, Int_t maxUnrolling = 3) override;
110 Int_t MakeReader(const char *classname, Option_t *option) override;
111 TPrincipal *Principal(const char *varexp, const char *selection, Option_t *option
112 ,Long64_t nentries, Long64_t firstentry) override;
113 Long64_t Process(const char *filename,Option_t *option, Long64_t nentries, Long64_t firstentry) override;
114 Long64_t Process(TSelector *selector,Option_t *option, Long64_t nentries, Long64_t firstentry) override;
115 void RecursiveRemove(TObject *obj) override;
116 Long64_t Scan(const char *varexp, const char *selection, Option_t *option
117 ,Long64_t nentries, Long64_t firstentry) override;
119 TSQLResult *Query(const char *varexp, const char *selection, Option_t *option
120 ,Long64_t nentries, Long64_t firstentry) override;
121 void SetEstimate(Long64_t n) override;
122 void SetScanRedirect(bool on=false) {fScanRedirect = on;}
124 void SetTree(TTree *t) override {fTree = t;}
125 void StartViewer(Int_t ww, Int_t wh) override;
126 Int_t UnbinnedFit(const char *formula ,const char *varexp, const char *selection,Option_t *option
127 ,Long64_t nentries, Long64_t firstentry) override;
128 void UpdateFormulaLeaves() override;
129
130 ClassDefOverride(TTreePlayer,3); //Manager class to play with TTrees
131};
132
133#endif
int Int_t
Definition RtypesCore.h:45
long long Long64_t
Definition RtypesCore.h:69
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
char name[80]
Definition TGX11.cxx:110
int nentries
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
A doubly linked list.
Definition TList.h:38
Mother of all ROOT objects.
Definition TObject.h:41
Principal Components Analysis (PCA)
Definition TPrincipal.h:21
A specialized TSelector for TTree::Draw.
virtual Double_t * GetW() const
TTreeFormula * GetSelect() const
TTreeFormula * GetVar(Int_t i) const
Return the TTreeFormula corresponding to the i-th component of the request formula (where the compone...
virtual Double_t * GetV4() const
See TSelectorDraw::GetVal.
TTreeFormula * GetVar3() const
See TSelectorDraw::GetVar.
virtual Double_t * GetV2() const
See TSelectorDraw::GetVal.
TTreeFormula * GetVar2() const
See TSelectorDraw::GetVar.
TTreeFormula * GetVar1() const
See TSelectorDraw::GetVar.
TTreeFormula * GetVar4() const
See TSelectorDraw::GetVar.
virtual Double_t * GetV1() const
See 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 ...
virtual Double_t * GetV3() const
See TSelectorDraw::GetVal.
virtual Int_t GetNfill() const
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition TSelector.h:31
Basic string class.
Definition TString.h:139
Used to pass a selection expression to the Tree drawing routine.
Implement some of the functionality of the class TTree requiring access to extra libraries (Histogram...
Definition TTreePlayer.h:37
Int_t MakeCode(const char *filename) override
Generate skeleton function for this Tree.
TTree * CopyTree(const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Copy a Tree with selection, make a clone of this Tree header, then copy the selected entries.
Long64_t DrawSelect(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Draw expression varexp for specified entries that matches the selection.
TList * fInput
! input list to the selector
Definition TTreePlayer.h:53
void DeleteSelectorFromFile()
Delete any selector created by this object.
bool ScanRedirected()
void SetEstimate(Long64_t n) override
Set number of entries to estimate variable limits.
Int_t UnbinnedFit(const char *formula, const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Unbinned fit of one or more variable(s) from a Tree.
void RecursiveRemove(TObject *obj) override
cleanup pointers in the player pointing to obj
Double_t * GetW() const override
Long64_t DrawScript(const char *wrapperPrefix, const char *macrofilename, const char *cutfilename, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Draw the result of a C++ script.
TSelectorDraw * fSelector
! Pointer to current selector
Definition TTreePlayer.h:50
void SetTree(TTree *t) override
Long64_t GetSelectedRows() const override
Definition TTreePlayer.h:81
Int_t MakeReader(const char *classname, Option_t *option) override
Generate skeleton selector class for this tree.
const char * GetNameByIndex(TString &varexp, Int_t *index, Int_t colindex)
Return name corresponding to colindex in varexp.
TTreeFormula * GetVar4() const override
See TSelectorDraw::GetVar.
Definition TTreePlayer.h:93
TTreeFormula * GetVar(Int_t i) const override
See TSelectorDraw::GetVar.
Definition TTreePlayer.h:85
TTreeFormula * GetVar2() const override
See TSelectorDraw::GetVar.
Definition TTreePlayer.h:89
Long64_t fSelectedRows
Number of selected entries.
Definition TTreePlayer.h:48
Long64_t Scan(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Loop on Tree and print entries passing selection.
TSelector * fSelectorFromFile
! Pointer to a user defined selector created by this TTreePlayer object
Definition TTreePlayer.h:51
const char * fScanFileName
Name of the file where Scan is redirected.
Definition TTreePlayer.h:46
TList * fFormulaList
! Pointer to a list of coordinated list TTreeFormula (used by Scan and Query)
Definition TTreePlayer.h:54
bool fScanRedirect
Switch to redirect TTree::Scan output to a file.
Definition TTreePlayer.h:45
TTree * fTree
! Pointer to current Tree
Definition TTreePlayer.h:44
Double_t * GetV1() const override
See TSelectorDraw::GetVal.
Definition TTreePlayer.h:97
Double_t * GetV4() const override
See TSelectorDraw::GetVal.
TTreeFormula * GetSelect() const override
Definition TTreePlayer.h:80
TH1 * GetHistogram() const override
Definition TTreePlayer.h:75
TTreeFormula * GetVar3() const override
See TSelectorDraw::GetVar.
Definition TTreePlayer.h:91
void SetScanFileName(const char *name)
Int_t GetNfill() const override
Definition TTreePlayer.h:78
void StartViewer(Int_t ww, Int_t wh) override
Start the TTreeViewer on this TTree.
Int_t MakeProxy(const char *classname, const char *macrofilename=nullptr, const char *cutfilename=nullptr, const char *option=nullptr, Int_t maxUnrolling=3) override
Generate a skeleton analysis class for this Tree using TBranchProxy.
Int_t MakeClass(const char *classname, Option_t *option) override
Generate skeleton analysis class for this Tree.
TPrincipal * Principal(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Interface to the Principal Components Analysis class.
Double_t * GetV2() const override
See TSelectorDraw::GetVal.
Definition TTreePlayer.h:99
void SetScanRedirect(bool on=false)
TSelector * fSelectorUpdate
! Set to the selector address when it's entry list needs to be updated by the UpdateFormulaLeaves fun...
Definition TTreePlayer.h:55
TH1 * fHistogram
! Pointer to histogram used for the projection
Definition TTreePlayer.h:49
void UpdateFormulaLeaves() override
this function is called by TChain::LoadTree when a new Tree is loaded.
Long64_t Process(const char *filename, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Process this tree executing the TSelector code in the specified filename.
TSelector * GetSelectorFromFile() const override
Definition TTreePlayer.h:83
TSQLResult * Query(const char *varexp, const char *selection, Option_t *option, Long64_t nentries, Long64_t firstentry) override
Loop on Tree and return TSQLResult object containing entries passing selection.
TClass * fSelectorClass
! Pointer to the actual class of the TSelectorFromFile
Definition TTreePlayer.h:52
const char * GetScanFileName() const
Definition TTreePlayer.h:79
TSelector * GetSelector() const override
Definition TTreePlayer.h:82
TTreePlayer(const TTreePlayer &)=delete
Long64_t GetEntries(const char *selection) override
Return the number of entries matching the selection.
Int_t GetDimension() const override
Definition TTreePlayer.h:74
Int_t fDimension
Dimension of the current expression.
Definition TTreePlayer.h:47
Double_t * GetV3() const override
See TSelectorDraw::GetVal.
TVirtualIndex * BuildIndex(const TTree *T, const char *majorname, const char *minorname) override
Build the index for the tree (see TTree::BuildIndex)
TTreeFormula * GetVar1() const override
See TSelectorDraw::GetVar.
Definition TTreePlayer.h:87
TTreePlayer()
Default Tree constructor.
TTreePlayer & operator=(const TTreePlayer &)=delete
Double_t * GetVal(Int_t i) const override
See TSelectorDraw::GetVal.
Definition TTreePlayer.h:95
~TTreePlayer() override
Tree destructor.
Int_t Fit(const char *formula, const char *varexp, const char *selection, Option_t *option, Option_t *goption, Long64_t nentries, Long64_t firstentry) override
Fit a projected item(s) from a Tree.
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...
A TTree represents a columnar dataset.
Definition TTree.h:79
Abstract interface for Tree Index.
Abstract base class defining the interface for the plugins that implement Draw, Scan,...
const Int_t n
Definition legend1.C:16