ATLAS Offline Software
Loading...
Searching...
No Matches
TrackingGeometryTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9#include "Acts/Geometry/TrackingGeometry.hpp"
10
11
12namespace ActsTrk {
14 ATH_MSG_DEBUG(name() << " initializing");
15 if (parent() != toolSvc()) {
16 ATH_MSG_ERROR("The tool is initialized as a private tool but should be public");
17 return StatusCode::FAILURE;
18 }
20 ATH_CHECK(m_rchk.initialize());
22 if (!m_detIdMap) {
23 return StatusCode::FAILURE;
24 }
25 return StatusCode::SUCCESS;
26}
27
28std::shared_ptr<const Acts::TrackingGeometry> TrackingGeometryTool::trackingGeometry() const {
29 return m_trackingGeometrySvc->trackingGeometry();
30}
31const Acts::TrackingVolume* TrackingGeometryTool::getEnvelope(const ActsTrk::SystemEnvelope envType) const {
32 return m_trackingGeometrySvc->getEnvelope(envType);
33}
34
38
39const GeometryContext& TrackingGeometryTool::getGeometryContext(const EventContext& ctx) const {
40 ATH_MSG_DEBUG("Creating alignment context for event");
41 const GeometryContext* geoCtx{nullptr};
42 if (!SG::get(geoCtx, m_rchk, ctx).isSuccess()) {
43 ATH_MSG_ERROR("Creating alignment context failed: read cond handle invalid!");
44 }
45 return *geoCtx;
46}
47
51
52
53std::unique_ptr<ActsTrk::DetectorElementToActsGeometryIdMap>
55 // create map from
56 auto detector_element_to_geoid = std::make_unique<DetectorElementToActsGeometryIdMap>();
57
58 struct Counter{
59 unsigned n_sensitive_elements{0};
60 unsigned n_detector_elements{0};
61 unsigned n_wrong_type{0};
62 };
63 Counter counter {};
64 trackingGeometry()->visitSurfaces([this, &counter, &detector_element_to_geoid](const Acts::Surface *surface) {
65 if (!surface || !surface->isSensitive()) {
66 ++counter.n_wrong_type;
67 return;
68 }
69 ++counter.n_sensitive_elements;
70 const auto* detEl = dynamic_cast<const IDetectorElementBase*>(surface->surfacePlacement());
71 if (!detEl) {
72 return;
73 }
74
75 auto insert_id = [&detector_element_to_geoid, &surface, &counter](const xAOD::UncalibMeasType type,
76 const IdentifierHash& hash) {
77 detector_element_to_geoid->insert(std::make_pair(makeDetectorElementKey(type, hash),
78 DetectorElementToActsGeometryIdMap::makeValue(surface->geometryId())));
79 ++counter.n_detector_elements;
80 };
81 switch(detEl->detectorType()) {
82 using enum DetectorType;
83 case Pixel:
85 dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
86 break;
87 case Sct:
89 dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
90 break;
91 case Hgtd:
93 dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
94 break;
95 case Trt: {
96 break;
97 }
99 case Mdt:
100 case Rpc:
101 case Tgc:
102 case Csc:
103 case Mm:
104 case sTgc:{
105 // surface map not needed for the muon detectors
106 ++counter.n_detector_elements;
107 break;
108 }
109 case UnDefined:
110 ATH_MSG_ERROR("Undefined element encountered");
111 counter.n_detector_elements = 0;
112 return;
113 }
114 }, true /*sensitive surfaces*/);
115 ATH_MSG_INFO( "Surfaces without associated detector elements " << (counter.n_sensitive_elements -counter.n_detector_elements)
116 << " (with " << counter.n_detector_elements << ")" );
117 if (counter.n_sensitive_elements > 0 &&
118 counter.n_detector_elements==0) {
119 ATH_MSG_ERROR( "No surface with associated detector element" );
120 return nullptr;
121 }
122 if (counter.n_wrong_type>0) {
123 ATH_MSG_WARNING( "Surfaces associated to detector elements not of type Trk::TrkDetElementBase :" << counter.n_wrong_type);
124 }
125 return detector_element_to_geoid;
126}
127}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
base class interface providing the bare minimal interface extension.
ActsTrk::GeoContextReadKey_t m_rchk
virtual std::shared_ptr< const Acts::TrackingGeometry > trackingGeometry() const override
Access to the built Acts tracking geometry.
std::unique_ptr< ActsTrk::DetectorElementToActsGeometryIdMap > createDetectorElementToGeoIdMap() const
Creates and popules the DetectorElement -> Acts::Surface geo identifier map from the geometry service...
virtual const ActsTrk::DetectorElementToActsGeometryIdMap * surfaceIdMap() const override
Returns the pointer to the identifier mapping between Acts::surface ID & IdentifierHash of the ITk su...
virtual const Acts::TrackingVolume * getEnvelope(const ActsTrk::SystemEnvelope envType) const override
Returns the envelope volume from the tracking geometry that's containing all volumes of the subsystem...
std::unique_ptr< const ActsTrk::DetectorElementToActsGeometryIdMap > m_detIdMap
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
virtual const ActsTrk::GeometryContext & getGeometryContext(const EventContext &ctx) const override
Retrieve the geometry context with alignment constants from store gate.
virtual const ActsTrk::GeometryContext & getNominalGeometryContext() const override
Returns the refrence to the nominal GeometryContext.
This is a "hash" representation of an Identifier.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
@ Mm
Maybe not needed in the migration.
@ Tgc
Resitive Plate Chambers.
@ sTgc
Micromegas (NSW).
@ Rpc
Monitored Drift Tubes.
@ Csc
Thin gap champers.
@ Mdt
MuonSpectrometer.
@ UnDefined
Small Thing Gap chambers (NSW).
DetectorElementKey makeDetectorElementKey(xAOD::UncalibMeasType meas_type, unsigned int identifier_hash)
SystemEnvelope
Define an enumeration to retrieve the envelope tracking volume from.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
UncalibMeasType
Define the type of the uncalibrated measurement.
static const Acts::GeometryIdentifier & makeValue(const Acts::GeometryIdentifier &geo_id)