Skip to content

Commit 085139b

Browse files
committed
eb2: store dt histos in the counters. simplifies the interface a bit
1 parent 3666527 commit 085139b

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/mesytec-mvlc/event_builder2.cc

+9-17
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ struct PerEventData
130130
std::deque<TimestampType> allTimestamps;
131131
// Module data and extracted timestamps are stored here.
132132
std::vector<std::deque<ModuleStorage>> moduleDatas;
133-
// timestamp delta histograms
134-
std::vector<ModuleDeltaHisto> dtHistograms;
135133
};
136134

137135
// Records module data and unmodified timestamps.
@@ -384,7 +382,7 @@ struct EventBuilder2::Private
384382
// The back of each 'moduleDatas' queue now contains the newest data+timestamp.
385383

386384
// Fill dt histograms
387-
for (auto &dtHisto: eventData.dtHistograms)
385+
for (auto &dtHisto: eventCtrs.dtHistograms)
388386
{
389387
auto ts0 = eventData.moduleDatas[dtHisto.moduleIndexes.first].back().timestamp;
390388
auto ts1 = eventData.moduleDatas[dtHisto.moduleIndexes.second].back().timestamp;
@@ -624,10 +622,9 @@ struct EventBuilder2::Private
624622
fmt::join(debugStamps, ", "));
625623

626624
outputModuleData_.resize(moduleCount);
625+
627626
for (size_t mi = 0; mi < moduleCount; ++mi)
628627
{
629-
auto &mcfg = eventCfg.moduleConfigs.at(mi);
630-
631628
if (!size_consistency_check(outputModuleStorage_[mi]))
632629
{
633630
spdlog::error(" tryFlush: mi={}, size_consistency_check failed", mi);
@@ -734,13 +731,8 @@ EventBuilder2::EventBuilder2(const EventBuilderConfig &cfg, Callbacks callbacks,
734731
resize_and_clear(ec.moduleConfigs.size(), ed.moduleDatas, ctrs.inputHits, ctrs.outputHits,
735732
ctrs.emptyInputs, ctrs.discardsAge, ctrs.stampFailed, ctrs.currentEvents,
736733
ctrs.currentMem, ctrs.maxEvents, ctrs.maxMem);
737-
}
738734

739-
for (size_t ei = 0; ei < cfg.eventConfigs.size(); ++ei)
740-
{
741-
auto &ec = cfg.eventConfigs.at(ei);
742-
auto &ed = d->perEventData_.at(ei);
743-
ed.dtHistograms = create_dt_histograms(ec.moduleConfigs, cfg.dtHistoBinning);
735+
ctrs.dtHistograms = create_dt_histograms(ec.moduleConfigs, cfg.dtHistoBinning);
744736
}
745737
}
746738

@@ -871,25 +863,25 @@ BuilderCounters EventBuilder2::getCounters() const
871863

872864
std::vector<std::vector<ModuleDeltaHisto>> EventBuilder2::getDtHistograms() const
873865
{
874-
std::unique_lock<mvlc::TicketMutex> guard(d->mutex_);
866+
const auto counters = getCounters();
875867
std::vector<std::vector<ModuleDeltaHisto>> result;
876868

877-
for (const auto &ed: d->perEventData_)
869+
for (const auto &eventCtrs: counters.eventCounters)
878870
{
879-
result.emplace_back(ed.dtHistograms);
871+
result.emplace_back(eventCtrs.dtHistograms);
880872
}
881873

882874
return result;
883875
}
884876

885877
std::vector<ModuleDeltaHisto> EventBuilder2::getDtHistograms(int eventIndex) const
886878
{
887-
std::unique_lock<mvlc::TicketMutex> guard(d->mutex_);
879+
const auto counters = getCounters();
888880
std::vector<ModuleDeltaHisto> result;
889881

890-
if (0 <= eventIndex && static_cast<size_t>(eventIndex) < d->perEventData_.size())
882+
if (0 <= eventIndex && static_cast<size_t>(eventIndex) < counters.eventCounters.size())
891883
{
892-
result = d->perEventData_.at(eventIndex).dtHistograms;
884+
result = counters.eventCounters.at(eventIndex).dtHistograms;
893885
}
894886

895887
return result;

src/mesytec-mvlc/event_builder2.hpp

+15-9
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ struct MESYTEC_MVLC_EXPORT EmptyTimestampExtractor
7777
std::optional<u32> operator()(const u32 *, size_t) { return {}; }
7878
};
7979

80-
// Configuration ==========
80+
// Timestamp delta histogramming =======================
8181

8282
struct MESYTEC_MVLC_EXPORT HistoBinning
8383
{
@@ -101,6 +101,15 @@ inline size_t counts(const Histo &histo)
101101
return std::accumulate(histo.bins.begin(), histo.bins.end(), static_cast<size_t>(0u));
102102
}
103103

104+
// For histogramming timestamp deltas between modules.
105+
struct ModuleDeltaHisto
106+
{
107+
std::pair<size_t, size_t> moduleIndexes;
108+
Histo histo;
109+
};
110+
111+
// Configuration ==========
112+
104113
struct MESYTEC_MVLC_EXPORT ModuleConfig
105114
{
106115
timestamp_extractor tsExtractor;
@@ -138,7 +147,7 @@ struct MESYTEC_MVLC_EXPORT EventCounters
138147
std::vector<size_t> discardsAge; // number of event discarded due to stamp age
139148
std::vector<size_t> stampFailed; // number of failed stamp extractions
140149

141-
// these can be determinted from the contents of the data buffers
150+
// these can be determined from the contents of the data buffers
142151
std::vector<size_t> currentEvents; // current events in the buffer
143152
std::vector<size_t> currentMem; // current buffer memory usage
144153

@@ -149,6 +158,10 @@ struct MESYTEC_MVLC_EXPORT EventCounters
149158

150159
// non-module specific
151160
size_t recordingFailed = 0;
161+
162+
// List of all dt histograms for this event. One histo for each module pair.
163+
// No duplicates.
164+
std::vector<ModuleDeltaHisto> dtHistograms;
152165
};
153166

154167
std::string MESYTEC_MVLC_EXPORT dump_counters(const EventCounters &counters);
@@ -158,13 +171,6 @@ struct MESYTEC_MVLC_EXPORT BuilderCounters
158171
std::vector<EventCounters> eventCounters;
159172
};
160173

161-
// For histogramming timestamp deltas between modules.
162-
struct ModuleDeltaHisto
163-
{
164-
std::pair<size_t, size_t> moduleIndexes;
165-
Histo histo;
166-
};
167-
168174
std::vector<ModuleDeltaHisto> MESYTEC_MVLC_EXPORT
169175
create_dt_histograms(const std::vector<ModuleConfig> &moduleConfigs, const HistoBinning &binConfig);
170176

0 commit comments

Comments
 (0)