# Dividing 2 branches from 2 different trees

**URL:** <https://root-forum.cern.ch/t/dividing-2-branches-from-2-different-trees/43538>\
**Category:** Newbie\
**Tags:** tree, hist, root\
**Created:** [February 13, 2021, 6:23pm UTC](https://root-forum.cern.ch/t/dividing-2-branches-from-2-different-trees/43538 "2021-02-13T18:23:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sara\_sellam](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sara_sellam/32/27402_2.png) [@sara\_sellam](https://root-forum.cern.ch/u/sara_sellam)\
**Post date:** [February 13, 2021, 6:23pm UTC](https://root-forum.cern.ch/t/dividing-2-branches-from-2-different-trees/43538/1 "2021-02-13T18:23:00Z")

</div>

Dear Experts,

I want to measure the reconstruction efficiency vs PT .

I want to divide ple\_PT(reconstructed)/ple\_TRUEPT(generated), without projecting them in a histogram.

Instead of h1-\>Divide(h2) where h1, and h2 are hists of ple\_PT and  
ple\_TRUEPT. I want to do :

tree-\>Project(“h”,“ple\_PT/ple\_TRUEPT”,"","")  
where ple\_PT is from tree A  
and ple\_TRUEPT is from tree B  
and the 2 trees don’t have the same nbr of events

this is because I want to avoid the bin migration when I do h1-\>Divide(h2) I don’t get the correct efficiency. I suspect that maybe ples generated in bin i are reconstructed in bin i+1

Anyone has an idea about what should I do?

Cheers

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [February 13, 2021, 6:27pm UTC](https://root-forum.cern.ch/t/dividing-2-branches-from-2-different-trees/43538/2 "2021-02-13T18:27:40Z")

</div>

You need to create “h1” and “h2” with exactly the same numbers of bins and x-axis ranges. Then the division will be fine.

---

<div class="post-metadata">

**Author:** ![sara\_sellam](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sara_sellam/32/27402_2.png) [@sara\_sellam](https://root-forum.cern.ch/u/sara_sellam)\
**Post date:** [February 13, 2021, 7:08pm UTC](https://root-forum.cern.ch/t/dividing-2-branches-from-2-different-trees/43538/3 "2021-02-13T19:08:35Z")

</div>

Thanks for your reply.

yes I am aware that I should use the same binning and the same x axis range. but what I get is totally wrong. this is why I suspected that I am having a bin migration.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [February 13, 2021, 7:22pm UTC](https://root-forum.cern.ch/t/dividing-2-branches-from-2-different-trees/43538/4 "2021-02-13T19:22:45Z")

</div>

The “reconstruction algorithm” may shift the value.

In principle, for each “generated” value, you would need a “reconstructed” one (either in the same tree or in two friend trees). You could then draw “reconstructed - generated” or “reconstructed / generated”.
