@@ -37,13 +37,12 @@ namespace o2::tpc
3737class 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" }},
0 commit comments