ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4FastSimulation
src
FatrasG4.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 "
FatrasG4.h
"
7
8
9
// Geant4 particle includes
10
#include "G4Gamma.hh"
11
#include "G4Electron.hh"
12
#include "G4Positron.hh"
13
#include "G4PionPlus.hh"
14
#include "G4PionMinus.hh"
15
16
//Geant4
17
#include "G4ParticleTable.hh"
18
#include "Randomize.hh"
19
20
// HepMCHelpers include
21
#include "
TruthUtils/HepMCHelpers.h
"
22
23
// G4 sensitive detector includes
24
#include "G4SDManager.hh"
25
26
//#define FATRASG4_DEBUG
27
28
29
FatrasG4::FatrasG4
(
const
std::string& name,
30
G4Region* region)
31
: G4VFastSimulationModel(name, region)
32
{
33
}
34
35
G4bool
FatrasG4::IsApplicable
(
const
G4ParticleDefinition&
particleType
)
36
{
37
// Check whether we can simulate the particle with FatrasG4
38
bool
isPhoton
= &
particleType
== G4Gamma::GammaDefinition();
39
bool
isElectron
= &
particleType
== G4Electron::ElectronDefinition();
40
bool
isPositron = &
particleType
== G4Positron::PositronDefinition();
41
bool
isHadron
=
MC::isHadron
(
particleType
.GetPDGEncoding());
42
43
// FatrasG4 is applicable if it is photon, electron, positron or any hadron
44
bool
isApplicable =
isPhoton
||
isElectron
|| isPositron ||
isHadron
;
45
46
#ifdef FATRASG4_DEBUG
47
const
std::string pName =
particleType
.GetParticleName();
48
G4cout<<
"[FatrasG4::IsApplicable] Got "
<< pName <<G4endl;
49
if
(isApplicable) G4cout<<
"[FatrasG4::IsApplicable] APPLICABLE"
<<G4endl;
50
else
G4cout<<
"[FatrasG4::IsApplicable] NOT APPLICABLE"
<<G4endl;
51
#endif
52
53
54
return
isApplicable;
55
}
56
57
G4bool
FatrasG4::ModelTrigger
(
const
G4FastTrack& fastTrack)
58
{
59
60
#ifdef FATRASG4_DEBUG
61
G4cout<<
"[FatrasG4::ModelTrigger] Got particle with "
<<
"\n"
62
<<
" pdg="
<<fastTrack.GetPrimaryTrack() -> GetDefinition()->GetPDGEncoding() <<
"\n"
63
<<
" Ekin="
<<fastTrack.GetPrimaryTrack() -> GetKineticEnergy() <<
"\n"
64
<<
" p="
<<fastTrack.GetPrimaryTrack() -> GetMomentum().mag() <<
"\n"
65
<<
" x="
<<fastTrack.GetPrimaryTrack() -> GetPosition().x() <<
"\n"
66
<<
" y="
<<fastTrack.GetPrimaryTrack() -> GetPosition().y() <<
"\n"
67
<<
" z="
<<fastTrack.GetPrimaryTrack() -> GetPosition().z() <<
"\n"
68
<<
" r="
<<fastTrack.GetPrimaryTrack() -> GetPosition().perp() <<
"\n"
69
<<
" eta="
<<fastTrack.GetPrimaryTrack() -> GetMomentum().eta() <<
"\n"
70
<<
" phi="
<<fastTrack.GetPrimaryTrack() -> GetMomentum().phi() <<
"\n"
71
<<G4endl;
72
#endif
73
74
const
G4ParticleDefinition * G4Particle = fastTrack.GetPrimaryTrack() -> GetDefinition();
75
76
// Check particle type
77
bool
isPhoton
= G4Particle == G4Gamma::Definition();
78
bool
isElectron
= G4Particle == G4Electron::Definition();
79
bool
isPositron = G4Particle == G4Positron::Definition();
80
81
// Pass all photons, electrons and positrons to FatrasG4
82
if
(
isPhoton
||
isElectron
|| isPositron){
83
#ifdef FATRASG4_DEBUG
84
G4cout<<
"[FatrasG4::ModelTrigger] Photons, electrons or positron. Model triggered."
<<G4endl;
85
#endif
86
return
true
;
87
}
88
else
return
false
;
89
90
}
91
92
void
FatrasG4::DoIt
(
const
G4FastTrack& fastTrack, G4FastStep& fastStep)
93
{
94
95
// VERY trivial DoIt method to get things work
96
// Get Geant4 primary track
97
const
G4Track * G4PrimaryTrack = fastTrack.GetPrimaryTrack();
98
99
#ifdef FATRASG4_DEBUG
100
G4cout<<
"[FatrasG4::DoIt] Handling particle with Ekin: "
<< G4PrimaryTrack->GetKineticEnergy() <<
" MeV. Killing the primary track."
<<G4endl;
101
#endif
102
103
// Just Kill particles below 10 MeV
104
if
(G4PrimaryTrack -> GetKineticEnergy() < 10){
105
fastStep.KillPrimaryTrack();
106
}
107
108
return
;
109
110
}
111
isElectron
bool isElectron(const T &p)
Definition
AtlasPID.h:208
isPhoton
bool isPhoton(const T &p)
Definition
AtlasPID.h:382
isHadron
bool isHadron(const T &p)
Definition
AtlasPID.h:357
FatrasG4.h
HepMCHelpers.h
ATLAS-specific HepMC functions.
FatrasG4::IsApplicable
virtual G4bool IsApplicable(const G4ParticleDefinition &) override final
Definition
FatrasG4.cxx:35
FatrasG4::ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack &) override final
Determines the applicability of the fast sim model to this particular track.
Definition
FatrasG4.cxx:57
FatrasG4::FatrasG4
FatrasG4(const std::string &name, G4Region *region)
Definition
FatrasG4.cxx:29
FatrasG4::DoIt
virtual void DoIt(const G4FastTrack &, G4FastStep &) override final
Definition
FatrasG4.cxx:92
particleType
Definition
particleType.h:29
MC::isHadron
bool isHadron(const T &p)
Definition
HepMCHelpers.h:358
Generated on
for ATLAS Offline Software by
1.17.0