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 188 of file ActsFatrasSimTool.h.

◆ ChargedPropagator

Definition at line 179 of file ActsFatrasSimTool.h.

◆ ChargedSelector

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

Definition at line 187 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 190 of file ActsFatrasSimTool.h.

◆ ChargedStepper

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

Definition at line 178 of file ActsFatrasSimTool.h.

◆ Generator

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

Definition at line 174 of file ActsFatrasSimTool.h.

◆ Navigator

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

Definition at line 176 of file ActsFatrasSimTool.h.

◆ NeutralInteractions

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

Definition at line 195 of file ActsFatrasSimTool.h.

◆ NeutralPropagator

Definition at line 182 of file ActsFatrasSimTool.h.

◆ NeutralSelector

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

Definition at line 194 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 196 of file ActsFatrasSimTool.h.

◆ NeutralStepper

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

Definition at line 181 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 200 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 18 of file ActsFatrasSimTool.cxx.

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

◆ ~ActsFatrasSimTool()

ISF::ActsFatrasSimTool::~ActsFatrasSimTool ( )
virtual

Definition at line 23 of file ActsFatrasSimTool.cxx.

23{}

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 304 of file ActsFatrasSimTool.h.

304{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 232 of file ActsFatrasSimTool.cxx.

232 {
233 SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, ctx};
234 if (!readHandle.isValid()) {
235 ATH_MSG_ERROR(name() + ": Failed to retrieve magnetic field condition data " + m_fieldCacheCondObjInputKey.key() + ".");
236 }
237 else ATH_MSG_DEBUG(name() << "retrieved magnetic field condition data "<< m_fieldCacheCondObjInputKey.key());
238 const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
239
240 return Acts::MagneticFieldContext(fieldCondObj);
241}
#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 25 of file ActsFatrasSimTool.cxx.

25 {
27 ATH_MSG_INFO("ISF::ActsFatrasSimTool update with ACTS version: v"
28 << Acts::VersionMajor << "." << Acts::VersionMinor << "."
29 << Acts::VersionPatch << " [" << Acts::CommitHash.value_or("unknown hash") << "]");
30 // Retrieve particle filter
31 if (!m_particleFilter.empty()) ATH_CHECK(m_particleFilter.retrieve());
32
33 // setup logger
34 m_logger = makeActsAthenaLogger(this, std::string("ActsFatras"),std::string("ActsFatrasSimTool"));
35
36 // retrieve tracking geo tool
38 m_trackingGeometry = m_trackingGeometryTool->trackingGeometry();
39
40 //retrieve Magnetfield tool
41 ATH_MSG_VERBOSE("Using ATLAS magnetic field service");
43
44 // Random number service
45 if (m_rngSvc.retrieve().isFailure()) {
46 ATH_MSG_FATAL("Could not retrieve " << m_rngSvc);
47 return StatusCode::FAILURE;
48 }
49 // Get own engine with own seeds
50 m_randomEngine = m_rngSvc->getEngine(this, m_randomEngineName.value());
51 if (!m_randomEngine) {
52 ATH_MSG_FATAL("Could not get random engine '" << m_randomEngineName.value() << "'");
53 return StatusCode::FAILURE;
54 }
55
56 // ISF truth service
57 ATH_CHECK (m_truthRecordSvc.retrieve());
58 ATH_MSG_DEBUG( "- Using ISF TruthRecordSvc : " << m_truthRecordSvc.typeAndName() );
59 return StatusCode::SUCCESS;
60}
#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 222 of file ActsFatrasSimTool.h.

222 {
223 std::vector<SiHitCollection> hitcolls;
224 hitcolls.push_back(m_pixelSiHits);
225 hitcolls.push_back(m_sctSiHits);
226 ATH_CHECK(m_ActsFatrasWriteHandler->WriteHits(hitcolls,ctx));
227 ATH_CHECK(m_truthRecordSvc->releaseEvent());
228 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 241 of file ActsFatrasSimTool.h.

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

◆ 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 217 of file ActsFatrasSimTool.h.

217 {
218 ATH_CHECK(m_truthRecordSvc->initializeTruthCollection());
219 m_pixelSiHits.Clear();
220 m_sctSiHits.Clear();
221 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 229 of file ActsFatrasSimTool.h.

229 {
230 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 62 of file ActsFatrasSimTool.cxx.

64 {
65 ATH_MSG_VERBOSE("Particle " << isp << " received for simulation.");
66 // Check if particle passes filter, if there is one
67 if (!m_particleFilter.empty() && !m_particleFilter->passFilter(isp)) {
68 ATH_MSG_VERBOSE("ISFParticle " << isp << " does not pass selection. Ignoring.");
69 return StatusCode::SUCCESS;
70 }
71 // Process ParticleState from particle stack
72 // Wrap the input ISFParticle in an STL vector with size of 1
73 const ISF::ISFParticleVector ispVector(1, &isp);
74 ATH_CHECK(this->simulateVector(ctx, ispVector, secondaries, mcEventCollection));
75 ATH_MSG_VERBOSE("Simulation done");
76 return StatusCode::SUCCESS;
77}
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 79 of file ActsFatrasSimTool.cxx.

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

251{};

◆ m_ActsFatrasWriteHandler

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

Definition at line 273 of file ActsFatrasSimTool.h.

273 {
274 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 261 of file ActsFatrasSimTool.h.

261{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 281 of file ActsFatrasSimTool.h.

281{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 276 of file ActsFatrasSimTool.h.

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

◆ m_logger

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

Definition at line 264 of file ActsFatrasSimTool.h.

264{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 294 of file ActsFatrasSimTool.h.

294 {this, "LoopFraction", 0.5,
295 "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 292 of file ActsFatrasSimTool.h.

292 {this, "LoopProtection", true,
293 "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 286 of file ActsFatrasSimTool.h.

286 {this, "MaxRungeKuttaStepTrials", 10000,
287 "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 284 of file ActsFatrasSimTool.h.

284 {this, "MaxSteps", 1000,
285 "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 288 of file ActsFatrasSimTool.h.

288 {this, "MaxStepSize", 3.0,
289 "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 280 of file ActsFatrasSimTool.h.

280{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 282 of file ActsFatrasSimTool.h.

282{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 267 of file ActsFatrasSimTool.h.

267 {
268 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 290 of file ActsFatrasSimTool.h.

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

◆ m_pixelSiHits

SiHitCollection ISF::ActsFatrasSimTool::m_pixelSiHits
private

Definition at line 237 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 301 of file ActsFatrasSimTool.h.

301 {this, "ProcessTypeMap",
302 {{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 252 of file ActsFatrasSimTool.h.

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

◆ m_rngSvc

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

Definition at line 250 of file ActsFatrasSimTool.h.

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

◆ m_sctSiHits

SiHitCollection ISF::ActsFatrasSimTool::m_sctSiHits
private

Definition at line 238 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 298 of file ActsFatrasSimTool.h.

298 {this, "StepSizeCutOff", 0.,
299 "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 296 of file ActsFatrasSimTool.h.

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

◆ m_trackingGeometry

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

Definition at line 258 of file ActsFatrasSimTool.h.

◆ m_trackingGeometryTool

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

Definition at line 256 of file ActsFatrasSimTool.h.

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

◆ m_truthRecordSvc

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

Definition at line 270 of file ActsFatrasSimTool.h.

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

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