Project
Loading...
Searching...
No Matches
RawReaderBaseFIT.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 RawReaderFITBase.h Base 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// Base class only provides static linkID-moduleType conformity
19
20#ifndef ALICEO2_FIT_RAWREADERBASEFIT_H_
21#define ALICEO2_FIT_RAWREADERBASEFIT_H_
22#include <iostream>
23#include <vector>
24#include <Rtypes.h>
29#include <Framework/Logger.h>
30
31#include <gsl/span>
32
33namespace o2
34{
35namespace fit
36{
37
38// Common raw reader for FIT
39template <typename DigitBlockFITtype, typename DataBlockPMtype, typename DataBlockTCMtype>
40class RawReaderBaseFIT : public RawReaderBase<DigitBlockFITtype, DataBlockPMtype, DataBlockTCMtype>
41{
42 public:
43 typedef DigitBlockFITtype DigitBlockFIT_t;
44 typedef typename DigitBlockFIT_t::LookupTable_t LookupTable_t;
45
46 typedef std::conditional_t<DataBlockPMtype::sIsPadded, typename DataBlockPMtype::DataBlockInvertedPadding_t, DataBlockPMtype> DataBlockPM_t;
47 typedef std::conditional_t<DataBlockTCMtype::sIsPadded, typename DataBlockTCMtype::DataBlockInvertedPadding_t, DataBlockTCMtype> DataBlockTCM_t;
48
49 typedef std::conditional_t<DataBlockPMtype::sIsPadded, DataBlockPMtype, typename DataBlockPMtype::DataBlockInvertedPadding_t> DataBlockPMpadded_t;
50 typedef std::conditional_t<DataBlockTCMtype::sIsPadded, DataBlockTCMtype, typename DataBlockTCMtype::DataBlockInvertedPadding_t> DataBlockTCMpadded_t;
51
53 RawReaderBaseFIT() = default;
54 ~RawReaderBaseFIT() = default;
55 void reserve(std::size_t nElements, std::size_t nElemMap = 0)
56 {
57 auto& vecDataBlocksPM = RawReaderBase_t::template getVecDataBlocks<DataBlockPM_t>();
58 vecDataBlocksPM.reserve(nElements);
59 auto& vecDataBlocksTCM = RawReaderBase_t::template getVecDataBlocks<DataBlockTCM_t>();
60 vecDataBlocksTCM.reserve(nElements);
61 // one need to reserve memory for map
62 for (std::size_t iElem = 0; iElem < nElemMap; iElem++) {
64 }
66 }
67 // deserialize payload to raw data blocks and proccesss them to digits
68 template <typename... T>
69 void process(bool isPadded, gsl::span<const uint8_t> payload, uint16_t feeID, T&&... feeParameters)
70 {
71 if (LookupTable_t::Instance().isTCM(std::forward<T>(feeParameters)...)) {
72 // TCM data proccessing
73 if (isPadded) {
74 RawReaderBase_t::template processBinaryData<DataBlockTCMpadded_t>(payload, feeID, std::forward<T>(feeParameters)...);
75 } else {
76 RawReaderBase_t::template processBinaryData<DataBlockTCM_t>(payload, feeID, std::forward<T>(feeParameters)...);
77 }
78 } else if (LookupTable_t::Instance().isPM(std::forward<T>(feeParameters)...)) {
79 // PM data proccessing
80 if (isPadded) {
81 RawReaderBase_t::template processBinaryData<DataBlockPMpadded_t>(payload, feeID, std::forward<T>(feeParameters)...);
82 } else {
83 RawReaderBase_t::template processBinaryData<DataBlockPM_t>(payload, feeID, std::forward<T>(feeParameters)...);
84 }
85 } else {
86 auto& metric = RawReaderBase_t::addMetric(feeID, std::forward<T>(feeParameters)..., false);
88 LOG(error) << "Unregistered in ChannelMap link!";
89 metric.print();
90 }
91 }
92};
93} // namespace fit
94} // namespace o2
95
96#endif
Definition of the RAW Data Header.
std::conditional_t< DataBlockPMtype::sIsPadded, DataBlockPMtype, typename DataBlockPMtype::DataBlockInvertedPadding_t > DataBlockPMpadded_t
std::conditional_t< DataBlockTCMtype::sIsPadded, DataBlockTCMtype, typename DataBlockTCMtype::DataBlockInvertedPadding_t > DataBlockTCMpadded_t
void reserve(std::size_t nElements, std::size_t nElemMap=0)
std::conditional_t< DataBlockTCMtype::sIsPadded, typename DataBlockTCMtype::DataBlockInvertedPadding_t, DataBlockTCMtype > DataBlockTCM_t
DigitBlockFIT_t::LookupTable_t LookupTable_t
DigitBlockFITtype DigitBlockFIT_t
void process(bool isPadded, gsl::span< const uint8_t > payload, uint16_t feeID, T &&... feeParameters)
std::conditional_t< DataBlockPMtype::sIsPadded, typename DataBlockPMtype::DataBlockInvertedPadding_t, DataBlockPMtype > DataBlockPM_t
RawReaderBase< DigitBlockFITtype, DataBlockPMtype, DataBlockTCMtype > RawReaderBase_t
RawDataMetric & addMetric(uint16_t feeID, uint8_t linkID, uint8_t epID, bool isRegisteredFEE=true)
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"