Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Shaper.cc
Go to the documentation of this file.
1#include <iostream>
2#include <algorithm>
3
4#include <Math/SpecFuncMathCore.h>
5
7#include "Garfield/Shaper.hh"
8
9namespace {
10
11double Heaviside(const double t, const double t0) {
12 if (t < t0)
13 return 0;
14 else if (fabs(t - t0) < Garfield::Small)
15 return 0.5;
16 else
17 return 1;
18}
19
20}
21
22namespace Garfield {
23
24Shaper::Shaper(const unsigned int n, const double tau, const double g,
25 std::string shaperType) :
26 m_n(n),
27 m_tau(tau),
28 m_g(g) {
29
30 std::transform(shaperType.begin(), shaperType.end(),
31 shaperType.begin(), toupper);
32 if (shaperType == "UNIPOLAR") {
33 m_type = ShaperType::Unipolar;
34 m_tp = m_n * m_tau;
35 m_prefactor = exp(m_n);
36 m_transfer_func_sq = (exp(2 * m_n) / pow(2 * m_n, 2 * m_n)) * m_tp *
37 ROOT::Math::tgamma(2 * m_n);
38 } else if (shaperType == "BIPOLAR") {
39 m_type = ShaperType::Bipolar;
40 const double r = m_n - sqrt(m_n);
41 m_tp = r * m_tau;
42 m_prefactor = exp(r) / sqrt(m_n);
43 m_transfer_func_sq = (exp(2 * r) / pow(2 * r, 2 * m_n)) * r * m_tp *
44 ROOT::Math::tgamma(2 * m_n - 1);
45 } else {
46 std::cerr << m_className << ": Unknown shaper type.\n";
47 }
48}
49
50double Shaper::Shape(const double t) const {
51 switch (m_type) {
52 case ShaperType::Unipolar:
53 return UnipolarShaper(t);
54 case ShaperType::Bipolar:
55 return BipolarShaper(t);
56 default:
57 break;
58 }
59 return 0;
60}
61
62double Shaper::UnipolarShaper(const double t) const {
63 double f = m_prefactor * pow(t / m_tp, m_n) * exp(-t / m_tau) * Heaviside(t, 0.);
64 return m_g * f;
65}
66
67double Shaper::BipolarShaper(const double t) const {
68 double f = m_prefactor * (m_n - t / m_tau) * pow(t / m_tp, m_n - 1) * exp(-t / m_tau) * Heaviside(t, 0.);
69 return m_g * f;
70}
71
72}
double BipolarShaper(const double t) const
Transfer function for a bipolar shaper.
Definition: Shaper.cc:67
Shaper()=delete
Default constructor.
double Shape(const double t) const
Evaluate the transfer function.
Definition: Shaper.cc:50
double UnipolarShaper(const double t) const
Transfer function for a unipolar shaper.
Definition: Shaper.cc:62
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615