326{
328
329 const int pdg =
parent->pdgCode();
330
331
332 if ( pdg>10000 ) return chDef;
333
334
335
336
337
338
339 static std::mutex processMapMutex;
340
341
342 static const StatusCode g4RunManagerInit = [&]() {
343 std::scoped_lock lock(processMapMutex);
347 }();
348 if (g4RunManagerInit.isFailure()) return chDef;
349
350
351
354
356 ATH_MSG_DEBUG (
" [ g4sim ] No hadronic interactions registered for current particle type (pdg=" << pdg <<
")" );
357 std::scoped_lock lock(processMapMutex);
359 this_nc->initProcessPDG(pdg);
360 return chDef;
361 }
362
363
364 ATH_MSG_DEBUG (
" [ g4sim ] Found registered hadronic interactions for current particle type (pdg=" << pdg <<
")" );
365
366
367
368 const G4ParticleDefinition *g4parDef = G4ParticleTable::GetParticleTable()->FindParticle(pdg);
369 if ( g4parDef==0) {
370 ATH_MSG_WARNING(
"[ ---- ] Unable to find G4ParticleDefinition for particle with PID=" << pdg <<
" --> skipping hadronic interactions" );
371 return chDef;
372 }
373 G4DynamicParticle* inputPar = new G4DynamicParticle();
374 inputPar->SetDefinition( g4parDef);
375
378 return chDef;
379 }
381 inputPar->SetMomentum( mom);
382
383 G4Track g4track( inputPar, 0 , {0, 0, 0} );
384
385
386
387
389
391 return chDef;
392 }
393
394
395 G4Step g4step;
396 G4StepPoint* g4stepPoint = new G4StepPoint();
397 g4step.SetPreStepPoint( g4stepPoint);
398
401
402
403 g4track.SetStep( &g4step);
404
405
407
408
409
412
413
414 if( rand < 0.5)
process = processIter_elast->second;
415 }
416
417 ATH_MSG_VERBOSE (
" [ g4sim ] Computing " <<
process->GetProcessName() <<
" process with current particle" );
418
419
420
421
422
423 G4VParticleChange* g4change =
process->PostStepDoIt(g4track, g4step);
424 if (!g4change) {
425 ATH_MSG_WARNING(
" [ ---- ] Geant4 did not return any hadronic interaction information of particle with pdg=" << pdg );
426 return chDef;
427 }
428
429
430 unsigned int numSecondaries = g4change->GetNumberOfSecondaries();
431 ATH_MSG_DEBUG(
"[ g4sim ] Material update created " << numSecondaries <<
" Geant4 particle (s)." );
432
433
434 if ( numSecondaries ) {
435
437 ISF::ISFParticleVector::iterator childrenIt =
children.begin();
438 unsigned short numChildren = 0;
439 for (
unsigned int i = 0;
i < numSecondaries;
i++ ){
440
441
442 G4Track *trk = g4change->GetSecondary(i);
443 const G4DynamicParticle *dynPar = trk->GetDynamicParticle();
444
445
447 continue;
448
449
450 const G4ParticleDefinition *parDef = trk->GetParticleDefinition();
451
452
453 if (parDef->GetPDGEncoding()>1.e09) continue;
454
455
456
457
458
459 ATH_MSG_VERBOSE(
" [ g4sim ] Adding child particle to particle stack (pdg=" << parDef->GetPDGEncoding()
460 << " p=" << dynPar->GetTotalMomentum() );
461
462
463
464 const G4ThreeVector &momG4 = dynPar->GetMomentum();
466
469 ISF::ISFParticle* cParticle = new ISF::ISFParticle( position,
470 mom,
471 parDef->GetPDGMass(),
472 parDef->GetPDGCharge(),
473 parDef->GetPDGEncoding(),
474 status,
475 time,
476 *parent,
477 id );
480
481 *childrenIt = cParticle;
482 ++childrenIt; numChildren++;
483 }
484
486
487
488 const int processForTI = 121;
489 ISF::ISFTruthIncident truth( const_cast<ISF::ISFParticle&>(*parent),
490 children,
491 processForTI,
495
496
497 truth.updateChildParticleProperties();
498
499
500 for (auto *childParticle : children) {
501 if (!childParticle->getTruthBinding()) {
502 ATH_MSG_ERROR(
"Could not retrieve TruthBinding from child ISFParticle "<< *childParticle);
503 }
504 }
505
506
507 g4change->Clear();
509
510 }
511
512
513 g4change->Clear();
514 return chDef;
515}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATLAS_THREAD_SAFE
void setNextSimID(SimSvcID simID)
register the next SimSvcID
void setNextGeoID(AtlasDetDescr::AtlasRegion geoID)
register the next AtlasDetDescr::AtlasRegion
std::map< int, G4VProcess * > m_g4HadrInelasticProcesses
std::vector< std::pair< float, std::pair< G4Material *, G4MaterialCutsCouple > > > m_g4Material
std::map< int, G4VProcess * > m_g4HadrElasticProcesses
unsigned int retrieveG4MaterialIndex(const Trk::Material *ematprop) const
random number service
const std::string process
Eigen::Matrix< double, 3, 1 > Vector3D
::StatusCode StatusCode
StatusCode definition for legacy code.
constexpr int UNDEFINED_ID
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...