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 <climits>
17#include <cstdint>
18#include <exception>
19#include <iosfwd>
20#include <string>
21
22#include "Rtypes.h"
23
25
26namespace o2::emcal
27{
28
44{
45 public:
49 class PatchIndexException final : public std::exception
50 {
51 public:
55
57 ~PatchIndexException() noexcept final = default;
58
61 int8_t getIndex() const { return mIndex; }
62
65 const char* what() const noexcept final
66 {
67 return mMessage.data();
68 }
69
72 void printStream(std::ostream& stream) const;
73
74 private:
75 int8_t mIndex = -1;
76 std::string mMessage;
77 };
78
81
83 ~TRUDataHandler() = default;
84
86 void reset();
87
92 void setPatch(unsigned int index, unsigned int time)
93 {
94 checkPatchIndex(index);
95 mPatchTimes[index] = time;
96 }
97
100 void setFired(bool fired) { mL0Fired = fired; }
101
104 void setL0time(int l0time) { mL0Time = l0time; }
105
108 void setTRUIndex(int index) { mTRUIndex = index; }
109
112 bool isFired() const { return mL0Fired; }
113
114 int8_t getL0time() const { return mL0Time; }
115
120 bool hasPatch(unsigned int index) const
121 {
122 checkPatchIndex(index);
123 return mPatchTimes[index] < UCHAR_MAX;
124 }
125
130 uint8_t getPatchTime(unsigned int index) const
131 {
132 checkPatchIndex(index);
133 return mPatchTimes[index];
134 }
135
138 bool hasAnyPatch() const
139 {
140 for (int ipatch = 0; ipatch < mPatchTimes.size(); ipatch++) {
141 if (hasPatch(ipatch)) {
142 return true;
143 }
144 }
145 return false;
146 }
147
150 int getTRUIndex() const { return mTRUIndex; }
151
154 void printStream(std::ostream& stream) const;
155
156 private:
159 void checkPatchIndex(unsigned int index) const
160 {
161 if (index >= mPatchTimes.size()) {
162 throw PatchIndexException(index);
163 }
164 }
165
166 std::array<uint8_t, o2::emcal::TriggerMappingV2::PATCHESINTRU> mPatchTimes;
167 bool mL0Fired = false;
168 int8_t mL0Time = -1;
169 int8_t mTRUIndex = -1;
170 ClassDefNV(TRUDataHandler, 1);
171};
172
177std::ostream& operator<<(std::ostream& stream, const TRUDataHandler& data);
178
183std::ostream& operator<<(std::ostream& stream, const TRUDataHandler::PatchIndexException& error);
184
185} // namespace o2::emcal
186#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