Project
Loading...
Searching...
No Matches
TRUDataHandler.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_EMCAL_TRUDataHandler_H
12#define ALICEO2_EMCAL_TRUDataHandler_H
13
14#include <array>
15#include <bitset>
16#include <cstdint>
17#include <exception>
18#include <iosfwd>
19#include <string>
20
21#include "Rtypes.h"
22
24
25namespace o2::emcal
26{
27
43{
44 public:
48 class PatchIndexException final : public std::exception
49 {
50 public:
54
56 ~PatchIndexException() noexcept final = default;
57
60 int8_t getIndex() const { return mIndex; }
61
64 const char* what() const noexcept final
65 {
66 return mMessage.data();
67 }
68
71 void printStream(std::ostream& stream) const;
72
73 private:
74 int8_t mIndex = -1;
75 std::string mMessage;
76 };
77
80
82 ~TRUDataHandler() = default;
83
85 void reset();
86
91 void setPatch(unsigned int index, unsigned int time)
92 {
93 checkPatchIndex(index);
94 mPatchTimes[index] = time;
95 }
96
99 void setFired(bool fired) { mL0Fired = fired; }
100
103 void setL0time(int l0time) { mL0Time = l0time; }
104
107 void setTRUIndex(int index) { mTRUIndex = index; }
108
111 bool isFired() const { return mL0Fired; }
112
113 int8_t getL0time() const { return mL0Time; }
114
119 bool hasPatch(unsigned int index) const
120 {
121 checkPatchIndex(index);
122 return mPatchTimes[index] < UCHAR_MAX;
123 }
124
129 uint8_t getPatchTime(unsigned int index) const
130 {
131 checkPatchIndex(index);
132 return mPatchTimes[index];
133 }
134
137 bool hasAnyPatch() const
138 {
139 for (int ipatch = 0; ipatch < mPatchTimes.size(); ipatch++) {
140 if (hasPatch(ipatch)) {
141 return true;
142 }
143 }
144 return false;
145 }
146
149 int getTRUIndex() const { return mTRUIndex; }
150
153 void printStream(std::ostream& stream) const;
154
155 private:
158 void checkPatchIndex(unsigned int index) const
159 {
160 if (index >= mPatchTimes.size()) {
161 throw PatchIndexException(index);
162 }
163 }
164
165 std::array<uint8_t, o2::emcal::TriggerMappingV2::PATCHESINTRU> mPatchTimes;
166 bool mL0Fired = false;
167 int8_t mL0Time = -1;
168 int8_t mTRUIndex = -1;
169 ClassDefNV(TRUDataHandler, 1);
170};
171
176std::ostream& operator<<(std::ostream& stream, const TRUDataHandler& data);
177
182std::ostream& operator<<(std::ostream& stream, const TRUDataHandler::PatchIndexException& error);
183
184} // namespace o2::emcal
185#endif
int16_t time
Definition RawEventData.h:4
Handler of errors related to invalid trigger patch IDs.
void printStream(std::ostream &stream) const
Print error on output stream.
~PatchIndexException() noexcept final=default
Destructor.
int8_t getIndex() const
Get patch index raising the exception.
const char * what() const noexcept final
Access Error message.
Helper class to handle decoded TRU data during the reconstruction.
void setL0time(int l0time)
Set the L0 time of the TRU.
bool hasPatch(unsigned int index) const
Check whehther the patch at the given index has fired.
uint8_t getPatchTime(unsigned int index) const
Get the trigger time of the trigger patch at a given index.
void setPatch(unsigned int index, unsigned int time)
Set reconstructed trigger patch.
bool isFired() const
Check whether the TRU was fired (at least one patch above threshold)
int getTRUIndex() const
Get the index of the TRU in global (STU) index schemes.
~TRUDataHandler()=default
Destructor.
void setFired(bool fired)
Mark TRU as fired (containing at least one patch above threshold)
bool hasAnyPatch() const
Check whether the TRU has any patch fired.
void printStream(std::ostream &stream) const
Print TRU information to an output stream.
void reset()
Reset handler.
void setTRUIndex(int index)
Set the index of the TRU (in global STU indexing scheme)
GLuint index
Definition glcorearb.h:781
GLboolean * data
Definition glcorearb.h:298
GLuint GLuint stream
Definition glcorearb.h:1806
std::ostream & operator<<(std::ostream &stream, const Cell &cell)
Stream operator for EMCAL cell.
Definition Cell.cxx:355