TTree GetMaximum/Minimum and arrays

Dear ROOTers,

I have problem with the simple TTree::GetMaximum() (same for GetMinimum()). I have a very very simple tree:

root [1] t3->Show(0) ======> EVENT:0 data_uncorr = 0.692981, 3.1346 data = 0.692981, -14.5881 data_pca = -0.531974, 0.317373
with 3 arrays with 2 elements each. If I inspect the value of the first element of one of the arrays:

[code]root [2] t3->Scan(“data[0]”)


  • Row * data[0] *

  •    0 * 0.6929806 *
    
  •    1 * -0.225166 *
    
  •    2 * 2.4479802 *
    
  •    3 * -5.183904 *
    
  •    4 * 1.1622624 *
    
  •    5 * 1.7613392 *
    
  •    6 * 3.0095173 *
    
  •    7 * -0.966987 *
    
  •    8 * 3.2889281 *
    
  •    9 * -2.093070 *
    
  •   10 * 1.1647273 *
    
  •   11 * 1.7720121 *
    
  •   12 * 3.6472161 *
    
  •   13 * -1.056948 *
    
  •   14 * 2.4577540 *
    
  •   15 * 5.4074670 *
    
  •   16 * 2.6424944 *
    
  •   17 * 2.5678389 *
    
  •   18 * 2.8672568 *
    
  •   19 * 4.1759014 *
    
  •   20 * -0.420431 *
    
  •   21 * 2.1318243 *
    
  •   22 * 2.9746373 *
    
  •   23 * 1.6315013 *
    
  •   24 * 1.4438320 *
    

Type to continue or q to quit ==> q


(Long64_t)25[/code]
while if I use GetMinimum():

root [3] t3->GetMinimum("data[0]") (Double_t)0.00000000000000000e+00
if instead I do it on the whole array (not just on the first element, but this clearly is NOT what I need), it works:

root [4] t3->GetMinimum("data") (Double_t)(-1.92736564591542958e+01)
where I’m wrong?

Thanks,
Matteo

Hi Matteo,

The currently implementation of GetMinimum and GetMaximum does indeed only support trivial cases (and in the case [0], it simply does not find the proper leaf). The same implementation deficiency leads to ROOT-8505.

The solution is to rewrite those two functions in using TTreeFormula.

In the meantime, you can awkwardly get the information from TTree::Draw by creating an histogram and asking the minimum or maximum from the histogram.

Cheers,
Philippe.

Ciao,

I found several posts about the limitations, but I was thinking that my tree was enough ‘simple’… Just to let you know: if the correct leaf is not found, anyhow, no warning is issued; simply the result is zero, that maybe is not the best…

Anyhow I understand the problem and I will use a workaround (like the one you proposed).

Thanks,
Matteo