R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BDigitizingChannel.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019 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#pragma once
15#include "R3BShared.h"
16#include <TRandom3.h>
17#include <fmt/core.h>
18#include <vector>
19
20namespace R3B::Digitizing
21{
22 class AbstractPaddle;
23 const double MAXTIME = 1e100;
24
25 // output data structure of channel
27 {
28 double qdc{};
29 double tdc{ MAXTIME };
30 double qdcUnSat{};
32 ChannelHit() = default;
33 };
34
35 // output data structure for Cal Data
37 {
38 double tot{};
39 double tle{};
41 ChannelCalSignal() = default;
42 };
43
44 // input data structure of channel
46 {
47 double time{};
48 double intensity{};
49
53 ChannelSignal() = default;
54
61 ChannelSignal(double time_val, double intensity_val)
62 : time{ time_val }
63 , intensity{ intensity_val }
64 {
65 }
66
74 auto operator<(const ChannelSignal& rhs) const -> bool { return (time < rhs.time); }
75 };
76
78 {
79 public:
80 using Hit = ChannelHit;
83 using Hits = std::vector<Hit>;
84 using CalSignals = std::vector<CalSignal>;
85
86 explicit AbstractChannel(R3B::Side side, bool has_cal_output = false);
87
88 // rule of 5
89 virtual ~AbstractChannel() = default;
90 AbstractChannel(const AbstractChannel& other) = delete;
91 auto operator=(const AbstractChannel& other) -> AbstractChannel& = delete;
92 AbstractChannel(AbstractChannel&& other) = default;
93 auto operator=(AbstractChannel&& other) -> AbstractChannel& = delete;
94
95 void Construct();
96
104 void Reset();
105
106 void AddSignal(const Signal& signal)
107 {
108 ++signal_size_;
109 add_signal(signal);
110 }
111 virtual auto HasFired() -> bool { return not hits_.empty(); }
112
113 void EnableCal(bool is_enabled = true) { has_cal_output_ = is_enabled; }
114
115 // Getters:
116 [[nodiscard]] auto GetSide() const -> R3B::Side { return side_; }
117 [[nodiscard]] auto GetPaddle() const -> AbstractPaddle* { return paddle_; }
118 [[nodiscard]] auto GetSignalSize() const -> int { return signal_size_; }
119
120 [[nodiscard]] auto GetCalSignals() const -> const CalSignals& { return cal_signals_; }
121 [[nodiscard]] auto GetHits() const -> const Hits& { return hits_; }
122 [[nodiscard]] auto GetTrigTime() const -> double { return trig_time_; }
123
124 void SetPaddle(AbstractPaddle* v_paddle) { paddle_ = v_paddle; }
125 void AttachToPaddle(AbstractPaddle* paddle) { paddle_ = paddle; };
126 static auto GetDefaultRandomGen() -> TRandom3&;
127
128 private:
129 bool has_cal_output_ = false;
131 double trig_time_ = 0.;
136
137 virtual void construct_hits(Hits& signals) = 0;
138 virtual void construct_cal_signals(CalSignals& cal_signals) const {};
139 virtual void extra_reset() {}
140 virtual void pre_construct() {}
141 virtual void add_signal(Signal signal) = 0;
142
143 void calculate_trig_time();
144 };
145} // namespace R3B::Digitizing
146
147template <>
148class fmt::formatter<R3B::Digitizing::ChannelHit>
149{
150 public:
151 static constexpr auto parse(format_parse_context& ctx) { return ctx.end(); }
152 template <typename FmtContent>
153 constexpr auto format(const R3B::Digitizing::ChannelHit& signal, FmtContent& ctn) const
154 {
155 return format_to(ctn.out(),
156 "{{qdc: {}, tdc: {}, adcUnSat: {}, side: {}}}",
157 signal.qdc,
158 signal.tdc,
159 signal.qdcUnSat,
160 signal.side);
161 }
162};
163
164template <>
165class fmt::formatter<R3B::Digitizing::ChannelCalSignal>
166{
167 public:
168 static constexpr auto parse(format_parse_context& ctx) { return ctx.end(); }
169 template <typename FmtContent>
170 constexpr auto format(const R3B::Digitizing::ChannelCalSignal& signal, FmtContent& ctn) const
171 {
172 return format_to(ctn.out(), "{{ToT: {}, Leading edge: {}, side: {}}}", signal.tot, signal.tle, signal.side);
173 }
174};
175
176template <>
177class fmt::formatter<R3B::Digitizing::ChannelSignal>
178{
179 public:
180 static constexpr auto parse(format_parse_context& ctx) { return ctx.end(); }
181 template <typename FmtContent>
182 constexpr auto format(const R3B::Digitizing::ChannelSignal& hit, FmtContent& ctn) const
183 {
184 return format_to(ctn.out(), "{{time: {} ns, light dep: {} MeV}}", hit.time, hit.intensity);
185 }
186};
void AddSignal(const Signal &signal)
int signal_size_
Size of the signal inputs.
void Reset()
Reset the data in the Channel for the new event.
AbstractPaddle * paddle_
pointer to the paddle who owns this channel
virtual void construct_hits(Hits &signals)=0
std::vector< CalSignal > CalSignals
static auto GetDefaultRandomGen() -> TRandom3 &
AbstractChannel(R3B::Side side, bool has_cal_output=false)
bool has_cal_output_
Flag of whether cal output is enabled.
virtual ~AbstractChannel()=default
auto GetHits() const -> const Hits &
void AttachToPaddle(AbstractPaddle *paddle)
AbstractChannel(const AbstractChannel &other)=delete
auto GetCalSignals() const -> const CalSignals &
virtual void add_signal(Signal signal)=0
R3B::Side side_
side of the channel
CalSignals cal_signals_
output cal signals from the channel
void EnableCal(bool is_enabled=true)
Hits hits_
output hits from the channel
auto GetPaddle() const -> AbstractPaddle *
auto operator=(const AbstractChannel &other) -> AbstractChannel &=delete
double trig_time_
trigger time of the channel
virtual void construct_cal_signals(CalSignals &cal_signals) const
AbstractChannel(AbstractChannel &&other)=default
void SetPaddle(AbstractPaddle *v_paddle)
auto operator=(AbstractChannel &&other) -> AbstractChannel &=delete
static constexpr auto parse(format_parse_context &ctx)
constexpr auto format(const R3B::Digitizing::ChannelCalSignal &signal, FmtContent &ctn) const
static constexpr auto parse(format_parse_context &ctx)
constexpr auto format(const R3B::Digitizing::ChannelHit &signal, FmtContent &ctn) const
constexpr auto format(const R3B::Digitizing::ChannelSignal &hit, FmtContent &ctn) const
static constexpr auto parse(format_parse_context &ctx)
ChannelSignal(double time_val, double intensity_val)
Constructor with two input values.
ChannelSignal()=default
Default constructor.
double time
Time value of the channel signal.
double intensity
Intensity of the channel signal.
auto operator<(const ChannelSignal &rhs) const -> bool
Less operator between two channel signals.