diff --git a/PropagatorAlgSvc.py b/PropagatorAlgSvc.py deleted file mode 100644 index 61b20dc..0000000 --- a/PropagatorAlgSvc.py +++ /dev/null @@ -1,53 +0,0 @@ -import os -import sys -from pprint import pprint -from Gaudi.Configuration import * - -from Configurables import PropagatorAlg -from Configurables import GeoSvc - -sys.path.append('/home/delitez/ACTS/spack/k4actstracking') -import actsUnits - - -algList = [] - -b = PropagatorAlg("PropagatorAlg") -# -b.mode = 0 -b.sterileLogger = False -b.debugOutput = False -b.energyLoss = True -b.multipleScattering = True -b.recordMaterialInteractions = True -b.ntests = 100 -b.d0Sigma = 15 * actsUnits.um -b.z0Sigma = 55 * actsUnits.mm -b.phiSigma = 0.001 -b.thetaSigma = 0.001 -b.covarianceTransport = False -b.qpSigma = 0.0001 / 1 * actsUnits.GeV -b.tSigma = 1 * actsUnits.ns -b.ptLoopers = 500 * actsUnits.MeV -b.maxStepSize = 3 * actsUnits.m -b.sensitiveIDopt = 0 - -algList.append(b) - - -a = GeoSvc("GeoSvc") -a.detectors = ["/home/delitez/ACTS/acts/thirdparty/OpenDataDetector/xml/OpenDataDetector.xml"] -a.debugGeometry = True -a.outputFileName = "MyObjFile" - - -from Configurables import ApplicationMgr - -from Configurables import THistSvc -THistSvc().Output = ["rec DATAFILE='propagatorAlgOutput.root' TYP='ROOT' OPT='RECREATE'"] -THistSvc().OutputLevel = DEBUG -THistSvc().PrintAll = True -THistSvc().AutoSave = True -THistSvc().AutoFlush = True - -ApplicationMgr(TopAlg=algList, EvtSel="NONE", EvtMax=500, ExtSvc=[a], OutputLevel=DEBUG) diff --git a/k4ActsTracking/src/components/GeoSvc.cpp b/k4ActsTracking/src/components/GeoSvc.cpp index dbaecc2..f3bcb59 100644 --- a/k4ActsTracking/src/components/GeoSvc.cpp +++ b/k4ActsTracking/src/components/GeoSvc.cpp @@ -97,8 +97,6 @@ StatusCode GeoSvc::buildDD4HepGeo() { /// Create a geometry OBJ file StatusCode GeoSvc::createGeoObj() { - - Acts::ObjVisualization3D m_obj; if (!m_trackingGeo) { diff --git a/k4ActsTracking/src/components/GeoSvc.h b/k4ActsTracking/src/components/GeoSvc.h index 840eb61..18057f0 100644 --- a/k4ActsTracking/src/components/GeoSvc.h +++ b/k4ActsTracking/src/components/GeoSvc.h @@ -38,7 +38,7 @@ class GeoSvc : public extends { Acts::GeometryContext m_trackingGeoCtx; /// ACTS Tracking Geometry -// std::unique_ptr m_trackingGeo{nullptr}; + // std::unique_ptr m_trackingGeo{nullptr}; std::shared_ptr m_trackingGeo{nullptr}; /// ACTS Material Decorator @@ -73,9 +73,9 @@ class GeoSvc : public extends { StatusCode createGeoObj(); -// virtual const Acts::TrackingGeometry& trackingGeometry() const; -// virtual std::shared_ptr m_trackingGeo{nullptr}; - virtual std::shared_ptr trackingGeometry() const; + // virtual const Acts::TrackingGeometry& trackingGeometry() const; + // virtual std::shared_ptr m_trackingGeo{nullptr}; + virtual std::shared_ptr trackingGeometry() const; }; //inline const Acts::TrackingGeometry& GeoSvc::trackingGeometry() const { return *m_trackingGeo; } diff --git a/k4ActsTracking/src/components/IPropagatorAlg.h b/k4ActsTracking/src/components/IPropagatorAlg.h index d7ae684..d26d22e 100644 --- a/k4ActsTracking/src/components/IPropagatorAlg.h +++ b/k4ActsTracking/src/components/IPropagatorAlg.h @@ -8,7 +8,6 @@ #include class GAUDI_API IPropagatorAlg : virtual public IService { - public: DeclareInterfaceID(IPropagatorAlg, 1, 0); diff --git a/k4ActsTracking/src/components/PropagationOptions.hpp b/k4ActsTracking/src/components/PropagationOptions.hpp index d9aa47b..75c5d60 100644 --- a/k4ActsTracking/src/components/PropagationOptions.hpp +++ b/k4ActsTracking/src/components/PropagationOptions.hpp @@ -20,182 +20,138 @@ namespace ActsExamples { -namespace Options { - -/// @brief PropagatorAlg options -/// -/// @tparam aopt_t Type of the options class from boost -inline void addPropagationOptions( - boost::program_options::options_description& opt) { - namespace po = boost::program_options; - using namespace Acts::UnitLiterals; - opt.add_options()( - "prop-debug", po::value()->default_value(false), - "Run in debug mode, will create propagation screen output.")( - "prop-step-collection", - po::value()->default_value("propagation-steps"), - "Propgation step collection.")( - "prop-stepper", po::value()->default_value(1), - "Propgation type: 0 (StraightLine), 1 (Eigen), 2 (Atlas).")( - "prop-mode", po::value()->default_value(0), - "Propgation modes: 0 (inside-out), 1 (surface to surface).")( - "prop-cov", po::value()->default_value(false), - "Propagate (random) test covariances.")( - "prop-energyloss", po::value()->default_value(true), - "Apply energy loss correction - in extrapolation mode only.")( - "prop-scattering", po::value()->default_value(true), - "Apply scattering correction - in extrapolation mode only.")( - "prop-record-material", po::value()->default_value(true), - "Record the material interaction and - in extrapolation mode only.")( - "prop-material-collection", - po::value()->default_value("propagation-material"), - "Propagation material collection.")( - "prop-ntests", po::value()->default_value(1000), - "Number of tests performed.")("prop-resolve-material", - po::value()->default_value(true), - "Resolve all smaterial surfaces.")( - "prop-resolve-passive", po::value()->default_value(false), - "Resolve all passive surfaces.")("prop-resolve-sensitive", - po::value()->default_value(true), - "Resolve all sensitive surfaces.")( - "prop-d0-sigma", po::value()->default_value(15_um), - "Sigma of the transverse impact parameter [in mm].")( - "prop-z0-sigma", po::value()->default_value(55_mm), - "Sigma of the longitudinal impact parameter [in mm].")( - "prop-phi-sigma", po::value()->default_value(0.001), - "Sigma of the azimuthal angle [in rad].")( - "prop-theta-sigma", po::value()->default_value(0.001), - "Sigma of the polar angle [in rad].")( - "prop-qp-sigma", po::value()->default_value(0.0001 / 1_GeV), - "Sigma of the signed inverse momentum [in GeV^{-1}].")( - "prop-t-sigma", po::value()->default_value(1_ns), - "Sigma of the time parameter [in ns].")( - "prop-corr-offd", po::value>(), - "The 15 off-diagonal correlation rho(d0,z0), rho(d0,phi), [...], " - "rho(z0,phi), rho(z0, theta), [...], rho(qop,t). Row-wise.")( - "prop-phi-range", po::value>()->default_value({{-M_PI, M_PI}}), - "Azimutal angle phi range for proprapolated tracks.")( - "prop-eta-range", po::value>()->default_value({{-4., 4.}}), - "Pseudorapidity range for proprapolated tracks.")( - "prop-pt-range", - po::value>()->default_value({{100_MeV, 100_GeV}}), - "Transverse momentum range for proprapolated tracks [in GeV].")( - "prop-max-stepsize", po::value()->default_value(3_m), - "Maximum step size for the propagation [in mm].")( - "prop-pt-loopers", po::value()->default_value(500_MeV), - "Transverse momentum below which loops are being detected [in GeV]."); -} - -/// Read the pgropagator options and return a Config file -/// -/// @tparam vmap_t is the Type of the Parameter map to be read out -/// @tparam propagator_t is the Type of the Propagator used -/// -/// @returns a Config object for the PropagatorAlg -inline PropagatorAlg::Config readPropagationConfig( - const boost::program_options::variables_map& vm) { - using namespace Acts::UnitLiterals; - PropagatorAlg::Config pAlgConfig; - - auto iphir = vm["prop-phi-range"].template as>(); - auto ietar = vm["prop-eta-range"].template as>(); - auto iptr = vm["prop-pt-range"].template as>(); - - /// Material interaction behavior - pAlgConfig.energyLoss = vm["prop-energyloss"].template as(); - pAlgConfig.multipleScattering = vm["prop-scattering"].template as(); - pAlgConfig.recordMaterialInteractions = - vm["prop-record-material"].template as(); - - /// Create the config for the Extrapoaltion algorithm - pAlgConfig.debugOutput = vm["prop-debug"].template as(); - pAlgConfig.ntests = vm["prop-ntests"].template as(); - pAlgConfig.mode = vm["prop-mode"].template as(); - pAlgConfig.d0Sigma = vm["prop-d0-sigma"].template as() * 1_mm; - pAlgConfig.z0Sigma = vm["prop-z0-sigma"].template as() * 1_mm; - pAlgConfig.phiSigma = vm["prop-phi-sigma"].template as(); - pAlgConfig.thetaSigma = vm["prop-theta-sigma"].template as(); - pAlgConfig.qpSigma = vm["prop-qp-sigma"].template as() / 1_GeV; - pAlgConfig.tSigma = vm["prop-t-sigma"].template as() * 1_ns; - - pAlgConfig.phiRange = {iphir[0], iphir[1]}; - pAlgConfig.etaRange = {ietar[0], ietar[1]}; - pAlgConfig.ptRange = {iptr[0] * 1_GeV, iptr[1] * 1_GeV}; - pAlgConfig.ptLoopers = vm["prop-pt-loopers"].template as() * 1_GeV; - pAlgConfig.maxStepSize = vm["prop-max-stepsize"].template as() * 1_mm; - - pAlgConfig.propagationStepCollection = - vm["prop-step-collection"].template as(); - pAlgConfig.propagationMaterialCollection = - vm["prop-material-collection"].template as(); - - /// The covariance transport - if (vm["prop-cov"].template as()) { - /// Set the covariance transport to true - pAlgConfig.covarianceTransport = true; - /// Set the covariance matrix - pAlgConfig.covariances(Acts::BoundIndices::eBoundLoc0) = - pAlgConfig.d0Sigma * pAlgConfig.d0Sigma; - pAlgConfig.covariances(Acts::BoundIndices::eBoundLoc1) = - pAlgConfig.z0Sigma * pAlgConfig.z0Sigma; - pAlgConfig.covariances(Acts::BoundIndices::eBoundPhi) = - pAlgConfig.phiSigma * pAlgConfig.phiSigma; - pAlgConfig.covariances(Acts::BoundIndices::eBoundTheta) = - pAlgConfig.thetaSigma * pAlgConfig.thetaSigma; - pAlgConfig.covariances(Acts::BoundIndices::eBoundQOverP) = - pAlgConfig.qpSigma * pAlgConfig.qpSigma; - pAlgConfig.covariances(Acts::BoundIndices::eBoundTime) = - pAlgConfig.tSigma * pAlgConfig.tSigma; - - // Only if they are properly defined, assign off-diagonals - if (vm.count("prop-corr-offd")) { - auto readOffd = vm["prop-corr-offd"].template as>(); - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, - Acts::BoundIndices::eBoundLoc1) = readOffd[0]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, - Acts::BoundIndices::eBoundPhi) = readOffd[1]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, - Acts::BoundIndices::eBoundTheta) = readOffd[2]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, - Acts::BoundIndices::eBoundQOverP) = readOffd[3]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, - Acts::BoundIndices::eBoundTime) = readOffd[4]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, - Acts::BoundIndices::eBoundPhi) = readOffd[5]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, - Acts::BoundIndices::eBoundTheta) = readOffd[6]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, - Acts::BoundIndices::eBoundQOverP) = readOffd[7]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, - Acts::BoundIndices::eBoundTime) = readOffd[8]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, - Acts::BoundIndices::eBoundTheta) = readOffd[9]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, - Acts::BoundIndices::eBoundQOverP) = readOffd[10]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, - Acts::BoundIndices::eBoundTime) = readOffd[11]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundTheta, - Acts::BoundIndices::eBoundQOverP) = readOffd[12]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundTheta, - Acts::BoundIndices::eBoundTime) = readOffd[13]; - pAlgConfig.correlations(Acts::BoundIndices::eBoundQOverP, - Acts::BoundIndices::eBoundTime) = readOffd[14]; - } else { - /// Some pre-defined values (non-trivial helical correlations) - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, - Acts::BoundIndices::eBoundPhi) = -0.8; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, - Acts::BoundIndices::eBoundQOverP) = -0.3; - pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, - Acts::BoundIndices::eBoundTheta) = -0.8; - pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, - Acts::BoundIndices::eBoundQOverP) = 0.4; + namespace Options { + + /// @brief PropagatorAlg options + /// + /// @tparam aopt_t Type of the options class from boost + inline void addPropagationOptions(boost::program_options::options_description& opt) { + namespace po = boost::program_options; + using namespace Acts::UnitLiterals; + opt.add_options()("prop-debug", po::value()->default_value(false), + "Run in debug mode, will create propagation screen output.")( + "prop-step-collection", po::value()->default_value("propagation-steps"), + "Propgation step collection.")("prop-stepper", po::value()->default_value(1), + "Propgation type: 0 (StraightLine), 1 (Eigen), 2 (Atlas).")( + "prop-mode", po::value()->default_value(0), "Propgation modes: 0 (inside-out), 1 (surface to surface).")( + "prop-cov", po::value()->default_value(false), "Propagate (random) test covariances.")( + "prop-energyloss", po::value()->default_value(true), + "Apply energy loss correction - in extrapolation mode only.")( + "prop-scattering", po::value()->default_value(true), + "Apply scattering correction - in extrapolation mode only.")( + "prop-record-material", po::value()->default_value(true), + "Record the material interaction and - in extrapolation mode only.")( + "prop-material-collection", po::value()->default_value("propagation-material"), + "Propagation material collection.")("prop-ntests", po::value()->default_value(1000), + "Number of tests performed.")( + "prop-resolve-material", po::value()->default_value(true), "Resolve all smaterial surfaces.")( + "prop-resolve-passive", po::value()->default_value(false), "Resolve all passive surfaces.")( + "prop-resolve-sensitive", po::value()->default_value(true), "Resolve all sensitive surfaces.")( + "prop-d0-sigma", po::value()->default_value(15_um), + "Sigma of the transverse impact parameter [in mm].")("prop-z0-sigma", + po::value()->default_value(55_mm), + "Sigma of the longitudinal impact parameter [in mm].")( + "prop-phi-sigma", po::value()->default_value(0.001), "Sigma of the azimuthal angle [in rad].")( + "prop-theta-sigma", po::value()->default_value(0.001), "Sigma of the polar angle [in rad].")( + "prop-qp-sigma", po::value()->default_value(0.0001 / 1_GeV), + "Sigma of the signed inverse momentum [in GeV^{-1}].")( + "prop-t-sigma", po::value()->default_value(1_ns), "Sigma of the time parameter [in ns].")( + "prop-corr-offd", po::value>(), + "The 15 off-diagonal correlation rho(d0,z0), rho(d0,phi), [...], " + "rho(z0,phi), rho(z0, theta), [...], rho(qop,t). Row-wise.")( + "prop-phi-range", po::value>()->default_value({{-M_PI, M_PI}}), + "Azimutal angle phi range for proprapolated tracks.")("prop-eta-range", + po::value>()->default_value({{-4., 4.}}), + "Pseudorapidity range for proprapolated tracks.")( + "prop-pt-range", po::value>()->default_value({{100_MeV, 100_GeV}}), + "Transverse momentum range for proprapolated tracks [in GeV].")( + "prop-max-stepsize", po::value()->default_value(3_m), + "Maximum step size for the propagation [in mm].")( + "prop-pt-loopers", po::value()->default_value(500_MeV), + "Transverse momentum below which loops are being detected [in GeV]."); } - } - return pAlgConfig; -} + /// Read the pgropagator options and return a Config file + /// + /// @tparam vmap_t is the Type of the Parameter map to be read out + /// @tparam propagator_t is the Type of the Propagator used + /// + /// @returns a Config object for the PropagatorAlg + inline PropagatorAlg::Config readPropagationConfig(const boost::program_options::variables_map& vm) { + using namespace Acts::UnitLiterals; + PropagatorAlg::Config pAlgConfig; + + auto iphir = vm["prop-phi-range"].template as>(); + auto ietar = vm["prop-eta-range"].template as>(); + auto iptr = vm["prop-pt-range"].template as>(); + + /// Material interaction behavior + pAlgConfig.energyLoss = vm["prop-energyloss"].template as(); + pAlgConfig.multipleScattering = vm["prop-scattering"].template as(); + pAlgConfig.recordMaterialInteractions = vm["prop-record-material"].template as(); + + /// Create the config for the Extrapoaltion algorithm + pAlgConfig.debugOutput = vm["prop-debug"].template as(); + pAlgConfig.ntests = vm["prop-ntests"].template as(); + pAlgConfig.mode = vm["prop-mode"].template as(); + pAlgConfig.d0Sigma = vm["prop-d0-sigma"].template as() * 1_mm; + pAlgConfig.z0Sigma = vm["prop-z0-sigma"].template as() * 1_mm; + pAlgConfig.phiSigma = vm["prop-phi-sigma"].template as(); + pAlgConfig.thetaSigma = vm["prop-theta-sigma"].template as(); + pAlgConfig.qpSigma = vm["prop-qp-sigma"].template as() / 1_GeV; + pAlgConfig.tSigma = vm["prop-t-sigma"].template as() * 1_ns; + + pAlgConfig.phiRange = {iphir[0], iphir[1]}; + pAlgConfig.etaRange = {ietar[0], ietar[1]}; + pAlgConfig.ptRange = {iptr[0] * 1_GeV, iptr[1] * 1_GeV}; + pAlgConfig.ptLoopers = vm["prop-pt-loopers"].template as() * 1_GeV; + pAlgConfig.maxStepSize = vm["prop-max-stepsize"].template as() * 1_mm; + + pAlgConfig.propagationStepCollection = vm["prop-step-collection"].template as(); + pAlgConfig.propagationMaterialCollection = vm["prop-material-collection"].template as(); + + /// The covariance transport + if (vm["prop-cov"].template as()) { + /// Set the covariance transport to true + pAlgConfig.covarianceTransport = true; + /// Set the covariance matrix + pAlgConfig.covariances(Acts::BoundIndices::eBoundLoc0) = pAlgConfig.d0Sigma * pAlgConfig.d0Sigma; + pAlgConfig.covariances(Acts::BoundIndices::eBoundLoc1) = pAlgConfig.z0Sigma * pAlgConfig.z0Sigma; + pAlgConfig.covariances(Acts::BoundIndices::eBoundPhi) = pAlgConfig.phiSigma * pAlgConfig.phiSigma; + pAlgConfig.covariances(Acts::BoundIndices::eBoundTheta) = pAlgConfig.thetaSigma * pAlgConfig.thetaSigma; + pAlgConfig.covariances(Acts::BoundIndices::eBoundQOverP) = pAlgConfig.qpSigma * pAlgConfig.qpSigma; + pAlgConfig.covariances(Acts::BoundIndices::eBoundTime) = pAlgConfig.tSigma * pAlgConfig.tSigma; + + // Only if they are properly defined, assign off-diagonals + if (vm.count("prop-corr-offd")) { + auto readOffd = vm["prop-corr-offd"].template as>(); + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundLoc1) = readOffd[0]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundPhi) = readOffd[1]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundTheta) = readOffd[2]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundQOverP) = readOffd[3]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundTime) = readOffd[4]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, Acts::BoundIndices::eBoundPhi) = readOffd[5]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, Acts::BoundIndices::eBoundTheta) = readOffd[6]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, Acts::BoundIndices::eBoundQOverP) = readOffd[7]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, Acts::BoundIndices::eBoundTime) = readOffd[8]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, Acts::BoundIndices::eBoundTheta) = readOffd[9]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, Acts::BoundIndices::eBoundQOverP) = readOffd[10]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, Acts::BoundIndices::eBoundTime) = readOffd[11]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundTheta, Acts::BoundIndices::eBoundQOverP) = readOffd[12]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundTheta, Acts::BoundIndices::eBoundTime) = readOffd[13]; + pAlgConfig.correlations(Acts::BoundIndices::eBoundQOverP, Acts::BoundIndices::eBoundTime) = readOffd[14]; + } else { + /// Some pre-defined values (non-trivial helical correlations) + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundPhi) = -0.8; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundQOverP) = -0.3; + pAlgConfig.correlations(Acts::BoundIndices::eBoundLoc1, Acts::BoundIndices::eBoundTheta) = -0.8; + pAlgConfig.correlations(Acts::BoundIndices::eBoundPhi, Acts::BoundIndices::eBoundQOverP) = 0.4; + } + } + + return pAlgConfig; + } -} -} // namespace Options - // namespace ActsExamples + } // namespace Options +} // namespace ActsExamples + // namespace ActsExamples diff --git a/k4ActsTracking/src/components/PropagatorAlg.cpp b/k4ActsTracking/src/components/PropagatorAlg.cpp index e5f7d8a..86439bd 100644 --- a/k4ActsTracking/src/components/PropagatorAlg.cpp +++ b/k4ActsTracking/src/components/PropagatorAlg.cpp @@ -6,19 +6,13 @@ #include "TGeoManager.h" #include "TTree.h" - DECLARE_COMPONENT(PropagatorAlg) - - using namespace Acts; - - std::optional PropagatorAlg::generateCovariance(std::mt19937& rng, std::normal_distribution& gauss) { if (covarianceTransport) { - Acts::BoundSymMatrix newCov(m_cfg.correlations); Acts::BoundVector covs_smeared = m_cfg.covariances; @@ -44,43 +38,34 @@ PropagatorAlg::PropagatorAlg(const std::string& aName, ISvcLocator* aSvcLoc) : G PropagatorAlg::~PropagatorAlg() {} StatusCode PropagatorAlg::initialize() { - m_geoSvc = service("GeoSvc"); - if (!m_geoSvc) { - std::cout << "Unable to locate Geometry Service. " << std::endl; - return StatusCode::FAILURE; - -} + std::cout << "Unable to locate Geometry Service. " << std::endl; + return StatusCode::FAILURE; + } -if (service("THistSvc", m_ths).isFailure()) { + if (service("THistSvc", m_ths).isFailure()) { error() << "Couldn't get THistSvc" << endmsg; return StatusCode::FAILURE; } -m_outputTree = new TTree ("hits", "PropagatorAlg hits ntuple"); -if (m_ths->regTree("/rec/NtuplesHits", m_outputTree).isFailure()) { + m_outputTree = new TTree("hits", "PropagatorAlg hits ntuple"); + if (m_ths->regTree("/rec/NtuplesHits", m_outputTree).isFailure()) { error() << "Couldn't register hits tree" << endmsg; } -initializeTrees(); - - -return StatusCode::SUCCESS; + initializeTrees(); + return StatusCode::SUCCESS; } - - - StatusCode PropagatorAlg::execute() { - cleanTrees(); std::mt19937 rng{1}; std::normal_distribution gauss(0., 1.); std::round(gauss(rng)); - std::uniform_real_distribution phiDist(0 , 2*M_PI); + std::uniform_real_distribution phiDist(0, 2 * M_PI); std::uniform_real_distribution etaDist(-4.0, 4.0); std::uniform_real_distribution ptDist(10., 20.); std::uniform_real_distribution qDist(0., 1.); @@ -95,10 +80,9 @@ StatusCode PropagatorAlg::execute() { if (recordMaterialInteractions) { recordedMaterial.reserve(ntests); } -for (size_t i = 0; i < 42; i++) { -testVar.push_back(i); -} - + for (size_t i = 0; i < 42; i++) { + testVar.push_back(i); + } // loop over number of particles for (size_t it = 0; it < ntests; ++it) { @@ -118,7 +102,6 @@ testVar.push_back(i); Acts::BoundVector pars; pars << d0, z0, phi, theta, qop, t; - Acts::Vector3 sPosition(0., 0., 0.); Acts::Vector3 sMomentum(0., 0., 0.); @@ -127,9 +110,8 @@ testVar.push_back(i); auto tGeometry = m_geoSvc->trackingGeometry(); - auto bField = std::make_shared(Vector3(0.,0.,2 * Acts::UnitConstants::T)); - Acts::BoundTrackParameters startParameters(surface, std::move(pars), - std::move(cov)); + auto bField = std::make_shared(Vector3(0., 0., 2 * Acts::UnitConstants::T)); + Acts::BoundTrackParameters startParameters(surface, std::move(pars), std::move(cov)); auto stepper = Acts::EigenStepper<>{std::move(bField)}; using Stepper = std::decay_t; @@ -138,42 +120,37 @@ testVar.push_back(i); Acts::Navigator navigator(navCfg); Propagator propagator(std::move(stepper), std::move(navigator)); - PropagationOutput pOut; pOut = executeTest(propagator, startParameters); - - - for (auto& step : pOut.first) { - - Acts::GeometryIdentifier::Value volumeID = 0; - Acts::GeometryIdentifier::Value boundaryID = 0; - Acts::GeometryIdentifier::Value layerID = 0; - Acts::GeometryIdentifier::Value approachID = 0; + for (auto& step : pOut.first) { + Acts::GeometryIdentifier::Value volumeID = 0; + Acts::GeometryIdentifier::Value boundaryID = 0; + Acts::GeometryIdentifier::Value layerID = 0; + Acts::GeometryIdentifier::Value approachID = 0; Acts::GeometryIdentifier::Value sensitiveID = 0; if (step.surface) { - auto geoID = step.surface->geometryId(); - volumeID = geoID.volume(); - boundaryID = geoID.boundary(); - layerID = geoID.layer(); - approachID = geoID.approach(); + auto geoID = step.surface->geometryId(); + volumeID = geoID.volume(); + boundaryID = geoID.boundary(); + layerID = geoID.layer(); + approachID = geoID.approach(); sensitiveID = geoID.sensitive(); } - if(sensitiveID >= sensitiveIDopt) { - - // a current volume overwrites the surface tagged one - if (step.volume != nullptr) { - volumeID = step.volume->geometryId().volume(); - } - // now fill - m_sensitiveID.push_back(sensitiveID); - m_approachID.push_back(approachID); - m_layerID.push_back(layerID); - m_boundaryID.push_back(boundaryID); - m_volumeID.push_back(volumeID); + if (sensitiveID >= sensitiveIDopt) { + // a current volume overwrites the surface tagged one + if (step.volume != nullptr) { + volumeID = step.volume->geometryId().volume(); + } + // now fill + m_sensitiveID.push_back(sensitiveID); + m_approachID.push_back(approachID); + m_layerID.push_back(layerID); + m_boundaryID.push_back(boundaryID); + m_volumeID.push_back(volumeID); m_x.push_back(step.position.x()); m_y.push_back(step.position.y()); @@ -182,51 +159,45 @@ testVar.push_back(i); m_dx.push_back(direction.x()); m_dy.push_back(direction.y()); m_dz.push_back(direction.z()); - - } - } -m_outputTree->Fill(); -} - - - -return StatusCode::SUCCESS; + } + m_outputTree->Fill(); + } + return StatusCode::SUCCESS; } StatusCode PropagatorAlg::finalize() { return StatusCode::SUCCESS; } -StatusCode PropagatorAlg::initializeTrees(){ - -m_outputTree->Branch("testVar", &testVar); -m_outputTree->Branch("g_x", &m_x); -m_outputTree->Branch("g_y", &m_y); -m_outputTree->Branch("g_z", &m_z); -m_outputTree->Branch("d_x", &m_dx); -m_outputTree->Branch("d_y", &m_dy); -m_outputTree->Branch("d_z", &m_dz); -m_outputTree->Branch("volume_id", &m_volumeID); -m_outputTree->Branch("boundary_id", &m_boundaryID); -m_outputTree->Branch("layer_id", &m_layerID); -m_outputTree->Branch("approach_id", &m_approachID); -m_outputTree->Branch("sensitive_id", &m_sensitiveID); -return StatusCode::SUCCESS; +StatusCode PropagatorAlg::initializeTrees() { + m_outputTree->Branch("testVar", &testVar); + m_outputTree->Branch("g_x", &m_x); + m_outputTree->Branch("g_y", &m_y); + m_outputTree->Branch("g_z", &m_z); + m_outputTree->Branch("d_x", &m_dx); + m_outputTree->Branch("d_y", &m_dy); + m_outputTree->Branch("d_z", &m_dz); + m_outputTree->Branch("volume_id", &m_volumeID); + m_outputTree->Branch("boundary_id", &m_boundaryID); + m_outputTree->Branch("layer_id", &m_layerID); + m_outputTree->Branch("approach_id", &m_approachID); + m_outputTree->Branch("sensitive_id", &m_sensitiveID); + return StatusCode::SUCCESS; } StatusCode PropagatorAlg::cleanTrees() { - testVar.clear(); - m_x.clear(); - m_y.clear(); - m_z.clear(); - m_dx.clear(); - m_dy.clear(); - m_dz.clear(); - m_volumeID.clear(); - m_boundaryID.clear(); - m_layerID.clear(); - m_approachID.clear(); - m_sensitiveID.clear(); + testVar.clear(); + m_x.clear(); + m_y.clear(); + m_z.clear(); + m_dx.clear(); + m_dy.clear(); + m_dz.clear(); + m_volumeID.clear(); + m_boundaryID.clear(); + m_layerID.clear(); + m_approachID.clear(); + m_sensitiveID.clear(); return StatusCode::SUCCESS; } diff --git a/k4ActsTracking/src/components/PropagatorAlg.h b/k4ActsTracking/src/components/PropagatorAlg.h index ad0e477..1a406c0 100644 --- a/k4ActsTracking/src/components/PropagatorAlg.h +++ b/k4ActsTracking/src/components/PropagatorAlg.h @@ -5,20 +5,19 @@ #ifndef PropagatorAlg_H #define PropagatorAlg_H - -#include "GaudiAlg/GaudiAlgorithm.h" #include "Gaudi/Property.h" +#include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiKernel/MsgStream.h" #include "GaudiKernel/Service.h" #include "GaudiKernel/ServiceHandle.h" #include "IGeoSvc.h" #include "IPropagatorAlg.h" -#include "Acts/Utilities/Logger.hpp" #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/EventData/NeutralTrackParameters.hpp" #include "Acts/EventData/TrackParameters.hpp" +#include "Acts/MagneticField/ConstantBField.hpp" #include "Acts/Propagator/AbortList.hpp" #include "Acts/Propagator/ActionList.hpp" #include "Acts/Propagator/DenseEnvironmentExtension.hpp" @@ -30,14 +29,14 @@ #include "Acts/Propagator/detail/SteppingLogger.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" #include "Acts/Utilities/Helpers.hpp" -#include "Acts/MagneticField/ConstantBField.hpp" +#include "Acts/Utilities/Logger.hpp" -#include "ProcessCode.hpp" #include "AlgorithmContext.hpp" #include "CommonGeometry.hpp" #include "CommonOptions.hpp" #include "IBaseDetector.hpp" #include "MagneticFieldOptions.hpp" +#include "ProcessCode.hpp" #include "WhiteBoard.hpp" @@ -47,26 +46,25 @@ #include #include -#include "GaudiKernel/MsgStream.h" -#include "GaudiKernel/Service.h" -#include "GaudiKernel/ServiceHandle.h" #include "Acts/Definitions/Units.hpp" #include "Acts/Utilities/Logger.hpp" #include "CommonOptions.hpp" #include "Gaudi/Property.h" #include "GaudiAlg/GaudiAlgorithm.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/Service.h" +#include "GaudiKernel/ServiceHandle.h" #include "Options.hpp" #include "GaudiKernel/ITHistSvc.h" -#include "TH1F.h" #include "TGraph.h" +#include "TH1F.h" #include #include - using RecordedMaterial = Acts::MaterialInteractor::result_type; using RecordedMaterialTrack = std::pair, RecordedMaterial>; using PropagationOutput = std::pair, RecordedMaterial>; @@ -75,7 +73,6 @@ std::optional generateCovariance(std::mt19937& rng, std::n class PropagatorAlg : public GaudiAlgorithm { public: struct Config { - /// how to set it up std::mt19937 randomNumberSvc{0}; @@ -99,26 +96,24 @@ class PropagatorAlg : public GaudiAlgorithm { Acts::BoundSymMatrix correlations = Acts::BoundSymMatrix::Identity(); }; - const Config& config() const { return m_cfg; } private: + Config m_cfg; + std::vector testvec; + std::mt19937 rng; + std::optional generateCovariance(std::mt19937& rng, std::normal_distribution& gauss); -Config m_cfg; -std::vector testvec; -std::mt19937 rng; -std::optional generateCovariance(std::mt19937& rng, std::normal_distribution& gauss); - -ITHistSvc* m_ths{nullptr}; -TTree* m_outputTree{nullptr}; + ITHistSvc* m_ths{nullptr}; + TTree* m_outputTree{nullptr}; std::vector testVar; - std::vector m_x; ///< global x - std::vector m_y; ///< global y - std::vector m_z; ///< global z - std::vector m_dx; ///< global direction x - std::vector m_dy; ///< global direction y - std::vector m_dz; ///< global direction z + std::vector m_x; ///< global x + std::vector m_y; ///< global y + std::vector m_z; ///< global z + std::vector m_dx; ///< global direction x + std::vector m_dy; ///< global direction y + std::vector m_dz; ///< global direction z std::vector m_volumeID; ///< volume identifier std::vector m_boundaryID; ///< boundary identifier @@ -126,101 +121,98 @@ TTree* m_outputTree{nullptr}; std::vector m_approachID; ///< surface identifier std::vector m_sensitiveID; ///< surface identifier -Config readPropagationConfig (const boost::program_options::variables_map& vm); - -Gaudi::Property mode{this, "mode", 0, "Option for propagation mode."}; - -Gaudi::Property sterileLogger{this, "sterileLogger", false, "Option to switch the logger to sterile."}; + Config readPropagationConfig(const boost::program_options::variables_map& vm); -Gaudi::Property debugOutput{this, "debugOutput", false, "Option for the debug output."}; + Gaudi::Property mode{this, "mode", 0, "Option for propagation mode."}; -Gaudi::Property energyLoss{this, "energyLoss", true, "Option to modify the behavior of the material interaction: energy loss."}; + Gaudi::Property sterileLogger{this, "sterileLogger", false, "Option to switch the logger to sterile."}; -Gaudi::Property multipleScattering{this, "multipleScattering", true, "Option to modify the behavior of the material interaction: scattering"}; + Gaudi::Property debugOutput{this, "debugOutput", false, "Option for the debug output."}; -Gaudi::Property recordMaterialInteractions{this, "recordMaterialInteractions", true, "Option to modify the behavior of the material interaction: record"}; + Gaudi::Property energyLoss{this, "energyLoss", true, + "Option to modify the behavior of the material interaction: energy loss."}; -Gaudi::Property ntests{this, "ntests", 0, "Option for number of particles"}; + Gaudi::Property multipleScattering{this, "multipleScattering", true, + "Option to modify the behavior of the material interaction: scattering"}; -Gaudi::Property covarianceTransport{this, "covarianceTransport", false, "Option for covariance transport."}; + Gaudi::Property recordMaterialInteractions{this, "recordMaterialInteractions", true, + "Option to modify the behavior of the material interaction: record"}; -Gaudi::Property d0Sigma{this, "d0Sigma", 0, "Option for d0 gaussian sigma"}; + Gaudi::Property ntests{this, "ntests", 0, "Option for number of particles"}; -Gaudi::Property z0Sigma{this, "z0Sigma", 0, "Option for z0 gaussian sigma"}; + Gaudi::Property covarianceTransport{this, "covarianceTransport", false, "Option for covariance transport."}; -Gaudi::Property phiSigma{this, "phiSigma", 0, "Option for phi gaussian sigma (used for covariance transport)"}; + Gaudi::Property d0Sigma{this, "d0Sigma", 0, "Option for d0 gaussian sigma"}; -Gaudi::Property thetaSigma{this, "thetaSigma", 0, "Option for theta gaussian sigma (used for covariance transport)"}; + Gaudi::Property z0Sigma{this, "z0Sigma", 0, "Option for z0 gaussian sigma"}; -Gaudi::Property qpSigma{this, "qpSigma", 0, "Option for qp gaussian sigma (used for covariance transport)"}; + Gaudi::Property phiSigma{this, "phiSigma", 0, + "Option for phi gaussian sigma (used for covariance transport)"}; -Gaudi::Property tSigma{this, "tSigma", 0, "Option for t gaussian sigma (used for covariance transport)"}; + Gaudi::Property thetaSigma{this, "thetaSigma", 0, + "Option for theta gaussian sigma (used for covariance transport)"}; -Gaudi::Property ptLoopers{this, "ptLoopers", 0, "Option for looper protection"}; + Gaudi::Property qpSigma{this, "qpSigma", 0, "Option for qp gaussian sigma (used for covariance transport)"}; -Gaudi::Property maxStepSize{this, "maxStepSize", 0, "Option for Max step size steering"}; + Gaudi::Property tSigma{this, "tSigma", 0, "Option for t gaussian sigma (used for covariance transport)"}; -Gaudi::Property sensitiveIDopt{this, "sensitiveIDopt", 0, "Option for sensitiveID"}; + Gaudi::Property ptLoopers{this, "ptLoopers", 0, "Option for looper protection"}; + Gaudi::Property maxStepSize{this, "maxStepSize", 0, "Option for Max step size steering"}; -template -PropagationOutput executeTest(Acts::Propagator, Acts::Navigator>& propagator, parameters_t& startParameters) { - PropagationOutput pOutput; - ACTS_LOCAL_LOGGER(Acts::getDefaultLogger("Propagation Logger", Acts::Logging::INFO)); + Gaudi::Property sensitiveIDopt{this, "sensitiveIDopt", 0, "Option for sensitiveID"}; - if ( mode == 0 ) { - using MaterialInteractor = Acts::MaterialInteractor; - using SteppingLogger = Acts::detail::SteppingLogger; - using EndOfWorld = Acts::EndOfWorldReached; + template + PropagationOutput executeTest(Acts::Propagator, Acts::Navigator>& propagator, + parameters_t& startParameters) { + PropagationOutput pOutput; + ACTS_LOCAL_LOGGER(Acts::getDefaultLogger("Propagation Logger", Acts::Logging::INFO)); - using ActionList = Acts::ActionList; - using AbortList = Acts::AbortList; - using PropagatorOptions = Acts::DenseStepperPropagatorOptions; + if (mode == 0) { + using MaterialInteractor = Acts::MaterialInteractor; + using SteppingLogger = Acts::detail::SteppingLogger; + using EndOfWorld = Acts::EndOfWorldReached; - const Acts::GeometryContext geoContext; - const Acts::MagneticFieldContext magFieldContext; + using ActionList = Acts::ActionList; + using AbortList = Acts::AbortList; + using PropagatorOptions = Acts::DenseStepperPropagatorOptions; - PropagatorOptions options(geoContext, magFieldContext, Acts::LoggerWrapper{logger()}); + const Acts::GeometryContext geoContext; + const Acts::MagneticFieldContext magFieldContext; - options.pathLimit = std::numeric_limits::max(); + PropagatorOptions options(geoContext, magFieldContext, Acts::LoggerWrapper{logger()}); - options.loopProtection = (startParameters.transverseMomentum() < ptLoopers); + options.pathLimit = std::numeric_limits::max(); + options.loopProtection = (startParameters.transverseMomentum() < ptLoopers); - auto& mInteractor = options.actionList.get(); - mInteractor.multipleScattering = multipleScattering; - mInteractor.energyLoss = energyLoss; - mInteractor.recordInteractions = recordMaterialInteractions; + auto& mInteractor = options.actionList.get(); + mInteractor.multipleScattering = multipleScattering; + mInteractor.energyLoss = energyLoss; + mInteractor.recordInteractions = recordMaterialInteractions; + auto& sLogger = options.actionList.get(); + sLogger.sterile = sterileLogger; - auto& sLogger = options.actionList.get(); - sLogger.sterile = sterileLogger; + options.maxStepSize = maxStepSize; - options.maxStepSize = maxStepSize; + auto result = propagator.propagate(startParameters, options); + if (result.ok()) { + const auto& resultValue = result.value(); + auto steppingResults = resultValue.template get(); - auto result = propagator.propagate(startParameters, options); - if (result.ok()) { - const auto& resultValue = result.value(); - auto steppingResults = - resultValue.template get(); - - - pOutput.first = std::move(steppingResults.steps); - - if (recordMaterialInteractions) { - auto materialResult = - resultValue.template get(); - pOutput.second = std::move(materialResult); - } - - } - return pOutput; + pOutput.first = std::move(steppingResults.steps); + if (recordMaterialInteractions) { + auto materialResult = resultValue.template get(); + pOutput.second = std::move(materialResult); + } + } + return pOutput; + } } -} public: - SmartIF m_geoSvc; explicit PropagatorAlg(const std::string&, ISvcLocator*); @@ -233,12 +225,9 @@ PropagationOutput executeTest(Acts::Propagator, Acts::Navig virtual StatusCode finalize() final; -virtual StatusCode initializeTrees() final; - -virtual StatusCode cleanTrees() final; - - + virtual StatusCode initializeTrees() final; + virtual StatusCode cleanTrees() final; }; // class diff --git a/k4ActsTracking/src/components/PropagatorInterface.hpp b/k4ActsTracking/src/components/PropagatorInterface.hpp index dae00cb..06a7b25 100644 --- a/k4ActsTracking/src/components/PropagatorInterface.hpp +++ b/k4ActsTracking/src/components/PropagatorInterface.hpp @@ -7,148 +7,135 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #pragma once -#include "PropagatorAlg.h" #include "Acts/Utilities/Logger.hpp" - +#include "PropagatorAlg.h" namespace ActsExamples { -///@brief Propagator wrapper -/// -/// This class encapsulates a propagator instance and exposes -/// propagation functions for neutral and charged particles. -/// @note This interface exists to decouple the concrete propagators from -/// the @c PropagatorAlg -class PropagatorInterface { - public: - virtual ~PropagatorInterface() = default; - - ///@brief Execute a propagation for charged particle parameters + ///@brief Propagator wrapper /// - ///@param context The algorithm context - ///@param cfg The propagation algorithm configuration - ///@param logger A logger wrapper instance - ///@param startParameters The start parameters - ///@return PropagationOutput - virtual PropagationOutput execute( - const AlgorithmContext& context, const PropagatorAlg::Config& cfg, - Acts::LoggerWrapper logger, - const Acts::BoundTrackParameters& startParameters) const = 0; - - ///@brief Execute a propagation for neutral particle parameters + /// This class encapsulates a propagator instance and exposes + /// propagation functions for neutral and charged particles. + /// @note This interface exists to decouple the concrete propagators from + /// the @c PropagatorAlg + class PropagatorInterface { + public: + virtual ~PropagatorInterface() = default; + + ///@brief Execute a propagation for charged particle parameters + /// + ///@param context The algorithm context + ///@param cfg The propagation algorithm configuration + ///@param logger A logger wrapper instance + ///@param startParameters The start parameters + ///@return PropagationOutput + virtual PropagationOutput execute(const AlgorithmContext& context, const PropagatorAlg::Config& cfg, + Acts::LoggerWrapper logger, + const Acts::BoundTrackParameters& startParameters) const = 0; + + ///@brief Execute a propagation for neutral particle parameters + /// + ///@param context The algorithm context + ///@param cfg The propagation algorithm configuration + ///@param logger A logger wrapper instance + ///@param startParameters The start parameters + ///@return PropagationOutput + virtual PropagationOutput execute(const AlgorithmContext& context, const PropagatorAlg::Config& cfg, + Acts::LoggerWrapper logger, + const Acts::NeutralBoundTrackParameters& startParameters) const = 0; + }; + + ///@brief Concrete instance of a propagator /// - ///@param context The algorithm context - ///@param cfg The propagation algorithm configuration - ///@param logger A logger wrapper instance - ///@param startParameters The start parameters - ///@return PropagationOutput - virtual PropagationOutput execute( - const AlgorithmContext& context, const PropagatorAlg::Config& cfg, - Acts::LoggerWrapper logger, - const Acts::NeutralBoundTrackParameters& startParameters) const = 0; -}; - -///@brief Concrete instance of a propagator -/// -/// This class implements a wrapped version of a concrete propagator. -/// It can be instantiated to comply with @c PropagatorInterface. -/// Setting up a @c PropagatorAlg with this looks like: -/// ```cpp -/// config.propagatorImpl = -/// std::make_shared>( -/// std::move(propagator)); -/// ``` -///@tparam propagator_t The concrete propagator to instantiate with -template -class ConcretePropagator : public PropagatorInterface { - public: - ConcretePropagator(propagator_t propagator) - : m_propagator{std::move(propagator)} {} - - PropagationOutput execute( - const AlgorithmContext& context, const PropagatorAlg::Config& cfg, - Acts::LoggerWrapper logger, - const Acts::BoundTrackParameters& startParameters) const override { - return executeTest(context, cfg, logger, startParameters); - } - - PropagationOutput execute( - const AlgorithmContext& context, const PropagatorAlg::Config& cfg, - Acts::LoggerWrapper logger, - const Acts::NeutralBoundTrackParameters& startParameters) const override { - return executeTest(context, cfg, logger, startParameters); - } - - private: - /// Templated execute test method for - /// charged and netural particles - /// @param [in] context is the contextual data of this event - /// @param [in] startParameters the start parameters - /// @param [in] pathLength the maximal path length to go - template - PropagationOutput executeTest( - const AlgorithmContext& context, const PropagatorAlg::Config& cfg, - Acts::LoggerWrapper logger, const parameters_t& startParameters, - double pathLength = std::numeric_limits::max()) const { - ACTS_DEBUG("Test propagation/extrapolation starts"); - - PropagationOutput pOutput; - - // This is the outside in mode - if (cfg.mode == 0) { - // The step length logger for testing & end of world aborter - using MaterialInteractor = Acts::MaterialInteractor; - using SteppingLogger = Acts::detail::SteppingLogger; - using EndOfWorld = Acts::EndOfWorldReached; - - // Action list and abort list - using ActionList = Acts::ActionList; - using AbortList = Acts::AbortList; - using PropagatorOptions = - Acts::DenseStepperPropagatorOptions; - - PropagatorOptions options(context.geoContext, context.magFieldContext, - Acts::LoggerWrapper{logger()}); - options.pathLimit = pathLength; - - // Activate loop protection at some pt value - options.loopProtection = - (startParameters.transverseMomentum() < cfg.ptLoopers); - - // Switch the material interaction on/off & eventually into logging mode - auto& mInteractor = options.actionList.get(); - mInteractor.multipleScattering = cfg.multipleScattering; - mInteractor.energyLoss = cfg.energyLoss; - mInteractor.recordInteractions = cfg.recordMaterialInteractions; - - // Switch the logger to sterile, e.g. for timing checks - auto& sLogger = options.actionList.get(); - sLogger.sterile = cfg.sterileLogger; - // Set a maximum step size - options.maxStepSize = cfg.maxStepSize; - - // Propagate using the propagator - auto result = m_propagator.propagate(startParameters, options); - if (result.ok()) { - const auto& resultValue = result.value(); - auto steppingResults = - resultValue.template get(); - - // Set the stepping result - pOutput.first = std::move(steppingResults.steps); - // Also set the material recording result - if configured - if (cfg.recordMaterialInteractions) { - auto materialResult = - resultValue.template get(); - pOutput.second = std::move(materialResult); + /// This class implements a wrapped version of a concrete propagator. + /// It can be instantiated to comply with @c PropagatorInterface. + /// Setting up a @c PropagatorAlg with this looks like: + /// ```cpp + /// config.propagatorImpl = + /// std::make_shared>( + /// std::move(propagator)); + /// ``` + ///@tparam propagator_t The concrete propagator to instantiate with + template class ConcretePropagator : public PropagatorInterface { + public: + ConcretePropagator(propagator_t propagator) : m_propagator{std::move(propagator)} {} + + PropagationOutput execute(const AlgorithmContext& context, const PropagatorAlg::Config& cfg, + Acts::LoggerWrapper logger, + const Acts::BoundTrackParameters& startParameters) const override { + return executeTest(context, cfg, logger, startParameters); + } + + PropagationOutput execute(const AlgorithmContext& context, const PropagatorAlg::Config& cfg, + Acts::LoggerWrapper logger, + const Acts::NeutralBoundTrackParameters& startParameters) const override { + return executeTest(context, cfg, logger, startParameters); + } + + private: + /// Templated execute test method for + /// charged and netural particles + /// @param [in] context is the contextual data of this event + /// @param [in] startParameters the start parameters + /// @param [in] pathLength the maximal path length to go + template + PropagationOutput executeTest(const AlgorithmContext& context, const PropagatorAlg::Config& cfg, + Acts::LoggerWrapper logger, const parameters_t& startParameters, + double pathLength = std::numeric_limits::max()) const { + ACTS_DEBUG("Test propagation/extrapolation starts"); + + PropagationOutput pOutput; + + // This is the outside in mode + if (cfg.mode == 0) { + // The step length logger for testing & end of world aborter + using MaterialInteractor = Acts::MaterialInteractor; + using SteppingLogger = Acts::detail::SteppingLogger; + using EndOfWorld = Acts::EndOfWorldReached; + + // Action list and abort list + using ActionList = Acts::ActionList; + using AbortList = Acts::AbortList; + using PropagatorOptions = Acts::DenseStepperPropagatorOptions; + + PropagatorOptions options(context.geoContext, context.magFieldContext, Acts::LoggerWrapper{logger()}); + options.pathLimit = pathLength; + + // Activate loop protection at some pt value + options.loopProtection = (startParameters.transverseMomentum() < cfg.ptLoopers); + + // Switch the material interaction on/off & eventually into logging mode + auto& mInteractor = options.actionList.get(); + mInteractor.multipleScattering = cfg.multipleScattering; + mInteractor.energyLoss = cfg.energyLoss; + mInteractor.recordInteractions = cfg.recordMaterialInteractions; + + // Switch the logger to sterile, e.g. for timing checks + auto& sLogger = options.actionList.get(); + sLogger.sterile = cfg.sterileLogger; + // Set a maximum step size + options.maxStepSize = cfg.maxStepSize; + + // Propagate using the propagator + auto result = m_propagator.propagate(startParameters, options); + if (result.ok()) { + const auto& resultValue = result.value(); + auto steppingResults = resultValue.template get(); + + // Set the stepping result + pOutput.first = std::move(steppingResults.steps); + // Also set the material recording result - if configured + if (cfg.recordMaterialInteractions) { + auto materialResult = resultValue.template get(); + pOutput.second = std::move(materialResult); + } } } + return pOutput; } - return pOutput; - } - private: - propagator_t m_propagator; -}; + private: + propagator_t m_propagator; + }; } // namespace ActsExamples