Belle II Software  release-08-01-10
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 
15 static const double realNaN = std::numeric_limits<double>::quiet_NaN();
16 
17 namespace Belle2 {
22  namespace ECL {
23  typedef std::pair<double, double> dd_t;
24 
26  class ShaperDSP_t {
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));
54  sv123shift_t operator +(const sv123shift_t&) const;
55  bool validshift(const sv123shift_t& x) const {return t + x.t > 0;}
56  };
57 
59  struct shaperdspshift_t: public sv123shift_t {
60  double et0;
61  double et1;
64  shaperdspshift_t(double _t, const ShaperDSP_t& _p) { init(_t, _p);}
65  void init(double, const ShaperDSP_t&) __attribute__((noinline));
68  };
69 
70  private:
72  static const double _defs[]; //
75  static constexpr double _filterdt = 0.2;
76 
78  double _cs0 = realNaN;
80  double _cc0 = realNaN;
82  double _cs1 = realNaN;
84  double _cc1 = realNaN;
86  double _ces = realNaN;
88  double _ced = realNaN;
90  double _dw0 = realNaN;
92  double _dw1 = realNaN;
94  double _dks0 = realNaN;
96  double _dks1 = realNaN;
98  double _ds = realNaN;
100  double _dd = realNaN;
102  double _dt0 = realNaN;
104  double _dt1 = realNaN;
105 
107  double _toff = realNaN;
109  double _w0 = realNaN;
111  double _w1 = realNaN;
112 
114  double _ccc = realNaN;
115 
118 
121 
124 
129 
131  void Sv123_init(double t01, double tb1, double t02, double tb2, double td1, double ts1);
133  void init(const double*, double) __attribute__((noinline));
135  void init(const double*) __attribute__((noinline));
136 
138  double Sv123(const sv123shift_t&) const;
140  dd_t ddSv123(const sv123shift_t&) const;
141 
144  double Sv123_filtered(const sv123shift_t&) const __attribute__((noinline));
146  dd_t ddSv123_filtered(const sv123shift_t&) const __attribute__((noinline));
147 
149  double ShaperDSP(const shaperdspshift_t&) const;
151  dd_t ddShaperDSP(const shaperdspshift_t&) const;
152 
153  public:
157  explicit ShaperDSP_t(const std::vector<double>& s) { init(s); }
159  ShaperDSP_t(const std::vector<double>& s, double u) { init(s, u); }
160 
161  ~ShaperDSP_t() {}
170  void init(const std::vector<double>& s, double u = -1);
172  double operator()(double) const;
174  double operator()(double*, double*);
176  void settimestride(double);
178  void setseedoffset(double);
180  void settimeseed(double);
182  void nextseed();
184  void fillvector(std::vector<double>&) const;
186  void fillvector(std::vector<dd_t>&) const;
188  void fillvector(double, std::vector<double>&) const;
190  void fillvector(double, std::vector<dd_t>&) const;
192  void fillarray(int, double*) const;
194  void fillarray(int, dd_t*) const;
196  void fillarray(double, int, double*) const;
198  void fillarray(double, int, dd_t*) const;
199  };
200  }
202 }
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:90
void fillvector(std::vector< double > &) const
fill vector with response function values and its derivative
Definition: shaperdsp.cc:417
dd_t ddSv123(const sv123shift_t &) const
calculate derivative of the Sv123 function
Definition: shaperdsp.cc:228
double _cs1
linear coefficient before sin of the second Bessel stage
Definition: shaperdsp.h:82
void init(const double *, double)
calculate some values for Sv123 function
Definition: shaperdsp.cc:308
double _dks1
decrement of the second Bessel stage
Definition: shaperdsp.h:96
double _cc0
linear coefficient before cos of the first Bessel stage
Definition: shaperdsp.h:80
double _dt0
coefficient for first exponent factor
Definition: shaperdsp.h:102
void settimeseed(double)
set initial time
Definition: shaperdsp.cc:371
double Sv123_filtered(const sv123shift_t &) const
Numerical calculation of the time convolution.
Definition: shaperdsp.cc:245
double _cc1
linear coefficient before cos of the second Bessel stage
Definition: shaperdsp.h:84
dd_t ddSv123_filtered(const sv123shift_t &) const
This is derivative of the confolution
Definition: shaperdsp.cc:259
shaperdspshift_t _tzero
initial time
Definition: shaperdsp.h:128
shaperdspshift_t _tstride
time step of the grid for response function calculation
Definition: shaperdsp.h:123
double _cs0
linear coefficient before sin of the first Bessel stage
Definition: shaperdsp.h:78
double _w1
weight coefficient at sv123(t+_filterdt) +sv123(t-_filterdt) = a/2
Definition: shaperdsp.h:111
double _dw1
circular frequency of the second Bessel stage
Definition: shaperdsp.h:92
ShaperDSP_t()
class constructor
Definition: shaperdsp.h:155
double _ced
linear coefficient before second part of tail section
Definition: shaperdsp.h:88
void settimestride(double)
set grid step for function calculation
Definition: shaperdsp.cc:361
double Sv123(const sv123shift_t &) const
calculate Sv123 function
Definition: shaperdsp.cc:218
double _toff
time offset
Definition: shaperdsp.h:107
dd_t ddShaperDSP(const shaperdspshift_t &) const
calculate derivative of the response function
Definition: shaperdsp.cc:289
double _ds
inverse scintillation decay time
Definition: shaperdsp.h:98
void nextseed()
substruct toffset to tzero
Definition: shaperdsp.cc:376
double _dd
inverse time of the differential stage
Definition: shaperdsp.h:100
double ShaperDSP(const shaperdspshift_t &) const
calculate response function
Definition: shaperdsp.cc:273
double _dks0
decrement of the first Bessel stage
Definition: shaperdsp.h:94
double _w0
weight coefficient at sv123(t) = (1-a)
Definition: shaperdsp.h:109
void setseedoffset(double)
set timeoffset
Definition: shaperdsp.cc:366
static constexpr double _filterdt
time shift that include in response function for numerical calculation time convolutions.
Definition: shaperdsp.h:75
void fillarray(int, double *) const
fill array for amplitude and time calculation
Definition: shaperdsp.cc:381
static const double _defs[]
parameters of the response function that use as default
Definition: shaperdsp.h:72
ShaperDSP_t(const std::vector< double > &s, double u)
class constructor
Definition: shaperdsp.h:159
shaperdspshift_t _toffset
time offset
Definition: shaperdsp.h:126
double operator()(double) const
wrapper of the function
Definition: shaperdsp.cc:350
double _ccc
exponent factor for tail part of the signal
Definition: shaperdsp.h:114
double _ces
linear coefficient before first part of tail section
Definition: shaperdsp.h:86
ShaperDSP_t(const std::vector< double > &s)
calculate derivative of the response function
Definition: shaperdsp.h:157
double _dt1
coefficient for second exponent factor
Definition: shaperdsp.h:104
sv123shift_t _tp
_filterdt
Definition: shaperdsp.h:117
void Sv123_init(double t01, double tb1, double t02, double tb2, double td1, double ts1)
calculate some values for Sv123 function
Definition: shaperdsp.cc:124
static const double realNaN
constant for double NaN
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:96
shaperdspshift_t & operator+=(const shaperdspshift_t &)
increment operator
Definition: shaperdsp.cc:86
void init(double, const ShaperDSP_t &)
initialise
Definition: shaperdsp.cc:79
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