From daedd7948f376c39c36178f5c9ad14d987ca9c06 Mon Sep 17 00:00:00 2001 From: MATTHEW STORTINI Date: Thu, 2 Jul 2026 15:21:31 -0500 Subject: [PATCH 1/2] basic filter, and new channel ID field in reco product --- DAQ/src/MSDHitsFromDTCEvents_module.cc | 10 +++++++--- RecoDataProducts/inc/MSDHit.hh | 3 +++ Trigger/CMakeLists.txt | 7 +++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/DAQ/src/MSDHitsFromDTCEvents_module.cc b/DAQ/src/MSDHitsFromDTCEvents_module.cc index 1e887a0895..148f0042f6 100644 --- a/DAQ/src/MSDHitsFromDTCEvents_module.cc +++ b/DAQ/src/MSDHitsFromDTCEvents_module.cc @@ -102,6 +102,9 @@ void art::MSDHitsFromDTCEvents::produce(Event& event) { for (size_t blockIndex = 0; blockIndex < decoder.block_count(); blockIndex++) { mu2e::MobileSyncDataDecoder::sync_data_t dataPacketsVec = decoder.GetMobileSyncPackets(blockIndex); + // get channel ID of data block + const int rocLinkID = + static_cast(dtcSubEvent.GetDataBlock(blockIndex)->GetHeader()->GetLinkID()); // get number of hits in packet const unsigned nHitsInPacket = decoder.GetNHitsPerPacket(); if (_debugLevel > 4) { @@ -117,13 +120,15 @@ void art::MSDHitsFromDTCEvents::produce(Event& event) { mu2e::MSDHit msdHit; if (decoder.GetHitTime(&packet, hit, hitTime)) { msdHit.setTime(hitTime); + msdHit.setChannelID(rocLinkID); if (decoder.GetHitTOT(&packet, hit, hitTOT)) { msdHit.setTOT(hitTOT); } msd_hits->emplace_back(msdHit); if (_debugLevel > 0) { - std::cout << "Hit " << hit << " in packet: time = " << msdHit.time() - << " ns, TOT = " << msdHit.tot() << " ns" << std::endl; + std::cout << "Hit " << hit << " in packet: channel ID = " << msdHit.channelID() + << " time = " << msdHit.time() << " ns, TOT = " << msdHit.tot() + << " ns" << std::endl; } } } @@ -193,4 +198,3 @@ artdaq::Fragments art::MSDHitsFromDTCEvents::getFragments(art::Event& event) { DEFINE_ART_MODULE(art::MSDHitsFromDTCEvents) // ====================================================================== - diff --git a/RecoDataProducts/inc/MSDHit.hh b/RecoDataProducts/inc/MSDHit.hh index ba4d8707fd..395e793e52 100644 --- a/RecoDataProducts/inc/MSDHit.hh +++ b/RecoDataProducts/inc/MSDHit.hh @@ -13,10 +13,12 @@ public: // setters void setTime(double time) { _time = time; } void setTOT(double tot) { _tot = tot; } + void setChannelID(int id) { _channelID = id; } // accessors double time() const { return _time; } double tot() const { return _tot; } + int channelID() const { return _channelID; } // check if field is present in payload bool hasTime() const { return _time >= 0; } @@ -26,6 +28,7 @@ private: // data members double _time{-1.0}; // time of hit double _tot{-1.0}; // time-over-threshold + int _channelID{-1}; // channel ID }; typedef std::vector MSDHitCollection; diff --git a/Trigger/CMakeLists.txt b/Trigger/CMakeLists.txt index df3dd537d4..4327ff481d 100644 --- a/Trigger/CMakeLists.txt +++ b/Trigger/CMakeLists.txt @@ -54,4 +54,11 @@ cet_build_plugin(TriggerInfoToCollections art::module Offline::RecoDataProducts ) +cet_build_plugin(MSDHitFilter art::module + REG_SOURCE src/MSDHitFilter_module.cc + LIBRARIES REG + Offline::RecoDataProducts + TRACE::MF +) + install_source(SUBDIRS src) From 8351b4ed350150f257469e3b45d2f8c47a074a9b Mon Sep 17 00:00:00 2001 From: MATTHEW STORTINI Date: Thu, 2 Jul 2026 15:23:57 -0500 Subject: [PATCH 2/2] simple filter module --- Trigger/src/MSDHitFilter_module.cc | 100 +++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 Trigger/src/MSDHitFilter_module.cc diff --git a/Trigger/src/MSDHitFilter_module.cc b/Trigger/src/MSDHitFilter_module.cc new file mode 100644 index 0000000000..610f5bb2fa --- /dev/null +++ b/Trigger/src/MSDHitFilter_module.cc @@ -0,0 +1,100 @@ +// +// Filter for mobile sync detector hits +// Michael MacKenzie, 2026 +// + +// Framework +#include "art/Framework/Core/EDFilter.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Principal/Handle.h" +#include "fhiclcpp/ParameterSet.h" + +// Offline +#include "Offline/RecoDataProducts/inc/MSDHit.hh" + +// C++ +#include + +// TRACE +#include "TRACE/tracemf.h" +#define TRACE_NAME "MSDHitFilter" + +namespace mu2e { + class MSDHitFilter : public art::EDFilter { + public: + + // Main configuration + struct Config { + using Name = fhicl::Name; + using Comment = fhicl::Comment; + fhicl::Atom tag {Name("tag") , Comment("Collection tag")}; + fhicl::Atom minHits{Name("minHits"), Comment("Minimum number of hits")}; + }; + + using Parameters = art::EDFilter::Table; + + explicit MSDHitFilter(const Parameters& config); + + + private: + bool filter (art::Event& event) override; + bool endRun (art::Run& run ) override; + bool goodHit (const MSDHit& hit); + + // Inputs + std::string _tag; + int _minHits = -1; + + // Data + unsigned long _nevt, _npass; + + }; + + //----------------------------------------------------------------------------- + MSDHitFilter::MSDHitFilter(const Parameters& conf) + : art::EDFilter{conf} + , _tag(conf().tag()) + , _minHits(conf().minHits()) + , _nevt(0) + , _npass(0) + { + } + + //----------------------------------------------------------------------------- + // Check if the hit is accepted + bool MSDHitFilter::goodHit(const MSDHit& hit) { + if(!hit.hasTime()) return false; // time must be defined for the hit + return true; + } + + //----------------------------------------------------------------------------- + bool MSDHitFilter::filter(art::Event& event) { + + // Count total events seen + ++_nevt; + + // Filter flag + bool passed = true; + + auto handle = event.getValidHandle(_tag); + const auto hits = handle.product(); + int naccepted = 0; + for(const auto& hit : *hits) if(goodHit(hit)) ++naccepted; + + passed &= naccepted >= _minHits; + + // Return the result + return passed; + } + + //----------------------------------------------------------------------------- + bool MSDHitFilter::endRun(art::Run& run) { + // Print a summary of the filter results + const float rate = (_nevt > 0) ? float(_npass)/float(_nevt) : 0.f; + TLOG(TLVL_DEBUG + 2) << "passed " << _npass << " events out of " << _nevt << " for a ratio of " << rate; + _nevt = 0; _npass = 0; // reset for the next run + return true; + } +} + +DEFINE_ART_MODULE(mu2e::MSDHitFilter)