Belle II Software development
shaperdsp.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#include <vector>
12#include <utility>
13#include <limits>
14
15static const double realNaN = std::numeric_limits<double>::quiet_NaN();
16
17namespace Belle2 {
22 namespace ECL {
23 typedef std::pair<double, double> dd_t;
24
27 public:
28
30 struct sv123shift_t {
32 double t;
34 double s0;
36 double c0;
38 double s1;
40 double c1;
42 double e0;
44 double e1;
46 double es;
48 double ed;
49
51 sv123shift_t(double _t, const ShaperDSP_t& _p) { init(_t, _p);}
52 void init(double, const ShaperDSP_t&) __attribute__((noinline));
55 bool validshift(const sv123shift_t& x) const {return t + x.t > 0;}
56 };
57
60 double et0;
61 double et1;
62
64 shaperdspshift_t(double _t, const ShaperDSP_t& _p) { init(_t, _p);}
65 // cppcheck-suppress duplInheritedMember ; each level initialises its own fields
66 void init(double, const ShaperDSP_t&) __attribute__((noinline));
69 };
70
71 private:
73 static const double _defs[]; //
76 static constexpr double _filterdt = 0.2;
77
79 double _cs0 = realNaN;
81 double _cc0 = realNaN;
83 double _cs1 = realNaN;
85 double _cc1 = realNaN;
87 double _ces = realNaN;
89 double _ced = realNaN;
91 double _dw0 = realNaN;
93 double _dw1 = realNaN;
95 double _dks0 = realNaN;
97 double _dks1 = realNaN;
99 double _ds = realNaN;
101 double _dd = realNaN;
103 double _dt0 = realNaN;
105 double _dt1 = realNaN;
106
108 double _toff = realNaN;
110 double _w0 = realNaN;
112 double _w1 = realNaN;
113
115 double _ccc = realNaN;
116
119
122
125
130
132 void Sv123_init(double t01, double tb1, double t02, double tb2, double td1, double ts1);
134 void init(const double*, double) __attribute__((noinline));
136 void init(const double*) __attribute__((noinline));
137
139 double Sv123(const sv123shift_t&) const;
141 dd_t ddSv123(const sv123shift_t&) const;
142
145 double Sv123_filtered(const sv123shift_t&) const __attribute__((noinline));
147 dd_t ddSv123_filtered(const sv123shift_t&) const __attribute__((noinline));
148
150 double ShaperDSP(const shaperdspshift_t&) const;
152 dd_t ddShaperDSP(const shaperdspshift_t&) const;
153
154 public:
158 explicit ShaperDSP_t(const std::vector<double>& s) { init(s); }
160 ShaperDSP_t(const std::vector<double>& s, double u) { init(s, u); }
161
162 ~ShaperDSP_t() {}
171 void init(const std::vector<double>& s, double u = -1);
173 double operator()(double) const;
175 double operator()(const double*, double*);
177 void settimestride(double);
179 void setseedoffset(double);
181 void settimeseed(double);
183 void nextseed();
185 void fillvector(std::vector<double>&) const;
187 void fillvector(std::vector<dd_t>&) const;
189 void fillvector(double, std::vector<double>&) const;
191 void fillvector(double, std::vector<dd_t>&) const;
193 void fillarray(int, double*) const;
195 void fillarray(int, dd_t*) const;
197 void fillarray(double, int, double*) const;
199 void fillarray(double, int, dd_t*) const;
200 };
201 }
203}
Class include function that calculate electronic response from energy deposit.
Definition shaperdsp.h:26
double _dw0
circular frequency of the first Bessel stage
Definition shaperdsp.h:91
void fillvector(std::vector< double > &) const
fill vector with response function values and its derivative
Definition shaperdsp.cc:418
dd_t ddSv123(const sv123shift_t &) const
calculate derivative of the Sv123 function
Definition shaperdsp.cc:229
double _cs1
linear coefficient before sin of the second Bessel stage
Definition shaperdsp.h:83
void init(const double *, double)
calculate some values for Sv123 function
Definition shaperdsp.cc:309
double _dks1
decrement of the second Bessel stage
Definition shaperdsp.h:97
double _cc0
linear coefficient before cos of the first Bessel stage
Definition shaperdsp.h:81
double _dt0
coefficient for first exponent factor
Definition shaperdsp.h:103
void settimeseed(double)
set initial time
Definition shaperdsp.cc:372
double Sv123_filtered(const sv123shift_t &) const
Numerical calculation of the time convolution.
Definition shaperdsp.cc:246
double _cc1
linear coefficient before cos of the second Bessel stage
Definition shaperdsp.h:85
dd_t ddSv123_filtered(const sv123shift_t &) const
This is derivative of the confolution.
Definition shaperdsp.cc:260
shaperdspshift_t _tzero
initial time
Definition shaperdsp.h:129
shaperdspshift_t _tstride
time step of the grid for response function calculation
Definition shaperdsp.h:124
double _cs0
linear coefficient before sin of the first Bessel stage
Definition shaperdsp.h:79
double _w1
weight coefficient at sv123(t+_filterdt) +sv123(t-_filterdt) = a/2
Definition shaperdsp.h:112
double _dw1
circular frequency of the second Bessel stage
Definition shaperdsp.h:93
ShaperDSP_t()
class constructor
Definition shaperdsp.h:156
double _ced
linear coefficient before second part of tail section
Definition shaperdsp.h:89
void settimestride(double)
set grid step for function calculation
Definition shaperdsp.cc:362
double Sv123(const sv123shift_t &) const
calculate Sv123 function
Definition shaperdsp.cc:219
double _toff
time offset
Definition shaperdsp.h:108
dd_t ddShaperDSP(const shaperdspshift_t &) const
calculate derivative of the response function
Definition shaperdsp.cc:290
double _ds
inverse scintillation decay time
Definition shaperdsp.h:99
void nextseed()
substruct toffset to tzero
Definition shaperdsp.cc:377
double _dd
inverse time of the differential stage
Definition shaperdsp.h:101
double ShaperDSP(const shaperdspshift_t &) const
calculate response function
Definition shaperdsp.cc:274
double _dks0
decrement of the first Bessel stage
Definition shaperdsp.h:95
double _w0
weight coefficient at sv123(t) = (1-a)
Definition shaperdsp.h:110
void setseedoffset(double)
set timeoffset
Definition shaperdsp.cc:367
static constexpr double _filterdt
time shift that include in response function for numerical calculation time convolutions.
Definition shaperdsp.h:76
void fillarray(int, double *) const
fill array for amplitude and time calculation
Definition shaperdsp.cc:382
static const double _defs[]
parameters of the response function that use as default
Definition shaperdsp.h:73
ShaperDSP_t(const std::vector< double > &s, double u)
class constructor
Definition shaperdsp.h:160
shaperdspshift_t _toffset
time offset
Definition shaperdsp.h:127
double operator()(double) const
wrapper of the function
Definition shaperdsp.cc:351
double _ccc
exponent factor for tail part of the signal
Definition shaperdsp.h:115
double _ces
linear coefficient before first part of tail section
Definition shaperdsp.h:87
ShaperDSP_t(const std::vector< double > &s)
calculate derivative of the response function
Definition shaperdsp.h:158
double _dt1
coefficient for second exponent factor
Definition shaperdsp.h:105
sv123shift_t _tp
_filterdt
Definition shaperdsp.h:118
void Sv123_init(double t01, double tb1, double t02, double tb2, double td1, double ts1)
calculate some values for Sv123 function
Definition shaperdsp.cc:125
static const double realNaN
This collects the B-meson properties in the hadronic B-decays It is used for the Ecms calibration in ...
Abstract base class for different kinds of events.
struct for a shift of the shaper dsp
Definition shaperdsp.h:59
shaperdspshift_t(double _t, const ShaperDSP_t &_p)
constructor from a ShaperDSP class
Definition shaperdsp.h:64
shaperdspshift_t operator+(const shaperdspshift_t &) const
addition operator
Definition shaperdsp.cc:97
shaperdspshift_t & operator+=(const shaperdspshift_t &)
increment operator
Definition shaperdsp.cc:87
void init(double, const ShaperDSP_t &)
initialise
Definition shaperdsp.cc:80
struct to encapsulate the electronic response from energy deposit
Definition shaperdsp.h:30
double e0
exponent factor for first Bessel stage
Definition shaperdsp.h:42
double es
first exponent factor for tail part of the signal.
Definition shaperdsp.h:46
double c0
cos of the first Bessel stage
Definition shaperdsp.h:36
double s1
sin of the second Bessel stage
Definition shaperdsp.h:38
double ed
second exponent factor for tail part of the signal.
Definition shaperdsp.h:48
sv123shift_t operator+(const sv123shift_t &) const
addition operator
Definition shaperdsp.cc:62
bool validshift(const sv123shift_t &x) const
check for a valid shift
Definition shaperdsp.h:55
double c1
cos of the second Bessel stage
Definition shaperdsp.h:40
sv123shift_t()
default constructor
Definition shaperdsp.h:50
double s0
sin of the first Bessel stage
Definition shaperdsp.h:34
double e1
exponent factor for second Bessel stage
Definition shaperdsp.h:44
void init(double, const ShaperDSP_t &)
initialise
Definition shaperdsp.cc:30
sv123shift_t & operator+=(const sv123shift_t &)
increment operator
Definition shaperdsp.cc:41
sv123shift_t(double _t, const ShaperDSP_t &_p)
constructor from a ShaperDSP class
Definition shaperdsp.h:51