How to get the Min and max value from a tree variable

Hello Rooters,
I need to get the Min and Max value from the tree variable.
I have 4 variables.
QSq,xBj , ixB(xB bin numbers), jQ2(QSq bin numbers)
I can read the variables properly.
But I need to find the QSq min and max values from each bin.

When I introduce following line.my root session exit unexpectedly.
Q2Min[j]= tree->GetMinimum(“QSq”);

Please see attached code and my root file.Could you please help me to figure this out?

Thanks
Dil
Tree_reading.cpp (1.2 KB)
xBQ2binning.root (1.9 MB)

May be it is s stupid question, but why not simply do:

% root xBQ2binning.root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01                        https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Jun 08 2022, 14:00:07                      |
  | From heads/master@v6-25-02-1465-gc9ea7609ee                      |
  | With Apple clang version 13.1.6 (clang-1316.0.21.2.5)            |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] 
Attaching file xBQ2binning.root as _file0...
(TFile *) 0x7fb2bcfd96b0
root [1] xBQ2binning_tree->GetMinimum("QSq")
(double) 1.5011401
root [2] 

Hello,
Yes,I can do what you mentioned without introducing binning.
But I need to find the Q2 [min,max] value inside each bin and generate some uniform random numbers.

Thanks
Dil

So you what to work on the resulting histogram.

xBQ2binning_tree->Draw("QSq","","goff")
->now htemp is ready to be used .....