ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrackingGeometryTool.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
12using namespace ActsTrk;
13
15 ATH_MSG_DEBUG(name() << " initializing");
16 if (parent() != toolSvc()) {
17 ATH_MSG_ERROR("The tool is initialized as a private tool but should be public");
18 return StatusCode::FAILURE;
19 }
21 ATH_CHECK(m_rchk.initialize());
23 if (!m_detIdMap) {
24 return StatusCode::FAILURE;
25 }
26 return StatusCode::SUCCESS;
27}
28
29std::shared_ptr<const Acts::TrackingGeometry> ActsTrackingGeometryTool::trackingGeometry() const {
30 return m_trackingGeometrySvc->trackingGeometry();
31}
35
37 ATH_MSG_DEBUG("Creating alignment context for event");
38 const GeometryContext* geoCtx{nullptr};
39 if (!SG::get(geoCtx, m_rchk, ctx).isSuccess()) {
40 ATH_MSG_ERROR("Creating alignment context failed: read cond handle invalid!");
41 }
42 return *geoCtx;
43}
44
48
49
50std::unique_ptr<ActsTrk::DetectorElementToActsGeometryIdMap>
52 // create map from
53 auto detector_element_to_geoid = std::make_unique<DetectorElementToActsGeometryIdMap>();
54
55 struct Counter{
56 unsigned n_sensitive_elements{0};
57 unsigned n_detector_elements{0};
58 unsigned n_wrong_type{0};
59 };
60 Counter counter {};
61 trackingGeometry()->visitSurfaces([this, &counter, &detector_element_to_geoid](const Acts::Surface *surface) {
62 if (!surface || !surface->associatedDetectorElement()) {
63 ++counter.n_wrong_type;
64 return;
65 }
66 ++counter.n_sensitive_elements;
67 const auto* detEl = dynamic_cast<const IDetectorElementBase*>(surface->associatedDetectorElement());
68 if (!detEl) {
69 return;
70 }
71
72 auto insert_id = [&detector_element_to_geoid, &surface, &counter](const xAOD::UncalibMeasType type,
73 const IdentifierHash& hash) {
74 detector_element_to_geoid->insert(std::make_pair(makeDetectorElementKey(type, hash),
75 DetectorElementToActsGeometryIdMap::makeValue(surface->geometryId())));
76 ++counter.n_detector_elements;
77 };
78 switch(detEl->detectorType()) {
79 using enum DetectorType;
80 case Pixel:
82 dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
83 break;
84 case Sct:
86 dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
87 break;
88 case Hgtd:
90 dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
91 break;
92 case Trt: {
93 break;
94 }
96 case Mdt:
97 case Rpc:
98 case Tgc:
99 case Csc:
100 case Mm:
101 case sTgc:{
102 // surface map not needed for the muon detectors
103 ++counter.n_detector_elements;
104 break;
105 }
106 case UnDefined:
107 ATH_MSG_ERROR("Undefined element encountered");
108 counter.n_detector_elements = 0;
109 return;
110 }
111 }, true /*sensitive surfaces*/);
112 ATH_MSG_INFO( "Surfaces without associated detector elements " << (counter.n_sensitive_elements -counter.n_detector_elements)
113 << " (with " << counter.n_detector_elements << ")" );
114 if (counter.n_sensitive_elements > 0 &&
115 counter.n_detector_elements==0) {
116 ATH_MSG_ERROR( "No surface with associated detector element" );
117 return nullptr;
118 }
119 if (counter.n_wrong_type>0) {
120 ATH_MSG_WARNING( "Surfaces associated to detector elements not of type Trk::TrkDetElementBase :" << counter.n_wrong_type);
121 }
122 return detector_element_to_geoid;
123}
#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)
virtual const ActsTrk::DetectorElementToActsGeometryIdMap * surfaceIdMap() const override
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
SG::ReadHandleKey< ActsTrk::GeometryContext > m_rchk
virtual const ActsTrk::GeometryContext & getNominalGeometryContext() const override
virtual std::shared_ptr< const Acts::TrackingGeometry > trackingGeometry() const override
virtual const ActsTrk::GeometryContext & getGeometryContext(const EventContext &ctx) const override
std::unique_ptr< const ActsTrk::DetectorElementToActsGeometryIdMap > m_detIdMap
std::unique_ptr< ActsTrk::DetectorElementToActsGeometryIdMap > createDetectorElementToGeoIdMap() const
Creates and popules the DetectorElement -> Acts::Surface geo identifier map from the geometry service...
base class interface providing the bare minimal interface extension.
This is a "hash" representation of an Identifier.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
DetectorElementKey makeDetectorElementKey(xAOD::UncalibMeasType meas_type, unsigned int identifier_hash)
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.
@ Trt
Maybe the Sct / Pixel for Itk become seperate entries?
@ Mdt
MuonSpectrometer.
@ UnDefined
Small Thing Gap chambers (NSW)
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)