From 71c399b381fda5a5bb865583517ab68346205b90 Mon Sep 17 00:00:00 2001 From: swetank18 Date: Fri, 23 Jan 2026 05:54:54 +0530 Subject: [PATCH 1/2] Fix edge case in analytical integral of exponential TF1 --- hist/hist/src/AnalyticalIntegrals.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/hist/hist/src/AnalyticalIntegrals.cxx b/hist/hist/src/AnalyticalIntegrals.cxx index ca7c402625c6b..3fe57034b888c 100644 --- a/hist/hist/src/AnalyticalIntegrals.cxx +++ b/hist/hist/src/AnalyticalIntegrals.cxx @@ -40,10 +40,20 @@ Double_t AnalyticalIntegral(TF1 *f, Double_t a, Double_t b) return TMath::QuietNaN(); } - if (num == 200)//expo: exp(p0+p1*x) - { - result = ( exp(p[0]+p[1]*xmax) - exp(p[0]+p[1]*xmin))/p[1]; + else if (num == 200) { // expo: exp(p0 + p1*x) + const double p0 = p[0]; + const double p1 = p[1]; + + if (p1 == 0) { + // Limit p1 -> 0: integral of constant exp(p0) + result = std::exp(p0) * (xmax - xmin); + } else { + const double ea = p0 + p1 * xmin; + const double eb = p0 + p1 * xmax; + result = (std::exp(eb) - std::exp(ea)) / p1; } +} + else if (num == 100)//gaus: [0]*exp(-0.5*((x-[1])/[2])^2)) { double amp = p[0]; From 319674fd884d948dcd64988a685a330d271d9341 Mon Sep 17 00:00:00 2001 From: swetank18 Date: Thu, 29 Jan 2026 03:18:08 +0530 Subject: [PATCH 2/2] Apply clang-format --- hist/hist/src/AnalyticalIntegrals.cxx | 33 ++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/hist/hist/src/AnalyticalIntegrals.cxx b/hist/hist/src/AnalyticalIntegrals.cxx index 3fe57034b888c..bdc5ded37d784 100644 --- a/hist/hist/src/AnalyticalIntegrals.cxx +++ b/hist/hist/src/AnalyticalIntegrals.cxx @@ -41,20 +41,20 @@ Double_t AnalyticalIntegral(TF1 *f, Double_t a, Double_t b) } else if (num == 200) { // expo: exp(p0 + p1*x) - const double p0 = p[0]; - const double p1 = p[1]; + const double p0 = p[0]; + const double p1 = p[1]; - if (p1 == 0) { - // Limit p1 -> 0: integral of constant exp(p0) - result = std::exp(p0) * (xmax - xmin); - } else { - const double ea = p0 + p1 * xmin; - const double eb = p0 + p1 * xmax; - result = (std::exp(eb) - std::exp(ea)) / p1; + if (p1 == 0) { + // Limit p1 -> 0: integral of constant exp(p0) + result = std::exp(p0) * (xmax - xmin); + } else { + const double ea = p0 + p1 * xmin; + const double eb = p0 + p1 * xmax; + result = (std::exp(eb) - std::exp(ea)) / p1; + } } -} - else if (num == 100)//gaus: [0]*exp(-0.5*((x-[1])/[2])^2)) + else if (num == 100) // gaus: [0]*exp(-0.5*((x-[1])/[2])^2)) { double amp = p[0]; double mean = p[1]; @@ -64,8 +64,7 @@ Double_t AnalyticalIntegral(TF1 *f, Double_t a, Double_t b) else result = amp * sqrt(2 * TMath::Pi()) * sigma * (ROOT::Math::gaussian_cdf(xmax, sigma, mean) - ROOT::Math::gaussian_cdf(xmin, sigma, mean)); // - } - else if (num == 400)//landau: root::math::landau(x,mpv=0,sigma=1,bool norm=false) + } else if (num == 400) // landau: root::math::landau(x,mpv=0,sigma=1,bool norm=false) { double amp = p[0]; @@ -76,8 +75,7 @@ Double_t AnalyticalIntegral(TF1 *f, Double_t a, Double_t b) result = amp*(ROOT::Math::landau_cdf(xmax,sigma,mean) - ROOT::Math::landau_cdf(xmin,sigma,mean)); else result = amp*sigma*(ROOT::Math::landau_cdf(xmax,sigma,mean) - ROOT::Math::landau_cdf(xmin,sigma,mean)); - } - else if (num == 500) //crystal ball + } else if (num == 500) // crystal ball { double amp = p[0]; double mean = p[1]; @@ -93,15 +91,14 @@ Double_t AnalyticalIntegral(TF1 *f, Double_t a, Double_t b) } } - else if (num >= 300 && num < 400)//polN + else if (num >= 300 && num < 400) // polN { Int_t n = num - 300; for (int i=0;i