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
14
16
18
20
21 ATH_CHECK( AthAlgTool::initialize() );
22 ATH_CHECK(m_ctxProvider.initialize());
23
25
27
28 std::array<std::string, 7 > caloNames = {"EMB1_Layer", "EMB2_Layer", "EMB3_Layer",
29 "TileBar0_Layer", "TileBar1_Layer",
30 "CaloLayerDiscNegativeZ", "CaloLayerDiscPositiveZ"};
31
32
33 m_trackingGeometrySvc->trackingGeometry()->visitVolumes([&](const Acts::TrackingVolume *vol) {
34
35 //get geo identifier
36 Acts::GeometryIdentifier geoId = vol->geometryId();
37 const auto & name = vol->volumeName();
38 ATH_MSG_DEBUG(name << " - " << geoId << " - surfaces: " << vol->surfaces().size());
39
40 if (std::ranges::contains(caloNames, name)){
41 vol->visitSurfaces([&](const Acts::Surface *surface){
42 ATH_MSG_DEBUG("This surface has ID" << surface->geometryId());
43 m_geoIdCaloSampleMap[surface->geometryId()] = static_cast<CaloSampling::CaloSample>(surface->geometryId().layer());
44 });
45 };
46 });
47
48 return StatusCode::SUCCESS;
49}
50
51std::unique_ptr<eflowTrackCaloPoints> PFTrackCaloExtensionTool::execute(const EventContext& ctx, const xAOD::TrackParticle* track) const {
52
53 ATH_MSG_DEBUG("About to extrapolate track with pt, eta and phi: " << track->pt() << ", " << track->eta() << " and " << track->phi());
54
56 ElementLink<ActsTrk::CaloExtensionContainer> trackCaloExtensionLink = extensionReadDecorHandle(*track);
57
58 std::map<eflowCalo::LAYER, const Acts::BoundTrackParameters*> parametersMap;
59 const Acts::GeometryContext gctx = m_ctxProvider.getGeometryContext(ctx);
60
61 if (!trackCaloExtensionLink.isValid()) {
62 ATH_MSG_DEBUG("Decoration exists, but this track has no valid CaloExtension link (null link)");
63 }
64 else{
65 const ActsTrk::CaloExtension* trackCaloExtension = *trackCaloExtensionLink;
66 ATH_MSG_DEBUG("Have CaloExtensions with size " << trackCaloExtension->size() << " for this track");
67 ATH_MSG_DEBUG("Are the parameters empty?: " << trackCaloExtension->parameters().empty());
68
69 for (const Acts::BoundTrackParameters& pars : trackCaloExtension->parameters()) {
70 const Acts::Surface& surface = pars.referenceSurface();
71 ATH_MSG_DEBUG("Geometry ID of surface is " << surface.geometryId());
72
73 const auto thisGeoID = surface.geometryId();
74
75 if (m_geoIdCaloSampleMap.contains(thisGeoID)) {
76 CaloSampling::CaloSample caloSample = m_geoIdCaloSampleMap.at(thisGeoID);
77 ATH_MSG_DEBUG("This surface is in the calorimeter with CaloSample " << caloSample << " and eta, phi: " << pars.position(gctx).eta() << ", " << pars.position(gctx).phi());
78 /* parametersMap may have several entries for Tile1,2,3
79 due to the simplfification of eflowCalo::LAYER which only considers
80 Tile in general and not barrel, exctended barrel and gap.
81 The impact is negligible as the eta/phi of these entries are very similar
82 https://its.cern.ch/jira/browse/ATLJETMET-242
83 */
84 parametersMap[eflowCalo::translateSampl(caloSample)] = &pars;
85 }
86 }
87 }
88
89 return std::make_unique<eflowTrackCaloPoints>(parametersMap, gctx);
90}
91
93 return StatusCode::SUCCESS;
94}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
Handle class for reading a decoration on an object.
The CaloExtension holds the ID extrapolation states through the calorimeter and the associated CaloCl...
std::size_t size() const
Number of extensions stored in the instance.
const Acts::BoundTrackParameters & parameters(const std::size_t parIdx) const
Returns the extension parameters associated with the n-th extension.
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_extensionReadDecorKey
virtual std::unique_ptr< eflowTrackCaloPoints > execute(const EventContext &ctx, const xAOD::TrackParticle *track) const override
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
ActsTrk::ContextUtility m_ctxProvider
The ContextUtility will give us access to the Acts geometry context.
std::map< Acts::GeometryIdentifier, CaloSampling::CaloSample > m_geoIdCaloSampleMap
virtual StatusCode initialize() override
virtual StatusCode finalize() override
Handle class for reading a decoration on an object.
static LAYER translateSampl(CaloCell_ID::CaloSample sampl)
TrackParticle_v1 TrackParticle
Reference the current persistent version: