6#include "GaudiKernel/IInterface.h"
8#include "Acts/Geometry/TrackingGeometry.hpp"
9#include "Acts/Material/IntersectionMaterialAssigner.hpp"
10#include "Acts/Material/BinnedSurfaceMaterialAccumulater.hpp"
11#include "Acts/Material/TrackingGeometryMaterial.hpp"
31 std::vector<const Acts::Surface*> materialSurfaces = {};
33 auto surfaceSelector = [&](
const Acts::Surface* surface) {
34 if (surface->surfaceMaterial() !=
nullptr &&
35 std::ranges::find(materialSurfaces, surface) == materialSurfaces.end()) {
36 materialSurfaces.push_back(surface);
44 Acts::IntersectionMaterialAssigner::Config assingerConfig;
45 assingerConfig.surfaces = materialSurfaces;
46 auto materialAssigner = std::make_shared<Acts::IntersectionMaterialAssigner>(assingerConfig,
50 Acts::BinnedSurfaceMaterialAccumulater::Config accumulaterConfig;
51 accumulaterConfig.materialSurfaces = materialSurfaces;
52 auto materialAccumulater = std::make_shared<Acts::BinnedSurfaceMaterialAccumulater>(accumulaterConfig,
56 Acts::MaterialMapper::Config mapperConfig;
57 mapperConfig.assignmentFinder = materialAssigner;
58 mapperConfig.surfaceMaterialAccumulater = materialAccumulater;
65 return StatusCode::SUCCESS;
70 Acts::TrackingGeometryMaterial detectorMaterial =
m_materialMapper->finalizeMaps(*m_mappingState);
76 materialWriter->writeMaterial(geoContext, detectorMaterial);
79 return StatusCode::SUCCESS;
88 if (!materialTracks.
isValid()) {
90 return StatusCode::FAILURE;
99 if (!unmappedMaterialTracks.
isPresent()) {
100 auto coll = std::make_unique<ActsTrk::RecordedMaterialTrackCollection>();
103 auto* unmappedColl = unmappedMaterialTracks.
ptr();
105 ATH_MSG_ERROR(
"RecordedMaterialTrackCollection ptr() is null for key "
107 return StatusCode::FAILURE;
111 auto coll = std::make_unique<ActsTrk::RecordedMaterialTrackCollection>();
114 auto* mappedColl = mappedMaterialTracks.
ptr();
116 ATH_MSG_ERROR(
"RecordedMaterialTrackCollection ptr() is null for key "
118 return StatusCode::FAILURE;
121 auto mappingState =
const_cast<Acts::MaterialMapper::State*
>(m_mappingState.get());
124 Acts::MagneticFieldContext magFieldContext;
127 for (
const auto& materialTrack : *materialTracks) {
129 *mappingState, geoContext.
context(), magFieldContext, materialTrack);
131 mappedColl->push_back(
mapped);
135 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Acts::GeometryContext context() const
SG::WriteHandleKey< RecordedMaterialTrackCollection > m_mappedMaterialTrackCollectionKey
The mapped and unmapped material tracks.
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< RecordedMaterialTrackCollection > m_unmappedMaterialTrackCollectionKey
SG::ReadHandleKey< RecordedMaterialTrackCollection > m_materialTrackCollectionKey
The RecordedMaterialTrackCollection to read.
std::shared_ptr< Acts::MaterialMapper > m_materialMapper
The material mapper from the ACTS core components.
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
The tracking geometry service to retrive the geometry context and material surfaces.
virtual ~MaterialMapping()
ToolHandleArray< IMaterialWriterTool > m_materialMapWriters
The material map writes.
MaterialMapping(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
virtual StatusCode finalize() override
An algorithm that can be simultaneously executed in multiple threads.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
std::vector< std::string > mapped