R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BDigitizingPaddle.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
17#include "R3BShared.h"
18#include <R3BLogger.h>
19#include <RtypesCore.h>
20#include <functional>
21#include <memory>
22#include <vector>
23
24namespace R3B::Digitizing
25{
26
27 template <typename Type>
28 struct LRPair
29 {
30 Type left{};
31 Type right{};
32 LRPair(Type p_left, Type p_right)
33 : left(p_left)
34 , right(p_right)
35 {
36 }
37 LRPair() = default;
38 };
39
40 struct PaddleHit
41 {
42 double energy{};
43 double time{};
44 double position{};
49
50 PaddleHit() = default;
51
53 : left_channel_cal{ p_signals.left }
54 , right_channel_cal{ p_signals.right }
55 {
56 }
57
59 : left_channel_hit{ p_signals.left }
60 , right_channel_hit{ p_signals.right }
61 {
62 }
63 };
64
66 {
67 double time; //<! Time of the energy depostion [ns]
68 double energy_dep; //<! Energy depostion [MeV]
69 double distance_to_center; //<! Distance to the center point of the paddle [cm]
70 };
71
73 {
74 public:
75 template <typename Type>
77 using Hit = PaddleHit;
79 using Hits = std::vector<Hit>;
81 using SignalCouplingStrategy = std::function<std::vector<ChannelSignalPair>(const AbstractPaddle&,
83 const AbstractChannel::Hits&)>;
84
85 explicit AbstractPaddle(int paddleID, SignalCouplingStrategy strategy = SignalCouplingByTime);
86 [[nodiscard]] auto HasFired() const -> bool;
87 [[nodiscard]] auto HasHalfFired() const -> bool;
88 void Construct();
89 void Reset();
90
91 // rule of 5
92 virtual ~AbstractPaddle() = default;
93 AbstractPaddle(const AbstractPaddle& other) = delete;
94 auto operator=(const AbstractPaddle& other) -> AbstractPaddle& = delete;
95 AbstractPaddle(AbstractPaddle&& other) = default;
96 auto operator=(AbstractPaddle&& other) -> AbstractPaddle& = delete;
97
98 void DepositLight(const Signal& signal);
99
100 void SetChannel(std::unique_ptr<AbstractChannel> channel);
101
103
104 // Getters:
105 [[nodiscard]] auto GetPaddleID() const -> int { return paddle_id_; }
106 [[nodiscard]] auto GetHits() const -> const std::vector<Hit>& { return signal_hits_; }
107 [[nodiscard]] auto GetSignalCouplingStragtegy() const -> const SignalCouplingStrategy&
108 {
110 }
111 [[nodiscard]] auto GetLeftChannel() const -> const AbstractChannel* { return left_channel_.get(); }
112 [[nodiscard]] auto GetLeftChannelRef() const -> auto& { return *left_channel_; }
113 [[nodiscard]] auto GetChannel(R3B::Side side) const -> const Digitizing::AbstractChannel&;
114 [[nodiscard]] auto GetRightChannelRef() const -> auto& { return *right_channel_; }
115 [[nodiscard]] auto GetRightChannel() const -> const AbstractChannel* { return right_channel_.get(); }
116 [[nodiscard]] auto GetTrigTime() const -> double;
117
118 // Setters:
119 void SetPaddleID(int paddle_id) { paddle_id_ = paddle_id; }
120
121 [[nodiscard]] virtual auto match_hits(const AbstractChannel::Hit& /*firstSignal*/,
122 const AbstractChannel::Hit& /*secondSignal*/) const -> float
123 {
124 return 0.;
125 }
126
127 private:
130 std::unique_ptr<AbstractChannel> left_channel_;
131 std::unique_ptr<AbstractChannel> right_channel_;
133
134 // virtual private functions
135 virtual void extra_reset() {}
136 virtual void pre_construct() {}
137 [[nodiscard]] virtual auto compute_time(const AbstractChannel::Hit& firstSignal,
138 const AbstractChannel::Hit& secondSignal) const -> double = 0;
139 [[nodiscard]] virtual auto compute_energy(const AbstractChannel::Hit& firstSignal,
140 const AbstractChannel::Hit& secondSignal) const -> double = 0;
141 [[nodiscard]] virtual auto compute_position(const AbstractChannel::Hit& rightSignal,
142 const AbstractChannel::Hit& leftSignal) const -> double = 0;
143 [[nodiscard]] virtual auto compute_channel_signals(const Signal& hit) const
145
146 // non-virtual private functions
147 void construct_paddle_signals(Hits& paddle_signals,
148 const AbstractChannel::Hits& firstSignals,
149 const AbstractChannel::Hits& secondSignals) const;
150
151 public:
152 static auto SignalCouplingByTime(const AbstractPaddle& self,
153 const AbstractChannel::Hits& firstSignals,
154 const AbstractChannel::Hits& secondSignals) -> std::vector<ChannelSignalPair>;
155 };
156} // namespace R3B::Digitizing
virtual auto compute_energy(const AbstractChannel::Hit &firstSignal, const AbstractChannel::Hit &secondSignal) const -> double=0
virtual auto compute_position(const AbstractChannel::Hit &rightSignal, const AbstractChannel::Hit &leftSignal) const -> double=0
virtual auto compute_channel_signals(const Signal &hit) const -> Pair< AbstractChannel::Signal >=0
std::unique_ptr< AbstractChannel > left_channel_
auto GetRightChannel() const -> const AbstractChannel *
virtual auto match_hits(const AbstractChannel::Hit &, const AbstractChannel::Hit &) const -> float
auto GetLeftChannel() const -> const AbstractChannel *
auto GetRightChannelRef() const -> auto &
void construct_paddle_signals(Hits &paddle_signals, const AbstractChannel::Hits &firstSignals, const AbstractChannel::Hits &secondSignals) const
std::unique_ptr< AbstractChannel > right_channel_
std::function< std::vector< ChannelSignalPair >(const AbstractPaddle &, const AbstractChannel::Hits &, const AbstractChannel::Hits &)> SignalCouplingStrategy
void DepositLight(const Signal &signal)
virtual auto compute_time(const AbstractChannel::Hit &firstSignal, const AbstractChannel::Hit &secondSignal) const -> double=0
Pair< std::reference_wrapper< const AbstractChannel::Hit > > ChannelSignalPair
void SetChannel(std::unique_ptr< AbstractChannel > channel)
auto GetSignalCouplingStragtegy() const -> const SignalCouplingStrategy &
static auto SignalCouplingByTime(const AbstractPaddle &self, const AbstractChannel::Hits &firstSignals, const AbstractChannel::Hits &secondSignals) -> std::vector< ChannelSignalPair >
auto GetLeftChannelRef() const -> auto &
auto GetChannel(R3B::Side side) const -> const Digitizing::AbstractChannel &
void SetSignalCouplingStrategy(const SignalCouplingStrategy &strategy)
auto GetHits() const -> const std::vector< Hit > &
SignalCouplingStrategy signal_coupling_strategy_
AbstractPaddle(int paddleID, SignalCouplingStrategy strategy=SignalCouplingByTime)
LRPair(Type p_left, Type p_right)
const AbstractChannel::CalSignal * right_channel_cal
Reference to the right channel cal.
const AbstractChannel::Hit * right_channel_hit
Reference to the right channel hit.
const AbstractChannel::Hit * left_channel_hit
Reference to the left channel hit.
PaddleHit(LRPair< const AbstractChannel::Hit * > p_signals)
double energy
The energy of the paddle hit [MeV].
const AbstractChannel::CalSignal * left_channel_cal
Reference to the left channel cal.
PaddleHit(LRPair< const AbstractChannel::CalSignal * > p_signals)
double position
The distance to the center point of the paddle [cm].
double time
The time of the paddle hit [ns].