TTree
class description - source file - inheritance tree
protected:
const Text_t* GetNameByIndex(TString& varexp, Int_t* index, Int_t colindex)
virtual Int_t MakeChopt(Option_t* option)
virtual Int_t MakeFitOptions(Option_t* option)
virtual void MakeIndex(TString& varexp, Int_t* index)
virtual void SetDirectory(TDirectory* dir)
void TakeAction(Int_t nfill, Int_t& npoints, Int_t& action, TObject* obj, Option_t* option)
void TakeEstimate(Int_t nfill, Int_t& npoints, Int_t action, TObject* obj, Option_t* option)
public:
TTree TTree()
TTree TTree(Text_t* name, Text_t* title, Int_t maxvirtualsize = 0)
TTree TTree(TTree&)
virtual void ~TTree()
virtual void AddTotBytes(Int_t tot)
virtual void AddZipBytes(Int_t zip)
virtual void AutoSave()
TBranch* Branch(Text_t* name, Text_t* classname, void* addobj, Int_t bufsize = 32000, Int_t splitlevel = 1)
TBranch* Branch(Text_t* name, void* address, Text_t* leaflist, Int_t bufsize = 32000)
TBranch* Branch(Text_t* name, void* clonesaddress, Int_t bufsize = 32000, Int_t splitlevel = 1)
virtual void Browse(TBrowser* b)
TClass* Class()
virtual void ClearFormula()
virtual TTree* CloneTree(Int_t nevents = -1)
virtual void CompileVariables(Text_t* varexp, Text_t* selection)
virtual Int_t CopyEvents(TTree* tree, Int_t nevents = -1)
virtual void CreatePacketGenerator(Int_t nevents, Stat_t firstEvent)
virtual void Draw(Text_t* varexp, Text_t* selection, Option_t* option, Int_t nevents = 1000000000, Int_t firstevent = 0)
virtual void Draw(TCut varexp, TCut selection, Option_t* option, Int_t nevents = 1000000000, Int_t firstevent = 0)
virtual void Draw(Option_t* opt)
void DropBuffers(Int_t nbytes)
virtual void EstimateLimits(Int_t estimate, Int_t nevents = 1000000000, Int_t firstevent = 0)
virtual void EventLoop(Int_t& action, TObject* obj, Int_t nevents = 1000000000, Int_t firstevent = 0, Option_t* option)
virtual Int_t Fill()
void FindGoodLimits(Int_t nbins, Int_t& newbins, Float_t& xmin, Float_t& xmax)
virtual void Fit(Text_t* formula, Text_t* varexp, Text_t* selection, Option_t* option, Option_t* goption, Int_t nevents = 1000000000, Int_t firstevent = 0)
virtual TBranch* GetBranch(Text_t* name)
TFile* GetCurrentFile()
TDirectory* GetDirectory()
virtual Stat_t GetEntries()
virtual Int_t GetEstimate()
virtual Int_t GetEvent(Int_t event = 0, Int_t getall = 0)
TEventList* GetEventList()
virtual Int_t GetEventNumber(Int_t event)
virtual TLeaf* GetLeaf(Text_t* name)
virtual TList* GetListOfActiveBranches()
virtual TObjArray* GetListOfBranches()
virtual TObjArray* GetListOfLeaves()
virtual Int_t GetMaxEventLoop()
virtual Float_t GetMaximum(Text_t* columname)
virtual Int_t GetMaxVirtualSize()
virtual Float_t GetMinimum(Text_t* columname)
TTreeFormula* GetMultiplicity()
virtual Int_t GetNbranches()
virtual void GetNextPacket(TSlave* sl, Int_t& nevents, Stat_t& firstevent, Stat_t& processed)
virtual Int_t GetOldEventNumber()
TPacketGenerator* GetPacketGenerator()
virtual Int_t GetPacketSize()
virtual Int_t GetReadEvent()
virtual Int_t GetScanField()
TTreeFormula* GetSelect()
virtual Int_t GetSelectedRows()
TSelector* GetSelector()
virtual Stat_t GetTotBytes()
virtual Float_t* GetV1()
virtual Float_t* GetV2()
virtual Float_t* GetV3()
TTreeFormula* GetVar1()
TTreeFormula* GetVar2()
TTreeFormula* GetVar3()
TTreeFormula* GetVar4()
virtual Double_t* GetW()
virtual Stat_t GetZipBytes()
virtual void IncrementTotalBuffers(Int_t nbytes)
virtual TClass* IsA()
virtual Bool_t IsFolder()
virtual Int_t LoadTree(Int_t event)
virtual void Loop(Option_t* option, Int_t nevents = 1000000000, Int_t firstevent = 0)
virtual Int_t MakeCode(char* filename = 0)
Bool_t MemoryFull(Int_t nbytes)
virtual void Print(Option_t* option)
virtual void Project(Text_t* hname, Text_t* varexp, Text_t* selection, Option_t* option, Int_t nevents = 1000000000, Int_t firstevent = 0)
virtual void Reset(Option_t* option)
virtual void Scan(Text_t* varexp, Text_t* selection, Option_t* option, Int_t nevents = 1000000000, Int_t firstevent = 0)
virtual void SetAutoSave(Int_t autosave = 10000000)
virtual void SetBranchAddress(Text_t* bname, void* add)
virtual void SetBranchStatus(Text_t* bname, Bool_t status = 1)
virtual void SetEstimate(Int_t nevents = 10000)
virtual void SetEventList(TEventList* list)
virtual void SetMaxEventLoop(Int_t maxev = 1000000000)
virtual void SetMaxVirtualSize(Int_t size = 0)
virtual void SetName(Text_t* name)
virtual void SetPacketSize(Int_t size = 100)
virtual void SetScanField(Int_t n = 50)
virtual void SetSelector(Text_t* macroname)
virtual void SetSelector(TSelector* selector = 0)
virtual void SetUpdate(Int_t freq = 0)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
virtual void Streamer(TBuffer& b)
virtual void UpdateActiveBranches()
protected:
Int_t fScanField Number of runs before prompting in Scan
Int_t fDraw Last event loop number when object was drawn
Int_t fUpdate Update frequency for EventLoop
Int_t fMaxEventLoop Maximum number of events to process
Int_t fMaxVirtualSize Maximum total size of buffers kept in memory
Int_t fAutoSave Autosave tree when fAutoSave bytes produced
Stat_t fEntries Number of entries
Stat_t fTotBytes Total number of bytes in all branches before compression
Stat_t fZipBytes Total number of bytes in all branches after compression
Stat_t fSavedBytes Number of autosaved bytes
TTreeFormula* fVar1 Pointer to first variable formula
TTreeFormula* fVar2 Pointer to second variable formula
TTreeFormula* fVar3 Pointer to third variable formula
TTreeFormula* fVar4 Pointer to fourth variable formula
TTreeFormula* fSelect Pointer to selection formula
TTreeFormula* fMultiplicity Pointer to formula giving ndata per event
Int_t fOldEventNumber Number of the previously read event
Int_t fReadEvent Number of the event being processed
Int_t fTotalBuffers Total number of bytes in branch buffers
Int_t fEstimate Number of events to estimate histogram limits
Int_t fDimension Dimension of the current expression
Int_t fSelectedRows Number of selected events
Int_t fPacketSize Number of events in one packet for parallel root
Int_t fNbins[4] Number of bins per dimension
Float_t fVmin[4] Minima of varexp columns
Float_t fVmax[4] Maxima of varexp columns
Float_t* fV1 Local buffer for variable 1
Float_t* fV2 Local buffer for variable 2
Float_t* fV3 Local buffer for variable 3
Double_t* fW Local buffer for weights
TDirectory* fDirectory Pointer to directory holding this tree
TObjArray fBranches List of Branches
TObjArray fLeaves Direct pointers to individual branch leaves
TList* fActiveBranches List of active branches
TEventList* fEventList Pointer to event selection list (if one)
TSelector* fSelector Pointer to current selector
TPacketGenerator* fPacketGen Packet generator
Int_t fNfill Local for EventLoop
See also
-
TChain, TNtuple
TTree
a TTree object has a header with a name and a title.
It consists of a list of independent branches (TBranch). Each branch
has its own definition and list of buffers. Branch buffers may be
automatically written to disk or kept in memory until the Tree attribute
fMaxVirtualSize is reached.
Variables of one branch are written to the same buffer.
A branch buffer is automatically compressed if the file compression
attribute is set (default).
Branches may be written to different files (see TBranch::SetFile).
The ROOT user can decide to make one single branch and serialize one
object into one single I/O buffer or to make several branches.
Making one single branch and one single buffer can be the right choice
when one wants to process only a subset of all entries in the tree.
(you know for example the list of event numbers you want to process).
Making several branches is particularly interesting in the data analysis
phase, when one wants to histogram some attributes of an object (event)
without reading all the attributes.
==> TTree *tree = new TTree(name, title, maxvirtualsize)
Creates a Tree with name and title. Maxvirtualsize is by default 64Mbytes,
maxvirtualsize = 64000000(default) means: Keeps as many buffers in memory until
the sum of all buffers is greater than 64 Megabyte. When this happens,
memory buffers are written to disk and deleted until the size of all
buffers is again below the threshold.
maxvirtualsize = 0 means: keep only one buffer in memory.
Various kinds of branches can be added to a tree:
A - simple structures or list of variables. (may be for C or Fortran structures)
B - any object (inheriting from TObject). (we expect this option be the most frequent)
C - a ClonesArray. (a specialized object for collections of same class objects)
==> Case A
======
TBranch *branch = tree->Branch(branchname,address, leaflist, bufsize)
* address is the address of the first item of a structure
* leaflist is the concatenation of all the variable names and types
separated by a colon character :
The variable name and the variable type are separated by a slash (/).
The variable type may be 0,1 or 2 characters. If no type is given,
the type of the variable is assumed to be the same as the previous
variable. If the first variable does not have a type, it is assumed
of type F by default. The list of currently supported types is given below:
- C : a character string terminated by the 0 character
- B : an 8 bit signed integer (Char_t)
- b : an 8 bit unsigned integer (UChar_t)
- S : a 16 bit signed integer (Short_t)
- s : a 16 bit unsigned integer (UShort_t)
- I : a 32 bit signed integer (Int_t)
- i : a 32 bit unsigned integer (UInt_t)
- F : a 32 bit floating point (Float_t)
- D : a 64 bit floating point (Double_t)
==> Case B
======
TBranch *branch = tree->Branch(branchname,object, bufsize, splitlevel)
object is the address of a pointer to an existing object (derived from TObject).
if splitlevel=1 (default), this branch will automatically be split
into subbranches, with one subbranch for each data member or object
of the object itself. In case the object member is a TClonesArray,
the mechanism described in case C is applied to this array.
if splitlevel=0, the object is serialized in the branch buffer.
==> Case C
======
TBranch *branch = tree->Branch(branchname,clonesarray, bufsize, splitlevel)
clonesarray is the address of a pointer to a TClonesArray.
The TClonesArray is a direct access list of objects of the same class.
For example, if the TClonesArray is an array of TTrack objects,
this function will create one subbranch for each data member of
the object TTrack.
==> branch->SetAddress(Void *address)
In case of dynamic structures changing with each event for example, one must
redefine the branch address before filling the branch again.
This is done via the TBranch::SetAddress member function.
==> tree->Fill()
loops on all defined branches and for each branch invokes the Fill function.
See also the class TNtuple (a simple Tree with only one branch)
/*
*/
=============================================================================
______________________________________________________________________________
*-*-*-*-*-*-*A simple example with histograms and a tree*-*-*-*-*-*-*-*-*-*
*-* ===========================================
This program creates :
- a one dimensional histogram
- a two dimensional histogram
- a profile histogram
- a tree
These objects are filled with some random numbers and saved on a file.
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
#include "TROOT.h"
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TRandom.h"
#include "TTree.h"
TROOT simple("simple","Histograms and trees");
//______________________________________________________________________________
main(int argc, char **argv)
{
// Create a new ROOT binary machine independent file.
// Note that this file may contain any kind of ROOT objects, histograms,trees
// pictures, graphics objects, detector geometries, tracks, events, etc..
// This file is now becoming the current directory.
TFile hfile("htree.root","RECREATE","Demo ROOT file with histograms & trees");
// Create some histograms and a profile histogram
TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
TH2F *hpxpy = new TH2F("hpxpy","py ps px",40,-4,4,40,-4,4);
TProfile *hprof = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20);
// Define some simple structures
typedef struct {Float_t x,y,z;} POINT;
typedef struct {
Int_t ntrack,nseg,nvertex;
UInt_t flag;
Float_t temperature;
} EVENTN;
static POINT point;
static EVENTN eventn;
// Create a ROOT Tree
TTree *tree = new TTree("T","An example of ROOT tree with a few branches");
tree->Branch("point",&point,"x:y:z");
tree->Branch("eventn",&eventn,"ntrack/I:nseg:nvertex:flag/i:temperature/F");
tree->Branch("hpx","TH1F",&hpx,128000,0);
Float_t px,py,pz;
static Float_t p[3];
//--------------------Here we start a loop on 1000 events
for ( Int_t i=0; i<1000; i++) {
gRandom->Rannor(px,py);
pz = px*px + py*py;
Float_t random = gRandom->::Rndm(1);
// Fill histograms
hpx->Fill(px);
hpxpy->Fill(px,py,1);
hprof->Fill(px,pz,1);
// Fill structures
p[0] = px;
p[1] = py;
p[2] = pz;
point.x = 10*(random-1);;
point.y = 5*random;
point.z = 20*random;
eventn.ntrack = Int_t(100*random);
eventn.nseg = Int_t(2*eventn.ntrack);
eventn.nvertex = 1;
eventn.flag = Int_t(random+0.5);
eventn.temperature = 20+random;
// Fill the tree. For each event, save the 2 structures and 3 objects
// In this simple example, the objects hpx, hprof and hpxpy are slightly
// different from event to event. We expect a big compression factor!
tree->Fill();
}
//--------------End of the loop
tree->Print();
// Save all objects in this file
hfile.Write();
// Close the file. Note that this is automatically done when you leave
// the application.
hfile.Close();
return 0;
}
TTree(): TNamed()
*-*-*-*-*-*-*-*-*-*-*Default Tree constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ========================
TTree(const Text_t *name,const Text_t *title, Int_t maxvirtualsize)
:TNamed(name,title)
*-*-*-*-*-*-*-*-*-*Normal Tree constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ======================
The Tree is created in the current directory
Use the various functions Branch below to add branches to this Tree.
~TTree()
*-*-*-*-*-*-*-*-*-*-*Tree destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =================
void AutoSave()
*-*-*-*-*-*-*-*-*-*-*AutoSave tree header every fAutoSave bytes*-*-*-*-*-*
*-* ==========================================
When large Trees are produced, it is safe to activate the AutoSave
procedure. Some branches may have buffers holding many events.
AutoSave is automatically called by TTree::Fill when the number of bytes
generated since the previous AutoSave is greater than fAutoSave bytes.
This function may also be invoked by the user, for example every
N events.
Each AutoSave generates a new key on the file.
In case your program crashes before closing the file holding this tree,
the file will be automatically recovered when you will connect the file
in UPDATE mode.
The Tree will be recovered at the status corresponding to the last AutoSave.
TBranch* Branch(const Text_t *name, void *address, const Text_t *leaflist,Int_t bufsize)
*-*-*-*-*-*-*-*-*-*-*Create a new TTree Branch*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =========================
This Branch constructor is provided to support non-objects in
a Tree. The variables described in leaflist may be simple variables
or structures.
See the two following constructors for writing objects in a Tree.
By default the branch buffers are stored in the same file as the Tree.
use TBranch::SetFile to specify a different file
TBranch* Branch(const Text_t *name, const Text_t *classname, void *addobj, Int_t bufsize, Int_t splitlevel)
*-*-*-*-*-*-*-*-*-*-*Create a new TTree BranchObject*-*-*-*-*-*-*-*-*-*-*-*
*-* ===============================
Build a TBranchObject for an object of class classname.
addobj is the address of a pointer to an object of class classname.
IMPORTANT: classname must derive from TObject.
This option requires access to the library where the corresponding class
is defined. Accessing one single data member in the object implies
reading the full object.
See the next Branch constructor for a more efficient storage
in case the event consists of arrays of identical objects.
By default the branch buffers are stored in the same file as the Tree.
use TBranch::SetFile to specify a different file
TBranch* Branch(const Text_t *name, void *clonesaddress, Int_t bufsize, Int_t splitlevel)
*-*-*-*-*-*-*-*-*-*-*Create a new TTree BranchClones*-*-*-*-*-*-*-*-*-*-*-*
*-* ===============================
name: global name of this BranchClones
bufsize: buffersize in bytes of each individual data member buffer
clonesaddress is the address of a pointer to a TClonesArray.
This Tree option is provided in case each event consists of one
or more arrays of same class objects (tracks, hits,etc).
This function creates as many branches as there are public data members
in the objects pointed by the TClonesArray. Note that these data members
can be only basic data types, not pointers or objects.
BranchClones have the following advantages compared to the two other
solutions (Branch and BranchObject).
- When reading the Tree data, it is possible to read selectively
a subset of one object (may be just one single data member).
- This solution minimizes the number of objects created/destructed.
- Data members of the same type are consecutive in the basket buffers,
therefore optimizing the compression algorithm.
- Array processing notation becomes possible in the query language.
By default the branch buffers are stored in the same file as the Tree.
use TBranch::SetFile to specify a different file
void Browse(TBrowser *b)
void ClearFormula()
*-*-*-*-*-*-*Delete internal buffers*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =======================
TTree* CloneTree(Int_t nevents)
Create a clone of this tree and copy nevents
By default copy all events
IMPORTANT: Before invoking this function, the branch addresses
of this TTree must have been set.
For examples of CloneTree, see tutorials
-copytree:
Example of Root macro to copy a subset of a Tree to a new Tree
The input file has been generated by the program in $ROOTSYS/test/Event
with Event 1000 1 1 1
-copytree2:
Example of Root macro to copy a subset of a Tree to a new Tree
One branch of the new Tree is written to a separate file
The input file has been generated by the program in $ROOTSYS/test/Event
with Event 1000 1 1 1
void CompileVariables(const Text_t *varexp, const Text_t *selection)
*-*-*-*-*-*-*Compile input variables and selection expression*-*-*-*-*-*
*-* ================================================
varexp is an expression of the general form e1:e2:e3
where e1,etc is a formula referencing a combination of the columns
Example:
varexp = x simplest case: draw a 1-Dim distribution of column named x
= sqrt(x) : draw distribution of sqrt(x)
= x*y/z
= y:sqrt(x) 2-Dim dsitribution of y versus sqrt(x)
selection is an expression with a combination of the columns
Example:
selection = "x<y && sqrt(z)>3.2"
in a selection all the C++ operators are authorized
Int_t CopyEvents(TTree *tree, Int_t nevents)
Copy nevents from tree to this tree
By default copy all events
Return number of bytes copied to this tree.
void CreatePacketGenerator(Int_t nevents, Stat_t firstEvent)
Create or reset the packet generator.
void Draw(TCut varexp, TCut selection, Option_t *option, Int_t nevents, Int_t firstevent)
*-*-*-*-*-*-*-*-*-*-*Draw expression varexp for specified events-*-*-*-*-*
*-* ===========================================
This function accepts TCut objects as arguments.
Useful to use the string operator +
example:
ntuple.Draw("x",cut1+cut2+cut3);
void Draw(const Text_t *varexp0, const Text_t *selection, Option_t *option,Int_t nevents, Int_t firstevent)
*-*-*-*-*-*-*-*-*-*-*Draw expression varexp for specified events-*-*-*-*-*
*-* ===========================================
varexp is an expression of the general form e1:e2:e3
where e1,etc is a formula referencing a combination of the columns
Example:
varexp = x simplest case: draw a 1-Dim distribution of column named x
= sqrt(x) : draw distribution of sqrt(x)
= x*y/z
= y:sqrt(x) 2-Dim dsitribution of y versus sqrt(x)
selection is an expression with a combination of the columns
Example:
selection = "x<y && sqrt(z)>3.2"
in a selection all the C++ operators are authorized
option is the drawing option
see TH1::Draw for the list of all drawing options.
If option contains the string "goff", no graphics is generated.
nevents is the number of events to process (default is all)
first is the first event to process (default is 0)
Saving the result of Draw to an histogram
=========================================
By default the temporary histogram created is called htemp.
If varexp0 contains >>hnew (following the variable(s) name(s),
the new histogram created is called hnew and it is kept in the current
directory.
Example:
tree.Draw("sqrt(x)>>hsqrt","y>0")
will draw sqrt(x) and save the histogram as "hsqrt" in the current
directory.
By default, the specified histogram is reset.
To continue to append data to an existing histogram, use "+" in front
of the histogram name;
tree.Draw("sqrt(x)>>+hsqrt","y>0")
will not reset hsqrt, but will continue filling.
Making a Profile histogram
==========================
In case of a 2-Dim expression, one can generate a TProfile histogram
instead of a TH2F histogram by specyfying option=prof or option=profs.
The option=prof is automatically selected in case of y:x>>pf
where pf is an existing TProfile histogram.
Saving the result of Draw to a TEventList
=========================================
TTree::Draw can be used to fill a TEventList object (list of event numbers)
instead of histogramming one variable.
If varexp0 has the form >>elist , a TEventList object named "elist"
is created in the current directory. elist will contain the list
of event numbers satisfying the current selection.
Example:
tree.Draw(">>yplus","y>0")
will create a TEventList object named "yplus" in the current directory.
In an interactive session, one can type (after TTree::Draw)
yplus.Print("all")
to print the list of event numbers in the list.
By default, the specified event list is reset.
To continue to append data to an existing list, use "+" in front
of the list name;
tree.Draw(">>+yplus","y>0")
will not reset yplus, but will enter the selected events at the end
of the existing list.
Using a TEventList as Input
===========================
Once a TEventList object has been generated, it can be used as input
for TTree::Draw. Use TTree::SetEventList to set the current event list
Example:
TEventList *elist = (TEventList*)gDirectory->Get("yplus");
tree->SetEventList(elist);
tree->Draw("py");
Note: Use tree->SetEventList(0) if you do not want use the list as input.
How to obtain more info from TTree::Draw
========================================
Once TTree::Draw has been called, it is possible to access useful
information still stored in the TTree object via the following functions:
-GetSelectedRows() // return the number of events accepted by the
//selection expression. In case where no selection
//was specified, returns the number of events processed.
-GetV1() //returns a pointer to the float array of V1
-GetV2() //returns a pointer to the float array of V2
-GetV3() //returns a pointer to the float array of V3
-GetW() //returns a pointer to the double array of Weights
//where weight equal the result of the selection expression.
where V1,V2,V3 correspond to the expressions in
TTree::Draw("V1:V2:V3",selection);
Example:
Root > ntuple->Draw("py:px","pz>4");
Root > TGraph *gr = new TGraph(ntuple->GetSelectedRows(),
ntuple->GetV2(), ntuple->GetV1());
Root > gr->Draw("ap"); //draw graph in current pad
creates a TGraph object with a number of points corresponding to the
number of events selected by the expression "pz>4", the x points of the graph
being the px values of the Tree and the y points the py values.
Important note: By default TTree::Draw creates the arrays obtained
with GetV1, GetV2, GetV3, GetW with a length corresponding to the
parameter fEstimate. By default fEstimate=10000 and can be modified
via TTree::SetEstimate. A possible recipee is to do
tree->SetEstimate(tree->GetEntries());
You must call SetEstimate if the expected number of selected rows
is greater than 10000.
You can use the option "goff" to turn off the graphics output
of TTree::Draw in the above example.
void DropBuffers(Int_t)
*-*-*-*-*Drop branch buffers to accomodate nbytes below MaxVirtualsize*-*-*-*
void EstimateLimits(Int_t, Int_t nevents, Int_t firstevent)
*-*-*-*-*Estimate histogram limits for conditions of input parameters*-*-*-*
*-* ============================================================
The estimation of the limits is based on estimate events
The first estimate/2 and the last esstimate/2 events are used.
This algorithm is in general good enough to make a reasonable estimation
with a small number of events.
nevents is the number of events to process (default is all)
first is the first event to process (default is 0)
void EventLoop(Int_t &action, TObject *obj, Int_t nevents, Int_t firstevent, Option_t *option)
*-*-*-*-*-*-*-*-*-*-*-*-*Loop on all events*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ==================
nevents is the number of events to process (default is all)
first is the first event to process (default is 0)
action = 1 Fill 1-D histogram obj
= 2 Fill 2-D histogram obj
= 3 Fill 3-D histogram obj
= 4 Fill Profile histogram obj
= 5 Fill a TEventlist
= 11 Estimate Limits
= 12 Fill 2-D PolyMarker obj
= 13 Fill 3-D PolyMarker obj
action < 0 Evaluate Limits for case abs(action)
Int_t Fill()
*-*-*-*-*Fill all branches of a Tree*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ===========================
This function loops on all the branches of this tree.
For each branch, it copies to the branch buffer (basket) the current
values of the leaves data types.
If a leaf is a simple data type, a simple conversion to a machine
independent format has to be done.
void FindGoodLimits(Int_t nbins, Int_t &newbins, Float_t &xmin, Float_t &xmax)
*-*-*-*-*-*-*-*-*Find reasonable bin values*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ==========================
void Fit(const Text_t *formula ,const Text_t *varexp, const Text_t *selection,Option_t *option ,Option_t *goption,Int_t nevents, Int_t firstevent)
*-*-*-*-*-*-*-*-*Fit a projected item(s) from a Tree*-*-*-*-*-*-*-*-*-*
*-* ======================================
formula is a TF1 expression.
See TTree::Draw for explanations of the other parameters.
By default the temporary histogram created is called htemp.
If varexp contains >>hnew , the new histogram created is called hnew
and it is kept in the current directory.
Example:
tree.Fit(pol4,sqrt(x)>>hsqrt,y>0)
will fit sqrt(x) and save the histogram as "hsqrt" in the current
directory.
TBranch* GetBranch(const Text_t *name)
*-*-*-*-*-*Return pointer to the branch with name*-*-*-*-*-*-*-*
*-* ======================================
TFile* GetCurrentFile()
*-*-*-*-*-*Return pointer to the current file*-*-*-*-*-*-*-*
*-* ==================================
Int_t GetEvent(Int_t event, Int_t getall)
*-*-*-*-*-*Read all branches of event and return total number of bytes*-*-*
*-* ===========================================================
getall = 0 : get only active branches
getall = 1 : get all branches
Int_t GetEventNumber(Int_t event)
*-*-*-*-*-*Return event number corresponding to event*-*-*
*-* ==========================================
if no selection list returns event
else returns the event number corresponding to the list index=event
TLeaf* GetLeaf(const Text_t *name)
*-*-*-*-*-*Return pointer to the 1st Leaf named name in any Branch-*-*-*-*-*
*-* =======================================================
Float_t GetMaximum(Text_t *columname)
*-*-*-*-*-*-*-*-*Return maximum of column with name columname*-*-*-*-*-*-*
*-* ============================================
Float_t GetMinimum(Text_t *columname)
*-*-*-*-*-*-*-*-*Return minimum of column with name columname*-*-*-*-*-*-*
*-* ============================================
const Text_t* GetNameByIndex(TString &varexp, Int_t *index,Int_t colindex)
*-*-*-*-*-*-*-*-*Return name corresponding to colindex in varexp*-*-*-*-*-*
*-* ===============================================
varexp is a string of names separated by :
index is an array with pointers to the start of name[i] in varexp
void GetNextPacket(TSlave *sl, Int_t &nevents, Stat_t &firstevent, Stat_t &processed)
Return in nevents and firstevent the optimal range of events (packet)
to be processed by slave sl. See TPacketGenerator for the algorithm
used to get the packet size.
TSelector* GetSelector()
*-*-*-*-*-*Return current selector or create default selector
*-* ==================================================
Int_t LoadTree(Int_t event)
*-*-*-*-*-*-*-*-*Set current Tree event
*-* ======================
void Loop(Option_t *option, Int_t nevents, Int_t firstevent)
*-*-*-*-*-*-*-*-*Loop on nevents of this tree starting at firstevent
*-* ===================================================
Int_t MakeChopt(Option_t *)
*-*-*-*-*-*-*-*-*Fill Hoption structure with the codes in option*-*-*-*-*-*
*-* ===============================================
Int_t MakeCode(const char *filename)
====>
*-*-*-*-*-*-*-*-*Generate skeleton function for this Tree*-*-*-*-*-*-*
*-* ========================================
The function code is written on filename
if filename is NULL, filename will be nameoftree.C
The generated code includes the following:
- Identification of the original Tree and Input file name
- Connection of the Tree file
- Declaration of Tree variables
- Setting of branches addresses
- a skeleton for the event loop
To use this function:
- connect your Tree file (eg: TFile f("myfile.root");)
- T->MakeCode("anal.C");
where T is the name of the Tree in file myfile.root
and anal.C the name of the file created by this function.
Author: Rene Brun
====>
Int_t MakeFitOptions(Option_t *)
*-*-*-*-*-*-*-*-*Fill Foption structure with the codes in option*-*-*-*-*-*
*-* ===============================================
void MakeIndex(TString &varexp, Int_t *index)
*-*-*-*-*-*-*-*-*Build Index array for names in varexp*-*-*-*-*-*-*-*-*-*-*
*-* =====================================
Bool_t MemoryFull(Int_t nbytes)
*-*-*-*-*-*Check if adding nbytes to memory we are still below MaxVirtualsize
*-* ==================================================================
void Print(Option_t *option)
Print a summary of the Tree contents. In case options are "p" or "pa"
print information about the TPacketGenerator ("pa" is equivalent to
TPacketGenerator::Print("all")).
void Project(Text_t *hname, Text_t *varexp, Text_t *selection, Option_t *option,Int_t nevents, Int_t firstevent)
*-*-*-*-*-*-*-*-*Make a projection of a Tree using selections*-*-*-*-*-*-*
*-* =============================================
Depending on the value of varexp (described in Draw) a 1-D,2-D,etc
projection of the Tree will be filled in histogram hname.
Note that the dimension of hname must match with the dimension of varexp.
void Reset(Option_t *option)
*-*-*-*-*-*-*-*Reset buffers and entries count in all branches/leaves*-*-*
*-* ======================================================
void Scan(const Text_t *varexp, const Text_t *selection, Option_t *, Int_t nevents, Int_t firstevent)
*-*-*-*-*-*-*-*-*Loop on Tree & print events following selection*-*-*-*-*-*
*-* ===============================================
void SetBranchAddress(const Text_t *bname, void *add)
*-*-*-*-*-*-*-*-*Set branch address*-*-*-*-*-*-*-*
*-* ==================
If object is a TTree, this function is only an interface to TBranch::SetAddress
Function overloaded by TChain.
void SetBranchStatus(const Text_t *bname, Bool_t status)
*-*-*-*-*-*-*-*-*Set branch status Process or DoNotProcess*-*-*-*-*-*-*-*
*-* =========================================
bname is the name of a branch. if bname="*", apply to all branches.
status = 1 branch will be processed
= 0 branch will not be processed
void SetDirectory(TDirectory *dir)
Remove reference to this tree from current directory and add
reference to new directory dir. dir can be 0 in which case the tree
does not belong to any directory.
void SetEstimate(Int_t n)
*-*-*-*-*-*-*-*-*Set number of events to estimate variable limits*-*-*-*
*-* ================================================
void SetName(const Text_t *name)
*-*-*-*-*-*-*-*-*-*-*Change the name of this Tree*-*-*-*-*-*-*-*-*-*-*
*-* ============================
void SetPacketSize(Int_t size)
*-*-*-*-*-*-*-*-*Set number of events per packet for parallel root*-*-*-*-*
*-* =================================================
void SetSelector(TSelector *selector)
*-*-*-*-*-*-*-*-*Set current selector to user selector*-*-*-*-*-*-*-*
*-* =====================================
void SetSelector(const Text_t *macroname)
*-*-*-*-*-*-*-*-*Set current selector to macroname*-*-*-*-*-*-*-*
*-* =================================
void Streamer(TBuffer &b)
*-*-*-*-*-*-*-*-*Stream a class object*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =========================================
void TakeAction(Int_t nfill, Int_t &npoints, Int_t &action, TObject *obj, Option_t *option)
*-*-*-*-*-*Execute action for object obj nfill times*-*-*-*-*-*-*-*-*-*
*-* =========================================
void TakeEstimate(Int_t nfill, Int_t &, Int_t action, TObject *obj, Option_t *option)
*-*-*-*-*-*Estimate limits for 1-D, 2-D or 3-D objects*-*-*-*-*-*-*-*-*-*
*-* ===========================================
void UpdateActiveBranches()
*-*-*-*-*-*-*-*-*Build the list of active branches*-*-*-*-*-*-*-*
*-* =================================
Scan all branches and enter branches with active status in fActiveBranches.
Inline Functions
void AddTotBytes(Int_t tot)
void AddZipBytes(Int_t zip)
void Draw(Text_t* varexp, Text_t* selection, Option_t* option, Int_t nevents = 1000000000, Int_t firstevent = 0)
TDirectory* GetDirectory()
Stat_t GetEntries()
Int_t GetEstimate()
TEventList* GetEventList()
TList* GetListOfActiveBranches()
TObjArray* GetListOfBranches()
TObjArray* GetListOfLeaves()
Int_t GetMaxEventLoop()
Int_t GetMaxVirtualSize()
TTreeFormula* GetMultiplicity()
Int_t GetNbranches()
Int_t GetOldEventNumber()
TPacketGenerator* GetPacketGenerator()
Int_t GetPacketSize()
Int_t GetReadEvent()
Int_t GetScanField()
TTreeFormula* GetSelect()
Int_t GetSelectedRows()
TTreeFormula* GetVar1()
TTreeFormula* GetVar2()
TTreeFormula* GetVar3()
TTreeFormula* GetVar4()
Float_t* GetV1()
Float_t* GetV2()
Float_t* GetV3()
Double_t* GetW()
Stat_t GetTotBytes()
Stat_t GetZipBytes()
void IncrementTotalBuffers(Int_t nbytes)
Bool_t IsFolder()
void SetAutoSave(Int_t autosave = 10000000)
void SetEventList(TEventList* list)
void SetMaxEventLoop(Int_t maxev = 1000000000)
void SetMaxVirtualSize(Int_t size = 0)
void SetScanField(Int_t n = 50)
void SetUpdate(Int_t freq = 0)
TClass* Class()
TClass* IsA()
void ShowMembers(TMemberInspector& insp, char* parent)
TTree TTree(TTree&)
Author: Rene Brun 12/01/96
Last update: 2.00/12 01/10/98 21.21.22 by Rene Brun
Copyright (c) 1995-1998, The ROOT System, All rights reserved. *
ROOT page - Class index - 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.