TTree::Draw expression spanning several entries?

I would like to accomplish the following: For a very long TTree, I would not want to draw each entry into a TGraph via TTree::Draw(“myVar:myTime”), but rather the minimum (or maximum) of myVar for let’s say 1000 entries at a time.
Is that possible using a Draw() expression, like it is possible for Min$, Max$ and average (Sum$/Length$) over arrays within one entry? Or do I have to code an event loop that calculates this quantity?
Thanks a lot


TTreeDraw/TTreeFormula can only look at one entry a time. You could emulate what you need by calling TTree::Draw("myVar:myTime","","",1000,cursor);and grab the minimum and maximum of the graph for each iterations.

[quote]Or do I have to code an event loop that calculates this quantity?[/quote]You can also implement this using TTree::MakeProxy or TTreeMakeSelector. or using the following simple TTree::Draw script[code]// File mymin.h
#include “TH2F.h”

[code]// File mymin.C
double xmin;
double xmax;

TH2F *fHist;

void mymin_Begin(TTree *) {
fHist = new TH2F(“minmax”,"",100,-5,-2,100,2,5);

void mymin() {}

void mymin_Process(Long64_t entry) {
if ( (entry%1000) == 0 ) {
if (entry != 0) {
xmin = xmax = px;
} else {
if (px < xmin) xmin = px;
if (px > xmax) xmax = px;

void mymin_Terminate() {
and simply use as mytree->Draw(“mymin.C”,"",“nohist”);
This example works with $ROOTSYS/tutorials/hsimple.root (produced by $ROOTSYS/tutorials/hsimple.C).
Note that the data is stored in a branch named ‘px’ and it is retrieve automatically when using ‘px’ as a variable name.