Belle II Software development
TOPPulseHeightPar.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#include <top/dbobjects/TOPPulseHeightPar.h>
9#include <cmath>
10
11using namespace std;
12
13namespace Belle2 {
18
19 double TOPPulseHeightPar::getValue(double x) const
20 {
21 if (x <= 0 or x0 == 0) return 0;
22 double xx = x / x0;
23 double f = std::pow(xx, p1) * std::exp(-std::pow(xx, p2));
24 return f;
25 }
26
28 {
29 return p2 / std::tgamma((p1 + 1) / p2) / x0;
30 }
31
33 {
34 return std::tgamma((p1 + 2) / p2) / std::tgamma((p1 + 1) / p2) * x0;
35 }
36
38 {
39 double x2 = std::tgamma((p1 + 3) / p2) / std::tgamma((p1 + 1) / p2) * x0 * x0;
40 double x = getMean();
41 return std::sqrt(x2 - x * x);
42 }
43
45 {
46 return std::pow(p1 / p2, 1 / p2) * x0;
47 }
48
49 double TOPPulseHeightPar::getThresholdEffi(double threshold, double rmsNoise, int n) const
50 {
51 if (x0 == 0) return 0;
52 double s = 0;
53 double dx = (threshold + rmsNoise) / n;
54 double f0 = 0;
55 for (int i = 1; i <= n; i++) {
56 double f = getValue(dx * i);
57 s += (f0 + f) / 2;
58 f0 = f;
59 }
60 return 1 - s * dx * getNorm();
61 }
62
64}
double getThresholdEffi(double threshold, double rmsNoise, int n=100) const
Returns threshold efficiency.
double getMean() const
Returns distribution mean.
double getPeakPosition() const
Returns the position of distribution maximum.
double getNorm() const
Returns normalization constant.
double getValue(double x) const
Returns a value of non-normalized pulse height distribution at x Multiply with getNorm() to get norma...
double getRMS() const
Returns distribution standard deviation.
Abstract base class for different kinds of events.
STL namespace.
float p1
distribution parameter p1
float x0
distribution parameter x0 [ADC counts]
float p2
distribution parameter p2