ATLAS Offline Software
Loading...
Searching...
No Matches
PFTrackCaloExtensionTool.cxx
Go to the documentation of this file.
1/* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration */
2
4
5#include "Acts/Geometry/TrackingGeometry.hpp"
6#include "Acts/Material/MaterialInteraction.hpp"
7#include "Acts/Propagator/detail/SteppingLogger.hpp"
8#include "Acts/Surfaces/CurvilinearSurface.hpp"
9#include "Acts/Surfaces/PlaneSurface.hpp"
10
13
15
17
18 ATH_CHECK( AthAlgTool::initialize() );
19
22
23 std::array<std::string,3 > caloNames = {"EMB1_layer", "EMB2_layer", "EMB3_layer"};
24
25 m_trackingGeometrySvc->trackingGeometry()->visitVolumes([&](const Acts::TrackingVolume *vol) {
26 const auto & name = vol->volumeName();
27 ATH_MSG_DEBUG(name << " - " << vol->geometryId() << " - surfaces: " << vol->surfaces().size());
28 if (std::ranges::contains(caloNames, name)){
29 ATH_MSG_DEBUG("About to insert caloName " << name << " into map");
30 m_caloNameGeoIDMap[vol->geometryId()] = name;
31 }
32 });
33
34 return StatusCode::SUCCESS;
35}
36
37std::unique_ptr<eflowTrackCaloPoints> PFTrackCaloExtensionTool::execute(const EventContext& ctx, const xAOD::TrackParticle* track) const {
38
39 unsigned int lastMeasIdx = 0;
40 if (!track->indexOfParameterAtPosition(lastMeasIdx, xAOD::LastMeasurement)) {
41 ATH_MSG_ERROR("TrackParticle has no last measurement parameters");
42 return nullptr;
43 }
44
45 Acts::Vector3 lastPos{track->parameterX(lastMeasIdx),
46 track->parameterY(lastMeasIdx),
47 track->parameterZ(lastMeasIdx)};
48 Acts::Vector3 lastMom{ActsTrk::energyToActs(track->parameterPX(lastMeasIdx)),
49 ActsTrk::energyToActs(track->parameterPY(lastMeasIdx)),
50 ActsTrk::energyToActs(track->parameterPZ(lastMeasIdx))};
51
52 Acts::BoundVector lastBoundParams = Acts::BoundVector::Zero();
53 lastBoundParams[Acts::eBoundPhi] = lastMom.phi();
54 lastBoundParams[Acts::eBoundTheta] = lastMom.theta();
55 lastBoundParams[Acts::eBoundQOverP] = track->charge() / lastMom.norm();
56
57 std::shared_ptr<const Acts::Surface> lastSurface = Acts::CurvilinearSurface(lastPos, lastMom.normalized()).planeSurface()->getSharedPtr();
58
59 Acts::BoundTrackParameters boundPars{
60 std::move(lastSurface),
61 lastBoundParams,
62 std::nullopt,
63 Acts::ParticleHypothesis::pion()
64 };
65
66 Acts::Result<std::pair<std::vector<Acts::detail::Step>, Acts::RecordedMaterial>> result = m_extrapolationTool.get()->propagationSteps(ctx, boundPars);
67
68 if( !result.ok() ) {
69 ATH_MSG_WARNING("Error during extrapolation: " << result.error().message());
70 return nullptr;
71 }
72
73 const auto &[steps, _] = result.value();
74
75 ATH_MSG_DEBUG("Have extrapolated track with pt, eta and phi: " << track->pt() << ", " << track->eta() << " and " << track->phi());
76
77 for(const auto &step : steps) {
78
79
80 if( step.surface == nullptr || step.surface->geometryId().sensitive() == 0 ) {
81 continue;
82 }
83
84 Acts::GeometryIdentifier thisGeoID = step.geoID;
85 ATH_MSG_DEBUG("Got step with geoID " << thisGeoID);
86
87 if (m_caloNameGeoIDMap.contains(thisGeoID)){
88 const auto &p = step.position;
89 auto eta = Acts::VectorHelpers::eta(p);
90 auto phi = Acts::VectorHelpers::phi(p);
91 ATH_MSG_DEBUG("Eta and Phi in caloLayer " << m_caloNameGeoIDMap.at(thisGeoID) << " are " << eta << " and " << phi);
92 }
93 else ATH_MSG_WARNING("Could not find this GeometryIdentifier " << thisGeoID << " in the map");
94 }
95
96 ATH_MSG_DEBUG("Finished steps loop");
97 ATH_MSG_DEBUG("");
98
99 return std::make_unique<eflowTrackCaloPoints>();
100}
101
103 return StatusCode::SUCCESS;
104}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
virtual std::unique_ptr< eflowTrackCaloPoints > execute(const EventContext &ctx, const xAOD::TrackParticle *track) const override
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
virtual StatusCode initialize() override
std::map< Acts::GeometryIdentifier, std::string > m_caloNameGeoIDMap
virtual StatusCode finalize() override
constexpr double energyToActs(const double athenaE)
Converts an energy scalar from Athena to Acts units.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
@ LastMeasurement
Parameter defined at the position of the last measurement.