Belle II Software  release-06-02-00
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 // FRAMEWORK
12 #include <framework/core/Module.h>
13 #include <framework/datastore/StoreArray.h>
14 
15 // ECL
16 #include <ecl/dataobjects/ECLDigit.h>
17 #include <ecl/dataobjects/ECLDsp.h>
18 
19 class TMinuit;
20 
21 namespace Belle2 {
34  float m_covMatPacked[31 * (31 + 1) / 2] = {};
36  float sigma{ -1};
38  float& operator[](int i) { return m_covMatPacked[i];}
40  const float& operator[](int i) const { return m_covMatPacked[i];}
41  };
42 
48  struct val_der_t {
50  double f0;
52  double f1;
54  double f2;
55  };
56 
64  constexpr static int c_nt = 12;
66  constexpr static int c_ndt = 5;
68  constexpr static int c_ntail = 20;
70  constexpr static double c_dt = 0.5;
72  constexpr static double c_idt = 1 / c_dt;
74  constexpr static double c_dtn = c_dt / c_ndt;
76  constexpr static double c_idtn = c_ndt / c_dt;
80  std::pair<double, double> m_F[c_nt * c_ndt + c_ntail];
87  double m_r0;
89  double m_r1;
90 
94  explicit SignalInterpolation2(const std::vector<double>&);
99  void getshape(double, val_der_t*) const;
100  };
101 
104  class ECLWaveformFitModule : public Module {
105 
106  public:
107 
111 
115 
117  virtual void initialize() override;
118 
120  virtual void beginRun() override;
121 
124  virtual void event() override;
125 
127  virtual void endRun() override;
128 
130  virtual void terminate() override;
131 
133  virtual const char* eclDigitArrayName() const
134  { return "ECLDigits" ; }
135 
137  virtual const char* eclDspArrayName() const
138  { return "ECLDsps" ; }
139 
140 
141  private:
145  double m_EnergyThreshold{0.03};
146  double m_chi2Threshold25dof{57.1};
147  double m_chi2Threshold27dof{60.0};
148  bool m_TemplatesLoaded{false};
150  std::vector<double> m_ADCtoEnergy;
152  TMinuit* m_Minit2h{nullptr};
153  TMinuit* m_Minit2h2{nullptr};
154  void Fit2h(double& b, double& a0, double& t0, double& a1, double& chi2);
155  void Fit2hExtraPhoton(double& b, double& a0, double& t0, double& a1, double& A2, double& T2,
156  double& chi2);
159  CovariancePacked m_c[8736] = {};
160  bool m_CovarianceMatrix{true};
161  bool m_IsMCFlag{false};
162  };
164 } // end Belle2 namespace
Module performs offline fit for saved ecl waveforms.
void Fit2hExtraPhoton(double &b, double &a0, double &t0, double &a1, double &A2, double &T2, double &chi2)
Optimized fit using hadron component model plus out of time background photon.
virtual const char * eclDigitArrayName() const
ECLDigits Array Name.
virtual void initialize() override
Initialize variables.
double m_chi2Threshold25dof
chi2 threshold (25 dof) to classify offline fit as good fit.
virtual void event() override
event per event.
virtual void endRun() override
end run.
TMinuit * m_Minit2h
minuit minimizer for optimized fit
bool m_IsMCFlag
Flag to indicate if running over data or MC.
StoreArray< ECLDsp > m_eclDSPs
StoreArray ECLDsp.
virtual void terminate() override
terminate.
StoreArray< ECLDigit > m_eclDigits
StoreArray ECLDigit.
std::vector< double > m_ADCtoEnergy
calibration vector form adc to energy
void loadTemplateParameterArray()
loads waveform templates from database.
bool m_CovarianceMatrix
Option to use crystal dependent covariance matrices.
void Fit2h(double &b, double &a0, double &t0, double &a1, double &chi2)
Optimized fit using hadron component model.
virtual void beginRun() override
begin run.
TMinuit * m_Minit2h2
minuit minimizer for optimized fit with background photon
virtual const char * eclDspArrayName() const
ECLDspsArray Name.
CovariancePacked m_c[8736]
Packed covariance matrices.
double m_EnergyThreshold
energy threshold to fit pulse offline
double m_chi2Threshold27dof
chi2 threshold (27 dof) to classify offline fit as good fit.
bool m_TemplatesLoaded
Flag to indicate if waveform templates are loaded from database.
SignalInterpolation2 m_si[8736][3]
ShaperDSP signal shapes.
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Abstract base class for different kinds of events.
Struct to keep upper triangle of the covariance matrix.
const float & operator[](int i) const
rvalue access by index
float & operator[](int i)
lvalue access by index
float m_covMatPacked[31 *(31+1)/2]
packed matrix
float sigma
sigma noise
Interpolate 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 f(i_last + i...
constexpr static double c_idt
inverted time step
void getshape(double, val_der_t *) const
returns signal shape(+derivatives) in 31 equidistant time points starting from T0
SignalInterpolation2()
Default constructor.
constexpr static int c_ntail
tail steps
constexpr static double c_dtn
time substep
constexpr static double c_idtn
inverted time substep
constexpr static int c_nt
Signal function is sampled in c_nt time steps with c_ndt substeps + c_ntail steps c_dt is the time st...
constexpr static double c_dt
time step
constexpr static int c_ndt
substeps
std::pair< double, double > m_F[c_nt *c_ndt+c_ntail]
storage for function value + first derivative
Struct to return signal function information f0 is the function value f1 is the first derivative f2 i...
double f1
see struct description
double f0
see struct description
double f2
see struct description