Project
Loading...
Searching...
No Matches
RawDecoderSpec.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#ifndef ALICEO2_FOCAL_RAWDECODERSPEC_H
12#define ALICEO2_FOCAL_RAWDECODERSPEC_H
13
14#include <array>
15#include <map>
16#include <unordered_map>
17#include <vector>
18#include <gsl/span>
20#include "Framework/Task.h"
29
30namespace o2::focal
31{
32
33class PixelChip;
34
35namespace reco_workflow
36{
37
39{
40 public:
41 struct HBFData {
42 std::vector<std::array<PadLayerEvent, constants::PADS_NLAYERS>> mPadEvents;
43 std::vector<std::array<PixelLayerEvent, constants::PIXELS_NLAYERS>> mPixelEvent;
44 std::vector<o2::InteractionRecord> mPixelTriggers;
45 std::vector<std::vector<int>> mFEEs;
46 };
47 RawDecoderSpec() = default;
48 RawDecoderSpec(uint32_t outputSubspec, bool usePadData, bool usePixelData, bool debug) : mDebugMode(debug), mUsePadData(usePadData), mUsePixelData(usePixelData), mOutputSubspec(outputSubspec) {}
49 ~RawDecoderSpec() override = default;
50
51 void init(framework::InitContext& ctx) final;
52
53 void run(framework::ProcessingContext& ctx) final;
54
56
57 private:
58 void sendOutput(framework::ProcessingContext& ctx);
59 void resetContainers();
60 int decodePadData(const gsl::span<const char> padWords, o2::InteractionRecord& hbIR);
61 void decodePadEvent(const gsl::span<const char> padWords, o2::InteractionRecord& hbIR);
62 int decodePixelData(const gsl::span<const char> pixelWords, o2::InteractionRecord& hbIR, int fecID);
63 std::array<PadLayerEvent, constants::PADS_NLAYERS> createPadLayerEvent(const o2::focal::PadData& data) const;
64 void fillChipToLayer(PixelLayerEvent& pixellayer, const PixelChip& chipData, int feeID);
65 void fillEventPixeHitContainer(std::vector<PixelHit>& eventHits, std::vector<PixelChipRecord>& eventChips, const PixelLayerEvent& pixelLayer, int layerIndex);
66 int filterIncompletePixelsEventsHBF(HBFData& data, const std::vector<int>& expectFEEs);
67 void buildEvents();
68 bool consistencyCheckPixelFEE(const std::unordered_map<int, int>& counters) const;
69 int maxCounter(const std::unordered_map<int, int>& counters) const;
70 void printCounters(const std::unordered_map<int, int>& counters) const;
71 void printEvents(const std::unordered_map<int, std::vector<int>>& counters) const;
72 bool checkEventsHBFConsistency(const std::unordered_map<int, std::vector<int>>& counters) const;
73 void fillPixelEventHBFCount(const std::unordered_map<int, std::vector<int>>& counters);
74
75 bool mDebugMode = false;
76 bool mDisplayInconsistent = false;
77 bool mUsePadData = true;
78 bool mUsePixelData = true;
79 bool mFilterIncomplete = false;
80 bool mTimeframeHasPadData = false;
81 bool mTimeframeHasPixelData = false;
82 uint32_t mOutputSubspec = 0;
83 PadDecoder mPadDecoder;
84 PixelDecoder mPixelDecoder;
85 std::unique_ptr<PixelMapper> mPixelMapping;
86 std::map<o2::InteractionRecord, HBFData> mHBFs;
87 std::vector<TriggerRecord> mOutputTriggerRecords;
88 std::vector<PixelHit> mOutputPixelHits;
89 std::vector<PixelChipRecord> mOutputPixelChips;
90 std::vector<PadLayerEvent> mOutputPadLayers;
91
92 // Some counters
93 int mNumTimeframes = 0;
94 int mNumHBFPads = 0;
95 int mNumHBFPixels = 0;
96 int mNumEventsPads = 0;
97 int mNumEventsPixels = 0;
98 int mNumInconsistencyPixelHBF = 0;
99 int mNumInconsistencyPixelEvent = 0;
100 int mNumInconsistencyPixelEventHBF = 0;
101 std::map<int, int> mNumEventsHBFPads;
102 std::map<int, int> mNumEventsHBFPixels;
103 std::map<int, int> mNumHBFperTFPads;
104 std::map<int, int> mNumHBFperTFPixels;
105};
106
107framework::DataProcessorSpec getRawDecoderSpec(bool askDISTSTF, uint32_t outputSubspec, bool usePadData, bool usePixelData, bool debugMode);
108
109} // namespace reco_workflow
110
111} // namespace o2::focal
112
113#endif // ALICEO2_FOCAL_RAWDECODERSPEC_H
std::ostringstream debug
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(framework::InitContext &ctx) final
RawDecoderSpec(uint32_t outputSubspec, bool usePadData, bool usePixelData, bool debug)
void run(framework::ProcessingContext &ctx) final
GLint GLint GLsizei GLuint * counters
Definition glcorearb.h:3985
GLboolean * data
Definition glcorearb.h:298
framework::DataProcessorSpec getRawDecoderSpec(bool askDISTSTF, uint32_t outputSubspec, bool usePadData, bool usePixelData, bool debugMode)
std::vector< std::array< PadLayerEvent, constants::PADS_NLAYERS > > mPadEvents
std::vector< std::vector< int > > mFEEs
std::vector< o2::InteractionRecord > mPixelTriggers
std::vector< std::array< PixelLayerEvent, constants::PIXELS_NLAYERS > > mPixelEvent