Illustrates how to retrieve TTree variables in arrays.
This example:
- creates a simple TTree,
- generates TTree variables thanks to the
Draw method with goff option,
- retrieves some of them in arrays thanks to
GetVal,
- generates and draw graphs with these arrays.
The option goff in TTree::Draw behaves like any other drawing option except that, at the end, no graphics is produced ( goff= graphics off). This allows to generate as many TTree variables as needed. All the graphics options (except para and candle) are limited to four variables only. And para and candle need at least two variables.
Note that by default TTree::Draw creates the arrays obtained with GetVal with a length corresponding to the parameter fEstimate. By default fEstimate=1000000 and can be modified via TTree::SetEstimate. To keep in memory all the results use:
SetEstimate should be called if the expected number of selected rows is greater than 1000000.
The arrays' dimension is 5000
void treegetval() {
T->Branch("Run",&run,"Run/I");
T->Branch("Event",&evt,"Event/I");
T->Branch("z",&z,"z/F");
for (
Int_t i=0;i<10000;i++) {
if (i < 5000) run = 1;
else run = 2;
evt = i;
T->Fill();
}
Int_t n = T->Draw(
"x:y:z:Run:Event:sin(x):cos(x)",
"Run==1",
"goff");
printf(
"The arrays' dimension is %d\n",
n);
}
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 r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
A TGraph is an object made of two arrays X and Y with npoints each.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
This is the base class for the ROOT Random number generators.
A TTree represents a columnar dataset.
- Author
- Olivier Couet
Definition in file treegetval.C.