Skip to content

Commit 70fcdfe

Browse files
authored
Merge b3870af into sapling-pr-archive-ktf
2 parents 58f87f6 + b3870af commit 70fcdfe

File tree

16 files changed

+98
-47
lines changed

16 files changed

+98
-47
lines changed

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/GBTLink.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct GBTLink {
155155
long offs = sizeof(RDH);
156156
char* ptrR = ((char*)ptr) + sizeof(RDH);
157157
while (offs < szd) {
158-
const o2::itsmft::GBTWord* w = reinterpret_cast<const o2::itsmft::GBTWord*>(ptrR);
158+
const GBTWord* w = reinterpret_cast<const o2::itsmft::GBTWord*>(ptrR);
159159
std::string com = fmt::format(" | FeeID:{:#06x} offs: {:6} ", feeID, offs);
160160
if (w->isData()) {
161161
com += "data word";
@@ -164,12 +164,12 @@ struct GBTLink {
164164
} else if (w->isDataTrailer()) {
165165
com += "data trailer";
166166
} else if (w->isTriggerWord()) {
167-
com += "trigger word";
167+
const GBTTrigger* trw = (const GBTTrigger*)w;
168+
com += fmt::format("trigger word bc:{} orbit:{} noData:{} int:{} cont:{}", trw->bc, trw->orbit, trw->noData, trw->internal, trw->continuation);
168169
} else if (w->isDiagnosticWord()) {
169170
com += "diag word";
170171
} else if (w->isCalibrationWord()) {
171-
com += "calib word";
172-
com += fmt::format(" #{}", ((const GBTCalibration*)w)->calibCounter);
172+
com += fmt::format("calib word count:{:5} data:{:#08x}", ((const GBTCalibration*)w)->calibCounter, ((const GBTCalibration*)w)->calibUserField);
173173
} else if (w->isCableDiagnostic()) {
174174
com += "cable diag word";
175175
} else if (w->isStatus()) {

Detectors/Raw/src/RDHUtils.cxx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,48 +26,39 @@ using namespace o2::header;
2626
void RDHUtils::printRDH(const RAWDataHeaderV4& rdh)
2727
{
2828
std::bitset<32> trb(rdh.triggerType);
29-
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x Packet:%-3d MemSize:%-4d OffsNext:%-4d prio.:%d BL:%-5d HS:%-2d HV:%d",
30-
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId), int(rdh.packetCounter), int(rdh.memorySize),
31-
int(rdh.offsetToNext), int(rdh.priority), int(rdh.blockLength), int(rdh.headerSize), int(rdh.version));
32-
LOGF(info, "HBOrb:%-9u TrOrb:%-9u Trg:%32s HBBC:%-4d TrBC:%-4d Page:%-5d Stop:%d Par:%-5d DetFld:0x%04x", //
29+
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x HBOrb:%-9u TrOrb:%-9u Trg:%32s HBBC:%-4d TrBC:%-4d Packet:%-3d Page:%-5d Stop:%d Par:%-5d DetFld:0x%04x MemSize:%-4d OffsNext:%-4d prio.:%d BL:%-5d HS:%-2d HV:%d",
30+
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId),
3331
rdh.heartbeatOrbit, rdh.triggerOrbit, trb.to_string().c_str(), int(rdh.heartbeatBC), int(rdh.triggerBC),
34-
int(rdh.pageCnt), int(rdh.stop), int(rdh.par), int(rdh.detectorField));
32+
int(rdh.packetCounter), int(rdh.pageCnt), int(rdh.stop), int(rdh.par), int(rdh.detectorField), int(rdh.memorySize),
33+
int(rdh.offsetToNext), int(rdh.priority), int(rdh.blockLength), int(rdh.headerSize), int(rdh.version));
3534
}
3635

3736
//_________________________________________________
3837
void RDHUtils::printRDH(const RAWDataHeaderV5& rdh)
3938
{
4039
std::bitset<32> trb(rdh.triggerType);
41-
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x Packet:%-3d MemSize:%-5d OffsNext:%-5d prio.:%d HS:%-2d HV:%d",
42-
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId), int(rdh.packetCounter), int(rdh.memorySize),
40+
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x Orbit:%-9u BC:%-4d Stop:%d Page:%-5d Packet:%-3d Trg:%32s Par:%-5d DetFld:0x%04x MemSize:%-5d OffsNext:%-5d prio.:%d HS:%-2d HV:%d",
41+
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId), rdh.orbit, int(rdh.bunchCrossing), int(rdh.stop), int(rdh.pageCnt),
42+
int(rdh.packetCounter), trb.to_string().c_str(), int(rdh.detectorPAR), int(rdh.detectorField), int(rdh.memorySize),
4343
int(rdh.offsetToNext), int(rdh.priority), int(rdh.headerSize), int(rdh.version));
44-
LOGF(info, "Orbit:%-9u BC:%-4d Stop:%d Page:%-5d Trg:%32s Par:%-5d DetFld:0x%04x",
45-
rdh.orbit, int(rdh.bunchCrossing), int(rdh.stop), int(rdh.pageCnt), trb.to_string().c_str(),
46-
int(rdh.detectorPAR), int(rdh.detectorField));
4744
}
4845

4946
//_________________________________________________
5047
void RDHUtils::printRDH(const RAWDataHeaderV7& rdh)
5148
{
5249
std::bitset<32> trb(rdh.triggerType);
53-
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x SrcID:%s[%d] Packet:%-3d MemSize:%-5d OffsNext:%-5d prio.:%d HS:%-2d HV:%d",
54-
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId), DAQID::DAQtoO2(rdh.sourceID).str, int(rdh.sourceID), int(rdh.packetCounter),
55-
int(rdh.memorySize), int(rdh.offsetToNext), int(rdh.priority), int(rdh.headerSize), int(rdh.version));
56-
LOGF(info, "Orbit:%-9u BC:%-4d DataFormat:%-2d Stop:%d Page:%-5d Trg:%32s Par:%-5d DetFld:0x%04x",
57-
rdh.orbit, int(rdh.bunchCrossing), int(rdh.dataFormat), int(rdh.stop), int(rdh.pageCnt), trb.to_string().c_str(),
58-
int(rdh.detectorPAR), int(rdh.detectorField));
50+
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x SrcID:%s[%d] Orbit:%-9u BC:%-4d DataFormat:%-2d Stop:%d Page:%-5d Packet:%-3d Trg:%32s Par:%-5d DetFld:0x%04x MemSize:%-5d OffsNext:%-5d prio.:%d HS:%-2d HV:%d",
51+
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId), DAQID::DAQtoO2(rdh.sourceID).str, int(rdh.sourceID), rdh.orbit, int(rdh.bunchCrossing), int(rdh.dataFormat), int(rdh.stop), int(rdh.pageCnt), int(rdh.packetCounter),
52+
trb.to_string().c_str(), int(rdh.detectorPAR), int(rdh.detectorField), int(rdh.memorySize), int(rdh.offsetToNext), int(rdh.priority), int(rdh.headerSize), int(rdh.version));
5953
}
6054

6155
//_________________________________________________
6256
void RDHUtils::printRDH(const RAWDataHeaderV6& rdh)
6357
{
6458
std::bitset<32> trb(rdh.triggerType);
65-
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x SrcID:%s[%d] Packet:%-3d MemSize:%-5d OffsNext:%-5d prio.:%d HS:%-2d HV:%d",
66-
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId), DAQID::DAQtoO2(rdh.sourceID).str, int(rdh.sourceID), int(rdh.packetCounter),
67-
int(rdh.memorySize), int(rdh.offsetToNext), int(rdh.priority), int(rdh.headerSize), int(rdh.version));
68-
LOGF(info, "Orbit:%-9u BC:%-4d Stop:%d Page:%-5d Trg:%32s Par:%-5d DetFld:0x%04x",
69-
rdh.orbit, int(rdh.bunchCrossing), int(rdh.stop), int(rdh.pageCnt), trb.to_string().c_str(),
70-
int(rdh.detectorPAR), int(rdh.detectorField));
59+
LOGF(info, "EP:%d CRU:0x%04x Link:%-3d FEEID:0x%04x SrcID:%s[%d] Orbit:%-9u BC:%-4d Stop:%d Page:%-5d Packet:%-3d Trg:%32s Par:%-5d DetFld:0x%04x MemSize:%-5d OffsNext:%-5d prio.:%d HS:%-2d HV:%d",
60+
int(rdh.endPointID), int(rdh.cruID), int(rdh.linkID), int(rdh.feeId), DAQID::DAQtoO2(rdh.sourceID).str, int(rdh.sourceID), rdh.orbit, int(rdh.bunchCrossing), int(rdh.stop), int(rdh.pageCnt),
61+
int(rdh.packetCounter), trb.to_string().c_str(), int(rdh.detectorPAR), int(rdh.detectorField), int(rdh.memorySize), int(rdh.offsetToNext), int(rdh.priority), int(rdh.headerSize), int(rdh.version));
7162
}
7263

7364
//_________________________________________________

Detectors/TOF/base/include/TOFBase/WindowFiller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class WindowFiller
104104

105105
protected:
106106
// info TOF timewindow
107-
uint64_t mReadoutWindowCurrent = 0;
108-
InteractionRecord mFirstIR{0, 0}; // reference IR (1st IR of the timeframe)
107+
uint64_t mReadoutWindowCurrent = 0; // keeps track of current readout window
108+
InteractionRecord mFirstIR{0, 0}; // reference IR (1st IR of the timeframe)
109109
InteractionTimeRecord mEventTime;
110110

111111
bool mContinuous = true;

Detectors/TOF/simulation/include/TOFSimulation/Digitizer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ class Digitizer : public WindowFiller
8383
void setEffBoundary2(float val) { mEffBoundary2 = val; }
8484
void setEffBoundary3(float val) { mEffBoundary3 = val; }
8585

86+
// determines the readout window id, given a time in nanoseconds (relative
87+
// to orbit-reset)
88+
uint64_t getReadoutWindow(double timeNS) const
89+
{
90+
// event time shifted by 2 BC as safe margin before to change current readout window to account for decalibration
91+
return uint64_t((timeNS - Geo::BC_TIME * (Geo::OVERLAP_IN_BC + 2)) * Geo::READOUTWINDOW_INV);
92+
}
93+
8694
private:
8795
// parameters
8896
Int_t mMode;

Detectors/TOF/simulation/include/TOFSimulation/TOFSimParams.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct TOFSimParams : public o2::conf::ConfigurableParamHelper<TOFSimParams> {
3333
float eff_boundary2 = 0.833; // efficiency in the pad border
3434
float eff_boundary3 = 0.1; // efficiency in mBound3
3535

36+
float max_hit_time = 1000.; // time cutoff for hits (time of flight); default 1us
37+
3638
O2ParamDef(TOFSimParams, "TOFSimParams");
3739
};
3840

Detectors/TOF/simulation/src/Digitizer.cxx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ void Digitizer::init()
6969
{
7070

7171
// set first readout window in MC production getting
72+
// orbitFirstSampled corresponds to the start of the concrete timeframe (it is set in O2DPG productions)
7273
mReadoutWindowCurrent = uint64_t(o2::raw::HBFUtils::Instance().orbitFirstSampled) * Geo::NWINDOW_IN_ORBIT;
7374

7475
// method to initialize the parameters neede to digitize and the array of strip objects containing
@@ -91,12 +92,21 @@ void Digitizer::init()
9192

9293
int Digitizer::process(const std::vector<HitType>* hits, std::vector<Digit>* digits)
9394
{
95+
const double max_hit_time = TOFSimParams::Instance().max_hit_time;
96+
9497
// hits array of TOF hits for a given simulated event
9598
// digits passed from external to be filled, in continuous readout mode we will push it on mDigitsPerTimeFrame vector of vectors of digits
9699

97100
// printf("process event time = %f with %ld hits\n",mEventTime.getTimeNS(),hits->size());
98101

99-
uint64_t readoutwindow = uint64_t((mEventTime.getTimeNS() - Geo::BC_TIME * (Geo::OVERLAP_IN_BC + 2)) * Geo::READOUTWINDOW_INV); // event time shifted by 2 BC as safe margin before to change current readout window to account for decalibration
102+
uint64_t readoutwindow = getReadoutWindow(mEventTime.getTimeNS());
103+
104+
// determines the maximal readout window difference to a preceding RO which can still affect the current readout window
105+
int max_readout_diff = int(max_hit_time * Geo::READOUTWINDOW_INV) + 1;
106+
// early return based on events happening earlier than MAX_READOUT_DIFF away from current RO frame
107+
if (readoutwindow < mReadoutWindowCurrent && mReadoutWindowCurrent - readoutwindow > max_readout_diff) {
108+
return 0;
109+
}
100110

101111
if (mContinuous && readoutwindow > mReadoutWindowCurrent) { // if we are moving in future readout windows flush previous ones (only for continuous readout mode)
102112
digits->clear();
@@ -110,9 +120,18 @@ int Digitizer::process(const std::vector<HitType>* hits, std::vector<Digit>* dig
110120
for (auto& hit : *hits) {
111121
// TODO: put readout window counting/selection
112122
// neglect very slow particles (low energy neutrons)
113-
if (hit.GetTime() > 1000) { // 1 mus
123+
if (hit.GetTime() > max_hit_time) { // 1 mus
124+
continue;
125+
}
126+
127+
// discard hits arriving before the minimum readout window
128+
auto hit_ro_window = getReadoutWindow(double(hit.GetTime()) + mEventTime.getTimeNS() /*+ Geo::LATENCYWINDOW*/);
129+
130+
// discard hits arriving too early
131+
if (hit_ro_window < mReadoutWindowCurrent) {
114132
continue;
115133
}
134+
116135
processHit(hit, mEventTime.getTimeOffsetWrtBC() + Geo::LATENCYWINDOW);
117136
} // end loop over hits
118137

Detectors/TPC/simulation/include/TPCSimulation/SAMPAProcessing.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ inline float SAMPAProcessing::getZfromTimeBin(float timeBin, Side s) const
258258

259259
inline TimeBin SAMPAProcessing::getTimeBinFromTime(float time) const
260260
{
261+
if (time < 0.f) {
262+
// protection and convention for negative times (otherwise overflow)
263+
return 0;
264+
}
261265
return static_cast<TimeBin>(time / mEleParam->ZbinWidth);
262266
}
263267

Detectors/TPC/simulation/src/Digitizer.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ void Digitizer::process(const std::vector<o2::tpc::HitGroup>& hits,
111111
}
112112
const float absoluteTime = eleTime + mTDriftOffset + (mEventTime - mOutputDigitTimeOffset); /// in us
113113

114+
/// the absolute time needs to be within the readout limits
115+
/// (otherwise negative times would all be accumulated in the 0-th timebin further below)
116+
if (!(absoluteTime >= 0 /* && absoluteTime <= timeframelength */)) {
117+
continue;
118+
}
119+
114120
/// Attachment
115121
if (electronTransport.isElectronAttachment(driftTime)) {
116122
continue;
@@ -217,9 +223,14 @@ void Digitizer::setUseSCDistortions(std::string_view finp)
217223

218224
void Digitizer::setStartTime(double time)
219225
{
226+
// this is setting the first timebin index for the digit container
227+
// note that negative times w.r.t start of timeframe/data-taking == mOutputDigitTimeOffset
228+
// will yield the 0-th bin (due to casting logic in sampaProcessing)
220229
SAMPAProcessing& sampaProcessing = SAMPAProcessing::instance();
221230
sampaProcessing.updateParameters(mVDrift);
222-
mDigitContainer.setStartTime(sampaProcessing.getTimeBinFromTime(time - mOutputDigitTimeOffset));
231+
const auto timediff = time - mOutputDigitTimeOffset;
232+
const auto starttimebin = sampaProcessing.getTimeBinFromTime(timediff);
233+
mDigitContainer.setStartTime(starttimebin);
223234
}
224235

225236
void Digitizer::setLumiScaleFactor()

Framework/Core/include/Framework/DataProcessingStats.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <atomic>
1717
#include <cstdint>
1818
#include <array>
19+
#include <memory>
1920
#include <numeric>
2021
#include <mutex>
2122
#include <utility>
@@ -69,8 +70,16 @@ enum struct ProcessingStatsId : short {
6970

7071
/// Helper struct to hold statistics about the data processing happening.
7172
struct DataProcessingStats {
73+
// Parameters for the default behaviour
74+
struct DefaultConfig {
75+
int64_t minOnlinePublishInterval = 0;
76+
};
77+
78+
DefaultConfig config = {};
79+
7280
DataProcessingStats(std::function<void(int64_t& base, int64_t& offset)> getRealtimeBase,
73-
std::function<int64_t(int64_t base, int64_t offset)> getTimestamp);
81+
std::function<int64_t(int64_t base, int64_t offset)> getTimestamp,
82+
DefaultConfig config);
7483

7584
constexpr static ServiceKind service_kind = ServiceKind::Global;
7685
constexpr static unsigned short MAX_METRICS = 1 << 15;

Framework/Core/src/CommonServices.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,11 @@ o2::framework::ServiceSpec CommonServices::dataProcessingStats()
867867
clock_gettime(CLOCK_REALTIME, &now);
868868
uv_update_time(state.loop);
869869
uint64_t offset = now.tv_sec * 1000 - uv_now(state.loop);
870+
DataProcessingStats::DefaultConfig config = {
871+
.minOnlinePublishInterval = std::stoi(options.GetProperty<std::string>("dpl-stats-min-online-publishing-interval").c_str())};
870872
auto* stats = new DataProcessingStats(TimingHelpers::defaultRealtimeBaseConfigurator(offset, state.loop),
871-
TimingHelpers::defaultCPUTimeConfigurator(state.loop));
873+
TimingHelpers::defaultCPUTimeConfigurator(state.loop),
874+
config);
872875
auto& runningWorkflow = services.get<RunningWorkflowInfo const>();
873876

874877
// It makes no sense to update the stats more often than every 5s

0 commit comments

Comments
 (0)