Project
Loading...
Searching...
No Matches
RecoContainer.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
16
17#include <array>
18#include <cstdint>
19#include <exception>
20#include <iosfwd>
21#include <string>
22#include <tuple>
23#include <unordered_map>
24#include <vector>
25#include <gsl/span>
26#include <Rtypes.h>
32
33#ifndef ALICEO2_EMCAL_RECOCONTAINER_H
34#define ALICEO2_EMCAL_RECOCONTAINER_H
35
36namespace o2::emcal
37{
57
74{
75 public:
79 class TRUIndexException final : public std::exception
80 {
81 public:
84 TRUIndexException(std::size_t index);
85
87 ~TRUIndexException() noexcept final = default;
88
91 const char* what() const noexcept final { return mMessage.data(); }
92
95 std::size_t getIndex() const { return mIndex; }
96
99 void printStream(std::ostream& stream) const;
100
101 private:
102 std::size_t mIndex;
103 std::string mMessage;
104 };
105
107 EventContainer() = default;
108
111 EventContainer(const o2::InteractionRecord& currentIR);
112
114 ~EventContainer() = default;
115
118 void setTriggerBits(uint64_t triggerbits) { mTriggerBits = triggerbits; }
119
122 void setInteractionRecord(const o2::InteractionRecord& currentIR) { mInteractionRecord = currentIR; }
123
126 uint64_t getTriggerBits() const { return mTriggerBits; }
127
130 const o2::InteractionRecord& getInteractionRecord() const { return mInteractionRecord; }
131
134 const gsl::span<const RecCellInfo> getCells() const { return mCells; }
135
138 const gsl::span<const RecCellInfo> getLEDMons() const { return mLEDMons; }
139
142 int getNumberOfCells() const { return mCells.size(); }
143
146 int getNumberOfLEDMONs() const { return mLEDMons.size(); }
147
152 TRUDataHandler& getTRUData(std::size_t truIndex);
153
158 const TRUDataHandler& readTRUData(std::size_t truIndex) const;
159
162 const std::unordered_map<uint16_t, FastORTimeSeries>& getTimeSeriesContainer() const { return mL0FastORs; }
163
176 void setCell(int tower, double energy, double time, ChannelType_t celltype, int hwaddress, int ddlID, bool doMergeHGLG)
177 {
178 setCellCommon(tower, energy, time, celltype, false, hwaddress, ddlID, doMergeHGLG);
179 }
180
193 void setLEDMONCell(int tower, double energy, double time, ChannelType_t celltype, int hwaddress, int ddlID, bool doMergeHGLG)
194 {
195 setCellCommon(tower, energy, time, celltype, true, hwaddress, ddlID, doMergeHGLG);
196 }
197
206 void setFastOR(uint16_t fastORAbsID, uint8_t starttime, const gsl::span<const uint16_t> timesamples);
207
210 void sortCells(bool isLEDmon);
211
212 private:
221 void setCellCommon(int tower, double energy, double time, ChannelType_t celltype, bool isLEDmon, int hwaddress, int ddlID, bool doMergeHGLG);
222
225 bool isCellSaturated(double energy) const;
226
228 void initTRUs();
229
230 o2::InteractionRecord mInteractionRecord;
231 uint64_t mTriggerBits = 0;
232 std::vector<RecCellInfo> mCells;
233 std::vector<RecCellInfo> mLEDMons;
234 std::array<TRUDataHandler, TriggerMappingV2::ALLTRUS> mTRUData;
235 std::unordered_map<uint16_t, FastORTimeSeries> mL0FastORs;
236};
237
253{
254 public:
257 class InteractionNotFoundException final : public std::exception
258 {
259 public:
262 InteractionNotFoundException(const o2::InteractionRecord& currentIR) : mCurrentIR(currentIR)
263 {
264 mMessage = "Interaction record not found: Orbit " + std::to_string(mCurrentIR.orbit) + ", BC " + std::to_string(mCurrentIR.bc);
265 }
266
268 ~InteractionNotFoundException() noexcept final = default;
269
272 const char* what() const noexcept final
273 {
274 return mMessage.data();
275 };
276
279 const o2::InteractionRecord& getInteractionRecord() const { return mCurrentIR; }
280
281 private:
282 o2::InteractionRecord mCurrentIR;
283 std::string mMessage;
284 };
285
287 RecoContainer() = default;
288
290 ~RecoContainer() = default;
291
296
301 const EventContainer& getEventContainer(const o2::InteractionRecord& currentIR) const;
302
305 std::vector<o2::InteractionRecord> getOrderedInteractions() const;
306
309 std::size_t getNumberOfEvents() const { return mEvents.size(); }
310
312 void reset() { mEvents.clear(); }
313
314 private:
315 std::unordered_map<o2::InteractionRecord, EventContainer> mEvents;
316};
317
332{
333 public:
336 class InvalidAccessException : public std::exception
337 {
338 public:
341
343 ~InvalidAccessException() noexcept final = default;
344
347 const char* what() const noexcept final { return "Access to invalid element in reco container"; }
348 };
349
353 RecoContainerReader(RecoContainer&& container) = delete;
354
357
362
365 bool hasNext() const { return mCurrentEvent < mOrderedInteractions.size(); }
366
369 std::size_t getNumberOfEvents() const { return mDataContainer.getNumberOfEvents(); }
370
371 private:
372 RecoContainer& mDataContainer;
373 std::vector<o2::InteractionRecord> mOrderedInteractions;
374 std::size_t mCurrentEvent = 0;
375};
376
377} // namespace o2::emcal
378
379#endif
int16_t time
Definition RawEventData.h:4
EMCAL compressed cell information.
Definition Cell.h:59
Handler for access of TRU data with invalid TRU index.
void printStream(std::ostream &stream) const
Print error message on stream.
std::size_t getIndex() const
Get the TRU index raising the exception.
~TRUIndexException() noexcept final=default
Destructor.
const char * what() const noexcept final
Get the error message of the exception.
Containter of cells for a given event.
const std::unordered_map< uint16_t, FastORTimeSeries > & getTimeSeriesContainer() const
Access to container with FastOR time series.
void setTriggerBits(uint64_t triggerbits)
Set trigger bits of the interaction.
void setCell(int tower, double energy, double time, ChannelType_t celltype, int hwaddress, int ddlID, bool doMergeHGLG)
Add cell information to the event container.
int getNumberOfLEDMONs() const
Get the number of LEDMONs in the event.
void setFastOR(uint16_t fastORAbsID, uint8_t starttime, const gsl::span< const uint16_t > timesamples)
Add bunch of time series to the container.
void sortCells(bool isLEDmon)
Sort Cells / LEDMONs in container according to tower / module ID.
uint64_t getTriggerBits() const
Get trigger bits of the interaction.
~EventContainer()=default
Destructor.
const TRUDataHandler & readTRUData(std::size_t truIndex) const
Read-only access TRU data of a given TRU.
const gsl::span< const RecCellInfo > getCells() const
Get cells in container.
const o2::InteractionRecord & getInteractionRecord() const
Get interaction record of the event.
const gsl::span< const RecCellInfo > getLEDMons() const
Get LEDMONs in container.
int getNumberOfCells() const
Get the number of cells in the event.
EventContainer()=default
Constructor.
void setInteractionRecord(const o2::InteractionRecord &currentIR)
Set interaction record.
TRUDataHandler & getTRUData(std::size_t truIndex)
Read and write access TRU data of a given TRU.
void setLEDMONCell(int tower, double energy, double time, ChannelType_t celltype, int hwaddress, int ddlID, bool doMergeHGLG)
Add LEDMON information to the event container.
Handling of access to objects beyond container boundary.
const char * what() const noexcept final
Create error message.
~InvalidAccessException() noexcept final=default
Destructor.
Iterator over reco containers.
RecoContainerReader(RecoContainer &&container)=delete
~RecoContainerReader()=default
Destructor.
EventContainer & nextEvent()
Get the next event in container.
bool hasNext() const
Check whehter there are more events in the container.
std::size_t getNumberOfEvents() const
Get the number of events in the container.
Handling of access to trigger interaction record not present in container.
InteractionNotFoundException(const o2::InteractionRecord &currentIR)
Constructor.
const char * what() const noexcept final
Get error message of the exception.
const o2::InteractionRecord & getInteractionRecord() const
Get interaction record raising the exception.
~InteractionNotFoundException() noexcept final=default
Destructor.
Handler for cells/LEDMONS/Trigger data in timeframes.
std::size_t getNumberOfEvents() const
Get number of events in container.
~RecoContainer()=default
Destructor.
EventContainer & getEventContainer(const o2::InteractionRecord &currentIR)
Get container for trigger.
void reset()
Clear container.
RecoContainer()=default
Constructor.
std::vector< o2::InteractionRecord > getOrderedInteractions() const
Get sorted vector interaction records of triggers in container.
Helper class to handle decoded TRU data during the reconstruction.
GLuint index
Definition glcorearb.h:781
GLuint GLuint stream
Definition glcorearb.h:1806
ChannelType_t
Type of a raw data channel.
Definition Constants.h:33
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
uint32_t orbit
LHC orbit.
uint16_t bc
bunch crossing ID of interaction
Container class for cell information for merging.
int mHWAddressLG
HW address of LG (for monitoring)
bool mHGOutOfRange
Cell has only HG digits which are out of range.
int mDDLID
DDL of the channel (for monitoring)
bool mIsLGnoHG
Cell has only LG digits.
o2::emcal::Cell mCellData
Cell information.
int mHWAddressHG
HW address of HG (for monitoring)