X- axis intersection point from a TF1 fitted line

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.

As this point is also the minimum of the function I guess GetMinimumX() might be the solution ?

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

should fit your need

1 Like

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.

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

should fit your need

same as above. returns X_min as the function going downwards.

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);
      }
   }
}
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] 

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.

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

1 Like

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