Belle II Software development
CDCDedxSigmaPars.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <cdc/dbobjects/CDCDedxSigmaPars.h>
10#include <framework/logging/Logger.h>
11#include <framework/utilities/MathHelpers.h>
12#include <cmath>
13
14namespace Belle2 {
19
20 double CDCDedxSigmaPars::sigmaCurve(double x, const double* par, int version) const
21 {
22 // calculate the predicted mean value as a function of beta-gamma (bg)
23 // this is done with a different function depending dE/dx, nhit, and sin(theta)
24 double f = 0;
25
26 if (version == 0) {
27 if (par[0] == 1) { // return dedx parameterization
28 f = par[1] + par[2] * x;
29 } else if (par[0] == 2) { // return nhit or sin(theta) parameterization
30 f = par[1] * x * x * x * x + par[2] * x * x * x + par[3] * x * x + par[4] * x + par[5];
31 } else if (par[0] == 3) { // return cos(theta) parameterization
32 f = par[1] * std::exp(-0.5 * square(((x - par[2]) / par[3]))) +
33 par[4] * (pow5(x) * x) + par[5] * pow5(x) + par[6] * pow4(x) +
34 par[7] * x * x * x + par[8] * x * x + par[9] * x + par[10];
35 }
36 }
37
38 return f;
39 }
40
41 double CDCDedxSigmaPars::getSigma(double dedx, double nhit, double cosTheta, double timereso) const
42 {
43 const auto& params = m_sigmapars;
44 if (params.size() < 17) B2FATAL("CDCDedxSigmaPars: vector of parameters too short");
45
46 double dedxpar[3];
47 double nhitpar[6];
48 double cospar[11];
49 dedxpar[0] = 1; nhitpar[0] = 2; cospar[0] = 3;
50 for (int i = 0; i < 10; ++i) {
51 if (i < 2) dedxpar[i + 1] = params[i];
52 if (i < 5) nhitpar[i + 1] = params[i + 2];
53 cospar[i + 1] = params[i + 7];
54 }
55
56 // determine sigma from the parameterization
57 double corDedx = sigmaCurve(dedx, dedxpar, 0);
58
59 double nhit_min = 8, nhit_max = 37;
60 double corNHit = 0;
61 if (nhit < nhit_min) {
62 corNHit = sigmaCurve(nhit_min, nhitpar, 0) * std::sqrt(nhit_min / nhit);
63 } else if (nhit > nhit_max) {
64 corNHit = sigmaCurve(nhit_max, nhitpar, 0) * std::sqrt(nhit_max / nhit);
65 } else {
66 corNHit = sigmaCurve(nhit, nhitpar, 0);
67 }
68
69 double corCos = sigmaCurve(cosTheta, cospar, 0);
70
71 return (corDedx * corCos * corNHit * timereso);
72 }
73
75}
std::vector< double > m_sigmapars
dE/dx resolution parameters
double sigmaCurve(double x, const double *par, int version) const
parameterized resolution for predictions
double getSigma(double dedx, double nhit, double cosTheta, double timeReso) const
Returns predicted dE/dx sigma.
constexpr T square(const T &x)
Calculate the square of the input.
Definition MathHelpers.h:21
constexpr T pow5(const T &x)
Calculate the fifth power of the input.
Definition MathHelpers.h:46
constexpr T pow4(const T &x)
Calculate the fourth power of the input.
Definition MathHelpers.h:37
Abstract base class for different kinds of events.