ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_Geant4
ISF_Geant4Event
src
ISFG4Helper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// class header
6
#include "
ISF_Geant4Event/ISFG4Helper.h
"
7
8
// Geant4 includes
9
#include "G4Track.hh"
10
#include "G4ThreeVector.hh"
11
12
#include "
AtlasHepMC/GenParticle.h
"
13
#include "
TruthUtils/MagicNumbers.h
"
14
15
// G4Atlas includes
16
#include "
MCTruth/TrackInformation.h
"
17
18
// ISF includes
19
#include "
ISF_Event/ISFParticle.h
"
20
21
22
// ATLAS GeoPrimitves (Amg::Vector3D etc)
23
#include "
GeoPrimitives/GeoPrimitives.h
"
24
25
27
ISF::ISFParticle
*
28
iGeant4::ISFG4Helper::convertG4TrackToISFParticle
(
const
G4Track& aTrack,
29
const
ISF::ISFParticle
& parent,
30
ISF::TruthBinding
* truth)
31
{
32
const
G4ThreeVector& g4pos = aTrack.GetPosition();
33
const
double
gTime = aTrack.GetGlobalTime();
34
const
Amg::Vector3D
position(g4pos.x(),g4pos.y(),g4pos.z());
35
36
const
G4ThreeVector& g4mom = aTrack.GetMomentum();
37
const
Amg::Vector3D
momentum(g4mom.x(),g4mom.y(),g4mom.z());
38
39
const
G4ParticleDefinition &particleDefinition = *aTrack.GetDefinition();
40
double
mass = particleDefinition.GetPDGMass();
41
double
charge
= particleDefinition.GetPDGCharge();
42
int
pdgID = particleDefinition.GetPDGEncoding();
43
44
int
barcode = (truth && truth->
getCurrentGenParticle
() ) ?
HepMC::barcode
(truth->
getCurrentGenParticle
()) :
HepMC::UNDEFINED_ID
;
// FIXME barcode-based
45
const
int
id
= (truth && truth->
getCurrentGenParticle
() ) ?
HepMC::uniqueID
(truth->
getCurrentGenParticle
()) :
HepMC::UNDEFINED_ID
;
46
const
int
status = (truth && truth->
getCurrentGenParticle
() ) ? truth->
getCurrentGenParticle
()->status() : 1;
47
ISF::ISFParticle
*isp =
new
ISF::ISFParticle
( position,
48
momentum,
49
mass,
50
charge
,
51
pdgID,
52
status,
53
gTime,
54
parent,
55
id
,
56
barcode,
// FIXME barcode-based
57
truth
58
);
59
60
return
isp;
61
}
62
63
65
VTrackInformation
*
66
iGeant4::ISFG4Helper::getISFTrackInfo
(
const
G4Track& aTrack)
67
{
68
VTrackInformation
*
trackInfo
=
static_cast<
VTrackInformation
*
>
(aTrack.GetUserInformation());
69
return
trackInfo
;
70
}
71
72
74
TrackInformation
*
75
iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track
( G4Track& aTrack,
76
ISF::ISFParticle
& baseIsp,
77
VTrackInformation::TrackClassification
classification,
78
HepMC::GenParticlePtr
generationZeroGenParticle)
79
{
80
if
( aTrack.GetUserInformation() ) {
81
G4ExceptionDescription
description
;
82
description
<< G4String(
"ISFG4Helper::attachTrackInfoToNewG4Track: "
)
83
<<
"Trying to attach new TrackInformation object to G4Track which already has a TrackUserInformation attached (trackID: "
84
<< aTrack.GetTrackID() <<
", track pos: "
<<aTrack.GetPosition() <<
", mom: "
<<aTrack.GetMomentum()
85
<<
", parentID "
<< aTrack.GetParentID() <<
")"
;
86
G4Exception(
"ISFG4Helper::attachTrackInfoToNewG4Track"
,
"TrackUserInformationAlreadyExists"
, FatalException,
description
);
87
return
nullptr
;
88
}
89
90
auto
* truthBinding = baseIsp.
getTruthBinding
();
91
if
( !truthBinding ) {
92
G4ExceptionDescription
description
;
93
description
<< G4String(
"ISFG4Helper::attachTrackInfoToNewG4Track: "
)
94
<<
"No TruthBinding present in base ISFParticle (trackID: "
95
<< aTrack.GetTrackID() <<
", track pos: "
<<aTrack.GetPosition() <<
", mom: "
<<aTrack.GetMomentum()
96
<<
", parentID "
<< aTrack.GetParentID() <<
", ISFParticle: "
<<baseIsp<<
")"
;
97
G4Exception(
"ISFG4Helper::attachTrackInfoToNewG4Track"
,
"NoISFTruthBinding"
, FatalException,
description
);
98
return
nullptr
;
99
}
100
101
TrackInformation
*
trackInfo
=
new
TrackInformation
(
nullptr
, &baseIsp );
102
trackInfo
->SetPrimaryGenParticle( truthBinding->getPrimaryGenParticle() );
103
trackInfo
->SetGenerationZeroGenParticle( generationZeroGenParticle );
104
if
(classification !=
VTrackInformation::Secondary
) {
105
trackInfo
->SetCurrentGenParticle( truthBinding->getCurrentGenParticle() );
106
}
107
trackInfo
->SetClassification( classification );
108
aTrack.SetUserInformation(
trackInfo
);
109
110
return
trackInfo
;
111
}
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
GenParticle.h
GeoPrimitives.h
ISFG4Helper.h
ISFParticle.h
MagicNumbers.h
TrackInformation.h
ISF::ISFParticle
The generic ISF particle definition,.
Definition
ISFParticle.h:42
ISF::ISFParticle::getTruthBinding
const TruthBinding * getTruthBinding() const
pointer to the simulation truth - optional, can be 0
ISF::TruthBinding
Definition
TruthBinding.h:18
ISF::TruthBinding::getCurrentGenParticle
HepMC::GenParticlePtr getCurrentGenParticle()
pointer to the particle in the simulation truth
TrackInformation
Implementation of VTrackInformation.
Definition
TrackInformation.h:44
VTrackInformation
Instances of classes derived from this class are attached as UserInformation to G4Tracks.
Definition
VTrackInformation.h:30
VTrackInformation::TrackClassification
TrackClassification
Definition
VTrackInformation.h:32
VTrackInformation::Secondary
@ Secondary
Definition
VTrackInformation.h:32
iGeant4::ISFG4Helper::getISFTrackInfo
static VTrackInformation * getISFTrackInfo(const G4Track &aTrack)
return a valid UserInformation object of the G4Track for use within the ISF
Definition
ISFG4Helper.cxx:66
iGeant4::ISFG4Helper::convertG4TrackToISFParticle
static ISF::ISFParticle * convertG4TrackToISFParticle(const G4Track &aTrack, const ISF::ISFParticle &parent, ISF::TruthBinding *truth=nullptr)
convert the given G4Track into an ISFParticle
Definition
ISFG4Helper.cxx:28
iGeant4::ISFG4Helper::attachTrackInfoToNewG4Track
static TrackInformation * attachTrackInfoToNewG4Track(G4Track &aTrack, ISF::ISFParticle &baseIsp, VTrackInformation::TrackClassification classification, HepMC::GenParticlePtr generationZeroGenParticle=nullptr)
attach a new TrackInformation object to the given new (!) G4Track (the G4Track must not have a UserIn...
Definition
ISFG4Helper.cxx:75
description
std::string description
glabal timer - how long have I taken so far?
Definition
hcg.cxx:93
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
HepMC::barcode
int barcode(const T *p)
Definition
Barcode.h:15
HepMC::uniqueID
int uniqueID(const T &p)
Definition
MagicNumbers.h:89
HepMC::UNDEFINED_ID
constexpr int UNDEFINED_ID
Definition
MagicNumbers.h:57
HepMC::GenParticlePtr
HepMC3::GenParticlePtr GenParticlePtr
Definition
GenParticle.h:19
trackInfo
Definition
TrigInDetUtils.h:13
Generated on
for ATLAS Offline Software by
1.17.0