From b4f8cb2e5242f883503b11be5aa67316b9127f1e Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Thu, 9 Jan 2025 18:20:58 +0100 Subject: [PATCH 1/2] Drop declareProperty in ExtrapolationValidation --- .../TrkExAlgs/ExtrapolationValidation.h | 146 +++++++++-------- .../TrkExAlgs/src/ExtrapolationValidation.cxx | 149 +++++------------- 2 files changed, 117 insertions(+), 178 deletions(-) diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h index b8e0ccf7cfab..278b89f3e444 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h +++ b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -15,10 +15,12 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/IRndmGenSvc.h" #include "GaudiKernel/RndmGenerators.h" +#include "GaudiKernel/SystemOfUnits.h" #include "EventPrimitives/EventPrimitives.h" #include "GeoPrimitives/GeoPrimitivesHelpers.h" #include <string> +#include "TrkExInterfaces/IExtrapolator.h" class TTree; @@ -29,7 +31,6 @@ class TTree; namespace Trk { - class IExtrapolator; class Surface; class TrackingGeometry; class TrackingVolume; @@ -73,81 +74,92 @@ namespace Trk static Amg::Transform3D createTransform(double x, double y, double z, double phi=0., double theta=0., double alphaZ=0.); /** the highest volume */ - const TrackingVolume* m_highestVolume; + const TrackingVolume* m_highestVolume = nullptr; /** The Extrapolator to be retrieved */ - ToolHandle<IExtrapolator> m_extrapolator; + ToolHandle<IExtrapolator> m_extrapolator + {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}; /** Random Number setup */ - Rndm::Numbers* m_gaussDist; - Rndm::Numbers* m_flatDist; - - bool m_materialCollectionValidation; //!< run the material collection - - bool m_direct; //extrapolate directly - - TTree* m_validationTree; //!< Root Validation Tree - - std::string m_validationTreeName; //!< validation tree name - to be acessed by this from root - std::string m_validationTreeDescription; //!< validation tree description - second argument in TTree - std::string m_validationTreeFolder; //!< stream/folder to for the TTree to be written out - - double m_maximumR; //!< maximum R of the highest - double m_maximumZ; //!< maximum halfZ of the highest tracking volume - - double m_sigmaLoc; //!< local sigma of start value - double m_sigmaR; //!< r sigma of start value - double m_sigmaZ; //!< Z sigma of start value - double m_minEta; //!< Minimal eta value - double m_maxEta; //!< Maximal eta value - double m_minP; //!< Minimal p value - double m_maxP; //!< Maximal p value + Rndm::Numbers* m_gaussDist = nullptr; + Rndm::Numbers* m_flatDist = nullptr; + + BooleanProperty m_materialCollectionValidation + {this, "ValidateMaterialCollection", true}; + + BooleanProperty m_direct{this, "ExtrapolateDirectly", false, + "extrapolate directly"}; + + TTree* m_validationTree = nullptr; //!< Root Validation Tree + + StringProperty m_validationTreeName + {this, "ValidationTreeName", "ExtrapolationValidation", + "validation tree name - to be acessed by this from root"}; + StringProperty m_validationTreeDescription + {this, "ValidationTreeDescription", + "Output of the ExtrapolationValidation Algorithm", + "validation tree description - second argument in TTree"}; + StringProperty m_validationTreeFolder + {this, "ValidationTreeFolder", "/val/ExtrapolationValidation", + "stream/folder to for the TTree to be written out"}; + + double m_maximumR = 0.; //!< maximum R of the highest + double m_maximumZ = 0.; //!< maximum halfZ of the highest tracking volume + + DoubleProperty m_sigmaLoc{this, "StartPerigeeSigmaLoc", + 10.*Gaudi::Units::micrometer, "local sigma of start value"}; + DoubleProperty m_sigmaR{this, "StartPerigeeSigmaR", + 17.*Gaudi::Units::micrometer, "r sigma of start value"}; + DoubleProperty m_sigmaZ{this, "StartPerigeeSigmaZ", + 50.*Gaudi::Units::millimeter, "Z sigma of start value"}; + DoubleProperty m_minEta{this, "StartPerigeeMinEta", -3.}; + DoubleProperty m_maxEta{this, "StartPerigeeMaxEta", 3.}; + DoubleProperty m_minP{this, "StartPerigeeMinP", 0.5*Gaudi::Units::GeV}; + DoubleProperty m_maxP{this, "StartPerigeeMinP", 100.*Gaudi::Units::GeV}; - int m_particleType; //!< the particle typre for the extrap. - - int m_parameters; //!< maximum 3 : start - destination - backward - float m_parameterLoc1[TRKEXALGS_MAXPARAMETERS]; //!< start local 1 - float m_parameterLoc2[TRKEXALGS_MAXPARAMETERS]; //!< start local 2 - float m_parameterPhi[TRKEXALGS_MAXPARAMETERS]; //!< start phi - float m_parameterTheta[TRKEXALGS_MAXPARAMETERS]; //!< start theta - float m_parameterEta[TRKEXALGS_MAXPARAMETERS]; //!< start eta - float m_parameterQoverP[TRKEXALGS_MAXPARAMETERS]; //!< start qOverP - - float m_covarianceLoc1[TRKEXALGS_MAXPARAMETERS]; //!< start local 1 - float m_covarianceLoc2[TRKEXALGS_MAXPARAMETERS]; //!< start local 2 - float m_covariancePhi[TRKEXALGS_MAXPARAMETERS]; //!< start phi - float m_covarianceTheta[TRKEXALGS_MAXPARAMETERS]; //!< start theta - float m_covarianceQoverP[TRKEXALGS_MAXPARAMETERS]; //!< start qOverP - float m_covarianceDeterminant[TRKEXALGS_MAXPARAMETERS]; //!< start qOverP - - int m_destinationSurfaceType; //!< destination surface type - float m_startX; //!< startX - float m_startY; //!< startX - float m_startR; //!< startX - float m_startZ; //!< startX - float m_startP; //!< startP + IntegerProperty m_particleType{this, "ParticleType", 2, + "the particle type for the extrap."}; + + int m_parameters = 0; //!< maximum 3 : start - destination - backward + float m_parameterLoc1[TRKEXALGS_MAXPARAMETERS]{}; //!< start local 1 + float m_parameterLoc2[TRKEXALGS_MAXPARAMETERS]{}; //!< start local 2 + float m_parameterPhi[TRKEXALGS_MAXPARAMETERS]{}; //!< start phi + float m_parameterTheta[TRKEXALGS_MAXPARAMETERS]{}; //!< start theta + float m_parameterEta[TRKEXALGS_MAXPARAMETERS]{}; //!< start eta + float m_parameterQoverP[TRKEXALGS_MAXPARAMETERS]{}; //!< start qOverP + + float m_covarianceLoc1[TRKEXALGS_MAXPARAMETERS]{}; //!< start local 1 + float m_covarianceLoc2[TRKEXALGS_MAXPARAMETERS]{}; //!< start local 2 + float m_covariancePhi[TRKEXALGS_MAXPARAMETERS]{}; //!< start phi + float m_covarianceTheta[TRKEXALGS_MAXPARAMETERS]{}; //!< start theta + float m_covarianceQoverP[TRKEXALGS_MAXPARAMETERS]{}; //!< start qOverP + float m_covarianceDeterminant[TRKEXALGS_MAXPARAMETERS]{}; //!< start qOverP + + int m_destinationSurfaceType = 0; //!< destination surface type + float m_startX = 0.; //!< startX + float m_startY = 0.; //!< startX + float m_startR = 0.; //!< startX + float m_startZ = 0.; //!< startX + float m_startP = 0.; //!< startP - float m_estimationX; //!< estimation in X - float m_estimationY; //!< estimation in Y - float m_estimationR; //!< estimation in R - float m_estimationZ; //!< estimation in Z + float m_estimationX = 0.; //!< estimation in X + float m_estimationY = 0.; //!< estimation in Y + float m_estimationR = 0.; //!< estimation in R + float m_estimationZ = 0.; //!< estimation in Z - float m_destinationX; //!< destination in X - float m_destinationY; //!< destination in Y - float m_destinationR; //!< destination in R - float m_destinationZ; //!< destination in Z + float m_destinationX = 0.; //!< destination in X + float m_destinationY = 0.; //!< destination in Y + float m_destinationR = 0.; //!< destination in R + float m_destinationZ = 0.; //!< destination in Z // ---- output statistics - unsigned int m_triesFront; //!< events front - unsigned int m_breaksFront; //!< breaks front - unsigned int m_triesBack; //!< events back - unsigned int m_breaksBack; //!< breaks + unsigned int m_triesFront = 0; //!< events front + unsigned int m_breaksFront = 0; //!< breaks front + unsigned int m_triesBack = 0; //!< events back + unsigned int m_breaksBack = 0; //!< breaks - unsigned int m_collectedLayerFront; //!< collected material layers forward - unsigned int m_collectedLayerBack; //!< collected material layers backwards - - //AmgSymMatrix(5) * m_covariance; - + unsigned int m_collectedLayerFront = 0; //!< collected material layers forward + unsigned int m_collectedLayerBack = 0; //!< collected material layers backwards }; } // end of namespace diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolationValidation.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolationValidation.cxx index 32e45d7325f3..31988606c5b4 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolationValidation.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolationValidation.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 */ /////////////////////////////////////////////////////////////////// @@ -10,7 +10,6 @@ #include <cmath> #include "TrkExAlgs/ExtrapolationValidation.h" -#include "TrkExInterfaces/IExtrapolator.h" #include "TrkSurfaces/CylinderSurface.h" #include "TrkSurfaces/DiscSurface.h" #include "TrkSurfaces/PlaneSurface.h" @@ -22,86 +21,12 @@ // Validation mode - TTree includes #include "TTree.h" #include "GaudiKernel/ITHistSvc.h" -#include "GaudiKernel/SystemOfUnits.h" //================ Constructor ================================================= Trk::ExtrapolationValidation::ExtrapolationValidation(const std::string& name, ISvcLocator* pSvcLocator) : - AthAlgorithm(name,pSvcLocator), - m_highestVolume(nullptr), - m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"), - m_gaussDist(nullptr), - m_flatDist(nullptr), - m_materialCollectionValidation(true), - m_direct(false), - m_validationTree(nullptr), - m_validationTreeName("ExtrapolationValidation"), - m_validationTreeDescription("Output of the ExtrapolationValidation Algorithm"), - m_validationTreeFolder("/val/ExtrapolationValidation"), - m_maximumR(0.), - m_maximumZ(0.), - m_sigmaLoc(10.*Gaudi::Units::micrometer), - m_sigmaR(17.*Gaudi::Units::micrometer), - m_sigmaZ(50.*Gaudi::Units::millimeter), - m_minEta(-3.), - m_maxEta(3.), - m_minP(0.5*Gaudi::Units::GeV), - m_maxP(100.*Gaudi::Units::GeV), - m_particleType(2), - m_parameters(0), - m_parameterLoc1{}, //!< start local 1 - m_parameterLoc2{}, //!< start local 2 - m_parameterPhi{}, //!< start phi - m_parameterTheta{}, //!< start theta - m_parameterEta{}, //!< start eta - m_parameterQoverP{}, //!< start qOverP - m_covarianceLoc1{}, //!< start local 1 - m_covarianceLoc2{}, //!< start local 2 - m_covariancePhi{}, //!< start phi - m_covarianceTheta{}, //!< start theta - m_covarianceQoverP{}, //!< start qOverP - m_covarianceDeterminant{}, //!< start qOverP - m_destinationSurfaceType(0), - m_startX{}, //!< startX - m_startY{}, //!< startX - m_startR{}, //!< startX - m_startZ{}, //!< startX - m_startP{}, //!< startP - m_estimationX(0.), - m_estimationY(0.), - m_estimationR(0.), - m_estimationZ(0.), - m_destinationX(0.), - m_destinationY(0.), - m_destinationR(0.), - m_destinationZ(0.), - m_triesFront(0), - m_breaksFront(0), - m_triesBack(0), - m_breaksBack(0), - m_collectedLayerFront(0), - m_collectedLayerBack(0) -{ - // used algorithms and alg tools - declareProperty("Extrapolator", m_extrapolator); - declareProperty("ValidateMaterialCollection", m_materialCollectionValidation); - declareProperty("ExtrapolateDirectly", m_direct); - // TTree handling - declareProperty("ValidationTreeName", m_validationTreeName); - declareProperty("ValidationTreeDescription", m_validationTreeDescription); - declareProperty("ValidationTreeFolder", m_validationTreeFolder); - // algorithm steering - declareProperty("StartPerigeeSigmaLoc" , m_sigmaLoc); - declareProperty("StartPerigeeSigmaR" , m_sigmaR); - declareProperty("StartPerigeeSigmaZ" , m_sigmaZ); - declareProperty("StartPerigeeMinEta" , m_minEta); - declareProperty("StartPerigeeMaxEta" , m_maxEta); - declareProperty("StartPerigeeMinP" , m_minP); - declareProperty("StartPerigeeMaxP" , m_maxP); - declareProperty("ParticleType" , m_particleType); - -} + AthAlgorithm(name,pSvcLocator) {} //================ Destructor ================================================= @@ -124,7 +49,8 @@ StatusCode Trk::ExtrapolationValidation::initialize() ATH_CHECK( m_extrapolator.retrieve()); // create the new Tree - m_validationTree = new TTree(m_validationTreeName.c_str(), m_validationTreeDescription.c_str()); + m_validationTree = new TTree(m_validationTreeName.value().c_str(), + m_validationTreeDescription.value().c_str()); // the branches for the parameters m_validationTree->Branch("Parameters", &m_parameters, "params/I"); @@ -186,9 +112,9 @@ StatusCode Trk::ExtrapolationValidation::finalize() // Code entered here will be executed once at the end of the program run. ATH_MSG_INFO("================== Output Statistics ========================="); ATH_MSG_INFO("= Navigation : "); - ATH_MSG_INFO("= - breaks fwd : " << double(m_breaksFront)/double(m_triesFront) + ATH_MSG_INFO("= - breaks fwd : " << static_cast<double>(m_breaksFront)/static_cast<double>(m_triesFront) << " (" << m_breaksFront << "/" << m_triesFront << ")"); - ATH_MSG_INFO("= - breaks bwd : " << double(m_breaksBack)/double(m_triesBack) + ATH_MSG_INFO("= - breaks bwd : " << static_cast<double>(m_breaksBack)/static_cast<double>(m_triesBack) << " (" << m_breaksBack << "/" << m_triesBack << ")"); if (m_materialCollectionValidation){ ATH_MSG_INFO("= Material collection : "); @@ -251,24 +177,23 @@ StatusCode Trk::ExtrapolationValidation::execute() m_parameterEta[m_parameters] = m_minEta + m_flatDist->shoot()*(m_maxEta-m_minEta); m_parameterTheta[m_parameters] = 2.*std::atan(std::exp(-m_parameterEta[m_parameters])); - - m_covarianceLoc1[m_parameters] = fabs( m_parameterLoc1[m_parameters] * 0.1); - m_covarianceLoc2[m_parameters] = fabs( m_parameterLoc2[m_parameters] * 0.1); - m_covariancePhi[m_parameters] = fabs( m_parameterPhi[m_parameters] * 0.1); - m_covarianceTheta[m_parameters] = fabs(m_parameterTheta[m_parameters] * 0.1); + m_covarianceLoc1[m_parameters] = std::abs(m_parameterLoc1[m_parameters] * 0.1); + m_covarianceLoc2[m_parameters] = std::abs(m_parameterLoc2[m_parameters] * 0.1); + m_covariancePhi[m_parameters] = std::abs(m_parameterPhi[m_parameters] * 0.1); + m_covarianceTheta[m_parameters] = std::abs(m_parameterTheta[m_parameters] * 0.1); // this is fine double p = m_minP + m_flatDist->shoot()*(m_maxP-m_minP); double charge = (m_flatDist->shoot() > 0.5 ) ? -1. : 1.; m_parameterQoverP[m_parameters] = charge/p; - m_covarianceQoverP[m_parameters] = fabs(m_parameterQoverP[m_parameters] * 0.1); + m_covarianceQoverP[m_parameters] = std::abs(m_parameterQoverP[m_parameters] * 0.1); // for the momentum logging m_startP = p; // start - m_startR = fabs(m_sigmaR * m_gaussDist->shoot()); + m_startR = std::abs(m_sigmaR * m_gaussDist->shoot()); double surfacePhi = M_PI * m_flatDist->shoot(); surfacePhi *= (m_flatDist->shoot() > 0.5 ) ? -1. : 1.; m_startX = m_startR*cos(surfacePhi); @@ -354,20 +279,20 @@ StatusCode Trk::ExtrapolationValidation::execute() m_parameterTheta[m_parameters] = estimationParameters->parameters()[Trk::theta]; m_parameterQoverP[m_parameters] = estimationParameters->parameters()[Trk::qOverP]; if(estimationParameters->covariance()){ - m_covarianceLoc1[m_parameters] = (*estimationParameters->covariance())(0,0); - m_covarianceLoc2[m_parameters] = (*estimationParameters->covariance())(1,1); - m_covariancePhi[m_parameters] = (*estimationParameters->covariance())(2,2); - m_covarianceTheta[m_parameters] = (*estimationParameters->covariance())(3,3); - m_covarianceQoverP[m_parameters] = (*estimationParameters->covariance())(4,4); - m_covarianceDeterminant[m_parameters] = (estimationParameters->covariance())->determinant(); + m_covarianceLoc1[m_parameters] = (*estimationParameters->covariance())(0,0); + m_covarianceLoc2[m_parameters] = (*estimationParameters->covariance())(1,1); + m_covariancePhi[m_parameters] = (*estimationParameters->covariance())(2,2); + m_covarianceTheta[m_parameters] = (*estimationParameters->covariance())(3,3); + m_covarianceQoverP[m_parameters] = (*estimationParameters->covariance())(4,4); + m_covarianceDeterminant[m_parameters] = (estimationParameters->covariance())->determinant(); } else{ - m_covarianceLoc1[m_parameters] = 0; - m_covarianceLoc2[m_parameters] = 0; - m_covariancePhi[m_parameters] = 0; - m_covarianceTheta[m_parameters] = 0; - m_covarianceQoverP[m_parameters] = 0; - m_covarianceDeterminant[m_parameters] = 0; + m_covarianceLoc1[m_parameters] = 0; + m_covarianceLoc2[m_parameters] = 0; + m_covariancePhi[m_parameters] = 0; + m_covarianceTheta[m_parameters] = 0; + m_covarianceQoverP[m_parameters] = 0; + m_covarianceDeterminant[m_parameters] = 0; } // the start Momentum @@ -400,7 +325,8 @@ StatusCode Trk::ExtrapolationValidation::execute() destinationSurface, Trk::alongMomentum, false, - (Trk::ParticleHypothesis)m_particleType,Trk::addNoise).release(); + static_cast<Trk::ParticleHypothesis>(m_particleType.value()), + Trk::addNoise).release(); else if(!m_direct){ // material collection validation // get the vector of TrackStateOnSurfaces back const std::vector<const Trk::TrackStateOnSurface*>* @@ -409,7 +335,7 @@ StatusCode Trk::ExtrapolationValidation::execute() destinationSurface, Trk::alongMomentum, false, - (Trk::ParticleHypothesis)m_particleType); + static_cast<Trk::ParticleHypothesis>(m_particleType.value())); // get the last one and clone it if (collectedMaterial && !collectedMaterial->empty()){ @@ -418,9 +344,9 @@ StatusCode Trk::ExtrapolationValidation::execute() destParameters = destinationState->trackParameters() ? destinationState->trackParameters()->clone() : nullptr; m_collectedLayerFront += collectedMaterial->size(); // delete the layers / cleanup - std::vector<const Trk::TrackStateOnSurface*>::const_iterator tsosIter = collectedMaterial->begin(); - std::vector<const Trk::TrackStateOnSurface*>::const_iterator tsosIterEnd = collectedMaterial->end(); - for ( ; tsosIter != tsosIterEnd; delete(*tsosIter), ++tsosIter); + for (const auto* tsos : *collectedMaterial) { + delete tsos; + } } } @@ -430,7 +356,7 @@ StatusCode Trk::ExtrapolationValidation::execute() destinationSurface, Trk::alongMomentum, false, - (Trk::ParticleHypothesis)m_particleType).release(); + static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release(); } // ----------------------- check if forward call was successful and continue then @@ -477,7 +403,8 @@ StatusCode Trk::ExtrapolationValidation::execute() startSurface, Trk::oppositeMomentum, false, - (Trk::ParticleHypothesis)m_particleType,Trk::removeNoise).release(); + static_cast<Trk::ParticleHypothesis>(m_particleType.value()), + Trk::removeNoise).release(); else if(!m_direct){ // material collection validation // get the vector of TrackStateOnSurfaces back const std::vector<const Trk::TrackStateOnSurface*>* @@ -486,7 +413,7 @@ StatusCode Trk::ExtrapolationValidation::execute() startSurface, Trk::oppositeMomentum, false, - (Trk::ParticleHypothesis)m_particleType); + static_cast<Trk::ParticleHypothesis>(m_particleType.value())); // get the last one and clone it if (collectedBackMaterial && !collectedBackMaterial->empty()){ // get the last track state on surface & clone the destination parameters @@ -495,9 +422,9 @@ StatusCode Trk::ExtrapolationValidation::execute() backParameters = startState->trackParameters() ? startState->trackParameters()->clone() : nullptr; m_collectedLayerBack += collectedBackMaterial->size(); // delete the layers / cleanup - std::vector<const Trk::TrackStateOnSurface*>::const_iterator tsosIter = collectedBackMaterial->begin(); - std::vector<const Trk::TrackStateOnSurface*>::const_iterator tsosIterEnd = collectedBackMaterial->end(); - for ( ; tsosIter != tsosIterEnd; delete(*tsosIter), ++tsosIter); + for (const auto* tsos : *collectedBackMaterial) { + delete tsos; + } } } @@ -507,7 +434,7 @@ StatusCode Trk::ExtrapolationValidation::execute() startSurface, Trk::oppositeMomentum, false, - (Trk::ParticleHypothesis)m_particleType).release(); + static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release(); } // ----------------------- check if backward call was successful and continue then -- GitLab From 335682edcc4c09cd89157fdf8f583c12af4dbdfd Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Wed, 15 Jan 2025 19:08:11 +0100 Subject: [PATCH 2/2] Drop declareProperty in TrkExAlgs (2nd part) --- .../TrkExAlgs/ExtrapolationValidation.h | 2 +- .../TrkExAlgs/ExtrapolatorComparisonTest.h | 48 ++-- .../TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h | 63 +++-- .../TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h | 142 ++++++----- .../src/ExtrapolatorComparisonTest.cxx | 60 +---- .../TrkExAlgs/src/ExtrapolatorTest.cxx | 102 ++------ .../TrkExAlgs/src/RiddersAlgorithm.cxx | 234 +++++------------- 7 files changed, 240 insertions(+), 411 deletions(-) diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h index 278b89f3e444..45ed62d7d484 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h +++ b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolationValidation.h @@ -115,7 +115,7 @@ namespace Trk DoubleProperty m_minEta{this, "StartPerigeeMinEta", -3.}; DoubleProperty m_maxEta{this, "StartPerigeeMaxEta", 3.}; DoubleProperty m_minP{this, "StartPerigeeMinP", 0.5*Gaudi::Units::GeV}; - DoubleProperty m_maxP{this, "StartPerigeeMinP", 100.*Gaudi::Units::GeV}; + DoubleProperty m_maxP{this, "StartPerigeeMaxP", 100.*Gaudi::Units::GeV}; IntegerProperty m_particleType{this, "ParticleType", 2, "the particle type for the extrap."}; diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorComparisonTest.h b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorComparisonTest.h index c61a95fb0389..20bf585fd49f 100644 --- a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorComparisonTest.h +++ b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorComparisonTest.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -17,6 +17,7 @@ #include "Gaudi/Property.h" /*no forward decl: typedef*/ #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/EventContext.h" +#include "GaudiKernel/SystemOfUnits.h" #include "AthenaKernel/IAthRNGSvc.h" #include "AthenaKernel/RNGWrapper.h" #include "TrkExInterfaces/IExtrapolator.h" @@ -118,34 +119,43 @@ namespace Trk ToolHandle<Trk::IExtrapolator> m_atlasExtrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}; - double m_sigmaD0; //!< Sigma of distribution for D0 - double m_sigmaZ0; //!< Sigma of distribution for Z0 - double m_minPhi; //!< Minimal phi value - double m_maxPhi; //!< Maximal phi value - double m_minEta; //!< Minimal eta value - double m_maxEta; //!< Maximal eta value - double m_minPt; //!< Minimal p value - double m_maxPt; //!< Maximal p value + DoubleProperty m_sigmaD0 + {this, "StartPerigeeSigmaD0", 17.*Gaudi::Units::micrometer}; + DoubleProperty m_sigmaZ0 + {this, "StartPerigeeSigmaZ0", 50.*Gaudi::Units::micrometer}; + DoubleProperty m_minPhi{this, "StartPerigeeMinPhi", -M_PI}; + DoubleProperty m_maxPhi{this, "StartPerigeeMaxPhi", M_PI}; + DoubleProperty m_minEta{this, "StartPerigeeMinEta", -3.}; + DoubleProperty m_maxEta{this, "StartPerigeeMaxEta", 3.}; + DoubleProperty m_minPt + {this, "StartPerigeeMinPt", 0.5*Gaudi::Units::GeV}; + DoubleProperty m_maxPt + {this, "StartPerigeeMaxPt", 50000*Gaudi::Units::GeV}; - int m_particleType; //!< the particle typre for the extrap. + IntegerProperty m_particleType + {this, "ParticleType", 2, "the particle type for the extrap."}; /** member variables for algorithm properties: */ - unsigned int m_referenceSurfaces; + unsigned int m_referenceSurfaces = 0; - std::vector<double> m_referenceSurfaceRadius; - std::vector<double> m_referenceSurfaceHalflength; + DoubleArrayProperty m_referenceSurfaceRadius + {this, "ReferenceSurfaceRadius", {}}; + DoubleArrayProperty m_referenceSurfaceHalflength + {this, "ReferenceSurfaceHalfZ", {}}; - std::vector<double> m_referenceSurfaceNegativeBoundary; - std::vector<double> m_referenceSurfacePositiveBoundary; + std::vector<double> m_referenceSurfaceNegativeBoundary; + std::vector<double> m_referenceSurfacePositiveBoundary; std::vector< std::vector<const Trk::Surface*> > m_atlasReferenceSurfaceTriples; std::vector< std::vector< std::shared_ptr<const Acts::Surface> > > m_actsReferenceSurfaceTriples; - int m_eventsPerExecute; + IntegerProperty m_eventsPerExecute{this, "EventsPerExecute", 1}; - ServiceHandle<PropResultRootWriterSvc> m_atlasPropResultWriterSvc; - ServiceHandle<PropResultRootWriterSvc> m_actsPropResultWriterSvc; - ServiceHandle<IAthRNGSvc> m_rndmSvc; + ServiceHandle<PropResultRootWriterSvc> m_atlasPropResultWriterSvc + {this, "ATLASPropResultRootWriter", "ATLASPropResultRootWriterSvc"}; + ServiceHandle<PropResultRootWriterSvc> m_actsPropResultWriterSvc + {this, "ACTSPropResultRootWriter", "ACTSPropResultRootWriterSvc"}; + ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc"}; ATHRNG::RNGWrapper* m_randomEngine = nullptr; }; } // end of namespace diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h index 3d2683309a41..ac5595190caa 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h +++ b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/ExtrapolatorTest.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -15,15 +15,17 @@ #include "GaudiKernel/IRndmGenSvc.h" #include "GaudiKernel/RndmGenerators.h" #include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/SystemOfUnits.h" #include <string> #include <vector> + #include "TrkParameters/TrackParameters.h" +#include "TrkExInterfaces/IExtrapolator.h" +#include "TrkExInterfaces/IPropagator.h" namespace Trk { - class IExtrapolator; - class IPropagator; class Surface; class MagneticFieldProperties; /** @class ExtrapolatorTest @@ -64,40 +66,49 @@ namespace Trk Trk::Perigee generatePerigee(); /** The Extrapolator to be retrieved */ - ToolHandle<IExtrapolator> m_extrapolator; - ToolHandle<IPropagator> m_propagator; - MagneticFieldProperties* m_magFieldProperties; //!< magnetic field properties + ToolHandle<IExtrapolator> m_extrapolator + {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}; + PublicToolHandle<IPropagator> m_propagator + {this, "Propagator", "Trk::RungeKuttaPropagator/RungeKuttaPropagator"}; + MagneticFieldProperties* m_magFieldProperties = nullptr; //!< magnetic field properties /** Random Number setup */ - Rndm::Numbers* m_gaussDist; - Rndm::Numbers* m_flatDist; - - double m_sigmaD0; //!< Sigma of distribution for D0 - double m_sigmaZ0; //!< Sigma of distribution for Z0 - double m_minPhi; //!< Minimal phi value - double m_maxPhi; //!< Maximal phi value - double m_minEta; //!< Minimal eta value - double m_maxEta; //!< Maximal eta value - double m_minP; //!< Minimal p value - double m_maxP; //!< Maximal p value - - int m_direction; //!< extrapolation direction - - int m_particleType; //!< the particle typre for the extrap. + Rndm::Numbers* m_gaussDist = nullptr; + Rndm::Numbers* m_flatDist = nullptr; + + DoubleProperty m_sigmaD0 + {this, "StartPerigeeSigmaD0", 17.*Gaudi::Units::micrometer}; + DoubleProperty m_sigmaZ0 + {this, "StartPerigeeSigmaZ0", 50.*Gaudi::Units::micrometer}; + DoubleProperty m_minPhi{this, "StartPerigeeMinPhi", -M_PI}; + DoubleProperty m_maxPhi{this, "StartPerigeeMaxPhi", M_PI}; + DoubleProperty m_minEta{this, "StartPerigeeMinEta", -3.}; + DoubleProperty m_maxEta{this, "StartPerigeeMaxEta", 3.}; + DoubleProperty m_minP + {this, "StartPerigeeMinP", 0.5*Gaudi::Units::GeV}; + DoubleProperty m_maxP + {this, "StartPerigeeMaxP", 50000*Gaudi::Units::GeV}; + + IntegerProperty m_direction{this, "StartDirection", 1}; + IntegerProperty m_particleType + {this, "ParticleType", 2, "the particle type for the extrap."}; /** member variables for algorithm properties: */ - unsigned int m_referenceSurfaces; + unsigned int m_referenceSurfaces = 0; - std::vector<double> m_referenceSurfaceRadius; - std::vector<double> m_referenceSurfaceHalflength; + DoubleArrayProperty m_referenceSurfaceRadius + {this, "ReferenceSurfaceRadius", {}}; + DoubleArrayProperty m_referenceSurfaceHalflength + {this, "ReferenceSurfaceHalfZ", {}}; std::vector< std::vector<const Surface*> > m_referenceSurfaceTriples; std::vector<double> m_referenceSurfaceNegativeBoundary; std::vector<double> m_referenceSurfacePositiveBoundary; - int m_eventsPerExecute; std::vector<Trk::Perigee> m_perigees; - bool m_useExtrapolator; + + IntegerProperty m_eventsPerExecute{this, "EventsPerExecute", -1}; + BooleanProperty m_useExtrapolator{this, "UseExtrapolator", false}; }; } // end of namespace diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h index 9227fa136c80..54ef08c18d19 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h +++ b/Tracking/TrkExtrapolation/TrkExAlgs/TrkExAlgs/RiddersAlgorithm.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -14,9 +14,12 @@ #include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/IRndmGenSvc.h" #include "GaudiKernel/RndmGenerators.h" +#include "GaudiKernel/SystemOfUnits.h" #include "GeoPrimitives/GeoPrimitives.h" #include <string> +#include "TrkExInterfaces/IPropagator.h" + class AtlasDetectorID; class Identifier; class TTree; @@ -28,7 +31,6 @@ class TTree; namespace Trk { - class IPropagator; class MagneticFieldProperties; /** @class RiddersAlgorithm @@ -64,77 +66,89 @@ namespace Trk double x0, double x1, double x2); /** member variables for algorithm properties: */ - ToolHandle<IPropagator> m_propagator; - bool m_useCustomField; - bool m_useAlignedSurfaces; - double m_fieldValue; - MagneticFieldProperties* m_magFieldProperties; + PublicToolHandle<IPropagator> m_propagator + {this, "Propagator", "Trk::RungeKuttaPropagator/RungeKuttaPropagator"}; + BooleanProperty m_useCustomField{this, "UseCustomMagneticField", true}; + BooleanProperty m_useAlignedSurfaces{this, "UseAlignedSurfaces", true}; + DoubleProperty m_fieldValue + {this, "CustomFieldValue", 2.*Gaudi::Units::tesla}; + MagneticFieldProperties* m_magFieldProperties = nullptr; /** The smearing */ - double m_sigmaLoc; //!< local sigma of start value - double m_sigmaR; //!< r sigma of start value - double m_minPhi; //!< Minimal phi value - double m_maxPhi; //!< Maximal phi value - double m_minEta; //!< Minimal eta value - double m_maxEta; //!< Maximal eta value - double m_minP; //!< Minimal p value - double m_maxP; //!< Maximal p value + DoubleProperty m_sigmaLoc + {this, "StartPerigeeSigmaLoc", 100.*Gaudi::Units::micrometer}; + DoubleProperty m_sigmaR + {this, "StartPerigeeSigmaR", 0.}; + DoubleProperty m_minPhi{this, "StartPerigeeMinPhi", -M_PI}; + DoubleProperty m_maxPhi{this, "StartPerigeeMaxPhi", M_PI}; + DoubleProperty m_minEta{this, "StartPerigeeMinEta", -2.5}; + DoubleProperty m_maxEta{this, "StartPerigeeMaxEta", 2.5}; + DoubleProperty m_minP + {this, "StartPerigeeMinP", 0.5*Gaudi::Units::GeV}; + DoubleProperty m_maxP + {this, "StartPerigeeMaxP", 50000*Gaudi::Units::GeV}; /** To create the first extimations */ - double m_minimumR; - double m_maximumR; + DoubleProperty m_minimumR{this, "TargetSurfaceMinR", 10.}; + DoubleProperty m_maximumR{this, "TargetSurfaceMaxR", 1000.}; /** variations */ - std::vector<double> m_localVariations; - std::vector<double> m_angularVariations; - std::vector<double> m_qOpVariations; - - TTree* m_validationTree; //!< Root Validation Tree - - std::string m_validationTreeName; //!< validation tree name - to be acessed by this from root - std::string m_validationTreeDescription; //!< validation tree description - second argument in TTree - std::string m_validationTreeFolder; //!< stream/folder to for the TTree to be written out - - int m_steps; - float m_loc1loc1[RIDDLERSSTEPS]; - float m_loc1loc2[RIDDLERSSTEPS]; - float m_loc1phi[RIDDLERSSTEPS]; - float m_loc1theta[RIDDLERSSTEPS]; - float m_loc1qop[RIDDLERSSTEPS]; - float m_loc1steps[RIDDLERSSTEPS]; - - float m_loc2loc1[RIDDLERSSTEPS]; - float m_loc2loc2[RIDDLERSSTEPS]; - float m_loc2phi[RIDDLERSSTEPS]; - float m_loc2theta[RIDDLERSSTEPS]; - float m_loc2qop[RIDDLERSSTEPS]; - float m_loc2steps[RIDDLERSSTEPS]; - - float m_philoc1[RIDDLERSSTEPS]; - float m_philoc2[RIDDLERSSTEPS]; - float m_phiphi[RIDDLERSSTEPS]; - float m_phitheta[RIDDLERSSTEPS]; - float m_phiqop[RIDDLERSSTEPS]; - float m_phisteps[RIDDLERSSTEPS]; - - float m_thetaloc1[RIDDLERSSTEPS]; - float m_thetaloc2[RIDDLERSSTEPS]; - float m_thetaphi[RIDDLERSSTEPS]; - float m_thetatheta[RIDDLERSSTEPS]; - float m_thetaqop[RIDDLERSSTEPS]; - float m_thetasteps[RIDDLERSSTEPS]; - - float m_qoploc1[RIDDLERSSTEPS]; - float m_qoploc2[RIDDLERSSTEPS]; - float m_qopphi[RIDDLERSSTEPS]; - float m_qoptheta[RIDDLERSSTEPS]; - float m_qopqop[RIDDLERSSTEPS]; - float m_qopsteps[RIDDLERSSTEPS]; + DoubleArrayProperty m_localVariations{this, "LocalVariations", {}}; + DoubleArrayProperty m_angularVariations{this, "AngularVariations", {}}; + DoubleArrayProperty m_qOpVariations{this, "QopVariations", {}}; + + TTree* m_validationTree = nullptr; //!< Root Validation Tree + + StringProperty m_validationTreeName + {this, "ValidationTreeName", "RiddersTree", + "validation tree name - to be acessed by this from root"}; + StringProperty m_validationTreeDescription + {this, "ValidationTreeDescription", "Output of the RiddersAlgorithm", + "validation tree description - second argument in TTree"}; + StringProperty m_validationTreeFolder + {this, "ValidationTreeFolder", "/val/RiddersAlgorithm", + "stream/folder to for the TTree to be written out"}; + + int m_steps = 0; + float m_loc1loc1[RIDDLERSSTEPS]{}; + float m_loc1loc2[RIDDLERSSTEPS]{}; + float m_loc1phi[RIDDLERSSTEPS]{}; + float m_loc1theta[RIDDLERSSTEPS]{}; + float m_loc1qop[RIDDLERSSTEPS]{}; + float m_loc1steps[RIDDLERSSTEPS]{}; + + float m_loc2loc1[RIDDLERSSTEPS]{}; + float m_loc2loc2[RIDDLERSSTEPS]{}; + float m_loc2phi[RIDDLERSSTEPS]{}; + float m_loc2theta[RIDDLERSSTEPS]{}; + float m_loc2qop[RIDDLERSSTEPS]{}; + float m_loc2steps[RIDDLERSSTEPS]{}; + + float m_philoc1[RIDDLERSSTEPS]{}; + float m_philoc2[RIDDLERSSTEPS]{}; + float m_phiphi[RIDDLERSSTEPS]{}; + float m_phitheta[RIDDLERSSTEPS]{}; + float m_phiqop[RIDDLERSSTEPS]{}; + float m_phisteps[RIDDLERSSTEPS]{}; + + float m_thetaloc1[RIDDLERSSTEPS]{}; + float m_thetaloc2[RIDDLERSSTEPS]{}; + float m_thetaphi[RIDDLERSSTEPS]{}; + float m_thetatheta[RIDDLERSSTEPS]{}; + float m_thetaqop[RIDDLERSSTEPS]{}; + float m_thetasteps[RIDDLERSSTEPS]{}; + + float m_qoploc1[RIDDLERSSTEPS]{}; + float m_qoploc2[RIDDLERSSTEPS]{}; + float m_qopphi[RIDDLERSSTEPS]{}; + float m_qoptheta[RIDDLERSSTEPS]{}; + float m_qopqop[RIDDLERSSTEPS]{}; + float m_qopsteps[RIDDLERSSTEPS]{}; /** Random Number setup */ - Rndm::Numbers* m_gaussDist; - Rndm::Numbers* m_flatDist; + Rndm::Numbers* m_gaussDist = nullptr; + Rndm::Numbers* m_flatDist = nullptr; }; } // end of namespace diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorComparisonTest.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorComparisonTest.cxx index 94bfe972a72f..7e85f9d15577 100644 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorComparisonTest.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorComparisonTest.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -16,7 +16,6 @@ #include "TrkParametersBase/ParametersT.h" #include "EventPrimitives/EventPrimitives.h" -#include "GaudiKernel/SystemOfUnits.h" #include "GaudiKernel/ISvcLocator.h" // ACTS @@ -48,54 +47,19 @@ using xclock = std::chrono::steady_clock; //================ Constructor ================================================= -Trk::ExtrapolatorComparisonTest::ExtrapolatorComparisonTest(const std::string& name, ISvcLocator* pSvcLocator) - : - AthReentrantAlgorithm(name,pSvcLocator), - m_sigmaD0(17.*Gaudi::Units::micrometer), - m_sigmaZ0(50.*Gaudi::Units::millimeter), - m_minPhi(-M_PI), - m_maxPhi(M_PI), - m_minEta(-3.), - m_maxEta(3.), - m_minPt(0.5*Gaudi::Units::GeV), - m_maxPt(50000.*Gaudi::Units::GeV), - m_particleType(2), - m_referenceSurfaces(0), - m_eventsPerExecute(1), - m_atlasPropResultWriterSvc("ATLASPropResultRootWriterSvc", name), - m_actsPropResultWriterSvc("ACTSPropResultRootWriterSvc", name), - m_rndmSvc("AthRNGSvc", name) -{ - // algorithm steering - declareProperty("StartPerigeeSigmaD0" , m_sigmaD0 ); - declareProperty("StartPerigeeSigmaZ0" , m_sigmaZ0 ); - declareProperty("StartPerigeeMinPhi" , m_minPhi ); - declareProperty("StartPerigeeMaxPhi" , m_maxPhi ); - declareProperty("StartPerigeeMinEta" , m_minEta ); - declareProperty("StartPerigeeMaxEta" , m_maxEta ); - declareProperty("StartPerigeeMinPt" , m_minPt ); - declareProperty("StartPerigeeMaxPt" , m_maxPt ); - declareProperty("ParticleType" , m_particleType ); - declareProperty("ReferenceSurfaceRadius" , m_referenceSurfaceRadius ); - declareProperty("ReferenceSurfaceHalfZ" , m_referenceSurfaceHalflength); - declareProperty("EventsPerExecute" , m_eventsPerExecute ); - declareProperty("ATLASPropResultRootWriter" , m_atlasPropResultWriterSvc ); - declareProperty("ACTSPropResultRootWriter" , m_actsPropResultWriterSvc ); - declareProperty("RndmSvc" , m_rndmSvc ); -} +Trk::ExtrapolatorComparisonTest::ExtrapolatorComparisonTest(const std::string& name, ISvcLocator* pSvcLocator) : + AthReentrantAlgorithm(name,pSvcLocator) {} //================ Destructor ================================================= Trk::ExtrapolatorComparisonTest::~ExtrapolatorComparisonTest() { // cleanup of the Trk::Surfaces - std::vector< std::vector< const Trk::Surface* > >::const_iterator atlasSurfaceTripleIter = m_atlasReferenceSurfaceTriples.begin(); - std::vector< std::vector< const Trk::Surface* > >::const_iterator atlasSurfaceTripleIterEnd = m_atlasReferenceSurfaceTriples.end(); - for ( ; atlasSurfaceTripleIter != atlasSurfaceTripleIterEnd; ++atlasSurfaceTripleIter) { - std::vector<const Trk::Surface*>::const_iterator surfIter = (*atlasSurfaceTripleIter).begin(); - std::vector<const Trk::Surface*>::const_iterator surfIterEnd = (*atlasSurfaceTripleIter).end(); - for ( ; surfIter != surfIterEnd; delete (*surfIter), ++surfIter); - } + for (const auto& surfaceTriple : m_atlasReferenceSurfaceTriples) { + for (const auto* surface : surfaceTriple) { + delete surface; + } + } } @@ -118,8 +82,8 @@ StatusCode Trk::ExtrapolatorComparisonTest::initialize() // loop over it and create the for (unsigned int surface = 0; surface < m_referenceSurfaces; surface++) { - double radius = m_referenceSurfaceRadius.at(surface); - double halfZ = m_referenceSurfaceHalflength.at(surface); + double radius = m_referenceSurfaceRadius[surface]; + double halfZ = m_referenceSurfaceHalflength[surface]; // create the Surface triplet std::vector< const Trk::Surface*> trkSurfaceTriplet; @@ -224,7 +188,7 @@ StatusCode Trk::ExtrapolatorComparisonTest::execute(const EventContext& ctx) con *destinationSurface, Trk::alongMomentum, true, - (Trk::ParticleHypothesis)m_particleType).release(); + static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release(); auto end_fwd = xclock::now(); float ms_fwd = std::chrono::duration_cast<std::chrono::milliseconds>(end_fwd-start_fwd).count(); @@ -243,7 +207,7 @@ StatusCode Trk::ExtrapolatorComparisonTest::execute(const EventContext& ctx) con atlPerigee->associatedSurface(), Trk::oppositeMomentum, true, - (Trk::ParticleHypothesis)m_particleType).release(); + static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release(); auto end_bkw = xclock::now(); float ms_bkw = std::chrono::duration_cast<std::chrono::milliseconds>(end_bkw-start_bkw).count(); diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx index 72fa6b5939a3..d1fa581330be 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/ExtrapolatorTest.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -8,63 +8,18 @@ // Tracking #include "TrkExAlgs/ExtrapolatorTest.h" -#include "TrkExInterfaces/IExtrapolator.h" -#include "TrkExInterfaces/IPropagator.h" #include "TrkSurfaces/CylinderSurface.h" #include "TrkSurfaces/DiscSurface.h" #include "TrkEventPrimitives/ParticleHypothesis.h" #include "EventPrimitives/EventPrimitives.h" #include "TrkGeometry/MagneticFieldProperties.h" -#include "GaudiKernel/SystemOfUnits.h" // std #include <cmath> //================ Constructor ================================================= -Trk::ExtrapolatorTest::ExtrapolatorTest(const std::string& name, ISvcLocator* pSvcLocator) - : - AthAlgorithm(name,pSvcLocator), - m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"), - m_propagator("Trk::RungeKuttaPropagator/RungeKuttaPropagator"), - m_magFieldProperties(nullptr), - m_gaussDist(nullptr), - m_flatDist(nullptr), - m_sigmaD0(17.*Gaudi::Units::micrometer), - m_sigmaZ0(50.*Gaudi::Units::millimeter), - m_minPhi(-M_PI), - m_maxPhi(M_PI), - m_minEta(-3.), - m_maxEta(3.), - m_minP(0.5*Gaudi::Units::GeV), - m_maxP(50000.*Gaudi::Units::GeV), - m_direction(1), - m_particleType(2), - m_referenceSurfaces(0), - m_eventsPerExecute(-1), - m_useExtrapolator(false) -{ - // used algorithms and alg tools - declareProperty("Extrapolator", m_extrapolator); - declareProperty("Propagator", m_propagator); - - // algorithm steering - declareProperty("StartPerigeeSigmaD0" , m_sigmaD0); - declareProperty("StartPerigeeSigmaZ0" , m_sigmaZ0); - declareProperty("StartPerigeeMinPhi" , m_minPhi); - declareProperty("StartPerigeeMaxPhi" , m_maxPhi); - declareProperty("StartPerigeeMinEta" , m_minEta); - declareProperty("StartPerigeeMaxEta" , m_maxEta); - declareProperty("StartPerigeeMinP" , m_minP); - declareProperty("StartPerigeeMaxP" , m_maxP); - declareProperty("StartDirection" , m_direction); - declareProperty("ParticleType" , m_particleType); - - // template for property decalration - declareProperty("ReferenceSurfaceRadius", m_referenceSurfaceRadius); - declareProperty("ReferenceSurfaceHalfZ", m_referenceSurfaceHalflength); - declareProperty("EventsPerExecute", m_eventsPerExecute ); - declareProperty("UseExtrapolator", m_useExtrapolator ); -} +Trk::ExtrapolatorTest::ExtrapolatorTest(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name,pSvcLocator) {} //================ Destructor ================================================= @@ -73,17 +28,11 @@ Trk::ExtrapolatorTest::~ExtrapolatorTest() delete m_gaussDist; delete m_flatDist; // cleanup of the surfaces - std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIter = m_referenceSurfaceTriples.begin(); - std::vector< std::vector< const Trk::Surface* > >::const_iterator surfaceTripleIterEnd = m_referenceSurfaceTriples.end(); - for ( ; surfaceTripleIter != surfaceTripleIterEnd; ++surfaceTripleIter) - { - std::vector<const Trk::Surface*>::const_iterator surfIter = (*surfaceTripleIter).begin(); - std::vector<const Trk::Surface*>::const_iterator surfIterEnd = (*surfaceTripleIter).end(); - for ( ; surfIter != surfIterEnd; delete (*surfIter), ++surfIter); - - - } - + for (const auto& surfaceTriple : m_referenceSurfaceTriples) { + for (const auto* surface : surfaceTriple) { + delete surface; + } + } } @@ -93,18 +42,10 @@ StatusCode Trk::ExtrapolatorTest::initialize() { // Code entered here will be executed once at program start. - msg(MSG::INFO) << " initialize()" << endmsg; + ATH_MSG_INFO(" initialize()"); - // Get Extrapolator from ToolService - if (m_extrapolator.retrieve().isFailure()) { - msg(MSG::FATAL) << "Could not retrieve Tool " << m_extrapolator << ". Exiting."<<endmsg; - return StatusCode::FAILURE; - } - // Get Propagator from ToolService - if (m_propagator.retrieve().isFailure()) { - msg(MSG::FATAL) << "Could not retrieve Tool " << m_propagator << ". Exiting."<<endmsg; - return StatusCode::FAILURE; - } + ATH_CHECK( m_extrapolator.retrieve() ); + ATH_CHECK( m_propagator.retrieve() ); m_magFieldProperties = new Trk::MagneticFieldProperties(); @@ -210,7 +151,7 @@ void Trk::ExtrapolatorTest::runTest( const Trk::Perigee& initialPerigee ) { *destinationSurface, propagationDirection, false, - (Trk::ParticleHypothesis)m_particleType).release() + static_cast<Trk::ParticleHypothesis>(m_particleType.value())).release() : m_propagator @@ -220,21 +161,20 @@ void Trk::ExtrapolatorTest::runTest( const Trk::Perigee& initialPerigee ) { propagationDirection, false, *m_magFieldProperties, - (Trk::ParticleHypothesis)m_particleType) + static_cast<Trk::ParticleHypothesis>(m_particleType.value())) .release(); if (destParameters) { - // global position parameter - //const Amg::Vector3D& gp = destParameters->position(); - - // intersection output - ATH_MSG_VERBOSE(" [ intersection ] with surface at (x,y,z) = " << destParameters->position().x() << ", " << destParameters->position().y() << ", " << destParameters->position().z() ); - + // intersection output + ATH_MSG_VERBOSE(" [ intersection ] with surface at (x,y,z) = " << + destParameters->position().x() << ", " << + destParameters->position().y() << ", " << + destParameters->position().z() ); } else if (!destParameters) - ATH_MSG_DEBUG(" Extrapolation not successful! " ); - delete destParameters; + ATH_MSG_DEBUG(" Extrapolation not successful! " ); - } + delete destParameters; + } } //============================================================================================ diff --git a/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx b/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx index 151615cafb0b..97c31691f76e 100755 --- a/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx +++ b/Tracking/TrkExtrapolation/TrkExAlgs/src/RiddersAlgorithm.cxx @@ -1,18 +1,13 @@ /* - Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// // RiddersAlgorithm.cxx, (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// - - - - #include "TrkExAlgs/RiddersAlgorithm.h" // Trk stuff -#include "TrkExInterfaces/IPropagator.h" #include "TrkEventPrimitives/TransportJacobian.h" #include "TrkGeometry/MagneticFieldProperties.h" #include "TrkSurfaces/PlaneSurface.h" @@ -22,110 +17,17 @@ // Validation mode - TTree includes #include "TTree.h" #include "GaudiKernel/ITHistSvc.h" -#include "GaudiKernel/SystemOfUnits.h" #include <cmath> //================ Constructor ================================================= -Trk::RiddersAlgorithm::RiddersAlgorithm(const std::string& name, ISvcLocator* pSvcLocator) - : - AthAlgorithm(name,pSvcLocator), - m_propagator("Trk::RungeKuttaPropagator/RungeKuttaPropagator"), - m_useCustomField(true), - m_useAlignedSurfaces(true), - m_fieldValue(2.*Gaudi::Units::tesla), - m_magFieldProperties(nullptr), - m_sigmaLoc(100.*Gaudi::Units::micrometer), - m_sigmaR(0.0), - m_minPhi(-M_PI), - m_maxPhi(M_PI), - m_minEta(-2.5), - m_maxEta(2.5), - m_minP(0.5*Gaudi::Units::GeV), - m_maxP(50000.*Gaudi::Units::GeV), - m_minimumR(10.), - m_maximumR(1000.), - m_localVariations(), - m_angularVariations(), - m_qOpVariations(), - m_validationTree(nullptr), - m_validationTreeName("RiddersTree"), - m_validationTreeDescription("Output of the RiddersAlgorithm"), - m_validationTreeFolder("/val/RiddersAlgorithm"), - m_steps(0), - m_loc1loc1{}, - m_loc1loc2{}, - m_loc1phi{}, - m_loc1theta{}, - m_loc1qop{}, - m_loc1steps{}, - - m_loc2loc1{}, - m_loc2loc2{}, - m_loc2phi{}, - m_loc2theta{}, - m_loc2qop{}, - m_loc2steps{}, - - m_philoc1{}, - m_philoc2{}, - m_phiphi{}, - m_phitheta{}, - m_phiqop{}, - m_phisteps{}, - - m_thetaloc1{}, - m_thetaloc2{}, - m_thetaphi{}, - m_thetatheta{}, - m_thetaqop{}, - m_thetasteps{}, - - m_qoploc1{}, - m_qoploc2{}, - m_qopphi{}, - m_qoptheta{}, - m_qopqop{}, - m_qopsteps{}, - - m_gaussDist(nullptr), - m_flatDist(nullptr) -{ - - - declareProperty("Propagator" , m_propagator); - declareProperty("CustomFieldValue" , m_fieldValue); - declareProperty("UseCustomMagneticField" , m_useCustomField); - declareProperty("UseAlignedSurfaces" , m_useAlignedSurfaces); - - // TTree handling - declareProperty("ValidationTreeName", m_validationTreeName); - declareProperty("ValidationTreeDescription", m_validationTreeDescription); - declareProperty("ValidationTreeFolder", m_validationTreeFolder); - - declareProperty("StartPerigeeSigmaLoc" , m_sigmaLoc); - declareProperty("StartPerigeeMinPhi" , m_minPhi); - declareProperty("StartPerigeeMaxPhi" , m_maxPhi); - declareProperty("StartPerigeeMinEta" , m_minEta); - declareProperty("StartPerigeeMaxEta" , m_maxEta); - declareProperty("StartPerigeeMinP" , m_minP); - declareProperty("StartPerigeeMaxP" , m_maxP); - - declareProperty("TargetSurfaceMinR" , m_minimumR); - declareProperty("TargetSurfaceMaxR" , m_maximumR); - - declareProperty("LocalVariations" , m_localVariations); - declareProperty("AngularVariations" , m_angularVariations); - declareProperty("QopVariations" , m_qOpVariations); - - -} +Trk::RiddersAlgorithm::RiddersAlgorithm(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name,pSvcLocator) {} //================ Destructor ================================================= Trk::RiddersAlgorithm::~RiddersAlgorithm() { - delete m_gaussDist; delete m_flatDist; delete m_magFieldProperties; @@ -139,11 +41,7 @@ StatusCode Trk::RiddersAlgorithm::initialize() // Code entered here will be executed once at program start. ATH_MSG_INFO( " initialize()" ); - // Get Extrapolator from ToolService - if (m_propagator.retrieve().isFailure()) { - ATH_MSG_FATAL( "Could not retrieve Tool " << m_propagator << ". Exiting." ); - return StatusCode::FAILURE; - } + ATH_CHECK( m_propagator.retrieve() ); // Prepare the magnetic field properties if (!m_useCustomField) @@ -160,75 +58,67 @@ StatusCode Trk::RiddersAlgorithm::initialize() m_flatDist = new Rndm::Numbers(randSvc(), Rndm::Flat(0.,1.)); - // create the new Tree - m_validationTree = new TTree(m_validationTreeName.c_str(), m_validationTreeDescription.c_str()); - - // the branches for the start - m_validationTree->Branch("RiddersSteps", &m_steps, "steps/I"); - // loc 1 - m_validationTree->Branch("Loc1Loc1", m_loc1loc1, "loc1loc1[steps]/F"); - m_validationTree->Branch("Loc1Loc2", m_loc1loc2, "loc1loc2[steps]/F"); - m_validationTree->Branch("Loc1Phi", m_loc1phi, "loc1phi[steps]/F"); - m_validationTree->Branch("Loc1Theta", m_loc1theta, "loc1theta[steps]/F"); - m_validationTree->Branch("Loc1qOp", m_loc1qop, "loc1qop[steps]/F"); - m_validationTree->Branch("Loc1Steps", m_loc1steps, "loc1steps[steps]/F"); - // loc 2 - m_validationTree->Branch("Loc2Loc1", m_loc2loc1, "loc2loc1[steps]/F"); - m_validationTree->Branch("Loc2Loc2", m_loc2loc2, "loc2loc2[steps]/F"); - m_validationTree->Branch("Loc2Phi", m_loc2phi, "loc2phi[steps]/F"); - m_validationTree->Branch("Loc2Theta", m_loc2theta, "loc2theta[steps]/F"); - m_validationTree->Branch("Loc2qOp", m_loc2qop, "loc2qop[steps]/F"); - m_validationTree->Branch("Loc2Steps", m_loc2steps, "loc2steps[steps]/F"); - // phi - m_validationTree->Branch("PhiLoc1", m_philoc1, "philoc1[steps]/F"); - m_validationTree->Branch("PhiLoc2", m_philoc2 , "philoc2[steps]/F"); - m_validationTree->Branch("PhiPhi", m_phiphi, "phiphi[steps]/F"); - m_validationTree->Branch("PhiTheta", m_phitheta, "phitheta[steps]/F"); - m_validationTree->Branch("PhiqOp", m_phiqop, "phiqop[steps]/F"); - m_validationTree->Branch("PhiSteps", m_phisteps, "phisteps[steps]/F"); - // Theta - m_validationTree->Branch("ThetaLoc1", m_thetaloc1, "thetaloc1[steps]/F"); - m_validationTree->Branch("ThetaLoc2", m_thetaloc2, "thetaloc2[steps]/F"); - m_validationTree->Branch("ThetaPhi", m_thetaphi, "thetaphi[steps]/F"); - m_validationTree->Branch("ThetaTheta", m_thetatheta, "thetatheta[steps]/F"); - m_validationTree->Branch("ThetaqOp", m_thetaqop, "thetaqop[steps]/F"); - m_validationTree->Branch("ThetaSteps", m_thetasteps, "thetasteps[steps]/F"); - // Qop - m_validationTree->Branch("QopLoc1", m_qoploc1, "qoploc1[steps]/F"); - m_validationTree->Branch("QopLoc2", m_qoploc2, "qoploc2[steps]/F"); - m_validationTree->Branch("QopPhi", m_qopphi, "qopphi[steps]/F"); - m_validationTree->Branch("QopTheta", m_qoptheta, "qoptheta[steps]/F"); - m_validationTree->Branch("QopqOp", m_qopqop, "qopqop[steps]/F"); - m_validationTree->Branch("QopSteps", m_qopsteps, "qopsteps[steps]/F"); - - // now register the Tree - SmartIF<ITHistSvc> tHistSvc{service("THistSvc")}; - if (!tHistSvc){ - ATH_MSG_ERROR( "initialize() Could not find Hist Service -> Switching ValidationMode Off !" ); - delete m_validationTree; m_validationTree = nullptr; - } - if ((tHistSvc->regTree(m_validationTreeFolder, m_validationTree)).isFailure()) { - ATH_MSG_ERROR( "initialize() Could not register the validation Tree -> Switching ValidationMode Off !" ); - delete m_validationTree; m_validationTree = nullptr; - } - - if (m_localVariations.empty()){ - m_localVariations.push_back(0.01); - m_localVariations.push_back(0.001); - m_localVariations.push_back(0.0001); + // create the new Tree + m_validationTree = new TTree(m_validationTreeName.value().c_str(), + m_validationTreeDescription.value().c_str()); + + // the branches for the start + m_validationTree->Branch("RiddersSteps", &m_steps, "steps/I"); + // loc 1 + m_validationTree->Branch("Loc1Loc1", m_loc1loc1, "loc1loc1[steps]/F"); + m_validationTree->Branch("Loc1Loc2", m_loc1loc2, "loc1loc2[steps]/F"); + m_validationTree->Branch("Loc1Phi", m_loc1phi, "loc1phi[steps]/F"); + m_validationTree->Branch("Loc1Theta", m_loc1theta, "loc1theta[steps]/F"); + m_validationTree->Branch("Loc1qOp", m_loc1qop, "loc1qop[steps]/F"); + m_validationTree->Branch("Loc1Steps", m_loc1steps, "loc1steps[steps]/F"); + // loc 2 + m_validationTree->Branch("Loc2Loc1", m_loc2loc1, "loc2loc1[steps]/F"); + m_validationTree->Branch("Loc2Loc2", m_loc2loc2, "loc2loc2[steps]/F"); + m_validationTree->Branch("Loc2Phi", m_loc2phi, "loc2phi[steps]/F"); + m_validationTree->Branch("Loc2Theta", m_loc2theta, "loc2theta[steps]/F"); + m_validationTree->Branch("Loc2qOp", m_loc2qop, "loc2qop[steps]/F"); + m_validationTree->Branch("Loc2Steps", m_loc2steps, "loc2steps[steps]/F"); + // phi + m_validationTree->Branch("PhiLoc1", m_philoc1, "philoc1[steps]/F"); + m_validationTree->Branch("PhiLoc2", m_philoc2 , "philoc2[steps]/F"); + m_validationTree->Branch("PhiPhi", m_phiphi, "phiphi[steps]/F"); + m_validationTree->Branch("PhiTheta", m_phitheta, "phitheta[steps]/F"); + m_validationTree->Branch("PhiqOp", m_phiqop, "phiqop[steps]/F"); + m_validationTree->Branch("PhiSteps", m_phisteps, "phisteps[steps]/F"); + // Theta + m_validationTree->Branch("ThetaLoc1", m_thetaloc1, "thetaloc1[steps]/F"); + m_validationTree->Branch("ThetaLoc2", m_thetaloc2, "thetaloc2[steps]/F"); + m_validationTree->Branch("ThetaPhi", m_thetaphi, "thetaphi[steps]/F"); + m_validationTree->Branch("ThetaTheta", m_thetatheta, "thetatheta[steps]/F"); + m_validationTree->Branch("ThetaqOp", m_thetaqop, "thetaqop[steps]/F"); + m_validationTree->Branch("ThetaSteps", m_thetasteps, "thetasteps[steps]/F"); + // Qop + m_validationTree->Branch("QopLoc1", m_qoploc1, "qoploc1[steps]/F"); + m_validationTree->Branch("QopLoc2", m_qoploc2, "qoploc2[steps]/F"); + m_validationTree->Branch("QopPhi", m_qopphi, "qopphi[steps]/F"); + m_validationTree->Branch("QopTheta", m_qoptheta, "qoptheta[steps]/F"); + m_validationTree->Branch("QopqOp", m_qopqop, "qopqop[steps]/F"); + m_validationTree->Branch("QopSteps", m_qopsteps, "qopsteps[steps]/F"); + + // now register the Tree + SmartIF<ITHistSvc> tHistSvc{service("THistSvc")}; + if (!tHistSvc){ + ATH_MSG_ERROR( "initialize() Could not find Hist Service -> Switching ValidationMode Off !" ); + delete m_validationTree; m_validationTree = nullptr; } - - if (m_angularVariations.empty()){ - m_angularVariations.push_back(0.01); - m_angularVariations.push_back(0.001); - m_angularVariations.push_back(0.0001); + if ((tHistSvc->regTree(m_validationTreeFolder, m_validationTree)).isFailure()) { + ATH_MSG_ERROR( "initialize() Could not register the validation Tree -> Switching ValidationMode Off !" ); + delete m_validationTree; m_validationTree = nullptr; } - if (m_qOpVariations.empty()){ - m_qOpVariations.push_back(0.0001); - m_qOpVariations.push_back(0.00001); - m_qOpVariations.push_back(0.000001); - } + if (m_localVariations.empty()) + m_localVariations = {0.01, 0.001, 0.0001}; + + if (m_angularVariations.empty()) + m_angularVariations = {0.01, 0.001, 0.0001}; + + if (m_qOpVariations.empty()) + m_qOpVariations = {0.0001, 0.00001, 0.000001}; ATH_MSG_INFO( "initialize() successful in " ); return StatusCode::SUCCESS; -- GitLab