11#include <reconstruction/calibration/BeamSpotBoostInvMass/InvariantMassMuMuIntegrator.h>
12#include <reconstruction/calibration/BeamSpotBoostInvMass/InvariantMassMuMuStandAlone.h>
17#include <Math/SpecFuncMathCore.h>
18#include <Math/DistFunc.h>
20namespace Belle2::InvariantMassMuMuCalib {
80 const int N = 14500000;
81 double step = (b - a) / N;
83 for (
int i = 0; i <= N; ++i) {
84 double K = (i == 0 || i == N) ? 0.5 : 1;
85 double t = a + i * step;
86 s +=
eval(t) * step *
K;
101 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
102 double r2 = ROOT::Math::inc_gamma_c(1 -
m_slope, Eps /
m_tauL);
106 double step = (r2 - r1) / N;
108 for (
int i = 0; i <= N; ++i) {
109 double r = r1 + step * i;
110 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
111 double K = (i == 0 || i == N) ? 0.5 : 1;
115 s +=
eval(t) / est * step *
K;
124 else if (
m_x -
m_m0 >= -tMin) {
130 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
134 const int N = 150000;
135 double step = (r2 - r1) / N;
136 for (
int i = 0; i <= N; ++i) {
137 double r = r1 + step * i;
138 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
139 double K = (i == 0 || i == N) ? 0.5 : 1;
143 s1 +=
eval(t) / est * step *
K;
158 const int N = 150000;
159 double step = (r2 - r1) / N;
160 for (
int i = 0; i <= N; ++i) {
161 double r = r1 + step * i;
163 double K = (i == 0 || i == N) ? 0.5 : 1;
167 s2 +=
eval(t) / est * step *
K;
180 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
184 const int N = 150000;
185 double step = (r2 - r1) / N;
186 for (
int i = 0; i <= N; ++i) {
187 double r = r1 + step * i;
188 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
189 double K = (i == 0 || i == N) ? 0.5 : 1;
193 s1 +=
eval(t) / est * step *
K;
208 const int N = 150000;
209 double step = (r2 - r1) / N;
210 for (
int i = 0; i <= N; ++i) {
211 double r = r1 + step * i;
213 double K = (i == 0 || i == N) ? 0.5 : 1;
217 s2 +=
eval(t) / est * step *
K;
230 const int N = 150000;
231 double step = (r2 - r1) / N;
232 for (
int i = 0; i <= N; ++i) {
233 double r = r1 + step * i;
235 double K = (i == 0 || i == N) ? 0.5 : 1;
237 double est = exp(t /
m_tauR);
239 s3 +=
eval(t) / est * step *
K;
245 return (s1 + s2 + s3);
258 double s0 = integrate([&](
double t) {
270 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
273 double s = integrate([&](
double r) {
275 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
277 return eval(t) / est;
296 double s01 = integrate([&](
double t) {
301 double s02 = integrate([&](
double t) {
306 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
309 double s = integrate([&](
double r) {
311 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
313 return eval(t) / est;
320 return (s01 + s02 + s);
326 else if (
m_x -
m_m0 >= -tMin) {
335 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
339 s1 = integrate([&](
double r) {
341 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
343 return eval(t) / est;
362 s2 = integrate([&](
double r) {
365 return eval(t) / est;
369 return (s0 + s1 + s2);
373 assert(
m_eps <= tMin);
381 double r1 = ROOT::Math::inc_gamma_c(1 -
m_slope, a /
m_tauL);
385 s1 = integrate([&](
double r) {
387 double t =
m_tauL * ROOT::Math::gamma_quantile_c(r, 1 -
m_slope, 1);
389 return eval(t) / est;
406 s2 = integrate([&](
double r) {
409 return eval(t) / est;
422 s3 = integrate([&](
double r) {
424 double est = exp(t /
m_tauR);
425 return eval(t) / est;
430 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-...
double sqrt(double a)
sqrt for double