24#include <range/v3/algorithm/find_if.hpp>
25#include <range/v3/view/take.hpp>
26#include <range/v3/view/transform.hpp>
62 void DepositLight(
int paddle_id,
double time,
double energy_dep,
double dist)
65 paddle.DepositLight({ time, energy_dep, dist });
82 void Init(
int initial_capacity = 1);
131 template <
typename Unary>
134 for (
const auto& paddle : ranges::views::take(
paddles_,
size_))
163 template <
typename Unary>
167 ranges::views::transform([](
auto& paddle) ->
const AbstractPaddle& {
return *paddle; }));
172 std::vector<std::unique_ptr<AbstractPaddle>>
189 template <
typename ChannelClass,
typename = std::enable_if_t<std::is_base_of_v<AbstractChannel, ChannelClass>>>
192 template <
typename... Args>
194 :
BuildChannel([=](
Side side) {
return std::make_unique<ChannelClass>(side, args...); })
200 template <
typename PaddleClass,
typename = std::enable_if_t<std::is_base_of_v<AbstractPaddle, PaddleClass>>>
203 template <
typename... Args>
205 :
BuildPaddle([=](int paddleID) {
return std::make_unique<PaddleClass>(paddleID, args...); })
211 template <
typename PaddleClass,
typename ChannelClass,
typename InitFunc = std::function<
void()>>
218 InitFunc initFunc = []() {})
252 template <
typename... Args>
253 [[nodiscard]]
auto CreateEngine(Args&&... args) -> std::unique_ptr<
decltype(
Engine{ std::forward<Args>(args)... })>
255 return std::make_unique<
decltype(Engine{ std::forward<Args>(args)... })>(std::forward<Args>(args)...);
UseChannel< ChannelClass > channelClass_
Channel class factory.
Engine(const UsePaddle< PaddleClass > &p_paddleClass, const UseChannel< ChannelClass > &p_channelClass, InitFunc initFunc=[]() {})
auto make_new_paddle() const -> std::unique_ptr< AbstractPaddle > override
void SetInit(const InitFunc &initFunc)
Initialize the underlying data.
void ExtraInit(int) override
void ExtraReset() override
UsePaddle< PaddleClass > paddleClass_
Paddle class factory.
void reserve_additional_paddles(int num)
Reserve memories for additional number of paddles.
EngineInterface()=default
Default constructor.
virtual void ExtraReset()
auto operator=(const EngineInterface &other) -> EngineInterface &=delete
Copy assignment operator.
auto DoAllPaddles(Unary fnt) const
Accessor operator for all paddles stored in the current event.
auto operator=(EngineInterface &&other) -> EngineInterface &=delete
Move assignment operator.
virtual void ExtraInit(int initial_capacity)
EngineInterface(EngineInterface &&other)=delete
Move constructor.
void Init(int initial_capacity=1)
Initialization of the engine class.
EngineInterface(const EngineInterface &other)=delete
Copy constructor.
void Reset()
Reset the engine for a new event.
void Construct()
Construct singals from the paddles and channels.
virtual auto make_new_paddle() const -> std::unique_ptr< AbstractPaddle >=0
auto GetTriggerTime() const -> double
Get the trigger time of the current event.
auto add_paddle(int paddle_id) -> AbstractPaddle &
void DoEachPaddle(Unary fnt) const
Accessor operator for each paddle stored in the current event.
void DepositLight(int paddle_id, double time, double energy_dep, double dist)
Takes in a light deposition and pass it to the paddle.
std::vector< std::unique_ptr< AbstractPaddle > > paddles_
main data. This vector should rarely grow in the event loop!
virtual ~EngineInterface()=default
virtual destructor
std::atomic< int > size_
size of bars with valid signals in the current event
auto get_capacity() const
The number of preallocated bar objects in the engine.
NeuLAND digitizing finder task.
auto CreateEngine(Args &&... args) -> std::unique_ptr< decltype(Engine{ std::forward< Args >(args)... })>
UseChannel(const Args &... args)
std::function< std::unique_ptr< Type >(Side)> BuildChannel
std::function< std::unique_ptr< Type >(int)> BuildPaddle
UsePaddle(const Args &... args)