Belle II Software  release-05-02-19
shaperdsp.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015-2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Alexei Sibidanov *
7  * Alex Bobrov *
8  * *
9  * This software is provided "as is" without any warranty. *
10  **************************************************************************/
11 
12 #ifndef SHAPERDSP_T_H
13 #define SHAPERDSP_T_H
14 
15 #include <vector>
16 #include <utility>
17 #include <limits>
18 
19 static const double realNaN = std::numeric_limits<double>::quiet_NaN();
20 
21 namespace Belle2 {
26  namespace ECL {
27  typedef std::pair<double, double> dd_t;
28 
30  class ShaperDSP_t {
31  public:
32 
34  struct sv123shift_t {
36  double t;
38  double s0;
40  double c0;
42  double s1;
44  double c1;
46  double e0;
48  double e1;
50  double es;
52  double ed;
53 
54  sv123shift_t() {}
55  sv123shift_t(double _t, const ShaperDSP_t& _p) { init(_t, _p);}
56  void init(double, const ShaperDSP_t&) __attribute__((noinline));
57  sv123shift_t& operator +=(const sv123shift_t&);
58  sv123shift_t operator +(const sv123shift_t&) const;
59  bool validshift(const sv123shift_t& x) const {return t + x.t > 0;}
60  };
61 
63  struct shaperdspshift_t: public sv123shift_t {
64  double et0;
65  double et1;
67  shaperdspshift_t() {}
68  shaperdspshift_t(double _t, const ShaperDSP_t& _p) { init(_t, _p);}
69  void init(double, const ShaperDSP_t&) __attribute__((noinline));
70  shaperdspshift_t& operator +=(const shaperdspshift_t&);
71  shaperdspshift_t operator +(const shaperdspshift_t&) const;
72  };
73 
74  private:
76  static const double _defs[]; //
79  static constexpr double _filterdt = 0.2;
80 
82  double _cs0 = realNaN;
84  double _cc0 = realNaN;
86  double _cs1 = realNaN;
88  double _cc1 = realNaN;
90  double _ces = realNaN;
92  double _ced = realNaN;
94  double _dw0 = realNaN;
96  double _dw1 = realNaN;
98  double _dks0 = realNaN;
100  double _dks1 = realNaN;
102  double _ds = realNaN;
104  double _dd = realNaN;
106  double _dt0 = realNaN;
108  double _dt1 = realNaN;
109 
111  double _toff = realNaN;
113  double _w0 = realNaN;
115  double _w1 = realNaN;
116 
118  double _ccc = realNaN;
119 
122 
125 
128 
133 
135  void Sv123_init(double t01, double tb1, double t02, double tb2, double td1, double ts1);
137  void init(const double*, double) __attribute__((noinline));
139  void init(const double*) __attribute__((noinline));
140 
142  double Sv123(const sv123shift_t&) const;
144  dd_t ddSv123(const sv123shift_t&) const;
145 
148  double Sv123_filtered(const sv123shift_t&) const __attribute__((noinline));
150  dd_t ddSv123_filtered(const sv123shift_t&) const __attribute__((noinline));
151 
153  double ShaperDSP(const shaperdspshift_t&) const;
155  dd_t ddShaperDSP(const shaperdspshift_t&) const;
156 
157  public:
161  explicit ShaperDSP_t(const std::vector<double>& s) { init(s); }
163  ShaperDSP_t(const std::vector<double>& s, double u) { init(s, u); }
164 
165  ~ShaperDSP_t() {}
167  void init(const std::vector<double>& s, double u = 27.7221);
169  double operator()(double) const;
171  double operator()(double*, double*);
173  void settimestride(double);
175  void setseedoffset(double);
177  void settimeseed(double);
179  void nextseed();
181  void fillvector(std::vector<double>&) const;
183  void fillvector(std::vector<dd_t>&) const;
185  void fillvector(double, std::vector<double>&) const;
187  void fillvector(double, std::vector<dd_t>&) const;
189  void fillarray(int, double*) const;
191  void fillarray(int, dd_t*) const;
193  void fillarray(double, int, double*) const;
195  void fillarray(double, int, dd_t*) const;
196  };
197  }
199 }
200 #endif//SHAPERDSP_T_H
Belle2::ECL::ShaperDSP_t::_tzero
shaperdspshift_t _tzero
initial time
Definition: shaperdsp.h:132
Belle2::ECL::ShaperDSP_t::_ced
double _ced
linear coefficient before second part of tail section
Definition: shaperdsp.h:92
Belle2::ECL::ShaperDSP_t::ShaperDSP_t
ShaperDSP_t()
class constructor
Definition: shaperdsp.h:159
Belle2::ECL::ShaperDSP_t::settimeseed
void settimeseed(double)
set initial time
Definition: shaperdsp.cc:363
Belle2::ECL::ShaperDSP_t::sv123shift_t::c1
double c1
cos of the second Bessel stage
Definition: shaperdsp.h:44
Belle2::ECL::ShaperDSP_t::shaperdspshift_t::operator+=
shaperdspshift_t & operator+=(const shaperdspshift_t &)
increment operator
Definition: shaperdsp.cc:79
Belle2::ECL::ShaperDSP_t::_defs
static const double _defs[]
parameters of the response function that use as default
Definition: shaperdsp.h:76
Belle2::ECL::ShaperDSP_t::_cc1
double _cc1
linear coefficient before cos of the second Bessel stage
Definition: shaperdsp.h:88
Belle2::ECL::ShaperDSP_t
Class include function that calculate electronic response from energy deposit
Definition: shaperdsp.h:30
Belle2::ECL::ShaperDSP_t::sv123shift_t::s0
double s0
sin of the first Bessel stage
Definition: shaperdsp.h:38
Belle2::ECL::ShaperDSP_t::_dw1
double _dw1
circular frequency of the second Bessel stage
Definition: shaperdsp.h:96
Belle2::ECL::ShaperDSP_t::operator()
double operator()(double) const
wrapper of the function
Definition: shaperdsp.cc:342
Belle2::ECL::ShaperDSP_t::shaperdspshift_t::et1
double et1
Definition: shaperdsp.h:65
Belle2::ECL::ShaperDSP_t::_ccc
double _ccc
exponent factor for tail part of the signal
Definition: shaperdsp.h:118
Belle2::ECL::ShaperDSP_t::_toffset
shaperdspshift_t _toffset
time offset
Definition: shaperdsp.h:130
Belle2::ECL::ShaperDSP_t::fillvector
void fillvector(std::vector< double > &) const
fill vector with response function values and its derivative
Definition: shaperdsp.cc:409
Belle2::ECL::ShaperDSP_t::Sv123_init
void Sv123_init(double t01, double tb1, double t02, double tb2, double td1, double ts1)
calculate some values for Sv123 function
Definition: shaperdsp.cc:117
Belle2::ECL::ShaperDSP_t::_tm
sv123shift_t _tm
Definition: shaperdsp.h:124
Belle2::ECL::ShaperDSP_t::ShaperDSP_t
ShaperDSP_t(const std::vector< double > &s, double u)
class constructor
Definition: shaperdsp.h:163
Belle2::ECL::ShaperDSP_t::sv123shift_t::c0
double c0
cos of the first Bessel stage
Definition: shaperdsp.h:40
Belle2::ECL::ShaperDSP_t::_cs1
double _cs1
linear coefficient before sin of the second Bessel stage
Definition: shaperdsp.h:86
Belle2::ECL::ShaperDSP_t::setseedoffset
void setseedoffset(double)
set timeoffset
Definition: shaperdsp.cc:358
Belle2::ECL::ShaperDSP_t::_dks0
double _dks0
decrement of the first Bessel stage
Definition: shaperdsp.h:98
Belle2::ECL::ShaperDSP_t::settimestride
void settimestride(double)
set grid step for function calculation
Definition: shaperdsp.cc:353
Belle2::ECL::ShaperDSP_t::_dd
double _dd
inverse time of the differential stage
Definition: shaperdsp.h:104
Belle2::ECL::ShaperDSP_t::fillarray
void fillarray(int, double *) const
fill array for amplitude and time calculation
Definition: shaperdsp.cc:373
Belle2::ECL::ShaperDSP_t::ddSv123
dd_t ddSv123(const sv123shift_t &) const
calculate derivative of the Sv123 function
Definition: shaperdsp.cc:221
Belle2::ECL::ShaperDSP_t::Sv123_filtered
double Sv123_filtered(const sv123shift_t &) const __attribute__((noinline))
Numerical calculation of the time convolution.
Definition: shaperdsp.cc:238
Belle2::ECL::ShaperDSP_t::shaperdspshift_t
struct for a shift of the shaper dsp
Definition: shaperdsp.h:63
Belle2::ECL::ShaperDSP_t::sv123shift_t::es
double es
first exponent factor for tail part of the signal.
Definition: shaperdsp.h:50
Belle2::ECL::ShaperDSP_t::_tp
sv123shift_t _tp
_filterdt
Definition: shaperdsp.h:121
Belle2::ECL::ShaperDSP_t::sv123shift_t::e1
double e1
exponent factor for second Bessel stage
Definition: shaperdsp.h:48
Belle2::ECL::ShaperDSP_t::sv123shift_t
struct to encapsulate the electronic response from energy deposit
Definition: shaperdsp.h:34
Belle2::ECL::ShaperDSP_t::shaperdspshift_t::et0
double et0
Definition: shaperdsp.h:64
Belle2::ECL::ShaperDSP_t::sv123shift_t::operator+=
sv123shift_t & operator+=(const sv123shift_t &)
increment operator
Definition: shaperdsp.cc:34
Belle2::ECL::ShaperDSP_t::_dks1
double _dks1
decrement of the second Bessel stage
Definition: shaperdsp.h:100
Belle2::ECL::ShaperDSP_t::_dt0
double _dt0
coefficient for first exponent factor
Definition: shaperdsp.h:106
Belle2::ECL::ShaperDSP_t::init
void init(const double *, double) __attribute__((noinline))
calculate some values for Sv123 function
Definition: shaperdsp.cc:301
Belle2::ECL::ShaperDSP_t::nextseed
void nextseed()
substruct toffset to tzero
Definition: shaperdsp.cc:368
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECL::ShaperDSP_t::_dt1
double _dt1
coefficient for second exponent factor
Definition: shaperdsp.h:108
Belle2::ECL::ShaperDSP_t::sv123shift_t::operator+
sv123shift_t operator+(const sv123shift_t &) const
addition operator
Definition: shaperdsp.cc:55
Belle2::ECL::ShaperDSP_t::sv123shift_t::s1
double s1
sin of the second Bessel stage
Definition: shaperdsp.h:42
Belle2::ECL::ShaperDSP_t::_w0
double _w0
weight coefficient at sv123(t) = (1-a)
Definition: shaperdsp.h:113
Belle2::ECL::ShaperDSP_t::sv123shift_t::ed
double ed
second exponent factor for tail part of the signal.
Definition: shaperdsp.h:52
Belle2::ECL::ShaperDSP_t::ShaperDSP_t
ShaperDSP_t(const std::vector< double > &s)
calculate derivative of the response function
Definition: shaperdsp.h:161
Belle2::ECL::ShaperDSP_t::ddShaperDSP
dd_t ddShaperDSP(const shaperdspshift_t &) const
calculate derivative of the response function
Definition: shaperdsp.cc:282
Belle2::ECL::ShaperDSP_t::sv123shift_t::t
double t
time
Definition: shaperdsp.h:36
Belle2::ECL::ShaperDSP_t::_tstride
shaperdspshift_t _tstride
time step of the grid for response function calculation
Definition: shaperdsp.h:127
Belle2::ECL::ShaperDSP_t::ddSv123_filtered
dd_t ddSv123_filtered(const sv123shift_t &) const __attribute__((noinline))
This is derivative of the confolution
Definition: shaperdsp.cc:252
Belle2::ECL::ShaperDSP_t::_cc0
double _cc0
linear coefficient before cos of the first Bessel stage
Definition: shaperdsp.h:84
Belle2::ECL::ShaperDSP_t::ShaperDSP
double ShaperDSP(const shaperdspshift_t &) const
calculate response function
Definition: shaperdsp.cc:266
Belle2::realNaN
static const double realNaN
shortcut for NaN of double type
Definition: TagVertexModule.cc:64
Belle2::ECL::ShaperDSP_t::_w1
double _w1
weight coefficient at sv123(t+_filterdt) +sv123(t-_filterdt) = a/2
Definition: shaperdsp.h:115
Belle2::ECL::ShaperDSP_t::_ds
double _ds
inverse scintillation decay time
Definition: shaperdsp.h:102
Belle2::ECL::ShaperDSP_t::_toff
double _toff
time offset
Definition: shaperdsp.h:111
Belle2::ECL::ShaperDSP_t::shaperdspshift_t::init
void init(double, const ShaperDSP_t &) __attribute__((noinline))
initialise
Definition: shaperdsp.cc:72
Belle2::ECL::ShaperDSP_t::shaperdspshift_t::operator+
shaperdspshift_t operator+(const shaperdspshift_t &) const
addition operator
Definition: shaperdsp.cc:89
Belle2::ECL::ShaperDSP_t::sv123shift_t::e0
double e0
exponent factor for first Bessel stage
Definition: shaperdsp.h:46
Belle2::ECL::ShaperDSP_t::_filterdt
static constexpr double _filterdt
time shift that include in response function for numerical calculation time convolutions.
Definition: shaperdsp.h:79
Belle2::ECL::ShaperDSP_t::Sv123
double Sv123(const sv123shift_t &) const
calculate Sv123 function
Definition: shaperdsp.cc:211
Belle2::ECL::ShaperDSP_t::_cs0
double _cs0
linear coefficient before sin of the first Bessel stage
Definition: shaperdsp.h:82
Belle2::ECL::ShaperDSP_t::_dw0
double _dw0
circular frequency of the first Bessel stage
Definition: shaperdsp.h:94
Belle2::ECL::ShaperDSP_t::sv123shift_t::init
void init(double, const ShaperDSP_t &) __attribute__((noinline))
initialise
Definition: shaperdsp.cc:23
Belle2::ECL::ShaperDSP_t::_ces
double _ces
linear coefficient before first part of tail section
Definition: shaperdsp.h:90