ATLAS Offline Software
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 
12 using 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  }
20  ATH_CHECK(m_trackingGeometrySvc.retrieve());
21  ATH_CHECK(m_rchk.initialize());
22  m_detIdMap = createDetectorElementToGeoIdMap();
23  if (!m_detIdMap) {
24  return StatusCode::FAILURE;
25  }
26  return StatusCode::SUCCESS;
27 }
28 
29 std::shared_ptr<const Acts::TrackingGeometry> ActsTrackingGeometryTool::trackingGeometry() const {
30  return m_trackingGeometrySvc->trackingGeometry();
31 }
33  return m_detIdMap.get();
34 }
35 
37  ATH_MSG_DEBUG("Creating alignment context for event");
38  const ActsGeometryContext* 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 
46  return m_trackingGeometrySvc->getNominalContext();
47 }
48 
49 
50 std::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_detector_elements{0};
57  unsigned n_missing_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  const auto* detEl = dynamic_cast<const IDetectorElementBase*>(surface->associatedDetectorElement());
67  if (!detEl) {
68  ++counter.n_missing_detector_elements;
69  return;
70  }
71  auto insert_id = [&detector_element_to_geoid, &surface, &counter](const xAOD::UncalibMeasType type,
72  const IdentifierHash& hash) {
73  detector_element_to_geoid->insert(std::make_pair(makeDetectorElementKey(type, hash),
74  DetectorElementToActsGeometryIdMap::makeValue(surface->geometryId())));
75  ++counter.n_detector_elements;
76  };
77  switch(detEl->detectorType()) {
78  using enum DetectorType;
79  case Pixel:
81  dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
82  break;
83  case Sct:
85  dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
86  break;
87  case Hgtd:
89  dynamic_cast<const ActsDetectorElement*>(detEl)->identifyHash());
90  break;
91  case Trt: {
92  break;
93  }
95  case Mdt:
96  case Rpc:
97  case Tgc:
98  case Csc:
99  case Mm:
100  case sTgc:{
101  // surface map not needed for the muon detectors
102  ++counter.n_detector_elements;
103  break;
104  }
105  case UnDefined:
106  ATH_MSG_ERROR("Undefined element encountered");
107  counter.n_detector_elements = 0;
108  return;
109  }
110  }, true /*sensitive surfaces*/);
111  ATH_MSG_INFO( "Surfaces without associated detector elements " << counter.n_missing_detector_elements
112  << " (with " << counter.n_detector_elements << ")" );
113  if (counter.n_detector_elements==0) {
114  ATH_MSG_ERROR( "No surface with associated detector element" );
115  return nullptr;
116  }
117  if (counter.n_wrong_type>0) {
118  ATH_MSG_WARNING( "Surfaces associated to detector elements not of type Trk::TrkDetElementBase :" << counter.n_wrong_type);
119  }
120  return detector_element_to_geoid;
121 }
ActsTrackingGeometryTool::surfaceIdMap
virtual const ActsTrk::DetectorElementToActsGeometryIdMap * surfaceIdMap() const override
Definition: ActsTrackingGeometryTool.cxx:32
xAOD::UncalibMeasType::HGTDClusterType
@ HGTDClusterType
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ActsTrk::DetectorElementToActsGeometryIdMap
Definition: DetectorElementToActsGeometryIdMap.h:31
ActsTrk::DetectorType
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
Definition: GeometryDefs.h:17
Pixel
Definition: PixelFEUtils.h:16
xAOD::UncalibMeasType::StripClusterType
@ StripClusterType
ActsTrk::DetectorType::UnDefined
@ UnDefined
Small Thing Gap chambers (NSW)
ActsTrk::DetectorType::Tgc
@ Tgc
Resitive Plate Chambers.
ActsTrk::DetectorType::Sct
@ Sct
ActsTrk::DetectorType::sTgc
@ sTgc
Micromegas (NSW)
Hgtd
Definition: HgtdTimedClusteringTool.cxx:10
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ActsTrk::IDetectorElementBase
base class interface providing the bare minimal interface extension.
Definition: IDetectorElement.h:32
ActsTrackingGeometryTool::initialize
StatusCode initialize() override
Definition: ActsTrackingGeometryTool.cxx:14
ActsTrk::DetectorType::Mm
@ Mm
Maybe not needed in the migration.
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
ActsTrackingGeometryTool.h
ActsTrk::DetectorType::Csc
@ Csc
Thin gap champers.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ActsTrk::makeDetectorElementKey
DetectorElementKey makeDetectorElementKey(xAOD::UncalibMeasType meas_type, unsigned int identifier_hash)
Definition: DetectorElementToActsGeometryIdMap.h:23
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::DetectorElementToActsGeometryIdMap::makeValue
static const Acts::GeometryIdentifier & makeValue(const Acts::GeometryIdentifier &geo_id)
Definition: DetectorElementToActsGeometryIdMap.h:33
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrackingGeometryTool::getGeometryContext
virtual const ActsGeometryContext & getGeometryContext(const EventContext &ctx) const override
Definition: ActsTrackingGeometryTool.cxx:36
ActsTrk::DetectorType::Trt
@ Trt
Maybe the Sct / Pixel for Itk become seperate entries?
ActsDetectorElement
Definition: ActsDetectorElement.h:44
ActsDetectorElement.h
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
ActsTrackingGeometryTool::getNominalGeometryContext
virtual const ActsGeometryContext & getNominalGeometryContext() const override
Definition: ActsTrackingGeometryTool.cxx:45
ActsTrk::DetectorType::Mdt
@ Mdt
MuonSpectrometer.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::UncalibMeasType
UncalibMeasType
Define the type of the uncalibrated measurement.
Definition: MeasurementDefs.h:25
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
ActsTrk::DetectorType::Rpc
@ Rpc
Monitored Drift Tubes.
ActsTrackingGeometryTool::createDetectorElementToGeoIdMap
std::unique_ptr< ActsTrk::DetectorElementToActsGeometryIdMap > createDetectorElementToGeoIdMap() const
Creates and popules the DetectorElement -> Acts::Surface geo identifier map from the geometry service...
Definition: ActsTrackingGeometryTool.cxx:51
IDetectorElement.h
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
test_pyathena.counter
counter
Definition: test_pyathena.py:15
ActsTrackingGeometryTool::trackingGeometry
virtual std::shared_ptr< const Acts::TrackingGeometry > trackingGeometry() const override
Definition: ActsTrackingGeometryTool.cxx:29
xAOD::UncalibMeasType::PixelClusterType
@ PixelClusterType