Hey there,
I have been wasting a lot of time trying to change the labels on the histograms I create and save to an ntuple, but I always failed. Upon checking this simple root script, I realized, that even this simple script fails:
root [0] TH1D a("a", "a", 100, 0, 100)
(TH1D &) Name: a Title: a NbinsX: 100
root [1] a.GetXaxis() -> ChangeLabel(1, -1, 0.025, -1, -1, -1, "alma");
root [2] a.SaveAs("a.C")
Info in <TH1D::SaveAs>: C++ Macro file: a.C has been generated
root [3] a.GetXaxis() -> GetBinLabel(1)
(const char *) ""
root [4] a.Draw("") // Only this shows the correct label
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
More importantly, this fails too:
root [0] TH1D a("a", "a", 100, 0, 100)
(TH1D &) Name: a Title: a NbinsX: 100
root [1] a.GetXaxis() -> ChangeLabel(1, -1, 0.025, -1, -1, -1, "alma");
root [2] TFile::Open("alma.root", "RECREATE")
(TFile *) 0x2eb6a40
root [3] a.Write()
(Int_t) 301
I want to save my histograms with the correct labels, but the SaveAs() seem to fail achieving this. What am I doing wrong?
My root version is ROOT 6.08/02
.
Cheers,
Hunyadi Adam