From 6a8c14476c21990dc6b69dba2af1a7347945f632 Mon Sep 17 00:00:00 2001 From: John Chapman <John.Chapman@cern.ch> Date: Wed, 12 Mar 2025 10:06:45 +0100 Subject: [PATCH] Update other MuonPhaseII code to use central TruthUtils helper functions --- .../MuonDetDescr/ActsMuonDetectorTest/CMakeLists.txt | 4 ++-- .../ActsMuonDetectorTest/src/MuonDetectorNavTest.cxx | 4 +++- .../MuonPatternRecognitionAlgs/CMakeLists.txt | 4 ++-- .../src/CombinatorialNSWSeedFinderAlg.cxx | 6 +++--- .../MuonPatternRecognition/MuonTruthAlgsR4/CMakeLists.txt | 2 +- .../MuonTruthAlgsR4/src/TruthSegmentMaker.cxx | 6 ++++-- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/CMakeLists.txt b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/CMakeLists.txt index 9aa148699b8..4081f78700e 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/CMakeLists.txt +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration ################################################################################ # Package: ActsMuonDetectorTest @@ -10,7 +10,7 @@ atlas_add_component( ActsMuonDetectorTest src/components/*.cxx src/*.cxx LINK_LIBRARIES AthenaKernel StoreGateLib GeoModelUtilities MuonTesterTreeLib GaudiKernel MuonReadoutGeometryR4 MuonGeoModelR4Lib ActsGeometryLib AthenaPoolUtilities - xAODTruth xAODMuonSimHit CxxUtils) + xAODTruth xAODMuonSimHit CxxUtils TruthUtils) atlas_add_test( testMuonDetectorNav SCRIPT python -m ActsMuonDetectorTest.testMuonDetector diff --git a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/src/MuonDetectorNavTest.cxx b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/src/MuonDetectorNavTest.cxx index b6e60e51d65..a4a81b9e687 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/src/MuonDetectorNavTest.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonDetDescr/ActsMuonDetectorTest/src/MuonDetectorNavTest.cxx @@ -18,6 +18,8 @@ #include "xAODTruth/TruthVertex.h" +#include "TruthUtils/HepMCHelpers.h" + #include <fstream> using namespace Acts::UnitLiterals; @@ -145,7 +147,7 @@ namespace ActsTrk { const Acts::Experimental::Detector* detector = m_detVolSvc->detector().get(); for(const auto truthParticle : *truthParticles){ //Require that we only propagate on muons, and of status 1 - if(truthParticle->status() == 1 and truthParticle->pdgId() == 13){ + if(MC::isStable(truthParticle) and truthParticle->pdgId() == MC::MUON){ // FIXME not antimuons? const auto& particle = truthParticle->p4(); const auto& prodVertex = (!truthParticle->hasProdVtx()) ? nullptr : truthParticle->prodVtx(); double x = prodVertex ? prodVertex->x() : 0.; diff --git a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/CMakeLists.txt b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/CMakeLists.txt index d37e61ba6a0..3e9ec9366be 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/CMakeLists.txt +++ b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration ################################################################################ # Package: MuonPatternRecognitionAlgs ################################################################################ @@ -13,7 +13,7 @@ atlas_add_component( MuonPatternRecognitionAlgs src/components/*.cxx src/*.cxx LINK_LIBRARIES MuonVisualizationHelpersR4 MuonPatternEvent AthenaKernel StoreGateLib xAODMuonPrepData MuonSpacePoint MuonPatternHelpers MuonRecToolInterfacesR4 - MuonTruthHelpers ) + MuonTruthHelpers TruthUtils ) # Install files from the package: atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/src/CombinatorialNSWSeedFinderAlg.cxx b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/src/CombinatorialNSWSeedFinderAlg.cxx index 56262a5e1ce..c72e2f6bff5 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/src/CombinatorialNSWSeedFinderAlg.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonPatternRecognitionAlgs/src/CombinatorialNSWSeedFinderAlg.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ #include "CombinatorialNSWSeedFinderAlg.h" @@ -15,7 +15,7 @@ #include "xAODMeasurementBase/UncalibratedMeasurement.h" #include "xAODMuonPrepData/MMCluster.h" - +#include "TruthUtils/HepMCHelpers.h" #include <ranges> #include <vector> @@ -279,7 +279,7 @@ CombinatorialNSWSeedFinderAlg::findSeedsFromMaximum(const HoughMaximum &max, con for (const SpacePoint* sp : max.getHitsInMax()) { const auto* mmClust = static_cast<const xAOD::MMCluster*>(sp->primaryMeasurement()); const xAOD::MuonSimHit* simHit = getTruthMatchedHit(*mmClust); - if (!simHit || std::abs(simHit->pdgId()) != 13) continue; + if (!simHit || !MC::isMuon(simHit)) continue; const MuonGMR4::MmReadoutElement* reEle = mmClust->readoutElement(); const MuonGMR4::StripDesign& design = reEle->stripLayer(mmClust->measurementHash()).design(); const Amg::Transform3D toChamb = reEle->msSector()->globalToLocalTrans(gctx) * diff --git a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/CMakeLists.txt b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/CMakeLists.txt index e87f9bcb710..38f208ddb96 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/CMakeLists.txt +++ b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/CMakeLists.txt @@ -10,7 +10,7 @@ atlas_add_component( MuonTruthAlgsR4 src/components/*.cxx src/*.cxx LINK_LIBRARIES xAODMuonSimHit AthenaBaseComps GaudiKernel xAODMuon MuonIdHelpersLib MuonReadoutGeometryR4 xAODMuonPrepData MuonPatternEvent xAODMuonViews - TrkTruthData MuonTruthHelpers MuonRecHelperToolsLib) + TrkTruthData MuonTruthHelpers MuonRecHelperToolsLib TruthUtils) # Install files from the package: atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/src/TruthSegmentMaker.cxx b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/src/TruthSegmentMaker.cxx index 97f78cbd417..259b6267a78 100644 --- a/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/src/TruthSegmentMaker.cxx +++ b/MuonSpectrometer/MuonPhaseII/MuonPatternRecognition/MuonTruthAlgsR4/src/TruthSegmentMaker.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ #include "TruthSegmentMaker.h" @@ -18,6 +18,8 @@ #include "MuonPatternEvent/MuonHoughDefs.h" +#include "TruthUtils/HepMCHelpers.h" + #include "GaudiKernel/PhysicalConstants.h" #include <unordered_map> @@ -90,7 +92,7 @@ namespace MuonR4{ genParticle = genLink.cptr(); } /// skip empty truth matches for now - if (!genParticle || (m_useOnlyMuonHits && std::abs(simHit->pdgId()) != 13)) { + if (!genParticle || (m_useOnlyMuonHits && !MC::isMuon(simHit))) { ATH_MSG_VERBOSE("Skip hit "<<m_idHelperSvc->toString(simHit->identify())<< " pdgId: "<<simHit->pdgId()<<", energy: "<<simHit->kineticEnergy()); continue; -- GitLab