1414// / \author Markus Fasel <markus.fasel@cern.ch>, Oak Ridge National Laboratory
1515// / \since May 30, 2023
1616
17+ #include < array>
1718#include < cstdint>
1819#include < exception>
20+ #include < iosfwd>
1921#include < string>
2022#include < tuple>
2123#include < unordered_map>
2426#include < Rtypes.h>
2527#include < CommonDataFormat/InteractionRecord.h>
2628#include < DataFormatsEMCAL/Cell.h>
29+ #include < EMCALBase/TriggerMappingV2.h>
30+ #include < EMCALReconstruction/FastORTimeSeries.h>
31+ #include < EMCALReconstruction/TRUDataHandler.h>
2732
2833namespace o2 ::emcal
2934{
@@ -53,6 +58,36 @@ struct RecCellInfo {
5358class EventContainer
5459{
5560 public:
61+ // / \class TRUIndexException
62+ // / \brief Handler for access of TRU data with invalid TRU index
63+ // / \ingroup EMCALReconstruction
64+ class TRUIndexException final : public std::exception
65+ {
66+ public:
67+ // / \brief Constructor
68+ // / \param index TRU index raising the exception
69+ TRUIndexException (std::size_t index);
70+
71+ // / \brief Destructor
72+ ~TRUIndexException () noexcept final = default ;
73+
74+ // / \brief Get the error message of the exception
75+ // / \return Error message
76+ const char * what () const noexcept final { return mMessage .data (); }
77+
78+ // / \brief Get the TRU index raising the exception
79+ // / \return TRU index
80+ std::size_t getIndex () const { return mIndex ; }
81+
82+ // / \brief Print error message on stream
83+ // / \param stream Stream to print on
84+ void printStream (std::ostream& stream) const ;
85+
86+ private:
87+ std::size_t mIndex ; // /< TRU index raising the exception
88+ std::string mMessage ; // /< Buffer for error message
89+ };
90+
5691 // / \brief Constructor
5792 EventContainer () = default ;
5893
@@ -95,6 +130,22 @@ class EventContainer
95130 // / \return Number of LEDMONs
96131 int getNumberOfLEDMONs () const { return mLEDMons .size (); }
97132
133+ // / \brief Read and write access TRU data of a given TRU
134+ // / \param truIndex Index of the TRU
135+ // / \return TRU data handler for the TRU
136+ // / \throw TRUIndexException in case the TRU index is invalid (>= 52)
137+ TRUDataHandler& getTRUData (std::size_t truIndex);
138+
139+ // / \brief Read-only access TRU data of a given TRU
140+ // / \param truIndex Index of the TRU
141+ // / \return TRU data handler for the TRU
142+ // / \throw TRUIndexException in case the TRU index is invalid (>= 52)
143+ const TRUDataHandler& readTRUData (std::size_t truIndex) const ;
144+
145+ // / \brief Access to container with FastOR time series
146+ // / \return Container with time series
147+ const std::unordered_map<uint16_t , FastORTimeSeries>& getTimeSeriesContainer () const { return mL0FastORs ; }
148+
98149 // / \brief Add cell information to the event container
99150 // / \param tower Tower ID
100151 // / \param energy Cell energy
@@ -129,6 +180,16 @@ class EventContainer
129180 setCellCommon (tower, energy, time, celltype, true , hwaddress, ddlID, doMergeHGLG);
130181 }
131182
183+ // / \brief Add bunch of time series to the container
184+ // / \param fastORAbsID Absolute ID of the FastOR
185+ // / \param starttime Start time of the bunch
186+ // / \param timesamples Time samples of the bunch in time-reversed format
187+ // /
188+ // / In case a TimeSeries is already present for the given FastOR abs. ID in the container
189+ // / the bunch is added to this, otherwise a new TimeSeries is added with the ADCs of the
190+ // / bunch.
191+ void setFastOR (uint16_t fastORAbsID, uint8_t starttime, const gsl::span<const uint16_t > timesamples);
192+
132193 // / \brief Sort Cells / LEDMONs in container according to tower / module ID
133194 // / \param isLEDmon Switch between Cell and LEDMON
134195 void sortCells (bool isLEDmon);
@@ -148,21 +209,26 @@ class EventContainer
148209 // / \return True if the energy is in the saturation region, false otherwise
149210 bool isCellSaturated (double energy) const ;
150211
151- o2::InteractionRecord mInteractionRecord ;
152- uint64_t mTriggerBits = 0 ; // /< Trigger bits of the event
153- std::vector<RecCellInfo> mCells ; // /< Container of cells in event
154- std::vector<RecCellInfo> mLEDMons ; // /< Container of LEDMONs in event
212+ // / \brief Initialize the TRU handlers
213+ void initTRUs ();
214+
215+ o2::InteractionRecord mInteractionRecord ; // /< Interaction record of the event
216+ uint64_t mTriggerBits = 0 ; // /< Trigger bits of the event
217+ std::vector<RecCellInfo> mCells ; // /< Container of cells in event
218+ std::vector<RecCellInfo> mLEDMons ; // /< Container of LEDMONs in event
219+ std::array<TRUDataHandler, TriggerMappingV2::ALLTRUS> mTRUData ; // /< TRU status
220+ std::unordered_map<uint16_t , FastORTimeSeries> mL0FastORs ; // /< L0 FastOR time series
155221};
156222
157223// / \class RecoContainer
158- // / \brief Handler for cells in
224+ // / \brief Handler for cells/LEDMONS/Trigger data in timeframes
159225// / \ingroup EMCALReconstruction
160226class RecoContainer
161227{
162228 public:
163229 // / \class InteractionNotFoundException
164230 // / \brief Handling of access to trigger interaction record not present in container
165- class InteractionNotFoundException : public std ::exception
231+ class InteractionNotFoundException final : public std::exception
166232 {
167233 public:
168234 // / \brief Constructor
0 commit comments