Skip to content

Commit d08d21a

Browse files
mfasDajokonig
authored andcommitted
[EMCAL-916, EMCAL-537, EMCAL-550, EMCAL-911] Integrate TRU decoding into sync reco
- EMCAL-916: Add decoding of TRU data (FastORs and patch index) - EMCAL-911: Add handling of TRU data in RecoContainer - Provide helper classes for TRU- and FastOR decoding including the calculation of the L0timesum - EMCAL-537: Provide data structure for patches, TRUs and Timesums - EMCAL-550: Integration into RecoWorkflow: Output channels and option to disable trigger reconstruction
1 parent 78f6192 commit d08d21a

File tree

18 files changed

+978
-88
lines changed

18 files changed

+978
-88
lines changed

DataFormats/Detectors/EMCAL/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ o2_add_library(DataFormatsEMCAL
2222
src/ErrorTypeFEE.cxx
2323
src/CellLabel.cxx
2424
src/ClusterLabel.cxx
25+
src/CompressedTriggerData.cxx
2526
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat
2627
O2::Headers
2728
O2::MathUtils
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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_COMPRESSEDTRIGGERDATA_H
12+
#define ALICEO2_EMCAL_COMPRESSEDTRIGGERDATA_H
13+
14+
#include <cstdint>
15+
#include <iosfwd>
16+
17+
namespace o2::emcal
18+
{
19+
20+
/// \struct CompressedTRU
21+
/// \brief Compressed reconstructed TRU information
22+
/// \ingroup EMCALDataFormat
23+
struct CompressedTRU {
24+
uint8_t mTRUIndex; ///< TRU index
25+
uint8_t mTriggerTime; ///< Trigger time of the TRU
26+
bool mFired; ///< Fired status of the TRU
27+
uint8_t mNumberOfPatches; ///< Number of patches found for the TRU
28+
};
29+
30+
/// \struct CompressedTriggerPatch
31+
/// \brief Compressed reconstructed L0 trigger patch information
32+
/// \ingroup EMCALDataFormat
33+
struct CompressedTriggerPatch {
34+
uint8_t mTRUIndex; ///< Index of the TRU where the trigger patch has been found
35+
uint8_t mPatchIndexInTRU; ///< Index of the trigger patch in the TRU
36+
uint8_t mTime; ///< Reconstructed time of the trigger patch
37+
uint16_t mADC; ///< ADC sum of the trigger patch
38+
};
39+
40+
/// \struct CompressedL0TimeSum
41+
/// \brief Compressed L0 timesum information
42+
/// \ingroup EMCALDataFormat
43+
struct CompressedL0TimeSum {
44+
uint16_t mIndex; ///< Absolute ID of the FastOR
45+
uint16_t mTimesum; ///< ADC value of the time-sum (4-integral)
46+
};
47+
48+
/// \brief Output stream operator of the CompressedTRU
49+
/// \param stream Stream to write to
50+
/// \param tru TRU data to be streamed
51+
/// \return Stream after writing
52+
std::ostream& operator<<(std::ostream& stream, const CompressedTRU& tru);
53+
54+
/// \brief Output stream operator of the CompressedTriggerPatch
55+
/// \param stream Stream to write to
56+
/// \param patch Trigger patch to be streamed
57+
/// \return Stream after writing
58+
std::ostream& operator<<(std::ostream& stream, const CompressedTriggerPatch& patch);
59+
60+
/// \brief Output stream operator of the CompressedL0TimeSum
61+
/// \param stream Stream to write to
62+
/// \param timesum FastOR L0 timesum to be streamed
63+
/// \return Stream after writing
64+
std::ostream& operator<<(std::ostream& stream, const CompressedL0TimeSum& timesum);
65+
66+
} // namespace o2::emcal
67+
68+
#endif // ALICEO2_EMCAL_COMPRESSEDTRIGGERDATA_H
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
#include <iostream>
13+
#include "DataFormatsEMCAL/CompressedTriggerData.h"
14+
15+
std::ostream& o2::emcal::operator<<(std::ostream& stream, const o2::emcal::CompressedTRU& tru)
16+
{
17+
stream << "TRU " << tru.mTRUIndex << ": Fired " << (tru.mFired ? "yes" : "no") << ", time " << (tru.mFired ? std::to_string(static_cast<int>(tru.mTriggerTime)) : "Undefined") << ", number of patches " << tru.mNumberOfPatches;
18+
return stream;
19+
}
20+
21+
std::ostream& o2::emcal::operator<<(std::ostream& stream, const o2::emcal::CompressedTriggerPatch& patch)
22+
{
23+
stream << "Patch " << patch.mPatchIndexInTRU << " in TRU " << patch.mTRUIndex << ": Time " << patch.mTime << ", ADC " << patch.mADC;
24+
return stream;
25+
}
26+
27+
std::ostream& o2::emcal::operator<<(std::ostream& stream, const o2::emcal::CompressedL0TimeSum& timesum)
28+
{
29+
stream << "FastOR " << timesum.mIndex << ": " << timesum.mTimesum << " ADC counts";
30+
return stream;
31+
}

Detectors/EMCAL/base/include/EMCALBase/TriggerMappingV2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class TriggerMappingV2
4949
static constexpr unsigned int FASTORSPHI = (5 * FASTORSPHISM) + (1 * FASTORSPHISM / 3) /*EMCAL*/
5050
+ (3 * FASTORSPHISM) + (1 * FASTORSPHISM / 3) /*DCAL */; ///< Number of FastOR/EMCALs in Phi
5151
static constexpr unsigned int ALLFASTORS = FASTORSETA * FASTORSPHI; ///< Number of FastOR/EMCALs
52+
static constexpr unsigned int PATCHESINTRU = 77;
5253

5354
//********************************************
5455
// Index types

Detectors/EMCAL/base/src/TriggerMappingV2.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ TriggerMappingV2::IndexTRU TriggerMappingV2::getTRUIndexFromOnlineHardareAddree(
390390

391391
unsigned short branch = (hardwareAddress >> 11) & 0x1; // 0/1
392392

393-
IndexTRU truIndex = ((ddlID << 1) | branch) - 1; // 0..2
393+
IndexTRU truIndex = (((ddlID % 2) << 1) | branch) - 1; // 0..2
394394

395395
truIndex = (supermoduleID % 2) ? 2 - truIndex : truIndex;
396396

Detectors/EMCAL/reconstruction/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ o2_add_library(EMCALReconstruction
1616
src/AltroDecoder.cxx
1717
src/Bunch.cxx
1818
src/Channel.cxx
19+
src/FastORTimeSeries.cxx
1920
src/RecoParam.cxx
2021
src/RawDecodingError.cxx
2122
src/STUDecoderError.cxx
@@ -32,6 +33,7 @@ o2_add_library(EMCALReconstruction
3233
src/CTFCoder.cxx
3334
src/CTFHelper.cxx
3435
src/StuDecoder.cxx
36+
src/TRUDataHandler.cxx
3537
PUBLIC_LINK_LIBRARIES O2::Headers
3638
AliceO2::InfoLogger
3739
O2::DataFormatsEMCAL
@@ -49,6 +51,7 @@ o2_target_root_dictionary(
4951
include/EMCALReconstruction/RawPayload.h
5052
include/EMCALReconstruction/Bunch.h
5153
include/EMCALReconstruction/Channel.h
54+
include/EMCALReconstruction/FastORTimeSeries.h
5255
include/EMCALReconstruction/CaloFitResults.h
5356
include/EMCALReconstruction/CaloRawFitter.h
5457
include/EMCALReconstruction/CaloRawFitterStandard.h
@@ -59,6 +62,7 @@ o2_target_root_dictionary(
5962
include/EMCALReconstruction/DigitReader.h
6063
include/EMCALReconstruction/RecoParam.h
6164
include/EMCALReconstruction/StuDecoder.h
65+
include/EMCALReconstruction/TRUDataHandler.h
6266
)
6367

6468
o2_add_executable(rawreader-file
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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_FASTORTIMESERIES_H
12+
#define ALICEO2_EMCAL_FASTORTIMESERIES_H
13+
14+
#include <vector>
15+
#include <gsl/span>
16+
#include "Rtypes.h"
17+
18+
namespace o2::emcal
19+
{
20+
21+
/// \class FastORTimeSeries
22+
/// \brief Container for FastOR time series
23+
/// \author Markus Fasel <markus.fasel@cern.ch>, Oak Ridge National Laboratory
24+
/// \ingroup EMCALReconstruction
25+
/// \since April 19, 2024
26+
///
27+
/// Time series are encoded in bunches in the raw data, which are usually time-reversed.
28+
/// The FastORTimeSeries handles the time series of all bunches in the readout window,
29+
/// in proper future-direction time order, correcting the time-reversal from the Fake-ALTRO.
30+
/// Consequently the ADC samples are expected in time-reversed format. The function
31+
/// calculateL1TimeSum calculates the timesum of the timeseries as 4-integral with respect to
32+
/// a given L0 time, which is expected at the end of the time integration range.
33+
class FastORTimeSeries
34+
{
35+
public:
36+
/// @brief Dummy constructor
37+
FastORTimeSeries() = default;
38+
39+
/// \brief Construcor
40+
/// \param maxsamples Maximum number of time samples
41+
/// \param timesamples Time-reversed raw ADC samples
42+
/// \param starttime Start time
43+
FastORTimeSeries(int maxsamples, const gsl::span<const uint16_t> timesamples, uint8_t starttime)
44+
{
45+
setSize(maxsamples);
46+
fillReversed(timesamples, starttime);
47+
}
48+
49+
/// \brief Destructor
50+
~FastORTimeSeries() = default;
51+
52+
void setTimeSamples(const gsl::span<const uint16_t> timesamples, uint8_t starttime) { fillReversed(timesamples, starttime); }
53+
54+
/// \brief Calculate L0 timesum (4-integral of the ADC series) with respect to a given L0 time
55+
/// \param l0time L0 time (end of the time series)
56+
/// \return Timesum of the time series
57+
uint16_t calculateL1TimeSum(uint8_t l0time) const;
58+
59+
/// \brief Access raw ADC values (in forward time order)
60+
/// \return ADC values of the time series in forward time order
61+
const gsl::span<const uint16_t> getADCs() const { return mTimeSamples; }
62+
63+
/// \brief Clear ADC samples in the time series
64+
void clear();
65+
66+
private:
67+
/// \brief Set the container size for the ADC samples
68+
/// \param maxsamples Max. amount of samples to be handled
69+
void setSize(int maxsamples);
70+
71+
/// \brief Fill the internal time samples in proper time order
72+
/// \param timesamples Time-reversed time samples
73+
/// \param starttime Start time
74+
void fillReversed(const gsl::span<const uint16_t> timesamples, uint8_t starttime);
75+
76+
std::vector<uint16_t> mTimeSamples; ///< Raw ADC time samples (in forward time order)
77+
78+
ClassDef(FastORTimeSeries, 1);
79+
};
80+
81+
} // namespace o2::emcal
82+
83+
#endif

Detectors/EMCAL/reconstruction/include/EMCALReconstruction/RecoContainer.h

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
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>
@@ -24,6 +26,9 @@
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

2833
namespace o2::emcal
2934
{
@@ -53,6 +58,36 @@ struct RecCellInfo {
5358
class 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
160226
class 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

Comments
 (0)