# How to Use CERN ROOT Tools for Global Fit with Multiple TH1D Objects?

**URL:** <https://root-forum.cern.ch/t/how-to-use-cern-root-tools-for-global-fit-with-multiple-th1d-objects/62709>\
**Category:** Roofit and RooStats\
**Tags:** graphics, roofit, hist, root\
**Created:** [January 21, 2025, 7:33am UTC](https://root-forum.cern.ch/t/how-to-use-cern-root-tools-for-global-fit-with-multiple-th1d-objects/62709 "2025-01-21T07:33:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NuaaMtz](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nuaamtz/32/38310_2.png) [@NuaaMtz](https://root-forum.cern.ch/u/NuaaMtz)\
**Post date:** [January 21, 2025, 7:33am UTC](https://root-forum.cern.ch/t/how-to-use-cern-root-tools-for-global-fit-with-multiple-th1d-objects/62709/1 "2025-01-21T07:33:50Z")

</div>

Hello everyone,

I am currently engaged in data analysis for a specific reaction channel, where I need to determind the branch ratio of each channel. I have simulated possible process data using GEANT4. For this moment, there are three physical values and each save as histogram(TH1D\*). Simularly, for each simulated process, same physical value exits and also save as TH1D\*.

My goal is to make global fitting for the experimental data using those simulated data. Additionly, I am to evaluate the ratios that minimize the chi2.

One close code would be found at combinedFit\_8C.(new user could no post link)  
But there are some differents.

Thank you in advance and best regards,  
Tianzhu Mo

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [January 21, 2025, 9:08am UTC](https://root-forum.cern.ch/t/how-to-use-cern-root-tools-for-global-fit-with-multiple-th1d-objects/62709/2 "2025-01-21T09:08:24Z")

</div>

Hi,

Thanks for the post and welcome to the ROOT Community!  
I think [the example](https://root.cern.ch/doc/master/combinedFit_8C.html) you mention could bring you very far: don’t you just need to adapt the code to your histograms and extend the global fit from two histograms to three?

Cheers,  
Danilo

---

<div class="post-metadata">

**Author:** ![NuaaMtz](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nuaamtz/32/38310_2.png) [@NuaaMtz](https://root-forum.cern.ch/u/NuaaMtz)\
**Post date:** [January 21, 2025, 9:50am UTC](https://root-forum.cern.ch/t/how-to-use-cern-root-tools-for-global-fit-with-multiple-th1d-objects/62709/3 "2025-01-21T09:50:37Z")

</div>

Hi Danilo,

In the example I mentioned, the math function is used as follows:

```C++
 TF1 *fB = new TF1("fB", "expo", 0, 100);

```

and

```C++
   TF1 *fSB = new TF1("fSB", "expo + gaus(2)", 0, 100);

```

However, in my analysis, I required a different way. In this case,my fit funtion should be base on different histogram distribution like:a_h1+b_h2+c_h3.Here, h_ stands for histogram data rather than mathematical experession. Shard paramater are a,b and c.This is the most biggest different.

Best Regards,  
Tianzhu Mo

---

<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:** [January 21, 2025, 11:45am UTC](https://root-forum.cern.ch/t/how-to-use-cern-root-tools-for-global-fit-with-multiple-th1d-objects/62709/4 "2025-01-21T11:45:23Z")

</div>

[ROOT Forum → Search → TFractionFitter](https://root-forum.cern.ch/search?q=TFractionFitter%20order%3Alatest)

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [February 4, 2025, 11:45am UTC](https://root-forum.cern.ch/t/how-to-use-cern-root-tools-for-global-fit-with-multiple-th1d-objects/62709/5 "2025-02-04T11:45:47Z")

</div>

Closed on February 4, 2025, 11:45am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
