Create TH1 with TAxis

Dear Experts,
I have a TAxis Object I obtained from another histogram

TAxis *Ax = Hist->GetYaxis();

Now I want to create a new histogram with this Axis. Therefor I did the following:

TAxis * X = new TAxis(1000,0,2000);
TH2 * NewHist = new TH2(“ThisHist”,“MyHisto”,X,Ax);

This does not work and I have not found a way to make a new Histogram using a TAxis. Can anyone help?
Thanks,
Emil

Edit: I already have it running by creating an array of bins from the TAxis, but it would still be interesting for the future, if it is possible to directely use the TAxis.

Hi,

there is no such constructor mentioned in ROOT: TH2 Class Reference

1 Like
auto  X = new TAxis(1000,0,2000);
auto NewHist = new TH1D(“ThisHist”,“MyHisto”,X->GetBsins(),X->GetXmin(),X->GetXmax());