Belle II Software development
ECLWaveformFit.h
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#pragma once
10
11/* ECL headers. */
12#include <ecl/dataobjects/ECLDigit.h>
13#include <ecl/dataobjects/ECLDsp.h>
14#include <ecl/dbobjects/ECLAutoCovariance.h>
15#include <ecl/dbobjects/ECLCrystalCalib.h>
16#include <ecl/dbobjects/ECLDigitWaveformParameters.h>
17#include <ecl/dbobjects/ECLDigitWaveformParametersForMC.h>
18
19/* Basf2 headers. */
20#include <framework/core/Module.h>
21#include <framework/database/DBObjPtr.h>
22#include <framework/datastore/StoreArray.h>
23
24class TMinuit;
25
26namespace Belle2 {
39
41 float m_covMatPacked[31 * (31 + 1) / 2] = {};
42
44 float sigma{ -1};
45
47 float& operator[](int i) { return m_covMatPacked[i];}
48
50 const float& operator[](int i) const { return m_covMatPacked[i];}
51 };
52
58
63 constexpr static int c_nt = 12;
64
66 constexpr static int c_ndt = 5;
67
69 constexpr static int c_ntail = 20;
70
72 constexpr static double c_dt = 0.5;
73
75 constexpr static double c_idt = 1 / c_dt;
76
78 constexpr static double c_dtn = c_dt / c_ndt;
79
81 constexpr static double c_idtn = c_ndt / c_dt;
82
85
88
97 double m_r0;
98
100 double m_r1;
101
106
111 explicit SignalInterpolation2(const std::vector<double>&);
112
120 void getShape(double t0, double* function, double* derivatives) const;
121
122 };
123
128
129 public:
130
134
138
140 virtual void initialize() override;
141
143 virtual void beginRun() override;
144
147 virtual void event() override;
148
150 virtual void endRun() override;
151
153 virtual void terminate() override;
154
156 virtual const char* eclDigitArrayName() const
157 { return "ECLDigits" ; }
158
160 virtual const char* eclDspArrayName() const
161 { return "ECLDsps" ; }
162
163
164 private:
165
170
179 void fitPhotonHadron(
180 double& pedestal, double& amplitudePhoton, double& signalTime,
181 double& amplitudeHadron, double& chi2);
182
194 double& pedestal, double& amplitudePhoton, double& signalTime,
195 double& amplitudeHadron, double& amplitudeBackgroundPhoton,
196 double& timeBackgroundPhoton, double& chi2);
197
199 double m_EnergyThreshold{0.03};
200
203
206
209
211 bool m_TemplatesLoaded{false};
212
214 std::vector<double> m_ADCtoEnergy;
215
217 TMinuit* m_MinuitPhotonHadron = nullptr;
218
221
224
227
229 bool m_IsMCFlag{false};
230
233
236
239
242
245
248
251
252 };
253
255}
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Module performs offline fit for saved ECL waveforms.
CovariancePacked m_PackedCovariance[ECLElementNumbers::c_NCrystals]
Packed covariance matrices.
virtual void initialize() override
Initialize variables.
DBObjPtr< ECLDigitWaveformParameters > m_WaveformParameters
Waveform parameters.
TMinuit * m_MinuitPhotonHadron
Minuit minimizer for fit with photon and hadron.
DBObjPtr< ECLAutoCovariance > m_AutoCovariance
Autocovariance.
virtual void event() override
event per event.
virtual void endRun() override
end run.
bool m_IsMCFlag
Flag to indicate if running over data or MC.
void fitPhotonHadronBackgroundPhoton(double &pedestal, double &amplitudePhoton, double &signalTime, double &amplitudeHadron, double &amplitudeBackgroundPhoton, double &timeBackgroundPhoton, double &chi2)
Fit with photon, hadron, and background photon.
StoreArray< ECLDsp > m_eclDSPs
StoreArray ECLDsp.
virtual void terminate() override
terminate.
SignalInterpolation2 m_SignalInterpolation[ECLElementNumbers::c_NCrystals][3]
ShaperDSP signal shapes.
StoreArray< ECLDigit > m_eclDigits
StoreArray ECLDigit.
virtual const char * eclDspArrayName() const
ECLDspsArray Name.
std::vector< double > m_ADCtoEnergy
Calibration vector from ADC to energy.
void loadTemplateParameterArray()
Loads waveform templates from database.
bool m_CovarianceMatrix
Option to use crystal dependent covariance matrices.
DBObjPtr< ECLCrystalCalib > m_CrystalElectronics
Crystal electronics.
virtual void beginRun() override
begin run.
DBObjPtr< ECLCrystalCalib > m_CrystalEnergy
Crystal energy.
void fitPhotonHadron(double &pedestal, double &amplitudePhoton, double &signalTime, double &amplitudeHadron, double &chi2)
Fit with photon and hadron.
virtual const char * eclDigitArrayName() const
ECLDigits Array Name.
double m_EnergyThreshold
Energy threshold to fit pulse offline.
double m_Chi2Threshold25dof
chi2 threshold (25 dof) to classify offline fit as good fit.
TMinuit * m_MinuitPhotonHadronBackgroundPhoton
Minuit minimizer for fit with photon, hadron, and background photon.
DBObjPtr< ECLDigitWaveformParametersForMC > m_WaveformParametersForMC
Waveform parameters for MC.
bool m_TemplatesLoaded
Flag to indicate if waveform templates are loaded from database.
double m_Chi2Threshold27dof
chi2 threshold (27 dof) to classify offline fit as good fit.
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
Struct to keep upper triangle of the covariance matrix.
float m_covMatPacked[31 *(31+1)/2]
Packed matrix.
const float & operator[](int i) const
Rvalue access by index.
float & operator[](int i)
Lvalue access by index.
float sigma
Sigma noise.
Interpolation of signal shape using function values and the first derivative.
double m_r0
Assuming exponential drop of the signal function far away from 0, extrapolate it to +inf.
static constexpr int c_ntail
Number of tail steps.
double m_FunctionInterpolation[c_nt *c_ndt+c_ntail]
Function values.
SignalInterpolation2()
Default constructor.
void getShape(double t0, double *function, double *derivatives) const
Returns signal shape and derivatives in 31 equidistant time points starting from t0.
static constexpr int c_nt
Signal function is sampled in c_nt time steps with c_ndt substeps and c_ntail steps.
static constexpr double c_idt
Inverted time step.
double m_DerivativeInterpolation[c_nt *c_ndt+c_ntail]
Derivative values.
static constexpr double c_idtn
Inverted time substep.
static constexpr double c_dt
Time step.
static constexpr int c_ndt
Number of substeps.
static constexpr double c_dtn
Time substep.