LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ArtG4tkParticle.cc
Go to the documentation of this file.
1
2
#include "
artg4tk/DataProducts/G4DetectorHits/ArtG4tkParticle.hh
"
3
4
#include "Geant4/G4ParticleTable.hh"
5
6
#include <assert.h>
7
8
artg4tk::ArtG4tkParticle::ArtG4tkParticle
()
9
{
10
11
fPDG
= 0;
12
}
13
14
artg4tk::ArtG4tkParticle::ArtG4tkParticle
(
const
int
pdg,
const
CLHEP::HepLorentzVector& mom)
15
{
16
17
fPDG
= pdg;
18
fMomentum
= mom;
19
}
20
21
artg4tk::ArtG4tkParticle::ArtG4tkParticle
(
const
int
pdg,
const
CLHEP::Hep3Vector& mom)
22
{
23
24
SetPDG
(pdg);
25
SetMomentum
(mom);
26
}
27
28
artg4tk::ArtG4tkParticle::ArtG4tkParticle
(
const
artg4tk::ArtG4tkParticle
&
other
)
29
:
fPDG
(other.
fPDG
),
fMomentum
(other.
fMomentum
)
30
{}
31
32
// artg4tk::ArtG4tkParticle& ArtG4tkParticle::operator=( const ArtG4tkParticle& other )
33
//{
34
//
35
// fPDG = other.fPDG;
36
// fMomentum = other.fMomentum;
37
// return *this;
38
//
39
//}
40
41
void
42
artg4tk::ArtG4tkParticle::SetPDG
(
const
int
pdg)
43
{
44
45
fPDG
= pdg;
46
return
;
47
}
48
49
void
50
artg4tk::ArtG4tkParticle::SetMomentum
(
const
CLHEP::HepLorentzVector& mom)
51
{
52
53
fMomentum
= mom;
54
return
;
55
}
56
57
void
58
artg4tk::ArtG4tkParticle::SetMomentum
(
const
CLHEP::Hep3Vector& mom)
59
{
60
61
// NOTE(JVY): A bit of "risky business" in case of ions (apart from
62
// the 6 most basic ones) because they're added "on the fly"
63
// during Geant4 simulation... so if used in the job where
64
// Geant4 sim is also running, it's OK; otherwse better avoid.
65
//
66
assert(
fPDG
!= 0);
67
G4ParticleTable* ptable = G4ParticleTable::GetParticleTable();
68
G4ParticleDefinition* g4pd = ptable->FindParticle(
fPDG
);
69
assert(g4pd);
70
double
mass = g4pd->GetPDGMass();
71
double
e
= std::sqrt(mom.mag2() + mass * mass);
72
fMomentum
.setX(mom.x());
73
fMomentum
.setY(mom.y());
74
fMomentum
.setZ(mom.z());
75
fMomentum
.setE(e);
76
77
return
;
78
}
79
80
std::string
81
artg4tk::ArtG4tkParticle::GetName
()
const
82
{
83
84
// NOTE(JVY): again, this a bit of "risky business" when it comes
85
// to ions/nuclei that can be produced during Geant4 sim.
86
// It all works fine if the analyzer runs in the same job
87
// as Geant4 app because G4IonTable gets populated with
88
// newly produced ions as they appears (on-the-fly).
89
// (Elementary) Particles can be added to the table at the
90
// very start of the job, that's no problem.
91
// But when reading back evt.products, it's NOT the case.
92
// And somehow even G4IonTable::CreateAll<...> doesn't help.
93
//
94
// Maybe better to just store the name as a data member ???
95
96
assert(
fPDG
!= 0);
97
G4ParticleTable* ptable = G4ParticleTable::GetParticleTable();
98
G4ParticleDefinition* g4pd = ptable->FindParticle(
fPDG
);
99
100
// assert(g4pd);
101
102
if
(
fPDG
> 1000000000 && !g4pd) {
103
return
"GenericIon"
;
104
}
else
{
105
return
std::string(g4pd->GetParticleName().c_str());
106
}
107
}
artg4tk::ArtG4tkParticle::fPDG
int fPDG
Definition:
ArtG4tkParticle.hh:59
artg4tk::ArtG4tkParticle::SetPDG
void SetPDG(const int)
Definition:
ArtG4tkParticle.cc:42
artg4tk::ArtG4tkParticle::fMomentum
CLHEP::HepLorentzVector fMomentum
Definition:
ArtG4tkParticle.hh:60
artg4tk::ArtG4tkParticle::ArtG4tkParticle
ArtG4tkParticle()
Definition:
ArtG4tkParticle.cc:8
artg4tk::ArtG4tkParticle
Definition:
ArtG4tkParticle.hh:10
fhicl::other
Definition:
exception.h:26
ArtG4tkParticle.hh
artg4tk::ArtG4tkParticle::SetMomentum
void SetMomentum(const CLHEP::HepLorentzVector &)
Definition:
ArtG4tkParticle.cc:50
e
Float_t e
Definition:
plot.C:35
artg4tk::ArtG4tkParticle::GetName
std::string GetName() const
Definition:
ArtG4tkParticle.cc:81
artg4tk
v12_00_03
source
artg4tk
DataProducts
G4DetectorHits
ArtG4tkParticle.cc
Generated on Thu May 2 2024 20:59:30 for LArSoft by
1.8.11