LDMX Software
PulseShape.cxx
1#include "Tools/PulseShape.h"
2
3#include "Framework/Exception/Exception.h"
4
5namespace ldmx {
6
7// ---------------------------------------------------------------------------
8// FourPoleShape
9// ---------------------------------------------------------------------------
10
11FourPoleShape::FourPoleShape(double tp, double tp2) : tp_(tp), tp2_(tp2) {
12 if (tp2_ <= 0.0 || tp_ <= tp2_) {
13 EXCEPTION_RAISE("InvalidArgument", "FourPoleShape: requires tp > tp2 > 0");
14 }
15
16 a_ = (tp_ * tp_) / std::pow(tp_ - tp2_, 3.0);
17 b_ = (tp_ - tp2_) / (tp_ * tp2_);
18
19 // Approximate peak time: 3·(tp·tp2³)^(1/4)
20 const double t_peak = 3.0 * std::pow(tp_ * std::pow(tp2_, 3.0), 0.25);
21
22 // Evaluate un-normalised amplitude at the peak for normalisation.
23 peak_amp_ = a_ * (std::exp(-t_peak / tp_) -
24 std::exp(-t_peak / tp2_) *
25 (1.0 + t_peak * b_ + 0.5 * t_peak * t_peak * b_ * b_));
26}
27
28double FourPoleShape::eval(double t) const {
29 if (t <= 0.0) return 0.0;
30 const double g =
31 a_ * (std::exp(-t / tp_) -
32 std::exp(-t / tp2_) * (1.0 + t * b_ + 0.5 * t * t * b_ * b_));
33 return g / peak_amp_;
34}
35
36// ---------------------------------------------------------------------------
37// Factory
38// ---------------------------------------------------------------------------
39
40std::unique_ptr<PulseShape> PulseShape::make(const std::string& name, double tp,
41 double tp2) {
42 if (name == "CRRC") {
43 return std::make_unique<CRRCShape>(tp);
44 } else if (name == "FourPole") {
45 return std::make_unique<FourPoleShape>(tp, tp2);
46 }
47 EXCEPTION_RAISE("InvalidArgument", "PulseShape::make: unknown shape '" +
48 name + "'. Use 'CRRC' or 'FourPole'.");
49}
50
51// ---------------------------------------------------------------------------
52// HgcrocShape
53// ---------------------------------------------------------------------------
54
55HgcrocShape::HgcrocShape(double rate_up, double time_up, double rate_dn,
56 double time_dn, double time_peak)
57 : rate_up_(rate_up),
58 time_up_(time_up),
59 rate_dn_(rate_dn),
60 time_dn_(time_dn),
61 time_peak_(time_peak) {
62 norm_ = (1.0 + std::exp(rate_up_ * (time_peak_ - time_up_))) *
63 (1.0 + std::exp(rate_dn_ * (time_peak_ - time_dn_)));
64}
65
66double HgcrocShape::eval(double t) const {
67 return norm_ / ((1.0 + std::exp(rate_up_ * (t - time_up_ + time_peak_))) *
68 (1.0 + std::exp(rate_dn_ * (t - time_dn_ + time_peak_))));
69}
70
71} // namespace ldmx
double eval(double t) const override
Evaluate the peak-normalised pulse amplitude at time t [ns] after charge arrival.
double norm_
makes eval(0) = 1
Definition PulseShape.h:131