Skip to content

Commit c339a52

Browse files
authored
Merge 431dc1a into sapling-pr-archive-ktf
2 parents f2db3da + 431dc1a commit c339a52

File tree

6 files changed

+76
-49
lines changed

6 files changed

+76
-49
lines changed

Detectors/TRD/workflow/src/TRDDigitizerSpec.cxx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "TRDSimulation/Digitizer.h"
3333
#include "TRDSimulation/Detector.h" // for the Hit type
3434
#include "TRDSimulation/TRDSimParams.h"
35+
#include "DetectorsRaw/HBFUtils.h"
3536
#include <chrono>
3637

3738
using namespace o2::framework;
@@ -92,6 +93,8 @@ class TRDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
9293
size_t currTrig = 0; // from which collision is the current TRD trigger (only needed for debug information)
9394
bool firstEvent = true; // Flag for the first event processed
9495

96+
auto firstTF = InteractionTimeRecord(o2::raw::HBFUtils::Instance().getFirstSampledTFIR(), 0);
97+
9598
TStopwatch timer;
9699
timer.Start();
97100
// loop over all composite collisions given from context
@@ -100,6 +103,16 @@ class TRDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
100103
LOGF(debug, "Collision %lu out of %lu at %.1f ns started processing. Current pileup container size: %lu. Current number of digits accumulated: %lu",
101104
collID, irecords.size(), irecords[collID].getTimeNS(), mDigitizer.getPileupSignals().size(), digitsAccum.size());
102105
currentTime = irecords[collID];
106+
107+
// Note: Very crude filter to neglect collisions coming before
108+
// the first interaction record of the timeframe. Remove this, once these collisions can be handled
109+
// within the digitization routine. Collisions before this timeframe might impact digits of this timeframe.
110+
// See https://its.cern.ch/jira/browse/O2-5395.
111+
if (currentTime < firstTF) {
112+
LOG(info) << "Too early: Not digitizing collision " << collID;
113+
continue;
114+
}
115+
103116
// Trigger logic implemented here
104117
bool isNewTrigger = true; // flag newly accepted readout trigger
105118
if (firstEvent) {

Framework/Core/include/Framework/DataAllocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ class DataAllocator
140140
using DataDescription = o2::header::DataDescription;
141141
using SubSpecificationType = o2::header::DataHeader::SubSpecificationType;
142142
template <typename T>
143+
requires std::is_fundamental_v<T>
143144
struct UninitializedVector {
144-
static_assert(std::is_fundamental<T>::value, "UninitializedVector only allowed for fundamental types");
145145
using value_type = T;
146146
};
147147

Framework/Core/src/TableTreeHelpers.cxx

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -128,54 +128,6 @@ BranchToColumn::BranchToColumn(TBranch* branch, bool VLA, std::string name, EDat
128128
}
129129
}
130130

131-
template <typename T>
132-
inline T doSwap(T)
133-
{
134-
static_assert(always_static_assert_v<T>, "Unsupported type");
135-
}
136-
137-
template <>
138-
inline uint16_t doSwap(uint16_t x)
139-
{
140-
return swap16_(x);
141-
}
142-
143-
template <>
144-
inline uint32_t doSwap(uint32_t x)
145-
{
146-
return swap32_(x);
147-
}
148-
149-
template <>
150-
inline uint64_t doSwap(uint64_t x)
151-
{
152-
return swap64_(x);
153-
}
154-
155-
template <typename T>
156-
void doSwapCopy_(void* dest, void* source, int size) noexcept
157-
{
158-
auto tdest = static_cast<T*>(dest);
159-
auto tsrc = static_cast<T*>(source);
160-
for (auto i = 0; i < size; ++i) {
161-
tdest[i] = doSwap<T>(tsrc[i]);
162-
}
163-
}
164-
165-
void swapCopy(unsigned char* dest, char* source, int size, int typeSize) noexcept
166-
{
167-
switch (typeSize) {
168-
case 1:
169-
return (void)std::memcpy(dest, source, size);
170-
case 2:
171-
return doSwapCopy_<uint16_t>(dest, source, size);
172-
case 4:
173-
return doSwapCopy_<uint32_t>(dest, source, size);
174-
case 8:
175-
return doSwapCopy_<uint64_t>(dest, source, size);
176-
}
177-
}
178-
179131
std::pair<std::shared_ptr<arrow::ChunkedArray>, std::shared_ptr<arrow::Field>> BranchToColumn::read(TBuffer* buffer)
180132
{
181133
auto totalEntries = mBranch->GetEntries();

Framework/Foundation/include/Framework/Endian.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#ifndef O2_FRAMEWORK_ENDIAN_H_
1313
#define O2_FRAMEWORK_ENDIAN_H_
1414

15+
#include <cstdint>
16+
#include <concepts>
17+
#include <cstring>
1518
// Lookup file for __BYTE_ORDER
1619
#ifdef __APPLE__
1720
#include <machine/endian.h>
@@ -29,4 +32,50 @@
2932
#define O2_HOST_BYTE_ORDER __BYTE_ORDER
3033
#define O2_BIG_ENDIAN __BIG_ENDIAN
3134
#define O2_LITTLE_ENDIAN __LITTLE_ENDIAN
35+
36+
37+
template <typename T>
38+
requires std::same_as<T, uint16_t>
39+
inline uint16_t doSwap(uint16_t x)
40+
{
41+
return swap16_(x);
42+
}
43+
44+
template <typename T>
45+
requires std::same_as<T, uint32_t>
46+
inline uint32_t doSwap(uint32_t x)
47+
{
48+
return swap32_(x);
49+
}
50+
51+
template <typename T>
52+
requires std::same_as<T, uint64_t>
53+
inline uint64_t doSwap(uint64_t x)
54+
{
55+
return swap64_(x);
56+
}
57+
58+
template <typename T>
59+
inline void doSwapCopy_(void* dest, void* source, int size) noexcept
60+
{
61+
auto tdest = static_cast<T*>(dest);
62+
auto tsrc = static_cast<T*>(source);
63+
for (auto i = 0; i < size; ++i) {
64+
tdest[i] = doSwap<T>(tsrc[i]);
65+
}
66+
}
67+
68+
inline void swapCopy(unsigned char* dest, char* source, int size, int typeSize) noexcept
69+
{
70+
switch (typeSize) {
71+
case 1:
72+
return (void)std::memcpy(dest, source, size);
73+
case 2:
74+
return doSwapCopy_<uint16_t>(dest, source, size);
75+
case 4:
76+
return doSwapCopy_<uint32_t>(dest, source, size);
77+
case 8:
78+
return doSwapCopy_<uint64_t>(dest, source, size);
79+
}
80+
}
3281
#endif // O2_FRAMEWORK_ENDIAN_H_

Steer/DigitizerWorkflow/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ o2_add_executable(digitizer-workflow
5151
O2::MCHDigitFiltering
5252
O2::MFTSimulation
5353
O2::MIDSimulation
54+
O2::MIDRaw
5455
O2::PHOSSimulation
5556
O2::CPVSimulation
5657
O2::TOFSimulation

Steer/DigitizerWorkflow/src/MIDDigitizerSpec.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "Framework/Task.h"
2121
#include "Steer/HitProcessingManager.h" // for DigitizationContext
2222
#include "DetectorsBase/BaseDPLDigitizer.h"
23+
#include "DetectorsRaw/HBFUtils.h"
2324
#include "SimulationDataFormat/MCTruthContainer.h"
2425
#include "DataFormatsParameters/GRPObject.h"
2526
#include "DataFormatsMID/ROFRecord.h"
@@ -30,6 +31,7 @@
3031
#include "MIDSimulation/ChamberResponse.h"
3132
#include "MIDSimulation/ChamberEfficiencyResponse.h"
3233
#include "MIDSimulation/Geometry.h"
34+
#include "MIDRaw/ElectronicsDelay.h"
3335
#include "DataFormatsMID/MCLabel.h"
3436

3537
using namespace o2::framework;
@@ -83,6 +85,10 @@ class MIDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
8385
context->initSimChains(o2::detectors::DetID::MID, mSimChains);
8486
auto& irecords = context->getEventRecords();
8587

88+
auto firstTF = o2::raw::HBFUtils::Instance().getFirstSampledTFIR();
89+
auto delay = InteractionRecord(mElectronicsDelay.localToBC, 0);
90+
auto firstTimeTF = InteractionTimeRecord(firstTF + delay, 0);
91+
8692
auto& eventParts = context->getEventParts();
8793
std::vector<o2::mid::ColumnData> digits, digitsAccum;
8894
std::vector<o2::mid::ROFRecord> rofRecords;
@@ -93,6 +99,11 @@ class MIDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
9399
for (int collID = 0; collID < irecords.size(); ++collID) {
94100
// for each collision, loop over the constituents event and source IDs
95101
// (background signal merging is basically taking place here)
102+
103+
// Skip digits produced before the first orbit
104+
if (irecords[collID] < firstTimeTF) {
105+
continue;
106+
}
96107
auto firstEntry = digitsAccum.size();
97108
for (auto& part : eventParts[collID]) {
98109
mDigitizer->setEventID(part.entryID);
@@ -136,6 +147,7 @@ class MIDDPLDigitizerTask : public o2::base::BaseDPLDigitizer
136147
std::vector<TChain*> mSimChains;
137148
// RS: at the moment using hardcoded flag for continuos readout
138149
o2::parameters::GRPObject::ROMode mROMode = o2::parameters::GRPObject::CONTINUOUS; // readout mode
150+
ElectronicsDelay mElectronicsDelay; // Electronics delay
139151
};
140152

141153
o2::framework::DataProcessorSpec getMIDDigitizerSpec(int channel, bool mctruth)

0 commit comments

Comments
 (0)