7#include "CLHEP/Random/RandomEngine.h"
8#include "GaudiKernel/IInterface.h"
10#include "Acts/Geometry/TrackingGeometry.hpp"
11#include "Acts/Material/IntersectionMaterialAssigner.hpp"
27 std::vector<const Acts::Surface*> materialSurfaces = {};
29 auto surfaceSelector = [&](
const Acts::Surface* surface) {
30 if (surface->surfaceMaterial() !=
nullptr &&
31 std::ranges::find(materialSurfaces, surface) == materialSurfaces.end()) {
32 materialSurfaces.push_back(surface);
40 Acts::IntersectionMaterialAssigner::Config assingerConfig;
41 assingerConfig.surfaces = materialSurfaces;
42 auto materialAssigner = std::make_shared<Acts::IntersectionMaterialAssigner>(assingerConfig,
46 Acts::MaterialValidator::Config validatorConfig;
47 validatorConfig.materialAssigner = materialAssigner;
51 return StatusCode::SUCCESS;
62 auto coll = std::make_unique<ActsTrk::RecordedMaterialTrackCollection>();
67 auto* coll = materialTracks.
ptr();
69 ATH_MSG_ERROR(
"RecordedMaterialTrackCollection ptr() is null for key "
71 return StatusCode::FAILURE;
75 Acts::Vector3 startPosition(0., 0., 0.);
77 Acts::MagneticFieldContext magFieldContext;
81 CLHEP::HepRandomEngine *rndmEngine = wrapper->
getEngine(ctx);
84 for (std::size_t iTrack = 0; iTrack <
m_nTracks; ++iTrack) {
88 double theta = 2 * std::atan(std::exp(-
eta));
89 Acts::Vector3 direction(std::cos(
phi) * std::sin(
theta),
99 coll->push_back(std::move(rmTrack));
103 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#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)
A wrapper class for event-slot-local random engines.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Acts::GeometryContext context() const
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
The random number service.
SG::WriteHandleKey< RecordedMaterialTrackCollection > m_materialTrackCollectionKey
The RecordedMaterialTrackCollection to write.
virtual ~MaterialValidation()
MaterialValidation(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::pair< double, double > > m_etaRange
The eta range for track generation.
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
The tracking geometry service to retrive the geometry context and material surfaces.
std::shared_ptr< Acts::MaterialValidator > m_materialValidator
The material validator from the ACTS core components.
Gaudi::Property< size_t > m_nTracks
The number of tracks to use per event.
An algorithm that can be simultaneously executed in multiple threads.
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.