LDMX Software
PulseShape.cxx
1#include "Tracking/Digitization/PulseShape.h"
2
3#include "Framework/Exception/Exception.h"
4
5namespace tracking::digitization {
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} // namespace tracking::digitization