rjseen
1
Hi,
I figured this should be an easy problem but I can’t seem to find a solution for it.
I want to change the default input units of TH1F and TH2F to GeV instead of MeV. This includes MeV/c, MeV/c², MeV²/c⁴ etc.
How is this done?
new TH2F(“momentumVsMissingMassSquared”, 150,0,100000,150,-150000,150000); -> new TH2F(“momentumVsMissingMassSquared”,"",150,0,100,150,-0.150,0.150);
The goal is to get it in units of GeV on the axes when plotting. So I guess there’s that way of approaching the problem as well.
Any thought?
[url=https://root-forum.cern.ch/t/can-we-shift-histogram-for-several-channels/12050/2 we shift histogram for several channels?[/url]
rjseen
3
That does indeed solve the problem with the axes. Thanks!
If there’s anyone with a clue on how to change the default units do tell.
ferhue
4
You can also try with
h->GetXaxis()->SetLimits(h->GetXaxis()->GetXmin()/1000,h->GetXaxis()->GetXmax()/1000);
h->GetYaxis()->SetLimits(h->GetYaxis()->GetXmin()/1000,h->GetYaxis()->GetXmax()/1000);
Or instead, plot directly in the correct coordinates:
h->Fill(enex/1000, eney/1000);
//tree->Draw(eney/1000:enex/1000);