Project
Loading...
Searching...
No Matches
RawReaderFIT.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11//
12// file RawReaderFIT.h class for RAW data reading
13//
14// Artur.Furs
15// afurs@cern.ch
16//
17// Main purpuse is to decode FIT data blocks and push them to DigitBlockFIT for proccess
18#ifndef ALICEO2_FIT_RAWREADERFIT_H_
19#define ALICEO2_FIT_RAWREADERFIT_H_
20#include <iostream>
21#include <vector>
22#include <type_traits>
23#include <Rtypes.h>
26#include <Framework/Logger.h>
30#include <gsl/span>
31
32namespace o2
33{
34namespace fit
35{
36
37template <typename RawReaderType, bool useTrgInput = false>
38class RawReaderFIT : public RawReaderType
39{
40 public:
41 RawReaderFIT(o2::header::DataOrigin dataOrigin, bool dumpData) : mDataOrigin(dataOrigin), mDumpData(dumpData) {}
42 RawReaderFIT(const RawReaderFIT&) = default;
43 RawReaderFIT() = delete;
44 ~RawReaderFIT() = default;
45 typedef RawReaderType RawReader_t;
46 typedef typename RawReader_t::DigitBlockFIT_t DigitBlockFIT_t;
47 typedef typename RawReader_t::RawDataMetric_t RawDataMetric_t;
48 typedef typename DigitBlockFIT_t::LookupTable_t LookupTable_t;
49 typedef typename DigitBlockFIT_t::Digit_t Digit_t;
50 typedef typename DigitBlockFIT_t::SubDigit_t SubDigitTmp_t;
52 typedef typename Digit_t::DetTrigInput_t DetTrigInput_t;
53 typedef std::make_index_sequence<DigitBlockFIT_t::sNSubDigits> IndexesSubDigit;
54 typedef std::make_index_sequence<DigitBlockFIT_t::sNSingleSubDigits> IndexesSingleSubDigit;
55 typedef std::make_index_sequence<std::tuple_size_v<typename DigitBlockFIT_t::TupleVecDigitObjs_t>> IndexesAllDigits;
56 static constexpr bool sSubDigitExists = !std::is_same<SubDigitTmp_t, std::tuple<>>::value;
57 static constexpr bool sSingleSubDigitExists = !std::is_same<SingleSubDigitTmp_t, std::tuple<>>::value;
58 // Wrapping by std::tuple
59 typedef typename std::conditional<DigitBlockFIT_t::sNSubDigits != 1, SubDigitTmp_t, std::tuple<SubDigitTmp_t>>::type SubDigit_t;
60 typedef typename std::conditional<DigitBlockFIT_t::sNSingleSubDigits != 1, SingleSubDigitTmp_t, std::tuple<SingleSubDigitTmp_t>>::type SingleSubDigit_t;
61 static constexpr bool sUseTrgInput = useTrgInput;
63 std::vector<Digit_t> mVecDigit;
64 std::vector<DetTrigInput_t> mVecTrgInput;
65 std::vector<RawDataMetric> mVecRawDataMetric;
66 SubDigit_t mVecSubDigit; // tuple of vectors
70 void dumpRawDataMetrics() const
71 {
72 for (const auto& entry : mVecRawDataMetric) {
73 entry.print();
74 }
75 }
76 void reserveVecDPL(std::size_t nDigits, std::size_t nSubDigits)
77 {
78 mVecDigit.reserve(nDigits);
79 reserveSubDigits1<DigitBlockFIT_t>(nSubDigits);
80 }
81 template <typename T>
82 auto reserveSubDigits1(std::size_t nElements) -> std::enable_if_t<(T::sNSubDigits > 0)>
83 {
84 std::get<0>(mVecSubDigit).reserve(nElements);
85 }
86 template <typename T>
87 auto reserveSubDigits1(std::size_t nElements) -> std::enable_if_t<(T::sNSubDigits < 1)>
88 {
89 } // empty
90 void clear()
91 {
92 mVecDigit.clear();
93 if constexpr (sUseTrgInput) {
94 mVecTrgInput.clear();
95 }
96 if constexpr (sSubDigitExists) {
97 std::apply([](auto&... subDigit) {
98 ((subDigit.clear()), ...);
99 },
101 }
102 if constexpr (sSingleSubDigitExists) {
103 std::apply([](auto&... singleSubDigit) {
104 ((singleSubDigit.clear()), ...);
105 },
107 }
108 mVecRawDataMetric.clear();
109 }
110 template <std::size_t... IsubDigits, std::size_t... IsingleSubDigits>
111 auto callGetDigit(std::index_sequence<IsubDigits...>, std::index_sequence<IsingleSubDigits...>)
112 {
113 if constexpr (sUseTrgInput) {
114 RawReader_t::getDigits(mVecDigit, std::get<IsubDigits>(mVecSubDigit)..., std::get<IsingleSubDigits>(mVecSingleSubDigit)..., mVecTrgInput);
115 } else {
116 RawReader_t::getDigits(mVecDigit, std::get<IsubDigits>(mVecSubDigit)..., std::get<IsingleSubDigits>(mVecSingleSubDigit)...);
117 }
118 }
119 template <std::size_t... IDigits>
120 auto callGetDigitDirectly(o2::framework::ProcessingContext& pc, std::index_sequence<IDigits...>)
121 {
122 if constexpr (sUseTrgInput) {
123 RawReader_t::getDigits(getRefVec<std::tuple_element_t<IDigits, typename DigitBlockFIT_t::TupleVecDigitObjs_t>>(pc)..., getRefVec<typename std::vector<DetTrigInput_t>>(pc));
124 } else {
125 RawReader_t::getDigits(getRefVec<std::tuple_element_t<IDigits, typename DigitBlockFIT_t::TupleVecDigitObjs_t>>(pc)...);
126 }
127 }
128 template <std::size_t... IsubDigits, std::size_t... IsingleSubDigits>
129 auto callPrint(std::index_sequence<IsubDigits...>, std::index_sequence<IsingleSubDigits...>) const
130 {
131 DigitBlockFIT_t::print(mVecDigit, std::get<IsubDigits>(mVecSubDigit)..., std::get<IsingleSubDigits>(mVecSingleSubDigit)...);
132 }
138 {
140 LOG(debug) << "Number of Digits: " << mVecDigit.size();
141 if (mDumpData) {
143 }
144 RawReader_t::getMetrics(mVecRawDataMetric);
145 }
146 void configureOutputSpec(std::vector<o2::framework::OutputSpec>& outputSpec) const
147 {
148 outputSpec.emplace_back(mDataOrigin, Digit_t::sChannelNameDPL, 0, o2::framework::Lifetime::Timeframe);
149 if constexpr (sSubDigitExists) {
150 std::apply([&](const auto&... subDigit) {
151 ((outputSpec.emplace_back(mDataOrigin, (std::decay<decltype(subDigit)>::type::value_type::sChannelNameDPL), 0, o2::framework::Lifetime::Timeframe)), ...);
152 },
154 }
155 if constexpr (sSingleSubDigitExists) {
156 std::apply([&](const auto&... singleSubDigit) {
157 ((outputSpec.emplace_back(mDataOrigin, (std::decay<decltype(singleSubDigit)>::type::value_type::sChannelNameDPL), 0, o2::framework::Lifetime::Timeframe)), ...);
158 },
160 }
161 if constexpr (sUseTrgInput) {
162 outputSpec.emplace_back(mDataOrigin, DetTrigInput_t::sChannelNameDPL, 0, o2::framework::Lifetime::Timeframe);
163 }
164 outputSpec.emplace_back(mDataOrigin, "RawDataMetric", 0, o2::framework::Lifetime::Timeframe);
165 }
167 {
168 pc.outputs().snapshot(o2::framework::Output{mDataOrigin, Digit_t::sChannelNameDPL, 0}, mVecDigit);
169 if constexpr (sSubDigitExists) {
170 std::apply([&](const auto&... subDigit) {
171 ((pc.outputs().snapshot(o2::framework::Output{mDataOrigin, (std::decay<decltype(subDigit)>::type::value_type::sChannelNameDPL), 0}, subDigit)), ...);
172 },
174 }
175 if constexpr (sSingleSubDigitExists) {
176 std::apply([&](const auto&... singleSubDigit) {
177 ((pc.outputs().snapshot(o2::framework::Output{mDataOrigin, (std::decay<decltype(singleSubDigit)>::type::value_type::sChannelNameDPL), 0}, singleSubDigit)), ...);
178 },
180 }
181 if constexpr (sUseTrgInput) {
182 pc.outputs().snapshot(o2::framework::Output{mDataOrigin, DetTrigInput_t::sChannelNameDPL, 0}, mVecTrgInput);
183 }
185 }
186 template <typename VecDigitType>
188 {
189 auto& refVec = pc.outputs().make<VecDigitType>(o2::framework::Output{mDataOrigin, VecDigitType::value_type::sChannelNameDPL, 0});
190 return refVec;
191 }
193 {
195 }
197 {
198 if (mEnableEmptyTFprotection && mVecDigit.size() == 0) {
199 std::get<0>(mVecSubDigit).emplace_back();
200 }
201 }
202};
203
204} // namespace fit
205} // namespace o2
206
207#endif
std::ostringstream debug
RawReader_t::DigitBlockFIT_t DigitBlockFIT_t
std::make_index_sequence< std::tuple_size_v< typename DigitBlockFIT_t::TupleVecDigitObjs_t > > IndexesAllDigits
void dumpRawDataMetrics() const
void accumulateDigits(o2::framework::ProcessingContext &pc)
RawReaderFIT(o2::header::DataOrigin dataOrigin, bool dumpData)
SingleSubDigit_t mVecSingleSubDigit
DigitBlockHelper::GetSubDigitField< typenameDigitBlockFIT_t::VecSingleSubDigit_t >::vector_type SingleSubDigitTmp_t
std::conditional< DigitBlockFIT_t::sNSingleSubDigits!=1, SingleSubDigitTmp_t, std::tuple< SingleSubDigitTmp_t > >::type SingleSubDigit_t
DigitBlockFIT_t::LookupTable_t LookupTable_t
auto callGetDigit(std::index_sequence< IsubDigits... >, std::index_sequence< IsingleSubDigits... >)
static constexpr bool sSingleSubDigitExists
void makeSnapshot(o2::framework::ProcessingContext &pc) const
auto & getRefVec(o2::framework::ProcessingContext &pc)
RawReaderType RawReader_t
std::make_index_sequence< DigitBlockFIT_t::sNSubDigits > IndexesSubDigit
std::vector< DetTrigInput_t > mVecTrgInput
auto callGetDigitDirectly(o2::framework::ProcessingContext &pc, std::index_sequence< IDigits... >)
Digit_t::DetTrigInput_t DetTrigInput_t
std::vector< Digit_t > mVecDigit
std::make_index_sequence< DigitBlockFIT_t::sNSingleSubDigits > IndexesSingleSubDigit
auto callPrint(std::index_sequence< IsubDigits... >, std::index_sequence< IsingleSubDigits... >) const
DigitBlockFIT_t::SubDigit_t SubDigitTmp_t
static constexpr bool sSubDigitExists
auto reserveSubDigits1(std::size_t nElements) -> std::enable_if_t<(T::sNSubDigits< 1)>
std::conditional< DigitBlockFIT_t::sNSubDigits!=1, SubDigitTmp_t, std::tuple< SubDigitTmp_t > >::type SubDigit_t
RawReaderFIT(const RawReaderFIT &)=default
auto reserveSubDigits1(std::size_t nElements) -> std::enable_if_t<(T::sNSubDigits > 0)>
static constexpr bool sUseTrgInput
DigitBlockFIT_t::Digit_t Digit_t
void configureOutputSpec(std::vector< o2::framework::OutputSpec > &outputSpec) const
o2::header::DataOrigin mDataOrigin
std::vector< RawDataMetric > mVecRawDataMetric
RawReader_t::RawDataMetric_t RawDataMetric_t
void reserveVecDPL(std::size_t nDigits, std::size_t nSubDigits)
void snapshot(const Output &spec, T const &object)
decltype(auto) make(const Output &spec, Args... args)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
GLuint entry
Definition glcorearb.h:5735
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
TFitResultPtr fit(const size_t nBins, const T *arr, const T xMin, const T xMax, TF1 &func, std::string_view option="")
Definition fit.h:59
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"