# Dividing one axis of a TH3D by a TH1D

**URL:** <https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422>\
**Category:** Newbie\
**Created:** [April 2, 2019, 6:50pm UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422 "2019-04-02T18:50:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RootFruit](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@RootFruit](https://root-forum.cern.ch/u/RootFruit)\
**Post date:** [April 2, 2019, 6:50pm UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422/1 "2019-04-02T18:50:45Z")

</div>

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:

```auto
  void normalisation() {

    TFile *file = new TFile("~/Desktop/somepath/data.root","read");
    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:

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

```

Any ideas? Thanks!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 3, 2019, 8:33am UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422/2 "2019-04-03T08:33:35Z")

</div>

> [@RootFruit](#):
>
> Which gives me the error message:

Yes, [TAxis has no members Divide()](https://root.cern/doc/master/classTAxis.html).

---

<div class="post-metadata">

**Author:** ![RootFruit](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@RootFruit](https://root-forum.cern.ch/u/RootFruit)\
**Post date:** [April 4, 2019, 12:56pm UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422/3 "2019-04-04T12:56:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 4, 2019, 1:03pm UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422/4 "2019-04-04T13:03:01Z")

</div>

> [@RootFruit](#):
>
> I have a TH3D and I want to divide only **one** axis by a TH1D

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.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [April 4, 2019, 1:18pm UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422/5 "2019-04-04T13:18:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RootFruit](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/eada6e/32.png) [@RootFruit](https://root-forum.cern.ch/u/RootFruit)\
**Post date:** [April 4, 2019, 1:40pm UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422/6 "2019-04-04T13:40:20Z")

</div>

> [@moneta](#):
>
> The division is done at the bin level, i.e. you divide the bin content(x,y,z) of the 3D histogram

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.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [April 4, 2019, 2:08pm UTC](https://root-forum.cern.ch/t/dividing-one-axis-of-a-th3d-by-a-th1d/33422/7 "2019-04-04T14:08:46Z")

</div>

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
