CbmRoot
Loading...
Searching...
No Matches
EventBuilder.h
Go to the documentation of this file.
1/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
5#ifndef CBM_ALGO_EVENTBUILDER_H
6#define CBM_ALGO_EVENTBUILDER_H 1
7
8#include "CbmDefs.h"
9#include "DigiData.h"
10#include "DigiEventSelector.h"
11#include "EventBuilderConfig.h"
12
13#include <algorithm>
14#include <gsl/span>
15#include <map>
16#include <optional>
17#include <string>
18#include <vector>
19
20#include <xpu/host.h>
21
22namespace cbm::algo::evbuild
23{
24
31 size_t nDigisInEvents = 0;
32 size_t nDigis = 0;
33 };
34
35
55
56
73
74 public:
75 typedef std::pair<std::vector<DigiEvent>, EventBuilderMonitorData> resultType;
76
78 EventBuilder(const EventBuilderConfig& config) : fConfig(config) {}
79
80
82 virtual ~EventBuilder(){};
83
84
91 resultType operator()(const DigiData& ts, const std::vector<double> triggers,
92 std::optional<DigiEventSelector> selector) const;
93
94
96 std::string ToString() const;
97
98
99 private: // methods
106 DigiEvent BuildEvent(const DigiData& ts, EventBuilderMonitorData& monitor, double trigger) const;
107
108
126 template<typename Vector>
127 static Vector CopyRange(const Vector& source, double tMin, double tMax)
128 {
129 using Data = typename Vector::value_type;
130 auto comp1 = [](const Data& obj, double value) { return obj.GetTime() < value; };
131 auto comp2 = [](double value, const Data& obj) { return value < obj.GetTime(); };
132 auto lower = std::lower_bound(source.begin(), source.end(), tMin, comp1);
133 auto upper = std::upper_bound(lower, source.end(), tMax, comp2);
134 return Vector(lower, upper);
135 }
136
137
138 private: // data members
140 };
141
142} // namespace cbm::algo::evbuild
143
144#endif /* CBM_ALGO_EVENTBUILDER_H */
Configuration of the EventBuilder class.
Constructs CbmDigiEvents out of CbmDigiTimeslices.
DigiEvent BuildEvent(const DigiData &ts, EventBuilderMonitorData &monitor, double trigger) const
Build a single event from a trigger time.
virtual ~EventBuilder()
Destructor.
std::pair< std::vector< DigiEvent >, EventBuilderMonitorData > resultType
EventBuilderConfig fConfig
Configuration / parameters.
resultType operator()(const DigiData &ts, const std::vector< double > triggers, std::optional< DigiEventSelector > selector) const
Execution.
static Vector CopyRange(const Vector &source, double tMin, double tMax)
Copy data objects in a given time interval from the source to the target vector.
EventBuilder(const EventBuilderConfig &config)
Constructor.
std::string ToString() const
Info to string.
Collection of digis from all detector systems.
Definition DigiData.h:31
Event data with event number and trigger time.
Definition DigiData.h:79
Monitoring data for event building for one detector.
size_t nDigisInEvents
Number of digis collected into events.
size_t nDigis
Full number of digis in input source.
Monitoring data for event building.
size_t numTriggers
Number of input triggers.
EventBuilderDetectorMonitorData much
Monitoring data for MUCH.
EventBuilderDetectorMonitorData rich
Monitoring data for RICH.
size_t numEvents
Number of built and selected events.
EventBuilderDetectorMonitorData sts
Monitoring data for STS.
EventBuilderDetectorMonitorData tof
Monitoring data for TOF.
EventBuilderDetectorMonitorData bmon
Monitoring data for Bmon.
EventBuilderDetectorMonitorData trd2d
Monitoring data for TRD2D.
xpu::timings time
Time for event building.
EventBuilderDetectorMonitorData fsd
Monitoring data for FSD.
EventBuilderDetectorMonitorData trd
Monitoring data for TRD.
EventBuilderDetectorMonitorData psd
Monitoring data for PSD.