5#ifndef G4ATLASTOOLS_ACTSFATRASG4TOOL_H
6#define G4ATLASTOOLS_ACTSFATRASG4TOOL_H
21#include "GaudiKernel/ToolHandle.h"
22#include "GaudiKernel/ServiceHandle.h"
23#include "GaudiKernel/EventContext.h"
40#include "Acts/Utilities/UnitVectors.hpp"
43#include "Acts/Geometry/TrackingGeometry.hpp"
44#include "Acts/Geometry/GeometryContext.hpp"
45#include "Acts/MagneticField/MagneticFieldContext.hpp"
46#include "Acts/EventData/BoundTrackParameters.hpp"
47#include "Acts/Propagator/Navigator.hpp"
48#include "Acts/Propagator/EigenStepper.hpp"
49#include "Acts/Propagator/EigenStepperDefaultExtension.hpp"
50#include "Acts/Propagator/StraightLineStepper.hpp"
51#include "Acts/Propagator/detail/SteppingLogger.hpp"
52#include "Acts/Propagator/ActorList.hpp"
53#include "Acts/Propagator/Propagator.hpp"
54#include "Acts/Definitions/ParticleData.hpp"
55#include <Acts/Definitions/Algebra.hpp>
57#include "ActsFatras/EventData/Particle.hpp"
58#include "ActsFatras/EventData/Hit.hpp"
59#include "ActsFatras/EventData/GenerationProcess.hpp"
60#include "ActsFatras/Kernel/InteractionList.hpp"
61#include "ActsFatras/Kernel/SingleParticleSimulation.hpp"
62#include "ActsFatras/Kernel/MultiParticleSimulation.hpp"
63#include "ActsFatras/Kernel/SingleParticleSimulationResult.hpp"
64#include "ActsFatras/Kernel/detail/SimulationActor.hpp"
65#include "ActsFatras/Physics/Decay/NoDecay.hpp"
66#include "ActsFatras/Physics/StandardInteractions.hpp"
67#include "ActsFatras/Physics/ElectroMagnetic/PhotonConversion.hpp"
68#include "ActsFatras/Selectors/SurfaceSelectors.hpp"
76#include "G4FastTrack.hh"
77#include "G4FastStep.hh"
89class ActsFatrasG4Tool :
virtual public extends<AthAlgTool, IActsFatrasG4Tool, IPhysicsInitializationTool>
92 using base_class::base_class;
98 virtual StatusCode
finalize()
override;
103 virtual void simulateFatrasTrack(
const G4FastTrack& fastTrack, G4FastStep& fastStep)
override;
106 virtual const std::vector<SiHit>&
getPixelHitsCache(
const EventContext& ctx)
const override;
107 virtual const std::vector<SiHit>&
getSCTHitsCache(
const EventContext& ctx)
const override;
108 virtual void clearCaches(
const EventContext& ctx)
const override;
119 return surface.isSensitive();
130 template <
typename propagator_t,
typename interactions_t,
typename hit_surface_selector_t,
typename decay_t>
173 template <
typename generator_t>
174 Acts::Result<ActsFatras::SingleParticleSimulationResult>
simulate(
const Acts::GeometryContext &geoCtx,
175 const Acts::MagneticFieldContext &magCtx, generator_t &generator,
176 const ActsFatras::Particle &particle)
const
179 ACTS_VERBOSE(
"Using ActsFatrasSimTool simulate()");
181 using SteppingLogger = Acts::detail::SteppingLogger;
182 using SimulationActor = ActsFatras::detail::SimulationActor<generator_t, decay_t, interactions_t, hit_surface_selector_t>;
183 using Result =
typename SimulationActor::result_type;
184 using Actions = Acts::ActorList<SteppingLogger, SimulationActor, Acts::EndOfWorldReached>;
185 using PropagatorOptions =
typename propagator_t::template Options<Actions>;
188 PropagatorOptions options(geoCtx, magCtx);
191 actor.generator = &generator;
195 actor.initialParticle = particle;
197 Acts::BoundTrackParameters startPoint = Acts::BoundTrackParameters::createCurvilinear(particle.fourPosition(),
198 particle.direction(),
199 particle.qOverP(), std::nullopt,
200 particle.hypothesis()
202 options.pathLimit =
pathLimit * Acts::UnitConstants::cm;
205 options.stepping.maxStepSize =
maxStepSize * Acts::UnitConstants::m;
206 auto result =
propagator.propagate(startPoint, options);
207 if (not result.ok()) {
return result.error();}
232 ActsFatras::NoDecay>;
237 ActsFatras::NoSurface,
238 ActsFatras::NoDecay>;
247 std::shared_ptr<ATLASMagneticFieldWrapper>
m_bField;
261 StatusCode
applyPrimaryUpdate(
const G4Track&,
const std::vector<ActsFatras::Particle>& simulatedFinalParticles, G4FastStep& fastStep);
262 StatusCode
spawnSecondaries(
const std::vector<ActsFatras::Particle>& simulatedFinal,
const G4Track&, G4FastStep& fastStep);
266 const EventContext& ctx,
267 const G4Track& track,
268 const Acts::TrackingGeometry& trackingGeometry,
269 const std::vector<ActsFatras::Hit>& hits
273 const EventContext& ctx,
274 const G4Track& track,
275 const Acts::GeometryContext& anygctx,
276 const Acts::MagneticFieldContext& mctx,
287 Gaudi::Property<std::string>
m_randomEngineName{
this,
"RandomEngineName",
"RandomEngineName",
"Name of random number stream"};
295 std::shared_ptr<const Acts::Logger>
m_logger{
nullptr};
298 Gaudi::Property<double>
m_interact_minPt{
this,
"Interact_MinPt", 50.0,
"Min pT of the interactions (MeV)"};
300 Gaudi::Property<bool>
m_meanEnergyLoss{
this,
"MeanEnergyLoss",
true,
"Toggle between mean and mode evaluation of energy loss"};
301 Gaudi::Property<bool>
m_includeGradient{
this,
"IncludeGradient",
true,
"Boolean flag for inclusion of d(dEds)d(q/p) into energy loss"};
302 Gaudi::Property<double>
m_momentumCutOff{
this,
"MomentumCutOff", 0.,
"Cut-off value for the momentum in SI units"};
304 Gaudi::Property<double>
m_maxStep{
this,
"MaxSteps", 2000,
"Max number of steps"};
305 Gaudi::Property<double>
m_maxRungeKuttaStepTrials{
this,
"MaxRungeKuttaStepTrials", 10000,
"Max number of Runge-Kutta steps for the stepper step call"};
306 Gaudi::Property<double>
m_maxStepSize{
this,
"MaxStepSize", 3.0,
"Max step size (converted to Acts::UnitConstants::m)"};
307 Gaudi::Property<double>
m_pathLimit{
this,
"PathLimit", 3000.0,
"Track path limit (converted to Acts::UnitConstants::cm)"};
308 Gaudi::Property<bool>
m_loopProtection{
this,
"LoopProtection",
true,
"Loop protection, it adapts the pathLimit"};
309 Gaudi::Property<double>
m_loopFraction{
this,
"LoopFraction", 0.5,
"Allowed loop fraction, 1 is a full loop"};
310 Gaudi::Property<double>
m_tolerance{
this,
"Tolerance", 0.0001,
"Tolerance for the error of the integration"};
311 Gaudi::Property<double>
m_stepSizeCutOff{
this,
"StepSizeCutOff", 0.,
"Cut-off value for the step size"};
313 {{0,0}, {1,201}, {2,14}, {3,3}, {4,121}},
314 "proessType map <ActsFatras,G4>"
Maintain a set of objects, one per slot.
Hash map from integers/pointers allowing concurrent, lockless reads.
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
Property holding a SG store/key/clid from which a WriteHandle is made.
Define macros for attributes used to control the static checker.
A wrapper class for event-slot-local random engines.
Utility class to handle the three contexts neeeded in an ACTS reconstruction job 1) GeometryContext -...
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
Maintain a set of objects, one per slot.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Single particle simulation with fixed propagator, interactions, and decay.
std::shared_ptr< const Acts::Logger > localLogger
ChargedPropagator propagator
double maxRungeKuttaStepTrials
ActsFatras::NoDecay decay
Acts::Result< ActsFatras::SingleParticleSimulationResult > simulate(const Acts::GeometryContext &geoCtx, const Acts::MagneticFieldContext &magCtx, generator_t &generator, const ActsFatras::Particle &particle) const
Simulate a single particle without secondaries.
SingleParticleSimulation(propagator_t &&propagator_, std::shared_ptr< const Acts::Logger > localLogger_)
Alternatively construct the simulator with an external logger.
const Acts::Logger & logger() const
Provide access to the local logger instance, e.g. for logging macros.
HitSurfaceSelector selectHitSurface
ChargedInteractions interactions