ATLAS Offline Software
Loading...
Searching...
No Matches
AFatrasG4.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Header include
6#include "AFatrasG4.h"
7
8
9// Geant4 particle includes
10#include "G4Gamma.hh"
11#include "G4Electron.hh"
12#include "G4Positron.hh"
13
14//Geant4
15#include "G4ParticleTable.hh"
16#include "Randomize.hh"
17
18// HepMCHelpers include
20
21// G4 sensitive detector includes
22#include "G4SDManager.hh"
23
24//#define AFATRASG4_DEBUG
25
26
27AFatrasG4::AFatrasG4(const std::string& name,
28 G4Region* region,
29 const PublicToolHandle<IActsFatrasG4Tool>& ActsFatrasG4Tool,
30 AFatrasG4Tool * /*AFatrasG4Tool*/)
31
32: G4VFastSimulationModel(name, region),
34{
35}
36
37G4bool AFatrasG4::IsApplicable(const G4ParticleDefinition& particleType)
38{
39 // Check whether we can simulate the particle with FatrasG4
40 bool isPhoton = &particleType == G4Gamma::GammaDefinition();
41 bool isElectron = &particleType == G4Electron::ElectronDefinition();
42 bool isPositron = &particleType == G4Positron::PositronDefinition();
43 bool isHadron = MC::isHadron(particleType.GetPDGEncoding());
44
45 // FatrasG4 is applicable if it is photon, electron, positron or any hadron
46 bool isApplicable = isPhoton || isElectron || isPositron || isHadron;
47
48 #ifdef AFATRASG4_DEBUG
49 const std::string pName = particleType.GetParticleName();
50 G4cout<< "[AFatrasG4::IsApplicable] Got " << pName <<G4endl;
51 if(isApplicable) G4cout<<"[AFatrasG4::IsApplicable] APPLICABLE"<<G4endl;
52 else G4cout<<"[AFatrasG4::IsApplicable] NOT APPLICABLE"<<G4endl;
53 #endif
54
55
56 return isApplicable;
57}
58
59G4bool AFatrasG4::ModelTrigger(const G4FastTrack& fastTrack)
60{
61
62 #ifdef AFATRASG4_DEBUG
63 G4cout<<"[AFatrasG4::ModelTrigger] Got particle with " <<"\n"
64 <<" pdg=" <<fastTrack.GetPrimaryTrack() -> GetDefinition()->GetPDGEncoding() <<"\n"
65 <<" Ekin="<<fastTrack.GetPrimaryTrack() -> GetKineticEnergy() <<"\n"
66 <<" p=" <<fastTrack.GetPrimaryTrack() -> GetMomentum().mag() <<"\n"
67 <<" x=" <<fastTrack.GetPrimaryTrack() -> GetPosition().x() <<"\n"
68 <<" y=" <<fastTrack.GetPrimaryTrack() -> GetPosition().y() <<"\n"
69 <<" z=" <<fastTrack.GetPrimaryTrack() -> GetPosition().z() <<"\n"
70 <<" r=" <<fastTrack.GetPrimaryTrack() -> GetPosition().perp() <<"\n"
71 <<" eta=" <<fastTrack.GetPrimaryTrack() -> GetMomentum().eta() <<"\n"
72 <<" phi=" <<fastTrack.GetPrimaryTrack() -> GetMomentum().phi() <<"\n"
73 <<G4endl;
74 #endif
75
76 const G4ParticleDefinition * G4Particle = fastTrack.GetPrimaryTrack() -> GetDefinition();
77
78 // Check particle type
79 bool isPhoton = G4Particle == G4Gamma::Definition();
80 bool isElectron = G4Particle == G4Electron::Definition();
81 bool isPositron = G4Particle == G4Positron::Definition();
82
83 // Pass all photons, electrons and positrons to FatrasG4
84 if (isPhoton || isElectron || isPositron){
85 #ifdef AFATRASG4_DEBUG
86 G4cout<<"[AFatrasG4::ModelTrigger] Photons, electrons or positron. Model triggered."<<G4endl;
87 #endif
88 return true;
89 }
90 else return false;
91
92}
93
94void AFatrasG4::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
95{
96 #ifdef AFATRASG4_DEBUG
97 G4cout<<"AFatrasG4::DoIt called"<<G4endl;
98 #endif
99
100 if (!m_ActsFatrasG4Tool.isValid()) {
101 G4cerr << "ActsFatrasG4Tool not valid!" << G4endl;
102 fastStep.KillPrimaryTrack();
103 return;
104 }
105
106 m_ActsFatrasG4Tool->simulateFatrasTrack(fastTrack, fastStep);
107}
108
109
bool isElectron(const T &p)
Definition AtlasPID.h:208
bool isPhoton(const T &p)
Definition AtlasPID.h:382
bool isHadron(const T &p)
Definition AtlasPID.h:357
ATLAS-specific HepMC functions.
AFatrasG4(const std::string &name, G4Region *region, const PublicToolHandle< IActsFatrasG4Tool > &ActsFatrasG4Tool, AFatrasG4Tool *FatrasG4Tool)
Definition AFatrasG4.cxx:27
PublicToolHandle< IActsFatrasG4Tool > m_ActsFatrasG4Tool
Definition AFatrasG4.h:41
virtual G4bool ModelTrigger(const G4FastTrack &) override final
Determines the applicability of the fast sim model to this particular track.
Definition AFatrasG4.cxx:59
virtual void DoIt(const G4FastTrack &, G4FastStep &) override final
Definition AFatrasG4.cxx:94
virtual G4bool IsApplicable(const G4ParticleDefinition &) override final
Definition AFatrasG4.cxx:37
Tool for ACTS Fatras G4.
bool isHadron(const T &p)