hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
FitFunction.h
Go to the documentation of this file.
1#ifndef FITFUNCTION_H
2#define FITFUNCTION_H
3#include <TMath.h>
4#include "FunctionMath.h"
5#include <iostream>
6
13 public:
23
29 FIRST = 0,
30 THIRD = 1,
31 FIFTH = 2,
32 SEVENTH = 3
33 };
34
45
56 FitFunction(double m_mass_hypothesis, double m_window_size,
57 double m_bin_size, ModelOrder m_model_order,
59 bool m_exp_background = true) {
60 window_size = m_window_size;
61 bin_size = m_bin_size;
62 mass_hypothesis = m_mass_hypothesis;
63 sig_model = m_sig_model;
64 model_order = m_model_order;
65 exp_background = m_exp_background;
66
67 // The signal parameter is always one greater than the
68 // polynomial order.
70 order = 1;
71 sigParm = 2;
73 order = 3;
74 sigParm = 4;
76 order = 5;
77 sigParm = 6;
79 order = 7;
80 sigParm = 8;
81 }
82 }
83
92 double operator() (double *x, double *par) {
93 if(exp_background) {
94 return TMath::Power(10, calculateBackground(x, par)) + calculateSignal(x, par);
95 } else {
96 return calculateBackground(x, par) + calculateSignal(x, par);
97 }
98 }
99
100 protected:
102 double mass_hypothesis = 0;
103
105 double window_size = 0;
106
108 double bin_size = 0;
109
111 int order = 0;
112
115
118
120 bool exp_background = true;
121
130 virtual double calculateBackground(double *x, double *par) = 0;
131
140 double calculateSignal(double *x, double *par) {
142 {
143 return bin_size * FunctionMath::Gaussian(x[0], par[sigParm], par[sigParm + 1], par[sigParm + 2]);
144 }
146 {
147 return bin_size * FunctionMath::CrystalBall(x[0], par[sigParm], par[sigParm + 1], par[sigParm + 2], par[sigParm + 3], par[sigParm + 4]);
148 }
149 else
150 {
151 return 0.0;
152 }
153 }
154
161 double getCorrectedX(double x) {
162 return 2.0*(x - mass_hypothesis) / (window_size);
163 }
164
165 private:
167 int sigParm = 0;
168};
169
170#endif
description
Definition FitFunction.h:12
virtual double calculateBackground(double *x, double *par)=0
Calculates the value of the background function at the specified x and with the specified parameters.
ModelOrder
description
Definition FitFunction.h:28
BkgModel
description
Definition FitFunction.h:39
SignalFitModel
description
Definition FitFunction.h:18
double getCorrectedX(double x)
Gets a value of x corrected for window size and the mass hypothesis.
double window_size
double calculateSignal(double *x, double *par)
Calculates the value of the signal function at the specified x and with the specified parameters.
double mass_hypothesis
SignalFitModel sig_model
double bin_size
ModelOrder model_order
double operator()(double *x, double *par)
Calculates the value of the function at the specified x and with the specified parameters.
Definition FitFunction.h:92
FitFunction(double m_mass_hypothesis, double m_window_size, double m_bin_size, ModelOrder m_model_order, SignalFitModel m_sig_model=FitFunction::SignalFitModel::NONE, bool m_exp_background=true)
Constructor.
Definition FitFunction.h:56
bool exp_background
static double CrystalBall(double x, double amplitude, double mean, double stddev, double alpha, double n)
Defines a crystal ball function for signal-fitting.
static double Gaussian(double x, double amplitude, double mean, double stddev)
Defines a Gaussian function for signal-fitting.