# Dividing one axis of a TH3D by a TH1D

Hi root experts, newbie question:

I have a TH3D and I want to divide only one axis by a TH1D, while leaving the other axes unaffected. How do I do this?

So far I’ve tried:

``````  void normalisation() {

TH3D* histo3D_Original = (TH3D*)file->FindObjectAny("histo_3D");
TH1D* histo1D= (TH1D*)file->FindObjectAny("histo_1D");

TCanvas *canvas1 = new TCanvas();
canvas1->Divide(2,2);

canvas1->cd(1);
histo3D_Original->Draw("colz");

canvas1->cd(2);
histo1D->Draw("colz");

TH3D* histo3D_Clone = (TH3D*)histo3D_Original->Clone("histo3D_Clone");
histo3D_Clone->GetYaxis()->Divide(histo1D->GetXaxis,1);

canvas1->cd(3);
histo3D_Clone->Draw("colz");

file->Close();

}
``````

Which gives me the error message:

``````error: no member named 'Divide' in 'TAxis'
histo3D_Clone->GetYaxis()->Divide(histoFlux->GetXaxis,1);

``````

Any ideas? Thanks!

Which means there is no way to accomplish what I’m trying to achive?

I am not sure what that mean exactly. “Dividing an axis by an histogram” looks a bit weird seems to me. May be @moneta will have some idea about it.

Please indicate exactly which mathematical operation you would like to do.
The division is done at the bin level, i.e. you divide the bin content(x,y,z) of the 3D histogram

Lorenzo

This might already help me. By saying ‘dividing an axis by a histogram’ I mean that I want to take all the y bins of the 3D histogram and divide them by all the x bins of the 1D histogram, using the ->Divide function.

Maybe a little bit more detail: The y axis of the TH3D describes the energy of a particle, which needs to be normalized by the flux, which is described by the x axis of the TH1D.

Still I am confused. There are no y bins in a 3D histograms. A bin is having an x, y and z component. You might want to project (i.e. summing) for a given x all the corresponding bins or perform an average (Profile).

Also you seem to want to normalize coordinates ( y values). Instead in an histogram you normalize only bin contents (the 4th component in a 3d histogram).

I would suggest you describe with mathematical formulae what would you like to do

Lorenzo