From 912d35f304ecd2f0e5bd108bb878b13c56720efa Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Thu, 23 Jul 2026 13:02:42 -0500 Subject: [PATCH 1/2] Define an explicit 'match all' index value --- DataProducts/inc/SurfaceId.hh | 17 ++++++++--------- DataProducts/src/SurfaceId.cc | 1 + KinKalGeom/CMakeLists.txt | 1 + KinKalGeom/src/SConscript | 1 + Validation/src/ValKalSeed.cc | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/DataProducts/inc/SurfaceId.hh b/DataProducts/inc/SurfaceId.hh index 6147a3150e..860faed1b5 100644 --- a/DataProducts/inc/SurfaceId.hh +++ b/DataProducts/inc/SurfaceId.hh @@ -38,12 +38,10 @@ namespace mu2e { CRV_StrongBack=280, // CRV module Al strongback (tracker-side support plate) DS_HatchConcrete=300 // detector-area hatch concrete block approximation }; - - // Update this counter whenever you add/remove surface IDs from the enum above. - static constexpr std::size_t nSurfaceIds = 64; - - static std::string const& typeName(); - static std::map const& names(); + // Update this counter whenever you add/remove surface IDs from the enum above. + static constexpr std::size_t nSurfaceIds = 64; + static std::string const& typeName(); + static std::map const& names(); }; using SurfaceIdEnum = EnumToStringSparse; class SurfaceId { @@ -59,12 +57,13 @@ namespace mu2e { int index() const { return index_; } auto const& name() const { return sid_.name(); } - bool indexMatch(SurfaceId const& other) const { return index_ == other.index_ || index_ < 0 || other.index_ < 0; } - bool indexCompare(SurfaceId const& other) const { return index_<0 || other.index_ < 0 ? false : index_ < other.index_; } + bool indexMatch(SurfaceId const& other) const { return index_ == other.index_ || index_ == allIndices_ || other.index_ == allIndices_; } + bool indexCompare(SurfaceId const& other) const { return index_== allIndices_ || other.index_ == allIndices_ ? false : index_ < other.index_; } bool operator == (SurfaceId const& other ) const { return sid_ == other.sid_ && indexMatch(other) ; } bool operator != (SurfaceId const& other ) const { return sid_ != other.sid_ || !indexMatch(other) ; } bool operator < (SurfaceId const& other ) const { return sid_ == other.sid_ ? indexCompare(other) : sid_ < other.sid_; } - private: + static int allIndices_; // index wildcard + private: SurfaceIdEnum sid_; int index_; // index. Negative value is a wild card for matching }; diff --git a/DataProducts/src/SurfaceId.cc b/DataProducts/src/SurfaceId.cc index bef10f3b4f..e4bdfe2355 100644 --- a/DataProducts/src/SurfaceId.cc +++ b/DataProducts/src/SurfaceId.cc @@ -12,6 +12,7 @@ namespace mu2e { static const std::string type("SurfaceIdEnum"); return type; } + int SurfaceId::allIndices_(-1); // wildcard for index comparison namespace { using SurfaceIdName = std::pair; diff --git a/KinKalGeom/CMakeLists.txt b/KinKalGeom/CMakeLists.txt index b99bed90b4..f9014a79d7 100644 --- a/KinKalGeom/CMakeLists.txt +++ b/KinKalGeom/CMakeLists.txt @@ -5,6 +5,7 @@ cet_make_library( src/KKStrawMaterial.cc LIBRARIES PUBLIC Offline::ConfigTools + Offline::DataProducts KinKal::MatEnv KinKal::Geometry KinKal::Trajectory diff --git a/KinKalGeom/src/SConscript b/KinKalGeom/src/SConscript index eea1886bbb..8144b196ad 100644 --- a/KinKalGeom/src/SConscript +++ b/KinKalGeom/src/SConscript @@ -15,6 +15,7 @@ helper = mu2e_helper(env) mainlib = helper.make_mainlib([ 'mu2e_ConfigTools', + 'mu2e_DataProducts', 'KinKal_MatEnv', 'KinKal_Geometry', 'KinKal_Trajectory', diff --git a/Validation/src/ValKalSeed.cc b/Validation/src/ValKalSeed.cc index d677813379..56fa0f8f44 100644 --- a/Validation/src/ValKalSeed.cc +++ b/Validation/src/ValKalSeed.cc @@ -164,7 +164,7 @@ namespace mu2e { p = mom3.R(); rho = ikinter->position3().Rho(); } - auto stinters = ks.intersections(SurfaceId("ST_Foils",-1)); // match all foils + auto stinters = ks.intersections(SurfaceId("ST_Foils",SurfaceId::allIndices_)); // match all foils _hNST->Fill(stinters.size()); for (auto stinter : stinters) _hSTdP->Fill(stinter->dMom()); From 8845f0b8b64306501bd1a0cbaee81f728de13e2f Mon Sep 17 00:00:00 2001 From: David Nathan Brown Date: Fri, 24 Jul 2026 15:09:19 -0500 Subject: [PATCH 2/2] Use wildcard value for index matching --- DataProducts/inc/SurfaceId.hh | 2 +- Mu2eKinKal/inc/KKFit.hh | 2 +- Mu2eKinKal/src/CentralHelixFit_module.cc | 2 +- Mu2eKinKal/src/KinematicLineFit_module.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DataProducts/inc/SurfaceId.hh b/DataProducts/inc/SurfaceId.hh index 860faed1b5..957f5c2f65 100644 --- a/DataProducts/inc/SurfaceId.hh +++ b/DataProducts/inc/SurfaceId.hh @@ -65,7 +65,7 @@ namespace mu2e { static int allIndices_; // index wildcard private: SurfaceIdEnum sid_; - int index_; // index. Negative value is a wild card for matching + int index_; // index }; using SurfaceIdCollection = std::vector; // printout diff --git a/Mu2eKinKal/inc/KKFit.hh b/Mu2eKinKal/inc/KKFit.hh index 3b4dee0c0e..651b7b7d99 100644 --- a/Mu2eKinKal/inc/KKFit.hh +++ b/Mu2eKinKal/inc/KKFit.hh @@ -213,7 +213,7 @@ namespace mu2e { } // surfaces to sample; this interface is deprecatecd and should be replaced with extrapolation TODO for(auto const& sidname : fitconfig.sampleSurfaces()){ - ssids_.push_back(SurfaceId(sidname,-1)); // match all elements + ssids_.push_back(SurfaceId(sidname,SurfaceId::allIndices_)); // match all elements } } diff --git a/Mu2eKinKal/src/CentralHelixFit_module.cc b/Mu2eKinKal/src/CentralHelixFit_module.cc index ba96bd6135..888ec8e928 100644 --- a/Mu2eKinKal/src/CentralHelixFit_module.cc +++ b/Mu2eKinKal/src/CentralHelixFit_module.cc @@ -234,7 +234,7 @@ namespace mu2e { // surfaces to sample; this interface is deprecatecd and should be replaced with extrapolation TODO for(auto const& sidname : settings().modSettings().sampleSurfaces()) { - ssids_.push_back(SurfaceId(sidname,-1)); // match all elements + ssids_.push_back(SurfaceId(sidname,SurfaceId::allIndices_)); // match all elements } } diff --git a/Mu2eKinKal/src/KinematicLineFit_module.cc b/Mu2eKinKal/src/KinematicLineFit_module.cc index 293240b649..fd223f34dd 100644 --- a/Mu2eKinKal/src/KinematicLineFit_module.cc +++ b/Mu2eKinKal/src/KinematicLineFit_module.cc @@ -213,7 +213,7 @@ namespace mu2e { throw cet::exception("RECO")<<"mu2e::KinematicLineFit: Parameter constraint configuration error"<< endl; } for(auto const& sidname : settings().modSettings().sampleSurfaces()) { - ssids_.push_back(SurfaceId(sidname,-1)); // match all elements + ssids_.push_back(SurfaceId(sidname,SurfaceId::allIndices_)); // match all elements } // setup extrapolation if(settings().extrapSettings())extrap_ = make_unique(*settings().extrapSettings());