TH2F range

Hi, I’ve particles in energy range [1GeV; 1000GeV], I must draw TH2F whwere on x-axis there is the energy. I use a program to read the energy from CORSIKA files and it saves the histograms in root file. I know the energy is in the range [1GeV; 1000GeV] so, for example I define:

 int nbin12=1000;
  float xmin12=0.;
  float xmax12=1000.;
  float ymin12=1000;
  float ymax12=0.;  
  TH2F *hfirstint_primener = new TH2F("hfirstint_primener","",nbin12,xmin12,xmax12,nbin12,ymin12,ymax12);

because on the x-axis I want all the energy range, on the y-range I want that ROOT set the range. Unfortunatly, opening the root file I saw that root doesn’t use all the [0;1000] x-range, but for example it just show datas until 450 GeV… why? if I set the range for the x axis, why does root change it?

float ymin12 = 0.;
float ymax12 = 1000;

Note also that you may define any [xy]min and [xy]max but, after you fill the histogram, some bins may be empty if your “simulation” did not generate entries in them.

Hi pepe, thanks…but I’ve some set where for example ymin=-0.015 ymax=0.015 others where ymin=-70 ymax=70…so I need that root choise best range for the y-axis …but without deleting so much range of the x-axis… so I tried to set xmin=0 and xmax=1000 because I know the x range…but I can’t know the y-range, so I need an auto-range just for the y-range…

May be the section “Histograms with automatic bins” here
can help…

Hi cuet and thanks. But it’s what I did… I setted ymin>ymax to have automatic range…unfortunatly ROOT does not set just the y-axis range, but it set the automatic range for the x-axis too…so, for example, I’ve datas on x-axis from 1GeV to 1000 GeV, but ROOT just show the range 1-220 GeV on the plot…so I want to set x-axis using the range 1-1000, and just ask to ROOT to set only the y-axis, because the y axis depends it’s different for all particles and all data files.