11#include <reconstruction/calibration/BeamSpotBoostInvMass/InvariantMassMuMuIntegrator.h>
12#include <reconstruction/calibration/BeamSpotBoostInvMass/InvariantMassMuMuStandAlone.h>
13#include <framework/utilities/MathHelpers.h>
18#include <Math/SpecFuncMathCore.h>
19#include <Math/DistFunc.h>
21namespace Belle2::InvariantMassMuMuCalib {
81 const int N = 14500000;
82 double step = (b - a) / N;
84 for (
int i = 0; i <= N; ++i) {
85 double K = (i == 0 || i == N) ? 0.5 : 1;
86 double t = a + i * step;
87 s +=
eval(t) * step *
K;
102 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
103 double r2 = ROOT::Math::inc_gamma_c(1 -
m_slope, Eps /
m_tauL);
107 double step = (r2 - r1) / N;
109 for (
int i = 0; i <= N; ++i) {
110 double r = r1 + step * i;
111 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
112 double K = (i == 0 || i == N) ? 0.5 : 1;
116 s +=
eval(t) / est * step *
K;
125 else if (
m_x -
m_m0 >= -tMin) {
131 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
135 const int N = 150000;
136 double step = (r2 - r1) / N;
137 for (
int i = 0; i <= N; ++i) {
138 double r = r1 + step * i;
139 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
140 double K = (i == 0 || i == N) ? 0.5 : 1;
144 s1 +=
eval(t) / est * step *
K;
159 const int N = 150000;
160 double step = (r2 - r1) / N;
161 for (
int i = 0; i <= N; ++i) {
162 double r = r1 + step * i;
164 double K = (i == 0 || i == N) ? 0.5 : 1;
168 s2 +=
eval(t) / est * step *
K;
181 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
185 const int N = 150000;
186 double step = (r2 - r1) / N;
187 for (
int i = 0; i <= N; ++i) {
188 double r = r1 + step * i;
189 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
190 double K = (i == 0 || i == N) ? 0.5 : 1;
194 s1 +=
eval(t) / est * step *
K;
209 const int N = 150000;
210 double step = (r2 - r1) / N;
211 for (
int i = 0; i <= N; ++i) {
212 double r = r1 + step * i;
214 double K = (i == 0 || i == N) ? 0.5 : 1;
218 s2 +=
eval(t) / est * step *
K;
231 const int N = 150000;
232 double step = (r2 - r1) / N;
233 for (
int i = 0; i <= N; ++i) {
234 double r = r1 + step * i;
236 double K = (i == 0 || i == N) ? 0.5 : 1;
238 double est = exp(t /
m_tauR);
240 s3 +=
eval(t) / est * step *
K;
246 return (s1 + s2 + s3);
259 double s0 = integrate([&](
double t) {
271 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
274 double s = integrate([&](
double r) {
276 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
278 return eval(t) / est;
297 double s01 = integrate([&](
double t) {
302 double s02 = integrate([&](
double t) {
307 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
310 double s = integrate([&](
double r) {
312 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
314 return eval(t) / est;
321 return (s01 + s02 + s);
327 else if (
m_x -
m_m0 >= -tMin) {
336 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
340 s1 = integrate([&](
double r) {
342 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
344 return eval(t) / est;
363 s2 = integrate([&](
double r) {
366 return eval(t) / est;
370 return (s0 + s1 + s2);
374 assert(
m_eps <= tMin);
382 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
386 s1 = integrate([&](
double r) {
388 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
390 return eval(t) / est;
407 s2 = integrate([&](
double r) {
410 return eval(t) / est;
423 s3 = integrate([&](
double r) {
425 double est = exp(t /
m_tauR);
426 return eval(t) / est;
431 return (s0 + s1 + s2 + s3);
double integralKronrod(double a)
Integration of the PDF which avoids steps and uses variable transformation (Gauss-Konrod rule as back...
double m_tauR
1/slope of the right exponential tail
double m_eps
cut-off term for the power-spectrum caused by the ISR (in GeV)
double m_m0
invariant mass of the collisions
double m_sigmaK
sigma of the gaus in the convolution
double m_C
the coefficient between part below eps and above eps cut-off
double m_sigmaE
sigma of the external gaus
double m_x
the resulting PDF is function of this variable the actual rec-level mass
double m_tauL
1/slope of the left exponential tail
void init(double Mean, double Sigma, double SigmaK, double BMean, double BDelta, double Tau, double SigmaE, double Frac, double M0, double Eps, double CC, double Slope, double X)
Init the parameters of the PDF integrator.
double m_frac
fraction of events in the external gaus
double m_sigma
sigma of the resolution function
double m_bMean
(bRight + bLeft)/2 where bLeft, bRight are the transition points between gaus and exp (in sigma)
double m_slope
power in the power-like spectrum from the ISR
double eval(double t)
evaluate the PDF integrand for given t - the integration variable
double integralTrap(double a, double b)
Simple integration of the PDF for a to b based on the Trapezoidal rule (for validation)
double m_mean
mean position of the resolution function, i.e. (Gaus+Exp tails) conv Gaus
double m_bDelta
(bRight - bLeft)/2 where bLeft, bRight are the transition points between gaus and exp (in sigma)
double integralTrapImp(double Eps, double a)
Integration of the PDF which avoids steps and uses variable transformation (Trapezoidal rule as back-...
constexpr T square(const T &x)
Calculate the square of the input.
double sqrt(double a)
sqrt for double