How to draw min/max value from ntuple variables?


I’m quite a new ROOT user, trying to get to grips with it still, so sorry if this question is a bit basic.

I have an ntuple root file with x, y, t variables, with multiple values of t for specific x, y coordinates. I would like to draw this to a 3D graph where only the minimum value of t per coordinate is drawn, ignoring all other values of t.

Is there any way to do this? I’m not sure where to even start.

Thanks in advance!


let’s divide the problem in steps:

  1. Reading a TTree
  2. Getting the maximum of a collection
  3. Plotting values in a 3D graphic

Now, ROOT can help you in each of the steps!

  1. See and modify according to your needs.
  2. This one depends on how you stored the t values. In general, the STL library offers a way to get the min element of a collection
  3. Here you find the ROOT implementation of a 3D graph: … it_8C.html


Thanks for the reply!

I stupidly failed to mention that I’m forced to run ROOT version 5 as I’m using a windows machine, which doesn’t have TTreeReader. Is there an equivalent for ver 5?


   Float_t x,y,t;
   TTree *T = new TTree("T","test tree");
   TRandom r;
   for (Int_t i=0;i<5000;i++) {
      x = r.Gaus(10,1);
      y = r.Gaus(20,2);
      if (i<100) t = -100;
      else t = r.Landau(2,1);

   Int_t n = T->Draw("t","","goff");

   Double_t *vt = T->GetVal(0);
   Double_t min = 99999;
   for (int i=0; i<n;i++)  {if (vt[i] < min) min = vt[i];}
   T->Draw("x:y:t", Form("t==%f",min));