Project
Loading...
Searching...
No Matches
WindowFiller.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#ifndef ALICEO2_TOF_WINDOWFILLER_H_
13#define ALICEO2_TOF_WINDOWFILLER_H_
14
15#include "TOFBase/Geo.h"
16#include "TOFBase/Digit.h"
17#include "TOFBase/Strip.h"
20#include "TOFBase/Utils.h"
21
22namespace o2
23{
24namespace tof
25{
26
28{
29 public:
30 struct PatternData {
31 uint32_t pattern;
32 int icrate;
33
34 unsigned long row;
35
36 PatternData(uint32_t patt = 0, int icr = 0, unsigned long rw = 0) : pattern(patt), icrate(icr), row(rw) {}
37 };
38
40 int32_t bc[Geo::kNCrate] = {-1};
41 uint32_t eventCounter[Geo::kNCrate] = {0};
42 CrateHeaderData() { memset(bc, -1, Geo::kNCrate * 4); }
43 };
44
46 ~WindowFiller() = default;
47
48 void initObj();
49
50 void reset();
51
58
59 std::vector<Digit>* getDigitPerTimeFrame() { return &mDigitsPerTimeFrame; }
60 std::vector<ReadoutWindowData>* getReadoutWindowData() { return &mReadoutWindowData; }
61 std::vector<ReadoutWindowData>* getReadoutWindowDataFiltered() { return &mReadoutWindowDataFiltered; }
63
64 template <typename VROF, typename VPAT>
65 void setReadoutWindowData(const VROF& row, const VPAT& pattern)
66 {
67 // copy rowdata info needed to call fillDiagonsticFrequency when reading frm file (digits/ctf). Not needed when digitizing or decoding
68 mPatterns.clear();
69 mReadoutWindowData.clear();
70 for (const auto crow : row) {
71 mReadoutWindowData.push_back(crow);
72 }
73
74 for (const auto dia : pattern) {
75 mPatterns.push_back(dia);
76 }
77 }
78
79 void setNOrbitInTF(uint32_t norb) { o2::tof::Utils::setNOrbitInTF(norb); }
80 void fillOutputContainer(std::vector<Digit>& digits);
81 void flushOutputContainer(std::vector<Digit>& digits); // flush all residual buffered data
82 void setContinuous(bool value = true) { mContinuous = value; }
83 bool isContinuous() const { return mContinuous; }
84
86
88
90
92
94 {
96 }
97
98 std::vector<uint8_t>& getPatterns() { return mPatterns; }
99 void addPattern(const uint32_t val, int icrate, int orbit, int bc) { mCratePatterns.emplace_back(val, icrate, orbit * 3 + (bc + 100) / Geo::BC_IN_WINDOW); }
100 void addCrateHeaderData(unsigned long orbit, int crate, int32_t bc, uint32_t eventCounter);
102
103 void addCount(int channel) { mChannelCounts[channel]++; }
104
105 protected:
106 // info TOF timewindow
107 uint64_t mReadoutWindowCurrent = 0; // keeps track of current readout window
108 InteractionRecord mFirstIR{0, 0}; // reference IR (1st IR of the timeframe)
110
111 bool mContinuous = true;
112 bool mFutureToBeSorted = false;
113
114 // only needed from Decoder
115 int mMaskNoiseRate = -11;
116 int mChannelCounts[o2::tof::Geo::NCHANNELS]; // count of channel hits in the current TF (if MaskNoiseRate enabled)
117
118 // digit info
119 //std::vector<Digit>* mDigits;
120
121 static const int MAXWINDOWS = 2; // how many readout windows we can buffer
122
123 std::vector<Digit> mDigitsPerTimeFrame;
124 std::vector<ReadoutWindowData> mReadoutWindowData;
125 std::vector<ReadoutWindowData> mReadoutWindowDataFiltered;
126
128
129 // array of strips to store the digits per strip (one for the current readout window, one for the next one)
130 std::vector<Strip> mStrips[MAXWINDOWS];
131 std::vector<Strip>* mStripsCurrent = &(mStrips[0]);
132 std::vector<Strip>* mStripsNext[MAXWINDOWS - 1];
133
134 // arrays with digit and MCLabels out of the current readout windows (stored to fill future readout window)
135 std::vector<Digit> mFutureDigits;
136
137 std::vector<uint8_t> mPatterns;
138 std::vector<uint64_t> mErrors;
139
141
142 std::vector<PatternData> mCratePatterns;
143 std::vector<CrateHeaderData> mCrateHeaderData;
144
146
147 void fillDigitsInStrip(std::vector<Strip>* strips, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0);
148 // void fillDigitsInStrip(std::vector<Strip>* strips, o2::dataformats::MCTruthContainer<o2::tof::MCLabel>* mcTruthContainer, int channel, int tdc, int tot, int nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID);
149
152
153 void insertDigitInFuture(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label = 0, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0)
154 {
155 mFutureDigits.emplace_back(channel, tdc, tot, bc, label, triggerorbit, triggerbunch);
156 mFutureToBeSorted = true;
157 }
158
159 bool isMergable(Digit digit1, Digit digit2)
160 {
161 if (digit1.getChannel() != digit2.getChannel()) {
162 return false;
163 }
164
165 if (digit1.getBC() != digit2.getBC()) {
166 return false;
167 }
168
169 // Check if the difference is larger than the TDC dead time
170 if (std::abs(digit1.getTDC() - digit2.getTDC()) > Geo::DEADTIMETDC) {
171 return false;
172 }
173 return true;
174 }
175
177};
178} // namespace tof
179} // namespace o2
180#endif
Definition of the TOF cluster.
uint64_t orbit
Definition RawEventData.h:6
uint64_t bc
Definition RawEventData.h:5
Diagnostic class for TOF.
Definition Diagnostic.h:32
TOF digit implementation.
Definition Digit.h:31
uint64_t getBC() const
Definition Digit.h:58
Int_t getChannel() const
Definition Digit.h:49
uint16_t getTDC() const
Definition Digit.h:52
static constexpr Float_t DEADTIMETDC
Single channel TDC dead time (ps)
Definition Geo.h:162
@ kNCrate
Definition Geo.h:95
static constexpr int NCHANNELS
Definition Geo.h:124
static constexpr int BC_IN_WINDOW
Definition Geo.h:165
static void setNOrbitInTF(uint32_t norb)
Definition Utils.h:73
void addCrateHeaderData(unsigned long orbit, int crate, int32_t bc, uint32_t eventCounter)
std::vector< uint64_t > mErrors
void fillDigitsInStrip(std::vector< Strip > *strips, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, uint32_t triggerorbit=0, uint16_t triggerbunch=0)
std::vector< uint8_t > & getPatterns()
std::vector< CrateHeaderData > mCrateHeaderData
void setContinuous(bool value=true)
Diagnostic & getDiagnosticFrequency()
std::vector< Strip > mStrips[MAXWINDOWS]
static const int MAXWINDOWS
void addCount(int channel)
std::vector< PatternData > mCratePatterns
InteractionTimeRecord mEventTime
bool isContinuous() const
void setReadoutWindowData(const VROF &row, const VPAT &pattern)
bool isMergable(Digit digit1, Digit digit2)
std::vector< Strip > * mStripsCurrent
int mChannelCounts[o2::tof::Geo::NCHANNELS]
void resizeVectorFutureDigit(int size)
std::vector< Strip > * mStripsNext[MAXWINDOWS - 1]
void flushOutputContainer(std::vector< Digit > &digits)
void addPattern(const uint32_t val, int icrate, int orbit, int bc)
std::vector< Digit > * getDigitPerTimeFrame()
std::vector< ReadoutWindowData > mReadoutWindowDataFiltered
DigitHeader & getDigitHeader()
void setNOrbitInTF(uint32_t norb)
void setEventTime(InteractionTimeRecord value)
ClassDefNV(WindowFiller, 2)
std::vector< uint8_t > mPatterns
Diagnostic mDiagnosticFrequency
std::vector< Digit > mDigitsPerTimeFrame
void maskNoiseRate(int val)
void insertDigitInFuture(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label=0, uint32_t triggerorbit=0, uint16_t triggerbunch=0)
std::vector< Digit > mFutureDigits
std::vector< ReadoutWindowData > mReadoutWindowData
void setCurrentReadoutWindow(uint64_t value)
uint64_t getCurrentReadoutWindow() const
void setFirstIR(const o2::InteractionRecord &ir)
void fillOutputContainer(std::vector< Digit > &digits)
std::vector< ReadoutWindowData > * getReadoutWindowDataFiltered()
std::vector< ReadoutWindowData > * getReadoutWindowData()
InteractionRecord mFirstIR
GLsizeiptr size
Definition glcorearb.h:659
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLuint GLfloat * val
Definition glcorearb.h:1582
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t eventCounter[Geo::kNCrate]
PatternData(uint32_t patt=0, int icr=0, unsigned long rw=0)
o2::InteractionRecord ir(0, 0)
std::vector< Digit > digits
std::vector< int > row
std::array< uint16_t, 5 > pattern