# X- axis intersection point from a TF1 fitted line

**URL:** <https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893>\
**Category:** ROOT\
**Tags:** roofit, hist, root\
**Created:** [August 2, 2023, 3:55am UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893 "2023-08-02T03:55:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![thegame](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@thegame](https://root-forum.cern.ch/u/thegame)\
**Post date:** [August 2, 2023, 3:55am UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/1 "2023-08-02T03:55:55Z")

</div>

Hi all, I’m trying to fit the following peak at x =7 with a left-side skewed gaussian function  
`(TF1 *fitFunc = new TF1("fitFunc", leftSide_skew, 6, 7.3, 4)`; 4=parameters) and then trying to extract the x-axis point where the fiited line crosses the x-axis, as shown in the image. Is there a specific function that can extract the x intersection as a double? If not, I would also appreciate any additional ideas for how to extract this point. Thanks.

 ![histfit](https://root-forum.cern.ch/uploads/default/original/3X/8/f/8f23861beef9ed171a780b9f5cd30b4be6085038.png)

---

<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:** [August 2, 2023, 7:12am UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/2 "2023-08-02T07:12:03Z")

</div>

As this point is also the minimum of the function I guess [GetMinimumX()](https://root.cern/doc/v628/classTF1.html#a02342fe2af42e1fa20d8fac9ed2eaf5b) might be the solution ?

---

<div class="post-metadata">

**Author:** ![antodl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/3da27b/32.png) [@antodl](https://root-forum.cern.ch/u/antodl)\
**Post date:** [August 2, 2023, 7:45am UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/3 "2023-08-02T07:45:54Z")

</div>

` fitFunc->GetX(gPad->GetUymin())`

should fit your need

---

<div class="post-metadata">

**Author:** ![thegame](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@thegame](https://root-forum.cern.ch/u/thegame)\
**Post date:** [August 2, 2023, 10:51am UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/4 "2023-08-02T10:51:22Z")

</div>

I tried with GetMinimumX(); It returns the Xmin value as it should since the curve goes downward monotonically. I’m looking for something that calculates the roots of the TF1 fitFunc in a certain range.

---

<div class="post-metadata">

**Author:** ![thegame](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@thegame](https://root-forum.cern.ch/u/thegame)\
**Post date:** [August 2, 2023, 10:56am UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/5 "2023-08-02T10:56:05Z")

</div>

> `fitFunc->GetX(gPad->GetUymin())`
> 
> should fit your need

same as above. returns X\_min as the function going downwards.

---

<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:** [August 2, 2023, 12:49pm UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/6 "2023-08-02T12:49:00Z")

</div>

> [@thegame](#):
>
> I’m looking for something that calculates the roots of the TF1 fitFunc in a certain range.

```auto
void rootstf1() {
   auto C = new TCanvas();
   C->SetGrid();
   double xmin = -10., xmax = 10.;
   auto f = new TF1("f", "sin(x)/x", xmin, xmax);
   f->Draw();

   double y, xstep = 0.09, yesp = 0.00584;
   int i = 1;
   for (double s = xmin; s<=xmax ; s=s+xstep) {
      y = f->Eval(s);
      if (TMath::Abs(y)<yesp) {
         auto m = new TMarker(s,y,20);
         m->Draw();
         printf("%d zero found -> x = %f\n",i++,s);
      }
   }
}

```

```auto
Processing rootstf1.C...
1 zero found -> x = -9.460000
2 zero found -> x = -6.310000
3 zero found -> x = -3.160000
4 zero found -> x = 3.140000
5 zero found -> x = 6.290000
6 zero found -> x = 9.440000
root [1] 

```

 ![Screenshot 2023-08-02 at 15.49.53](https://root-forum.cern.ch/uploads/default/original/3X/d/8/d8593518a5143d1025920244f97a8fd35d5a1669.jpeg)

---

<div class="post-metadata">

**Author:** ![thegame](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@thegame](https://root-forum.cern.ch/u/thegame)\
**Post date:** [August 2, 2023, 2:15pm UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/7 "2023-08-02T14:15:19Z")

</div>

Thanks, @couet. I realized I didn’t portray my question accurately; I’m sorry about that. The y-axis is on a logarithmic scale. so that line never touches the x-axis at that point, although it appears as if it touches on a log scale. Thus, the question of finding the roots of the fitted function is somewhat invalid here. However, thanks for your time and suggestions.

---

<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:** [August 2, 2023, 2:23pm UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/8 "2023-08-02T14:23:46Z")

</div>

Yes I think you got the idea. You can adapt the code I sent to your use-case.

---

<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:** [August 16, 2023, 2:24pm UTC](https://root-forum.cern.ch/t/x-axis-intersection-point-from-a-tf1-fitted-line/55893/9 "2023-08-16T14:24:06Z")

</div>

Closed on August 16, 2023, 2:24pm UTC

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