ATLAS Offline Software
Loading...
Searching...
No Matches
ISF::ActsFatrasSimTool Class Reference

#include <ActsFatrasSimTool.h>

Inheritance diagram for ISF::ActsFatrasSimTool:
Collaboration diagram for ISF::ActsFatrasSimTool:

Classes

struct  HitSurfaceSelector
 Simple struct to select surfaces where hits should be generated. More...
struct  SingleParticleSimulation
 Single particle simulation with fixed propagator, interactions, and decay. More...

Public Types

using Generator = std::ranlux48
using Navigator = Acts::Navigator
using ChargedStepper = Acts::EigenStepper<Acts::EigenStepperDefaultExtension>
using ChargedPropagator = Acts::Propagator<ChargedStepper, Navigator>
using NeutralStepper = Acts::StraightLineStepper
using NeutralPropagator = Acts::Propagator<NeutralStepper, Navigator>
using ChargedSelector = ActsFatras::ChargedSelector
using ChargedInteractions
using ChargedSimulation
using NeutralSelector = ActsFatras::NeutralSelector
using NeutralInteractions = ActsFatras::InteractionList<ActsFatras::PhotonConversion>
using NeutralSimulation
using Simulation

Public Member Functions

 ActsFatrasSimTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~ActsFatrasSimTool ()
virtual StatusCode initialize () override
virtual StatusCode simulate (const EventContext &ctx, ISFParticle &isp, ISFParticleContainer &, McEventCollection *) override
virtual StatusCode simulateVector (const EventContext &ctx, const ISFParticleVector &particles, ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, McEventCollection *shadowTruth=nullptr) override
 Simulation call for vectors of particles.
virtual StatusCode setupEvent (const EventContext &) override
 Setup Event chain - in case of a begin-of event action is needed.
virtual StatusCode releaseEvent (const EventContext &ctx) override
 Release Event chain - in case of an end-of event action is needed.
virtual ISF::SimulationFlavor simFlavor () const override
virtual Acts::MagneticFieldContext getMagneticFieldContext (const EventContext &) const
virtual StatusCode sysInitialize () override
 Gaudi sysInitialize() methods.
virtual StatusCode setupEventST () override
 Setup Event chain - in case of a begin-of event action is needed (called by ISimulationSvc)
virtual StatusCode releaseEventST () override
 Release Event chain - in case of an end-of event action is needed (called by ISimulationSvc)
const ChronoEntity * chronoStart (const IChronoSvc::ChronoTag &tag)
 wrapper call to start chrono with given tag
const ChronoEntity * chronoStop (const IChronoSvc::ChronoTag &tag)
 wrapper call to stop chrono with given tag

Protected Attributes

ServiceHandle< IChronoStatSvc > m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
 The timing service for general usage.

Private Member Functions

template<class T>
StatusCode retrieveTool (ToolHandle< T > &thandle)
int getATLASProcessCode (ActsFatras::ProcessType actspt)

Private Attributes

SiHitCollection m_pixelSiHits
SiHitCollection m_sctSiHits
ServiceHandle< IAthRNGSvcm_rngSvc {this, "RNGService", "AthRNGSvc"}
ATHRNG::RNGWrapper *m_randomEngine ATLAS_THREAD_SAFE {}
Gaudi::Property< std::string > m_randomEngineName
PublicToolHandle< ActsTrk::ITrackingGeometryToolm_trackingGeometryTool
std::shared_ptr< const Acts::TrackingGeometry > m_trackingGeometry
SG::ReadCondHandleKey< AtlasFieldCacheCondObjm_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}
std::shared_ptr< const Acts::Logger > m_logger {nullptr}
PublicToolHandle< ISF::IParticleFilterm_particleFilter
ServiceHandle< ISF::ITruthSvcm_truthRecordSvc {this, "TruthRecordService", "ISF_TruthRecordSvc", ""}
ToolHandle< ActsFatrasWriteHandlerm_ActsFatrasWriteHandler
Gaudi::Property< double > m_interact_minPt
Gaudi::Property< bool > m_meanEnergyLoss {this, "MeanEnergyLoss", true, "Toggle between mean and mode evaluation of energy loss"}
Gaudi::Property< bool > m_includeGgradient {this, "IncludeGgradient", true, "Boolean flag for inclusion of d(dEds)d(q/p) into energy loss"}
Gaudi::Property< double > m_momentumCutOff {this, "MomentumCutOff", 0., "Cut-off value for the momentum in SI units"}
Gaudi::Property< double > m_maxStep
Gaudi::Property< double > m_maxRungeKuttaStepTrials
Gaudi::Property< double > m_maxStepSize
Gaudi::Property< double > m_pathLimit
Gaudi::Property< bool > m_loopProtection
Gaudi::Property< double > m_loopFraction
Gaudi::Property< double > m_tolerance
Gaudi::Property< double > m_stepSizeCutOff
Gaudi::Property< std::map< int, int > > m_processTypeMap

Detailed Description

Definition at line 70 of file ActsFatrasSimTool.h.

Member Typedef Documentation

◆ ChargedInteractions

Initial value:
ActsFatras::StandardChargedElectroMagneticInteractions

Definition at line 187 of file ActsFatrasSimTool.h.

◆ ChargedPropagator

Definition at line 178 of file ActsFatrasSimTool.h.

◆ ChargedSelector

using ISF::ActsFatrasSimTool::ChargedSelector = ActsFatras::ChargedSelector

Definition at line 186 of file ActsFatrasSimTool.h.

◆ ChargedSimulation

Initial value:
ActsFatras::NoDecay>
ActsFatras::StandardChargedElectroMagneticInteractions ChargedInteractions
Acts::Propagator< ChargedStepper, Navigator > ChargedPropagator
Simple struct to select surfaces where hits should be generated.
Single particle simulation with fixed propagator, interactions, and decay.

Definition at line 189 of file ActsFatrasSimTool.h.

◆ ChargedStepper

using ISF::ActsFatrasSimTool::ChargedStepper = Acts::EigenStepper<Acts::EigenStepperDefaultExtension>

Definition at line 177 of file ActsFatrasSimTool.h.

◆ Generator

using ISF::ActsFatrasSimTool::Generator = std::ranlux48

Definition at line 173 of file ActsFatrasSimTool.h.

◆ Navigator

using ISF::ActsFatrasSimTool::Navigator = Acts::Navigator

Definition at line 175 of file ActsFatrasSimTool.h.

◆ NeutralInteractions

using ISF::ActsFatrasSimTool::NeutralInteractions = ActsFatras::InteractionList<ActsFatras::PhotonConversion>

Definition at line 194 of file ActsFatrasSimTool.h.

◆ NeutralPropagator

Definition at line 181 of file ActsFatrasSimTool.h.

◆ NeutralSelector

using ISF::ActsFatrasSimTool::NeutralSelector = ActsFatras::NeutralSelector

Definition at line 193 of file ActsFatrasSimTool.h.

◆ NeutralSimulation

Initial value:
NeutralPropagator, NeutralInteractions, ActsFatras::NoSurface,
ActsFatras::NoDecay>
Acts::Propagator< NeutralStepper, Navigator > NeutralPropagator
ActsFatras::InteractionList< ActsFatras::PhotonConversion > NeutralInteractions

Definition at line 195 of file ActsFatrasSimTool.h.

◆ NeutralStepper

using ISF::ActsFatrasSimTool::NeutralStepper = Acts::StraightLineStepper

Definition at line 180 of file ActsFatrasSimTool.h.

◆ Simulation

Initial value:
ActsFatras::Simulation<ChargedSelector, ChargedSimulation,
ActsFatras::NeutralSelector NeutralSelector
ActsFatras::ChargedSelector ChargedSelector
SingleParticleSimulation< NeutralPropagator, NeutralInteractions, ActsFatras::NoSurface, ActsFatras::NoDecay > NeutralSimulation
SingleParticleSimulation< ChargedPropagator, ChargedInteractions, HitSurfaceSelector, ActsFatras::NoDecay > ChargedSimulation

Definition at line 199 of file ActsFatrasSimTool.h.

Constructor & Destructor Documentation

◆ ActsFatrasSimTool()

ISF::ActsFatrasSimTool::ActsFatrasSimTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 19 of file ActsFatrasSimTool.cxx.

22 : BaseSimulatorTool(type, name, parent) {}
BaseSimulatorTool()
Default constructor.

◆ ~ActsFatrasSimTool()

ISF::ActsFatrasSimTool::~ActsFatrasSimTool ( )
virtual

Definition at line 24 of file ActsFatrasSimTool.cxx.

24{}

Member Function Documentation

◆ chronoStart()

const ChronoEntity * ISF::BaseSimulatorTool::chronoStart ( const IChronoSvc::ChronoTag & tag)
inlineinherited

wrapper call to start chrono with given tag

Definition at line 98 of file BaseSimulatorTool.h.

98 {
99 if (m_chrono) return m_chrono->chronoStart( tag);
100 return nullptr;
101 }
ServiceHandle< IChronoStatSvc > m_chrono
The timing service for general usage.

◆ chronoStop()

const ChronoEntity * ISF::BaseSimulatorTool::chronoStop ( const IChronoSvc::ChronoTag & tag)
inlineinherited

wrapper call to stop chrono with given tag

Definition at line 104 of file BaseSimulatorTool.h.

104 {
105 if (m_chrono) return m_chrono->chronoStop( tag);
106 return nullptr;
107 }

◆ getATLASProcessCode()

int ISF::ActsFatrasSimTool::getATLASProcessCode ( ActsFatras::ProcessType actspt)
inlineprivate

Definition at line 303 of file ActsFatrasSimTool.h.

303{return m_processTypeMap[static_cast<uint32_t>(actspt)];};
Gaudi::Property< std::map< int, int > > m_processTypeMap
setEventNumber uint32_t

◆ getMagneticFieldContext()

Acts::MagneticFieldContext ISF::ActsFatrasSimTool::getMagneticFieldContext ( const EventContext & ctx) const
virtual

Definition at line 233 of file ActsFatrasSimTool.cxx.

233 {
234 SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx};
235 if (!readHandle.isValid()) {
236 ATH_MSG_ERROR(name() + ": Failed to retrieve magnetic field condition data " + m_fieldCacheCondObjInputKey.key() + ".");
237 }
238 else ATH_MSG_DEBUG(name() << "retrieved magnetic field condition data "<< m_fieldCacheCondObjInputKey.key());
239 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
240
241 return Acts::MagneticFieldContext(fieldCondObj);
242}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey

◆ initialize()

StatusCode ISF::ActsFatrasSimTool::initialize ( )
overridevirtual

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 26 of file ActsFatrasSimTool.cxx.

26 {
28 ATH_MSG_INFO("ISF::ActsFatrasSimTool update with ACTS version: v"
29 << Acts::VersionMajor << "." << Acts::VersionMinor << "."
30 << Acts::VersionPatch << " [" << Acts::CommitHash.value_or("unknown hash") << "]");
31 // Retrieve particle filter
32 if (!m_particleFilter.empty()) ATH_CHECK(m_particleFilter.retrieve());
33
34 // setup logger
35 m_logger = makeActsAthenaLogger(this, std::string("ActsFatras"),std::string("ActsFatrasSimTool"));
36
37 // retrieve tracking geo tool
39 m_trackingGeometry = m_trackingGeometryTool->trackingGeometry();
40
41 //retrieve Magnetfield tool
42 ATH_MSG_VERBOSE("Using ATLAS magnetic field service");
44
45 // Random number service
46 if (m_rngSvc.retrieve().isFailure()) {
47 ATH_MSG_FATAL("Could not retrieve " << m_rngSvc);
48 return StatusCode::FAILURE;
49 }
50 // Get own engine with own seeds
51 m_randomEngine = m_rngSvc->getEngine(this, m_randomEngineName.value());
52 if (!m_randomEngine) {
53 ATH_MSG_FATAL("Could not get random engine '" << m_randomEngineName.value() << "'");
54 return StatusCode::FAILURE;
55 }
56
57 // ISF truth service
58 ATH_CHECK (m_truthRecordSvc.retrieve());
59 ATH_MSG_DEBUG( "- Using ISF TruthRecordSvc : " << m_truthRecordSvc.typeAndName() );
60 return StatusCode::SUCCESS;
61}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
ServiceHandle< IAthRNGSvc > m_rngSvc
std::shared_ptr< const Acts::TrackingGeometry > m_trackingGeometry
std::shared_ptr< const Acts::Logger > m_logger
ServiceHandle< ISF::ITruthSvc > m_truthRecordSvc
PublicToolHandle< ISF::IParticleFilter > m_particleFilter
Gaudi::Property< std::string > m_randomEngineName
virtual StatusCode initialize() override

◆ releaseEvent()

virtual StatusCode ISF::ActsFatrasSimTool::releaseEvent ( const EventContext & )
inlineoverridevirtual

Release Event chain - in case of an end-of event action is needed.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 221 of file ActsFatrasSimTool.h.

221 {
222 std::vector<SiHitCollection> hitcolls;
223 hitcolls.push_back(m_pixelSiHits);
224 hitcolls.push_back(m_sctSiHits);
225 ATH_CHECK(m_ActsFatrasWriteHandler->WriteHits(hitcolls,ctx));
226 ATH_CHECK(m_truthRecordSvc->releaseEvent());
227 return StatusCode::SUCCESS; };
SiHitCollection m_pixelSiHits
ToolHandle< ActsFatrasWriteHandler > m_ActsFatrasWriteHandler

◆ releaseEventST()

virtual StatusCode ISF::BaseSimulatorTool::releaseEventST ( )
inlineoverridevirtualinherited

Release Event chain - in case of an end-of event action is needed (called by ISimulationSvc)

Reimplemented in ISF::BaseSimulatorG4Tool, and ISF::FastCaloSimV2Tool.

Definition at line 94 of file BaseSimulatorTool.h.

95 { return releaseEvent(Gaudi::Hive::currentContext()); }
virtual StatusCode releaseEvent(const EventContext &) override
Release Event chain - in case of an end-of event action is needed.

◆ retrieveTool()

template<class T>
StatusCode ISF::ActsFatrasSimTool::retrieveTool ( ToolHandle< T > & thandle)
inlineprivate

Definition at line 240 of file ActsFatrasSimTool.h.

240 {
241 if (!thandle.empty() && thandle.retrieve().isFailure()) {
242 ATH_MSG_FATAL("Cannot retrieve " << thandle << ". Abort.");
243 return StatusCode::FAILURE;
244 } else ATH_MSG_DEBUG("Successfully retrieved " << thandle);
245 return StatusCode::SUCCESS;
246 }

◆ setupEvent()

virtual StatusCode ISF::ActsFatrasSimTool::setupEvent ( const EventContext & )
inlineoverridevirtual

Setup Event chain - in case of a begin-of event action is needed.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 216 of file ActsFatrasSimTool.h.

216 {
217 ATH_CHECK(m_truthRecordSvc->initializeTruthCollection());
218 m_pixelSiHits.Clear();
219 m_sctSiHits.Clear();
220 return StatusCode::SUCCESS; };

◆ setupEventST()

virtual StatusCode ISF::BaseSimulatorTool::setupEventST ( )
inlineoverridevirtualinherited

Setup Event chain - in case of a begin-of event action is needed (called by ISimulationSvc)

Reimplemented in ISF::BaseSimulatorG4Tool, and ISF::FastCaloSimV2Tool.

Definition at line 67 of file BaseSimulatorTool.h.

68 { return setupEvent(Gaudi::Hive::currentContext()); }
virtual StatusCode setupEvent(const EventContext &) override
Setup Event chain - in case of a begin-of event action is needed.

◆ simFlavor()

virtual ISF::SimulationFlavor ISF::ActsFatrasSimTool::simFlavor ( ) const
inlineoverridevirtual

Definition at line 228 of file ActsFatrasSimTool.h.

228 {
229 return ISF::Fatras; };

◆ simulate()

StatusCode ISF::ActsFatrasSimTool::simulate ( const EventContext & ctx,
ISFParticle & isp,
ISFParticleContainer & secondaries,
McEventCollection * mcEventCollection )
overridevirtual

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 63 of file ActsFatrasSimTool.cxx.

65 {
66 ATH_MSG_VERBOSE("Particle " << isp << " received for simulation.");
67 // Check if particle passes filter, if there is one
68 if (!m_particleFilter.empty() && !m_particleFilter->passFilter(isp)) {
69 ATH_MSG_VERBOSE("ISFParticle " << isp << " does not pass selection. Ignoring.");
70 return StatusCode::SUCCESS;
71 }
72 // Process ParticleState from particle stack
73 // Wrap the input ISFParticle in an STL vector with size of 1
74 const ISF::ISFParticleVector ispVector(1, &isp);
75 ATH_CHECK(this->simulateVector(ctx, ispVector, secondaries, mcEventCollection));
76 ATH_MSG_VERBOSE("Simulation done");
77 return StatusCode::SUCCESS;
78}
virtual StatusCode simulateVector(const EventContext &ctx, const ISFParticleVector &particles, ISFParticleContainer &secondaries, McEventCollection *mcEventCollection, McEventCollection *shadowTruth=nullptr) override
Simulation call for vectors of particles.
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.

◆ simulateVector()

StatusCode ISF::ActsFatrasSimTool::simulateVector ( const EventContext & ctx,
const ISFParticleVector & particles,
ISFParticleContainer & secondaries,
McEventCollection * mcEventCollection,
McEventCollection * = nullptr )
overridevirtual

Simulation call for vectors of particles.

Reimplemented from ISF::BaseSimulatorTool.

Definition at line 80 of file ActsFatrasSimTool.cxx.

84 {
85
86 m_randomEngine->setSeed(m_randomEngineName, ctx);
87 CLHEP::HepRandomEngine* randomEngine = m_randomEngine->getEngine(ctx);
88 Generator generator(CLHEP::RandFlat::shoot(randomEngine->flat()));
89 ATH_MSG_VERBOSE(name() << " RNG seed " << CLHEP::RandFlat::shoot(randomEngine->flat()));
90 ATH_MSG_VERBOSE(name() << " received vector of size "
91 << particles.size() << " particles for simulation.");
92
93 // construct the ACTS simulator
94 Acts::Navigator navigator( Acts::Navigator::Config{ m_trackingGeometry }, m_logger);
95 auto bField = std::make_shared<ATLASMagneticFieldWrapper>();
96 auto chargedStepper = ChargedStepper(std::move(bField));
97 auto neutralStepper = NeutralStepper();
98 auto chargedPropagator = ChargedPropagator(chargedStepper, navigator, m_logger);
99 auto neutralPropagator = NeutralPropagator(neutralStepper, navigator, m_logger);
100 ChargedSimulation simulatorCharged(std::move(chargedPropagator), m_logger);
101 NeutralSimulation simulatorNeutral(std::move(neutralPropagator), m_logger);
102 Simulation simulator=Simulation(std::move(simulatorCharged),std::move(simulatorNeutral));
103 ATH_MSG_VERBOSE(name() << " Min pT for interaction " << m_interact_minPt * Acts::UnitConstants::MeV << " GeV");
104 // Acts propagater options
105 simulator.charged.maxStepSize = m_maxStepSize;
106 simulator.charged.maxStep = m_maxStep;
107 simulator.charged.pathLimit = m_pathLimit;
108 simulator.charged.maxRungeKuttaStepTrials = m_maxRungeKuttaStepTrials;
109 simulator.charged.loopProtection = m_loopProtection;
110 simulator.charged.loopFraction = m_loopFraction;
111 simulator.charged.targetTolerance = m_tolerance;
112 simulator.charged.stepSizeCutOff = m_stepSizeCutOff;
113 // Create interaction list
114 simulator.charged.interactions = ActsFatras::makeStandardChargedElectroMagneticInteractions(m_interact_minPt * Acts::UnitConstants::MeV);
115 // get Geo and Mag map
116 ATH_MSG_VERBOSE(name() << " Getting per event Geo and Mag map");
117 Acts::MagneticFieldContext mctx = getMagneticFieldContext(ctx);
118 const ActsTrk::GeometryContext& gctx = m_trackingGeometryTool->getNominalGeometryContext();
119 auto anygctx = gctx.context();
120 // Loop over ISFParticleVector and process each separately
121 ATH_MSG_VERBOSE(name() << " Processing particles in ISFParticleVector.");
122 for (const auto isfp : particles) {
123 // ====ACTSFatras Simulation====
124 // //
125 // input/output particle and hits containers
126 // Convert to ActsFatras::Particle
127 // ISF: Energy, mass, and momentum are in MeV, position in mm
128 // Acts: Energy, mass, and momentum are in GeV, position in mm
129 ATH_MSG_DEBUG(name() << " Convert ISF::Particle(mass) " << isfp->id()<<"|" << isfp<<"(" << isfp->mass() << ")");
130 std::vector<ActsFatras::Particle> input = std::vector<ActsFatras::Particle>{
131 ActsFatras::Particle(ActsFatras::Barcode().withVertexPrimary(0).withParticle(isfp->id()), static_cast<Acts::PdgParticle>(isfp->pdgCode()),
132 isfp->charge(),isfp->mass() * Acts::UnitConstants::MeV)
133 .setDirection(Acts::makeDirectionFromPhiEta(isfp->momentum().phi(), isfp->momentum().eta()))
134 .setAbsoluteMomentum(isfp->momentum().mag() * Acts::UnitConstants::MeV)
135 .setPosition4(ActsTrk::convertPosToActs(isfp->position(), isfp->timeStamp()))};
136 ATH_MSG_DEBUG(name() << " Propagating ActsFatras::Particle vertex|particle|generation|subparticle, " << input[0]);
137 std::vector<ActsFatras::Particle> simulatedInitial;
138 std::vector<ActsFatras::Particle> simulatedFinal;
139 std::vector<ActsFatras::Hit> hits;
140 // simulate
141 auto result=simulator.simulate(anygctx, mctx, generator, input, simulatedInitial, simulatedFinal, hits);
142 auto simulatedFailure=result.value();
143 if (simulatedFailure.size()>0){
144 for (const auto& simfail : simulatedFailure){
145 auto errCode = Acts::make_error_code(Acts::PropagatorError(simfail.error.value()));
146 ATH_MSG_WARNING(name() << " Particle id " <<simfail.particle.particleId()<< ": fail to be simulated during Propagation: " << errCode.message());
147 ATH_MSG_WARNING(name() << " Particle vertex|particle|generation|subparticle"<<simfail.particle << " starts from position" << Acts::toString(simfail.particle.position()) << " and direction " << Acts::toString(simfail.particle.direction()));
148 return StatusCode::SUCCESS;
149 }
150 }
151
152 ATH_MSG_DEBUG(name() << " initial particle " << simulatedInitial[0]);
153 ATH_MSG_DEBUG(name() << " ActsFatras simulator hits: " << hits.size());
154 int i = 0;
155 for (const auto& hit : hits) {
156 ATH_MSG_DEBUG(name() << " hit pos: " << hit.position() );
157 ++i;
158 if (i>5) break;
159 }
160 ATH_MSG_DEBUG(name() << " No. of particles after ActsFatras simulator: " << simulatedFinal.size());
161 if (!simulatedFinal.empty()){
162 ATH_MSG_DEBUG(name() << " start procesing secondaries");
163 auto itr = simulatedFinal.begin();
164 // Save hits of isfp
165 std::vector<ActsFatras::Hit> particle_hits;
166 if (itr->numberOfHits() > 0) {
167 std::copy(hits.begin(), hits.begin()+itr->numberOfHits(), std::back_inserter(particle_hits));
169 }
170 // Process secondaries
171 auto isKilled = !itr->isAlive();
172 int maxGeneration = simulatedFinal.back().particleId().generation();
173 ATH_MSG_DEBUG(name() << " maxGeneration: "<< maxGeneration);
174 for (int gen = 0; gen <= maxGeneration; ++gen){
175 ATH_MSG_DEBUG(name() << " start with generation "<< gen << "|" << maxGeneration << ": "<< *itr);
176 auto vecsecisfp = std::make_unique<ISF::ISFParticleVector>();
177 while (itr != simulatedFinal.end() && static_cast<int>(itr->particleId().generation()) == gen) {
178 ATH_MSG_DEBUG(name() << " genration "<< gen << "|" << maxGeneration << ": "<< *itr);
179 if(itr->isSecondary()){
180 // convert final particles to ISF::particle
181 const auto pos = ActsTrk::convertPosFromActs(itr->fourPosition()).first;
182 const auto mom = ActsTrk::convertMomFromActs(itr->fourMomentum()).first;
183 double mass = itr->mass() / Acts::UnitConstants::MeV;
184 double charge = itr->charge();
185 int pdgid = itr->pdg();
186 auto properTime = ActsTrk::timeToAthena(itr->time());
187 const int status = 1 + HepMC::SIM_STATUS_THRESHOLD;
188 const int id = HepMC::UNDEFINED_ID;
189 auto secisfp = new ISF::ISFParticle (pos,mom,mass,charge,pdgid,status,properTime,*isfp,id);
190 ATH_MSG_DEBUG(name() <<" secondaries particle (ACTS): "<<*itr<< "("<<itr->momentum()<<")|time "<<itr->time()<<"|process "<< getATLASProcessCode(itr->process()));
191 ATH_MSG_DEBUG(name() <<" secondaries particle (ISF): " << *secisfp << " time "<<secisfp->timeStamp());
192 vecsecisfp->push_back(secisfp);
193 }
194 else{
195 ATH_MSG_DEBUG(name() <<" primary particle found with generation "<< gen);
196 }
197 ++itr;
198 }
199 if (!vecsecisfp->empty()) {
200 ISF::ISFTruthIncident truth(*isfp,
201 *vecsecisfp,
202 getATLASProcessCode((itr-1)->process()),
203 isfp->nextGeoID(),
204 isKilled&&gen==maxGeneration ? ISF::fKillsPrimary : ISF::fPrimarySurvives
205 );
206 ATH_MSG_DEBUG(name() << " Truth incident parentPt2(MinPt2) " << truth.parentPt2() <<" (100 MeV)");
207 ATH_MSG_DEBUG(name() << " Truth incident ChildPt2(MinPt2) " << truth.childrenPt2Pass(300) <<" (300 MeV)");
208 m_truthRecordSvc->registerTruthIncident(truth, true);
209 truth.updateParentAfterIncidentProperties();
210 truth.updateChildParticleProperties();
211 for (auto *secisfp : *vecsecisfp){
212 if (secisfp->getTruthBinding()) {
213 secondaries.push_back(secisfp);
214 }
215 else {
216 ATH_MSG_WARNING("Secondary particle not written out to truth.\n Parent (" << isfp << ")\n Secondary (" << *secisfp <<")");
217 }
218 } // end of truth binding
219 }// end of store truth bind secondaries
220 }
221 }// end of secondaries
222 ATH_MSG_VERBOSE(name() << " No. of secondaries: " << secondaries.size());
223 ATH_MSG_DEBUG(name() << " End of particle " << isfp->id());
224
225 std::vector<ActsFatras::Particle>().swap(input);
226 std::vector<ActsFatras::Particle>().swap(simulatedInitial);
227 std::vector<ActsFatras::Particle>().swap(simulatedFinal);
228 std::vector<ActsFatras::Hit>().swap(hits);
229 } // end of isfp loop
230 return StatusCode::SUCCESS;
231}
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Definition AtlasPID.h:997
Acts::GeometryContext context() const
Gaudi::Property< double > m_maxStepSize
Acts::EigenStepper< Acts::EigenStepperDefaultExtension > ChargedStepper
Gaudi::Property< double > m_tolerance
Gaudi::Property< double > m_interact_minPt
ActsFatras::Simulation< ChargedSelector, ChargedSimulation, NeutralSelector, NeutralSimulation > Simulation
Gaudi::Property< double > m_maxStep
int getATLASProcessCode(ActsFatras::ProcessType actspt)
Gaudi::Property< double > m_pathLimit
Gaudi::Property< double > m_stepSizeCutOff
Gaudi::Property< bool > m_loopProtection
Gaudi::Property< double > m_maxRungeKuttaStepTrials
virtual Acts::MagneticFieldContext getMagneticFieldContext(const EventContext &) const
Gaudi::Property< double > m_loopFraction
Acts::StraightLineStepper NeutralStepper
const std::string process
constexpr double timeToAthena(const double actsT)
Converts a time unit from Acts to Athena units.
std::pair< Amg::Vector3D, double > convertMomFromActs(const Acts::Vector4 &actsMom)
Converts an Acts four-momentum vector into an pair of an Athena three-momentum and the paritcle's ene...
std::pair< Amg::Vector3D, double > convertPosFromActs(const Acts::Vector4 &actsPos)
Converts an Acts 4-vector into a pair of an Athena spatial vector and the passed time.
Acts::Vector4 convertPosToActs(const Amg::Vector3D &athenaPos, const double athenaTime=0.)
Converts a position vector & time from Athena units into Acts units.
constexpr int UNDEFINED_ID
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
@ fKillsPrimary
@ fPrimarySurvives
generator
Configure Herwig7 These are the commands corresponding to what would go into the regular Herwig infil...
status
Definition merge.py:16

◆ sysInitialize()

virtual StatusCode ISF::BaseSimulatorTool::sysInitialize ( )
inlineoverridevirtualinherited

Gaudi sysInitialize() methods.

Definition at line 49 of file BaseSimulatorTool.h.

50 {
52 ATH_CHECK( m_chrono.retrieve() );
53 return StatusCode::SUCCESS;
54 }
virtual StatusCode sysInitialize() override

Member Data Documentation

◆ ATLAS_THREAD_SAFE

ATHRNG::RNGWrapper* m_randomEngine ISF::ActsFatrasSimTool::ATLAS_THREAD_SAFE {}
private

Definition at line 250 of file ActsFatrasSimTool.h.

250{};

◆ m_ActsFatrasWriteHandler

ToolHandle<ActsFatrasWriteHandler> ISF::ActsFatrasSimTool::m_ActsFatrasWriteHandler
private
Initial value:
{
this, "ActsFatrasWriteHandler", "ActsFatrasWriteHandler"}

Definition at line 272 of file ActsFatrasSimTool.h.

272 {
273 this, "ActsFatrasWriteHandler", "ActsFatrasWriteHandler"};

◆ m_chrono

ServiceHandle<IChronoStatSvc> ISF::BaseSimulatorTool::m_chrono {this, "ChronoStatService", "ChronoStatSvc"}
protectedinherited

The timing service for general usage.

Definition at line 115 of file BaseSimulatorTool.h.

115{this, "ChronoStatService", "ChronoStatSvc"};

◆ m_fieldCacheCondObjInputKey

SG::ReadCondHandleKey<AtlasFieldCacheCondObj> ISF::ActsFatrasSimTool::m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}
private

Definition at line 260 of file ActsFatrasSimTool.h.

260{this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"};

◆ m_includeGgradient

Gaudi::Property<bool> ISF::ActsFatrasSimTool::m_includeGgradient {this, "IncludeGgradient", true, "Boolean flag for inclusion of d(dEds)d(q/p) into energy loss"}
private

Definition at line 280 of file ActsFatrasSimTool.h.

280{this, "IncludeGgradient", true, "Boolean flag for inclusion of d(dEds)d(q/p) into energy loss"};

◆ m_interact_minPt

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_interact_minPt
private
Initial value:
{this, "Interact_MinPt", 50.0,
"Min pT of the interactions (MeV)"}

Definition at line 275 of file ActsFatrasSimTool.h.

275 {this, "Interact_MinPt", 50.0,
276 "Min pT of the interactions (MeV)"};

◆ m_logger

std::shared_ptr<const Acts::Logger> ISF::ActsFatrasSimTool::m_logger {nullptr}
private

Definition at line 263 of file ActsFatrasSimTool.h.

263{nullptr};

◆ m_loopFraction

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_loopFraction
private
Initial value:
{this, "LoopFraction", 0.5,
"Allowed loop fraction, 1 is a full loop"}

Definition at line 293 of file ActsFatrasSimTool.h.

293 {this, "LoopFraction", 0.5,
294 "Allowed loop fraction, 1 is a full loop"};

◆ m_loopProtection

Gaudi::Property<bool> ISF::ActsFatrasSimTool::m_loopProtection
private
Initial value:
{this, "LoopProtection", true,
"Loop protection, it adapts the pathLimit"}

Definition at line 291 of file ActsFatrasSimTool.h.

291 {this, "LoopProtection", true,
292 "Loop protection, it adapts the pathLimit"};

◆ m_maxRungeKuttaStepTrials

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_maxRungeKuttaStepTrials
private
Initial value:
{this, "MaxRungeKuttaStepTrials", 10000,
"Maximum number of Runge-Kutta steps for the stepper step call"}

Definition at line 285 of file ActsFatrasSimTool.h.

285 {this, "MaxRungeKuttaStepTrials", 10000,
286 "Maximum number of Runge-Kutta steps for the stepper step call"};

◆ m_maxStep

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_maxStep
private
Initial value:
{this, "MaxSteps", 1000,
"Max number of steps"}

Definition at line 283 of file ActsFatrasSimTool.h.

283 {this, "MaxSteps", 1000,
284 "Max number of steps"};

◆ m_maxStepSize

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_maxStepSize
private
Initial value:
{this, "MaxStepSize", 3.0,
"Max step size (converted to Acts::UnitConstants::m)"}

Definition at line 287 of file ActsFatrasSimTool.h.

287 {this, "MaxStepSize", 3.0,
288 "Max step size (converted to Acts::UnitConstants::m)"};

◆ m_meanEnergyLoss

Gaudi::Property<bool> ISF::ActsFatrasSimTool::m_meanEnergyLoss {this, "MeanEnergyLoss", true, "Toggle between mean and mode evaluation of energy loss"}
private

Definition at line 279 of file ActsFatrasSimTool.h.

279{this, "MeanEnergyLoss", true, "Toggle between mean and mode evaluation of energy loss"};

◆ m_momentumCutOff

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_momentumCutOff {this, "MomentumCutOff", 0., "Cut-off value for the momentum in SI units"}
private

Definition at line 281 of file ActsFatrasSimTool.h.

281{this, "MomentumCutOff", 0., "Cut-off value for the momentum in SI units"};

◆ m_particleFilter

PublicToolHandle<ISF::IParticleFilter> ISF::ActsFatrasSimTool::m_particleFilter
private
Initial value:
{
this, "ParticleFilter", "", "Particle filter kinematic cuts, etc."}

Definition at line 266 of file ActsFatrasSimTool.h.

266 {
267 this, "ParticleFilter", "", "Particle filter kinematic cuts, etc."};

◆ m_pathLimit

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_pathLimit
private
Initial value:
{this, "PathLimit", 100.0,
"Track path limit (converted to Acts::UnitConstants::cm)"}

Definition at line 289 of file ActsFatrasSimTool.h.

289 {this, "PathLimit", 100.0,
290 "Track path limit (converted to Acts::UnitConstants::cm)"};

◆ m_pixelSiHits

SiHitCollection ISF::ActsFatrasSimTool::m_pixelSiHits
private

Definition at line 236 of file ActsFatrasSimTool.h.

◆ m_processTypeMap

Gaudi::Property<std::map<int,int> > ISF::ActsFatrasSimTool::m_processTypeMap
private
Initial value:
{this, "ProcessTypeMap",
{{0,0}, {1,201}, {2,14}, {3,3}, {4,121}}, "proessType map <ActsFatras,G4>"}

Definition at line 300 of file ActsFatrasSimTool.h.

300 {this, "ProcessTypeMap",
301 {{0,0}, {1,201}, {2,14}, {3,3}, {4,121}}, "proessType map <ActsFatras,G4>"};

◆ m_randomEngineName

Gaudi::Property<std::string> ISF::ActsFatrasSimTool::m_randomEngineName
private
Initial value:
{this, "RandomEngineName",
"RandomEngineName", "Name of random number stream"}

Definition at line 251 of file ActsFatrasSimTool.h.

251 {this, "RandomEngineName",
252 "RandomEngineName", "Name of random number stream"};

◆ m_rngSvc

ServiceHandle<IAthRNGSvc> ISF::ActsFatrasSimTool::m_rngSvc {this, "RNGService", "AthRNGSvc"}
private

Definition at line 249 of file ActsFatrasSimTool.h.

249{this, "RNGService", "AthRNGSvc"};

◆ m_sctSiHits

SiHitCollection ISF::ActsFatrasSimTool::m_sctSiHits
private

Definition at line 237 of file ActsFatrasSimTool.h.

◆ m_stepSizeCutOff

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_stepSizeCutOff
private
Initial value:
{this, "StepSizeCutOff", 0.,
"Cut-off value for the step size"}

Definition at line 297 of file ActsFatrasSimTool.h.

297 {this, "StepSizeCutOff", 0.,
298 "Cut-off value for the step size"};

◆ m_tolerance

Gaudi::Property<double> ISF::ActsFatrasSimTool::m_tolerance
private
Initial value:
{this, "Tolerance", 0.0001,
"Tolerance for the error of the integration"}

Definition at line 295 of file ActsFatrasSimTool.h.

295 {this, "Tolerance", 0.0001,
296 "Tolerance for the error of the integration"};

◆ m_trackingGeometry

std::shared_ptr<const Acts::TrackingGeometry> ISF::ActsFatrasSimTool::m_trackingGeometry
private

Definition at line 257 of file ActsFatrasSimTool.h.

◆ m_trackingGeometryTool

PublicToolHandle<ActsTrk::ITrackingGeometryTool> ISF::ActsFatrasSimTool::m_trackingGeometryTool
private
Initial value:
{
this, "TrackingGeometryTool", "ActsTrackingGeometryTool"}

Definition at line 255 of file ActsFatrasSimTool.h.

255 {
256 this, "TrackingGeometryTool", "ActsTrackingGeometryTool"};

◆ m_truthRecordSvc

ServiceHandle<ISF::ITruthSvc> ISF::ActsFatrasSimTool::m_truthRecordSvc {this, "TruthRecordService", "ISF_TruthRecordSvc", ""}
private

Definition at line 269 of file ActsFatrasSimTool.h.

269{this, "TruthRecordService", "ISF_TruthRecordSvc", ""};

The documentation for this class was generated from the following files: