R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BDigitizingTamex.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14#ifndef R3BROOT_DIGITIZINGTAMEX_H
15#define R3BROOT_DIGITIZINGTAMEX_H
23
25#include "R3BDigitizingPaddle.h"
26#include "TRandom3.h"
28
31
33{
34 class Channel;
35 struct Params
36 {
37 // NOLINTBEGIN
38 double fPMTThresh = 1.; // [MeV]
39 double fSaturationCoefficient = 0.012; // Saturation coefficient of PMTs
41 double fTimeRes = 0.15; // time + Gaus(0., fTimeRes) [ns]
42 double fEResRel = 0.05; // Gaus(e, fEResRel * e) []
43 double fEnergyGain = 15.0;
44 double fPedestal = 14.0;
45 double fTimeMax = 1000.; // ns
46 double fTimeMin = 1.; // ns
47 double fPileUpTimeWindow = 1000.; // ns
48 double fPileUpDistance = 100.; // ns
49 double fQdcMin = 0.067;
50 std::reference_wrapper<TRandom3> fRnd;
51 // NOLINTEND
52
53 explicit Params(TRandom3&);
54
55 // rule of 5
56 Params(Params&&) = delete;
57 auto operator=(const Params&) -> Params& = default;
58 auto operator=(Params&&) -> Params& = delete;
59 ~Params() = default;
60 Params(const Params& other) = default;
61 };
62
63 enum class PeakPileUpStrategy : uint8_t
64 {
68 };
69
70 class PMTPeak
71 {
72 public:
73 PMTPeak() = default;
75 auto operator<(const PMTPeak& rhs) const -> bool { return (time_ < rhs.time_); }
76 auto operator==(const PMTPeak& rhs) const -> bool { return std::abs(time_ - rhs.time_) < peakWidth; }
77 auto operator+=(const PMTPeak& other) -> PMTPeak&;
78 [[nodiscard]] auto GetQDC() const -> double { return qdc_; }
79 [[nodiscard]] auto GetLETime() const -> double { return time_; }
80 static constexpr double peakWidth = 15.0; // ns
81
82 private:
83 double qdc_ = 0.0;
84 double time_ = 0.0;
85 };
86
87 class FQTPeak
88 {
89 public:
90 FQTPeak(const PMTPeak& pmtPeak, Channel* channel);
91 FQTPeak() = default;
92
93 // Getters:
94 [[nodiscard]] auto GetWidth() const -> double { return width_; }
95 [[nodiscard]] auto GetQDC() const -> double { return qdc_; }
96 [[nodiscard]] auto GetLETime() const -> double { return leading_edge_time_; }
97 [[nodiscard]] auto GetTETime() const -> double { return trailing_edge_time_; }
98
99 auto operator==(const FQTPeak& other) const -> bool;
100 void operator+=(const FQTPeak& other);
101 auto operator-(const FQTPeak& other) const -> double { return leading_edge_time_ - other.leading_edge_time_; }
102 auto operator-(double time) const -> double { return leading_edge_time_ - time; };
103 auto operator>(const FQTPeak& other) const -> bool { return leading_edge_time_ - other.leading_edge_time_ > 0; }
104 auto operator<(const FQTPeak& other) const -> bool { return leading_edge_time_ - other.leading_edge_time_ < 0; }
105
106 void AddQDC(double qdc) { qdc_ += qdc; }
107
108 template <typename Par>
109 static auto WidthToQdc(double width, const Par& par) -> double
110 {
111 return std::max(1., width - par.fPedestal) / par.fEnergyGain;
112 }
113
114 template <typename Par>
115 static auto QdcToWidth(double qdc, const Par& par) -> double
116 {
117 auto width = 0.0;
118 if (qdc > par.fQdcMin)
119 {
120 width = qdc * par.fEnergyGain + par.fPedestal;
121 }
122 else
123 {
124 width = qdc * par.fEnergyGain * (par.fPedestal + 1);
125 }
126 return width;
127 }
128 explicit operator Digitizing::Channel::Signal() const;
129
130 private:
131 double width_ = 0.0; // the temperal width of the TmxPeak in [ns]
132 double qdc_ = 0.0; // the qdc value in [MeV] (without threshold)
133 double leading_edge_time_ = 0.0; // leading edge of the TmxPeak in [ns]
134 double trailing_edge_time_ = 0.0; // tailing edge of the TmxPeak
135 Channel* channel_ptr_ = nullptr;
136 };
137
139 {
140 public:
141 Channel(ChannelSide, PeakPileUpStrategy strategy, TRandom3&);
143 PeakPileUpStrategy strategy,
144 const Params&,
145 R3B::Neuland::Cal2HitPar* cal_to_hit_par = nullptr);
147 : Channel(side, strategy, GetDefaultRandomGen())
148 {
149 }
150 // Setters:
151 void SetPileUpStrategy(PeakPileUpStrategy strategy) { pileup_strategy_ = strategy; }
152 // auto SetHitModulPar(R3B::Neuland::HitModulePar hit_module_par)
153 // {
154 // neuland_hit_module_par_ = hit_module_par;
155 // } // Added for qdc in time
156
157 // Getters:
158 auto GetPar() -> Tamex::Params& { return par_; }
159 auto GetParConstRef() const -> const Tamex::Params& { return par_; }
160 auto GetFQTPeaks() -> const std::vector<FQTPeak>&;
161 auto GetPMTPeaks() -> const std::vector<PMTPeak>&;
162 auto GetCalSignals() -> CalSignals override;
163
164 void AddHit(Hit /*hit*/) override;
165 auto CreateSignal(const FQTPeak& peak) const -> Signal;
166 auto CreateCalSignal(const FQTPeak& peak) const -> CalSignal;
167
168 auto GetCal2HitPar() -> auto* { return neuland_hit_par_; }
169
170 private:
172 std::vector<PMTPeak> pmt_peaks_;
173 std::vector<FQTPeak> fqt_peaks_;
174 // static R3BNeulandHitPar* neuland_hit_par; // NOLINT
175 R3B::Neuland::Cal2HitPar* neuland_hit_par_ = nullptr;
176 Tamex::Params par_;
177
178 // private virtual functions
179 auto ConstructSignals() -> Signals override;
180 auto ConstructCalSignals() -> CalSignals override;
181 void AttachToPaddle(Digitizing::Paddle* paddle) override;
182
183 // private non-virtual functions
184 auto CheckPaddleIDInHitPar() const -> bool;
185 void SetHitModulePar(int PaddleId);
186 auto ToQdc(double) const -> double;
187 auto ToTdc(double) const -> double;
188 auto ToUnSatQdc(double) const -> double;
189 template <typename Peak>
190 void ApplyThreshold(/* inout */ std::vector<Peak>&);
191 auto ConstructFQTPeaks(std::vector<PMTPeak>& pmtPeaks) -> std::vector<FQTPeak>;
192 template <typename Peak>
193 static void PeakPileUp(/* inout */ std::vector<Peak>& peaks);
194
195 static void PeakPileUpWithDistance(/* inout */ std::vector<FQTPeak>& peaks, double distance);
196 static void PeakPileUpInTimeWindow(/* inout */ std::vector<FQTPeak>& peaks, double time_window);
197 void FQTPeakPileUp(/* inout */ std::vector<FQTPeak>& peaks);
198 auto CalculateTOT(const double& qdc) const -> double;
199 };
200
201} // namespace R3B::Digitizing::Neuland::Tamex
202#endif // R3BROOT_DIGITIZINGTAMEX_H
static auto GetDefaultRandomGen() -> TRandom3 &
std::vector< Signal > Signals
std::vector< CalSignal > CalSignals
void SetPileUpStrategy(PeakPileUpStrategy strategy)
auto GetParConstRef() const -> const Tamex::Params &
auto GetFQTPeaks() -> const std::vector< FQTPeak > &
auto GetPMTPeaks() -> const std::vector< PMTPeak > &
void AttachToPaddle(Digitizing::Paddle *paddle) override
Channel(ChannelSide side, PeakPileUpStrategy strategy=PeakPileUpStrategy::width)
auto CreateSignal(const FQTPeak &peak) const -> Signal
auto ConstructCalSignals() -> CalSignals override
Channel(ChannelSide, PeakPileUpStrategy strategy, TRandom3 &)
auto GetCalSignals() -> CalSignals override
auto CreateCalSignal(const FQTPeak &peak) const -> CalSignal
FQTPeak(const PMTPeak &pmtPeak, Channel *channel)
static auto QdcToWidth(double qdc, const Par &par) -> double
auto operator==(const FQTPeak &other) const -> bool
auto operator<(const FQTPeak &other) const -> bool
auto operator-(double time) const -> double
auto operator-(const FQTPeak &other) const -> double
auto operator>(const FQTPeak &other) const -> bool
static auto WidthToQdc(double width, const Par &par) -> double
auto operator+=(const PMTPeak &other) -> PMTPeak &
auto operator<(const PMTPeak &rhs) const -> bool
auto operator==(const PMTPeak &rhs) const -> bool
auto operator=(Params &&) -> Params &=delete
std::reference_wrapper< TRandom3 > fRnd
auto operator=(const Params &) -> Params &=default
Params(const Params &other)=default