Belle II Software  release-05-01-25
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 
18 namespace Belle2 {
23  namespace ECL {
24  typedef std::pair<double, double> dd_t;
25 
27  class ShaperDSP_t {
28  public:
29 
31  struct sv123shift_t {
33  double t;
35  double s0;
37  double c0;
39  double s1;
41  double c1;
43  double e0;
45  double e1;
47  double es;
49  double ed;
50 
51  sv123shift_t() {}
52  sv123shift_t(double _t, const ShaperDSP_t& _p) { init(_t, _p);}
53  void init(double, const ShaperDSP_t&) __attribute__((noinline));
55  sv123shift_t operator +(const sv123shift_t&) const;
56  bool validshift(const sv123shift_t& x) const {return t + x.t > 0;}
57  };
58 
60  struct shaperdspshift_t: public sv123shift_t {
61  double et0;
62  double et1;
64  shaperdspshift_t() {}
65  shaperdspshift_t(double _t, const ShaperDSP_t& _p) { init(_t, _p);}
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;
81  double _cc0;
83  double _cs1;
85  double _cc1;
87  double _ces;
89  double _ced;
91  double _dw0;
93  double _dw1;
95  double _dks0;
97  double _dks1;
99  double _ds;
101  double _dd;
103  double _dt0;
105  double _dt1;
106 
108  double _toff;
110  double _w0;
112  double _w1;
113 
115  double _ccc;
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:
156  ShaperDSP_t() { init(_defs); }
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() {}
164  void init(const std::vector<double>& s, double u = 27.7221);
166  double operator()(double) const;
168  double operator()(double*, double*);
170  void settimestride(double);
172  void setseedoffset(double);
174  void settimeseed(double);
176  void nextseed();
178  void fillvector(std::vector<double>&) const;
180  void fillvector(std::vector<dd_t>&) const;
182  void fillvector(double, std::vector<double>&) const;
184  void fillvector(double, std::vector<dd_t>&) const;
186  void fillarray(int, double*) const;
188  void fillarray(int, dd_t*) const;
190  void fillarray(double, int, double*) const;
192  void fillarray(double, int, dd_t*) const;
193  };
194  }
196 }
197 #endif//SHAPERDSP_T_H
Belle2::ECL::ShaperDSP_t::_tzero
shaperdspshift_t _tzero
initial time
Definition: shaperdsp.h:138
Belle2::ECL::ShaperDSP_t::_ced
double _ced
linear coefficient before second part of tail section
Definition: shaperdsp.h:98
Belle2::ECL::ShaperDSP_t::ShaperDSP_t
ShaperDSP_t()
class constructor
Definition: shaperdsp.h:165
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:50
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:82
Belle2::ECL::ShaperDSP_t::_cc1
double _cc1
linear coefficient before cos of the second Bessel stage
Definition: shaperdsp.h:94
Belle2::ECL::ShaperDSP_t
Class include function that calculate electronic response from energy deposit
Definition: shaperdsp.h:36
Belle2::ECL::ShaperDSP_t::sv123shift_t::s0
double s0
sin of the first Bessel stage
Definition: shaperdsp.h:44
Belle2::ECL::ShaperDSP_t::_dw1
double _dw1
circular frequency of the second Bessel stage
Definition: shaperdsp.h:102
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:71
Belle2::ECL::ShaperDSP_t::_ccc
double _ccc
exponent factor for tail part of the signal
Definition: shaperdsp.h:124
Belle2::ECL::ShaperDSP_t::_toffset
shaperdspshift_t _toffset
time offset
Definition: shaperdsp.h:136
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:130
Belle2::ECL::ShaperDSP_t::sv123shift_t::c0
double c0
cos of the first Bessel stage
Definition: shaperdsp.h:46
Belle2::ECL::ShaperDSP_t::_cs1
double _cs1
linear coefficient before sin of the second Bessel stage
Definition: shaperdsp.h:92
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:104
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:110
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:69
Belle2::ECL::ShaperDSP_t::sv123shift_t::es
double es
first exponent factor for tail part of the signal.
Definition: shaperdsp.h:56
Belle2::ECL::ShaperDSP_t::_tp
sv123shift_t _tp
_filterdt
Definition: shaperdsp.h:127
Belle2::ECL::ShaperDSP_t::sv123shift_t::e1
double e1
exponent factor for second Bessel stage
Definition: shaperdsp.h:54
Belle2::ECL::ShaperDSP_t::sv123shift_t
struct to encapsulate the electronic response from energy deposit
Definition: shaperdsp.h:40
Belle2::ECL::ShaperDSP_t::shaperdspshift_t::et0
double et0
Definition: shaperdsp.h:70
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:106
Belle2::ECL::ShaperDSP_t::_dt0
double _dt0
coefficient for first exponent factor
Definition: shaperdsp.h:112
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:114
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:48
Belle2::ECL::ShaperDSP_t::_w0
double _w0
weight coefficient at sv123(t) = (1-a)
Definition: shaperdsp.h:119
Belle2::ECL::ShaperDSP_t::sv123shift_t::ed
double ed
second exponent factor for tail part of the signal.
Definition: shaperdsp.h:58
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:42
Belle2::ECL::ShaperDSP_t::_tstride
shaperdspshift_t _tstride
time step of the grid for response function calculation
Definition: shaperdsp.h:133
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:90
Belle2::ECL::ShaperDSP_t::ShaperDSP
double ShaperDSP(const shaperdspshift_t &) const
calculate response function
Definition: shaperdsp.cc:266
Belle2::ECL::ShaperDSP_t::_w1
double _w1
weight coefficient at sv123(t+_filterdt) +sv123(t-_filterdt) = a/2
Definition: shaperdsp.h:121
Belle2::ECL::ShaperDSP_t::_ds
double _ds
inverse scintillation decay time
Definition: shaperdsp.h:108
Belle2::ECL::ShaperDSP_t::_toff
double _toff
time offset
Definition: shaperdsp.h:117
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:52
Belle2::ECL::ShaperDSP_t::_filterdt
static constexpr double _filterdt
time shift that include in response function for numerical calculation time convolutions.
Definition: shaperdsp.h:85
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:88
Belle2::ECL::ShaperDSP_t::_dw0
double _dw0
circular frequency of the first Bessel stage
Definition: shaperdsp.h:100
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:96