Skip to content

Commit f688652

Browse files
committed
TPC: add test workflow to create dummy CMV data
1 parent d961ddf commit f688652

4 files changed

Lines changed: 422 additions & 16 deletions

File tree

Detectors/TPC/workflow/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ o2_add_executable(idc-test-ft
198198
SOURCES test/test_ft_EPN_Aggregator.cxx
199199
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
200200

201+
o2_add_executable(cmv-test-generator
202+
COMPONENT_NAME tpc
203+
SOURCES test/test_cmv_generator.cxx
204+
PUBLIC_LINK_LIBRARIES O2::TPCWorkflow)
205+
201206
o2_add_executable(miptrack-filter
202207
COMPONENT_NAME tpc
203208
SOURCES src/tpc-miptrack-filter.cxx

Detectors/TPC/workflow/include/TPCWorkflow/TPCFLPCMVSpec.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ namespace o2::tpc
3737
class TPCFLPCMVDevice : public o2::framework::Task
3838
{
3939
public:
40-
TPCFLPCMVDevice(const int lane, const std::vector<uint32_t>& crus, const bool triggerPerFlp, const int nTFsBuffer)
41-
: mLane{lane}, mCRUs{crus}, mTriggerPerFLP{triggerPerFlp}, mNTFsBuffer{nTFsBuffer} {}
40+
TPCFLPCMVDevice(const int lane, const std::vector<uint32_t>& crus, const bool triggerPerFlp, const int nTFsBuffer, const bool enableTrigger = false)
41+
: mLane{lane}, mCRUs{crus}, mTriggerPerFLP{triggerPerFlp}, mNTFsBuffer{nTFsBuffer}, mEnableTrigger{enableTrigger} {}
4242

4343
void init(o2::framework::InitContext& ic) final
4444
{
4545
mDumpCMVs = ic.options().get<bool>("dump-cmvs-flp");
46-
mEnableTrigger = ic.options().get<bool>("trigger");
4746
mTriggerThresholdCMV = ic.options().get<float>("trigger-threshold-cmv");
4847
mTriggerThresholdMeanMax = ic.options().get<float>("trigger-threshold-cmvMeanMax");
4948
mTriggerThresholdMeanMin = ic.options().get<float>("trigger-threshold-cmvMeanMin");
@@ -78,14 +77,16 @@ class TPCFLPCMVDevice : public o2::framework::Task
7877
auto vecCMVs = pc.inputs().get<o2::pmr::vector<uint16_t>>(ref);
7978
mCMVs[cru].insert(mCMVs[cru].end(), vecCMVs.begin(), vecCMVs.end());
8079

81-
const bool cruTriggered = mEnableTrigger && evaluateTrigger(vecCMVs);
82-
if (!mTriggerPerFLP) {
83-
pc.outputs().snapshot(o2::framework::Output{o2::header::gDataOriginTPC, getDataDescriptionCMVTrigger(), tpcCRUHeader->subSpecification}, cruTriggered);
84-
} else {
85-
triggered |= cruTriggered;
80+
if (mEnableTrigger) {
81+
const bool cruTriggered = evaluateTrigger(vecCMVs);
82+
if (!mTriggerPerFLP) {
83+
pc.outputs().snapshot(o2::framework::Output{o2::header::gDataOriginTPC, getDataDescriptionCMVTrigger(), tpcCRUHeader->subSpecification}, cruTriggered);
84+
} else {
85+
triggered |= cruTriggered;
86+
}
8687
}
8788
}
88-
if (mTriggerPerFLP) {
89+
if (mEnableTrigger && mTriggerPerFLP) {
8990
const header::DataHeader::SubSpecificationType trigSubSpec{mCRUs.front() << 7};
9091
pc.outputs().snapshot(o2::framework::Output{o2::header::gDataOriginTPC, getDataDescriptionCMVTrigger(), trigSubSpec}, triggered);
9192
}
@@ -138,7 +139,7 @@ class TPCFLPCMVDevice : public o2::framework::Task
138139
int mCountTFsForBuffer{0}; ///< counts TFs to track when to send output
139140
std::unordered_map<unsigned int, o2::pmr::vector<uint16_t>> mCMVs{}; ///< buffered raw 16-bit CMV values per CRU
140141
std::unordered_map<uint32_t, uint64_t> mFirstOrbitBC{}; ///< first packed orbit/BC per CRU for the current buffer window
141-
bool mEnableTrigger{false}; ///< enable CMV trigger evaluation
142+
const bool mEnableTrigger{false}; ///< enable CMV trigger evaluation and CMVTRIGGER output (set at construction)
142143
float mTriggerThresholdCMV{-10.f}; ///< CMV value threshold: trigger sequence starts when value drops below this
143144
float mTriggerThresholdMeanMax{-40.f}; ///< upper bound on trigger-sequence mean CMV value
144145
float mTriggerThresholdMeanMin{-80.f}; ///< lower bound on trigger-sequence mean CMV value
@@ -199,7 +200,7 @@ class TPCFLPCMVDevice : public o2::framework::Task
199200
}
200201
};
201202

202-
o2::framework::DataProcessorSpec getTPCFLPCMVSpec(const int ilane, const std::vector<uint32_t>& crus, const bool triggerPerFlp, const int nTFsBuffer = 1)
203+
o2::framework::DataProcessorSpec getTPCFLPCMVSpec(const int ilane, const std::vector<uint32_t>& crus, const bool triggerPerFlp, const int nTFsBuffer = 1, const bool enableTrigger = false)
203204
{
204205
std::vector<o2::framework::OutputSpec> outputSpecs;
205206
std::vector<o2::framework::InputSpec> inputSpecs;
@@ -217,11 +218,11 @@ o2::framework::DataProcessorSpec getTPCFLPCMVSpec(const int ilane, const std::ve
217218
outputSpecs.emplace_back(o2::framework::ConcreteDataMatcher{o2::header::gDataOriginTPC, TPCFLPCMVDevice::getDataDescriptionCMVGroup(), subSpec}, o2::framework::Lifetime::Sporadic);
218219
outputSpecs.emplace_back(o2::framework::ConcreteDataMatcher{o2::header::gDataOriginTPC, TPCFLPCMVDevice::getDataDescriptionCMVOrbitInfo(), subSpec}, o2::framework::Lifetime::Sporadic);
219220

220-
if (!triggerPerFlp) {
221+
if (enableTrigger && !triggerPerFlp) {
221222
outputSpecs.emplace_back(o2::framework::ConcreteDataMatcher{o2::header::gDataOriginTPC, TPCFLPCMVDevice::getDataDescriptionCMVTrigger(), subSpec}, o2::framework::Lifetime::Timeframe);
222223
}
223224
}
224-
if (triggerPerFlp) { // Single per-FLP trigger output, subspec keyed on the first CRU
225+
if (enableTrigger && triggerPerFlp) { // Single per-FLP trigger output, subspec keyed on the first CRU
225226
const header::DataHeader::SubSpecificationType trigSubSpec{crus.front() << 7};
226227
outputSpecs.emplace_back(o2::framework::ConcreteDataMatcher{o2::header::gDataOriginTPC, TPCFLPCMVDevice::getDataDescriptionCMVTrigger(), trigSubSpec}, o2::framework::Lifetime::Timeframe);
227228
}
@@ -231,10 +232,9 @@ o2::framework::DataProcessorSpec getTPCFLPCMVSpec(const int ilane, const std::ve
231232
id.data(),
232233
inputSpecs,
233234
outputSpecs,
234-
o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<TPCFLPCMVDevice>(ilane, crus, triggerPerFlp, nTFsBuffer)},
235+
o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<TPCFLPCMVDevice>(ilane, crus, triggerPerFlp, nTFsBuffer, enableTrigger)},
235236
o2::framework::Options{
236237
{"dump-cmvs-flp", o2::framework::VariantType::Bool, false, {"Dump CMVs to file"}},
237-
{"trigger", o2::framework::VariantType::Bool, false, {"Enable CMV trigger evaluation"}},
238238
{"trigger-threshold-cmv", o2::framework::VariantType::Float, -10.f, {"CMV threshold: sequence starts when value drops below this (ADC units)"}},
239239
{"trigger-threshold-cmvMeanMax", o2::framework::VariantType::Float, -40.f, {"Upper bound on trigger-sequence mean CMV value"}},
240240
{"trigger-threshold-cmvMeanMin", o2::framework::VariantType::Float, -80.f, {"Lower bound on trigger-sequence mean CMV value"}},

Detectors/TPC/workflow/src/tpc-flp-cmv.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void customize(std::vector<ConfigParamSpec>& workflowOptions)
3232
{"time-lanes", VariantType::Int, 1, {"Number of parallel processing lanes (timeframes are split per device)"}},
3333
{"crus", VariantType::String, cruDefault.c_str(), {"List of CRUs, comma separated ranges, e.g. 0-3,7,9-15"}},
3434
{"n-TFs-buffer", VariantType::Int, 1, {"Buffer n-TFs before sending output"}},
35+
{"trigger", VariantType::Bool, false, {"Enable CMV trigger evaluation and produce the CMVTRIGGER output (no output is created when disabled)"}},
3536
{"trigger-per-flp", VariantType::Bool, false, {"Aggregate triggers of CRUs on FLP to a single trigger"}},
3637
{"configKeyValues", VariantType::String, "", {"Semicolon separated key=value strings"}}};
3738

@@ -49,6 +50,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
4950
const auto nLanes = std::min(static_cast<unsigned long>(config.options().get<int>("lanes")), nCRUs);
5051
const auto time_lanes = static_cast<unsigned int>(config.options().get<int>("time-lanes"));
5152
const auto crusPerLane = nCRUs / nLanes + ((nCRUs % nLanes) != 0);
53+
const bool enableTrigger = config.options().get<bool>("trigger");
5254
const bool triggerPerFLP = config.options().get<bool>("trigger-per-flp");
5355
const int nTFsBuffer = config.options().get<int>("n-TFs-buffer");
5456

@@ -67,7 +69,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& config)
6769
}
6870
const auto last = std::min(tpcCRUs.end(), first + crusPerLane);
6971
const std::vector<uint32_t> rangeCRUs(first, last);
70-
workflow.emplace_back(timePipeline(getTPCFLPCMVSpec(ilane, rangeCRUs, triggerPerFLP, nTFsBuffer), time_lanes));
72+
workflow.emplace_back(timePipeline(getTPCFLPCMVSpec(ilane, rangeCRUs, triggerPerFLP, nTFsBuffer, enableTrigger), time_lanes));
7173
}
7274

7375
return workflow;

0 commit comments

Comments
 (0)