Class to perform template fit on TOP waveform data Minimzation method is described here http://wwwa1.kph.uni-mainz.de/Vorlesungen/SS11/Statistik/.
More...
#include <TOPTemplateFitter.h>
|
void | PerformTemplateFitMinimize (const std::vector< short > &samples, const std::vector< short > &pedestals, const std::vector< float > &timingCorrection, const double risingEdgeCFD, const double fitRange) |
| performs the template fit
|
|
double | ComputeMinimizedParametersAndChisq (const MinimizationSums &sums, FitResult &result) |
| Compute the minimized parameters and chi square value.
|
|
void | CalculateParabolaVertex (const Point &p1, const Point &p2, const Point &p3, Point &vertex) |
| Calculate vertex coordinates of parabola given three data points.
|
|
Class to perform template fit on TOP waveform data Minimzation method is described here http://wwwa1.kph.uni-mainz.de/Vorlesungen/SS11/Statistik/.
Definition at line 30 of file TOPTemplateFitter.h.
◆ TOPTemplateFitter()
full constructor
- Parameters
-
wf | TOP raw waveform samples |
sampleTimes | database object holding time correction |
averageRMS | average sample RMS |
Definition at line 28 of file TOPTemplateFitter.cc.
32{
36 }
37}
static void InitializeTemplateFit()
Intializes the template fit using default values.
const TOPRawWaveform m_wf
raw sampled waveforms
static bool s_templateReInitialize
flag showing that the template samples have to be recomputed
const double m_averageRMS
average RMS of waveform samples, no database for this
double m_chisq
chi square value from template fit
const TOPSampleTimes m_sampleTimes
provides timing correction
◆ ~TOPTemplateFitter()
◆ CalculateParabolaVertex()
void CalculateParabolaVertex |
( |
const Point & |
p1, |
|
|
const Point & |
p2, |
|
|
const Point & |
p3, |
|
|
Point & |
vertex |
|
) |
| |
|
private |
Calculate vertex coordinates of parabola given three data points.
- Parameters
-
p1 | data point 1 |
p2 | data point 2 |
p3 | data point 3 |
vertex | vertex position |
Definition at line 108 of file TOPTemplateFitter.cc.
109{
110 double denom = (p1.first - p2.first) * (p1.first - p3.first) * (p2.first - p3.first);
111 double a = (p3.first * (p2.second - p1.second) + p2.first * (p1.second - p3.second) + p1.first *
112 (p3.second - p2.second)) / denom;
113 double b = (p3.first * p3.first * (p1.second - p2.second) + p2.first * p2.first * (p3.second - p1.second)
114 + p1.first * p1.first * (p2.second - p3.second)) / denom;
115 double c = (p2.first * p3.first * (p2.first - p3.first) * p1.second + p3.first * p1.first * (p3.first - p1.first) * p2.second
116 + p1.first * p2.first * (p1.first - p2.first) * p3.second) / denom;
117
118 vertex.first = -b / (2 * a);
119 vertex.second = c - b * b / (4 * a);
120}
◆ ComputeMinimizedParametersAndChisq()
Compute the minimized parameters and chi square value.
- Parameters
-
sums | minimization sums for chisq calculation |
result | minimized parameters |
- Returns
- chi square
Definition at line 165 of file TOPTemplateFitter.cc.
166{
167 const double determinant = sums.S1 * sums.Sxx - sums.Sx * sums.Sx;
168 result.amplitude = (-sums.Sx * sums.Sy + sums.S1 * sums.Sxy) / determinant;
169 result.backgroundOffset = (sums.Sxx * sums.Sy - sums.Sx * sums.Sxy) / determinant;
170 result.amplitudeError = sums.S1 / determinant;
171 result.backgroundOffsetError = sums.Sxx / determinant;
172 return sums.Syy - result.backgroundOffset * sums.Sy - result.amplitude * sums.Sxy;
173}
◆ getChisq()
double getChisq |
( |
| ) |
const |
|
inline |
◆ getChisqVector()
const std::vector< double > & getChisqVector |
( |
| ) |
const |
|
inline |
Returns calculated chisq values.
- Returns
- chisq vector
Definition at line 115 of file TOPTemplateFitter.h.
std::vector< double > m_chisq_vec
all computed chi square values from template fit
◆ getFitResult()
Returns fitted values with errors.
- Returns
- fitted values with errors
Definition at line 121 of file TOPTemplateFitter.h.
FitResult m_result
fit result from template fit
◆ getTemplateParameters()
Returns the template parameters.
- Returns
- template parameters
Definition at line 127 of file TOPTemplateFitter.h.
static TemplateParameters s_templateParameters
parameters used for the template calculation
◆ getTemplateResolution()
static int getTemplateResolution |
( |
| ) |
|
|
inlinestatic |
Returns the template resolution.
- Returns
- template resolution
Definition at line 139 of file TOPTemplateFitter.h.
static int s_templateResolution
resolution of template with respect to normal sample spacing
◆ getTemplateSamples()
static int getTemplateSamples |
( |
| ) |
|
|
inlinestatic |
Returns the total number of template samples.
- Returns
- total number of template samples
Definition at line 133 of file TOPTemplateFitter.h.
static int s_totalTemplateSamples
number of samples used for template
◆ getUseParabola()
static bool getUseParabola |
( |
| ) |
|
|
inlinestatic |
Returns useParabola.
- Returns
- useParabola
Definition at line 145 of file TOPTemplateFitter.h.
static bool s_useParabola
try improving fit by making use of parabolic shape of chisq values
◆ InitializeTemplateFit()
void InitializeTemplateFit |
( |
| ) |
|
|
static |
Intializes the template fit using default values.
Definition at line 59 of file TOPTemplateFitter.cc.
60{
63 B2FATAL("rising edge of template function invalid!");
64 }
65
68 const auto& tdc = geo->getNominalTDC();
69 const double dt = tdc.getSampleWidth();
70
73 }
74
76}
const TOPSignalShape & getSignalShape() const
Returns single photon signal shape.
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
static std::vector< double > s_templateSamples
precomputed template samples
double amplitude
amplitude of template function
double risingEdge
rising edge position of template in samples
◆ performTemplateFit()
void performTemplateFit |
( |
const double |
risingEdgeStart, |
|
|
const double |
fitRange |
|
) |
| |
Prepares data and performs the template fit in sample space.
- Parameters
-
risingEdgeStart | initial guess for rising edge position from CFD |
fitRange | range of template fit |
Definition at line 78 of file TOPTemplateFitter.cc.
80{
83 }
84
85
88 0.);
89
90
94
95
98 int minidx = std::distance(std::begin(
m_chisq_vec), it);
99 if (minidx > 0 && minidx < (
int)
m_chisq_vec.size() - 1) {
100 Point vertex;
104 }
105 }
106}
void PerformTemplateFitMinimize(const std::vector< short > &samples, const std::vector< short > &pedestals, const std::vector< float > &timingCorrection, const double risingEdgeCFD, const double fitRange)
performs the template fit
void CalculateParabolaVertex(const Point &p1, const Point &p2, const Point &p3, Point &vertex)
Calculate vertex coordinates of parabola given three data points.
double risingEdge
fitted rising edge
◆ PerformTemplateFitMinimize()
void PerformTemplateFitMinimize |
( |
const std::vector< short > & |
samples, |
|
|
const std::vector< short > & |
pedestals, |
|
|
const std::vector< float > & |
timingCorrection, |
|
|
const double |
risingEdgeCFD, |
|
|
const double |
fitRange |
|
) |
| |
|
private |
performs the template fit
- Parameters
-
samples | sample vector |
pedestals | pedestal vector |
timingCorrection | timing correction for samples |
risingEdgeCFD | rising edge from constant fraction discrimination |
fitRange | fit range |
Definition at line 122 of file TOPTemplateFitter.cc.
124{
125 if (samples.size() != pedestals.size() || samples.size() != timingCorrection.size()) {
126 B2FATAL("Size of sample, pedestal and timing correction vectors has to be equal!");
127 }
128
129
130 MinimizationSums sums;
131 FitResult result;
133
135 sums.clear();
137 for (int signalSampleIndex = risingEdgeCFD - fitRange; signalSampleIndex < risingEdgeCFD + fitRange; ++signalSampleIndex) {
138 if (signalSampleIndex < 0 || signalSampleIndex > (int)samples.size() - 1) continue;
139 int templateIndex = signalSampleIndex *
s_templateResolution - totalTemplateOffset + timingCorrection[signalSampleIndex];
140 if (templateIndex < 0 || templateIndex > (
int)
s_templateSamples.size() - 1)
continue;
141 double weight = 1. / (pedestals[signalSampleIndex] * pedestals[signalSampleIndex]);
143 double Sy = weight * samples[signalSampleIndex];
144 sums.S1 += weight;
145 sums.Sx += Sx;
146 sums.Sy += Sy;
149 sums.Syy += Sy * samples[signalSampleIndex];
150 }
157 }
158 }
159
163}
static int s_fineOffsetRange
range for offset between template and signal
double ComputeMinimizedParametersAndChisq(const MinimizationSums &sums, FitResult &result)
Compute the minimized parameters and chi square value.
double amplitude
fitted amplitude
double amplitudeError
fitted amplitude error
◆ setTemplateParameters()
Sets the template parameters.
- Parameters
-
params | template Parameters |
Definition at line 39 of file TOPTemplateFitter.cc.
◆ setTemplateResolution()
void setTemplateResolution |
( |
int |
resolution | ) |
|
|
static |
Set the template resolution.
- Parameters
-
resolution | template resolution |
Definition at line 52 of file TOPTemplateFitter.cc.
◆ setTemplateSamples()
void setTemplateSamples |
( |
int |
nSamples | ) |
|
|
static |
Set the total number of template samples.
- Parameters
-
nSamples | total number of template samples |
Definition at line 45 of file TOPTemplateFitter.cc.
◆ setUseParabola()
static void setUseParabola |
( |
bool |
use | ) |
|
|
inlinestatic |
◆ m_averageRMS
const double m_averageRMS |
|
private |
◆ m_chisq
◆ m_chisq_vec
std::vector<double> m_chisq_vec |
|
private |
◆ m_result
◆ m_sampleTimes
◆ m_wf
◆ s_fineOffsetRange
◆ s_templateParameters
◆ s_templateReInitialize
bool s_templateReInitialize = true |
|
staticprivate |
flag showing that the template samples have to be recomputed
Definition at line 225 of file TOPTemplateFitter.h.
◆ s_templateResolution
int s_templateResolution = 4 |
|
staticprivate |
resolution of template with respect to normal sample spacing
Definition at line 221 of file TOPTemplateFitter.h.
◆ s_templateSamples
std::vector< double > s_templateSamples |
|
staticprivate |
◆ s_totalTemplateSamples
int s_totalTemplateSamples = 64 |
|
staticprivate |
◆ s_useParabola
bool s_useParabola = true |
|
staticprivate |
try improving fit by making use of parabolic shape of chisq values
Definition at line 226 of file TOPTemplateFitter.h.
The documentation for this class was generated from the following files: