ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PHG4IonGun.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file PHG4IonGun.cc
1
#include "
PHG4IonGun.h
"
2
3
#include "
PHG4InEvent.h
"
4
#include "
PHG4Particle.h
"
// for PHG4Particle
5
#include "
PHG4Particlev3.h
"
6
7
#include <
fun4all/Fun4AllReturnCodes.h
>
8
9
#include <
phool/getClass.h
>
10
11
#include <Geant4/G4IonTable.hh>
12
#include <Geant4/G4ParticleDefinition.hh>
// for G4ParticleDefinition
13
#include <Geant4/G4String.hh>
// for G4String
14
#include <Geant4/G4SystemOfUnits.hh>
15
16
#include <algorithm>
// for fill
17
#include <cmath>
// for NAN
18
#include <iostream>
// for operator<<, basic_ostream
19
#include <iterator>
// for begin, end
20
21
using namespace
std;
22
23
PHG4IonGun::PHG4IonGun
(
const
string
&
name
)
24
:
PHG4ParticleGeneratorBase
(name)
25
,
ion
(new
PHG4Particlev3
())
26
{
27
}
28
29
void
PHG4IonGun::SetCharge
(
const
int
c
)
30
{
31
ioncharge
= c *
eplus
;
32
}
33
34
void
PHG4IonGun::SetMom
(
const
double
px,
const
double
py,
const
double
pz)
35
{
36
mom
[0] = px;
37
mom
[1] = py;
38
mom
[2] = pz;
39
}
40
41
int
PHG4IonGun::process_event
(
PHCompositeNode
*topNode)
42
{
43
// get pdg code for ions
44
UpdateParticle
();
45
PHG4InEvent
*ineve = findNode::getClass<PHG4InEvent>(topNode,
"PHG4INEVENT"
);
46
ReuseExistingVertex
(topNode);
// checks if we should reuse existing vertex
47
int
vtxindex = ineve->
AddVtx
(
get_vtx_x
(),
get_vtx_y
(),
get_vtx_z
(),
get_t0
());
48
// G4ParticleDefinition* ion = G4IonTable::GetIonTable()->GetIon(Z, A, excitEnergy);
49
//G4PrimaryParticle* g4part = new G4PrimaryParticle(ion);
50
// cout << "name: " << ion->GetParticleName() << ", pdgcode: " << ion->GetPDGEncoding() << endl;
51
PHG4Particle
*
particle
=
new
PHG4Particlev3
(
ion
);
52
SetParticleId
(particle, ineve);
53
ineve->
AddParticle
(vtxindex, particle);
54
return
Fun4AllReturnCodes::EVENT_OK
;
55
}
56
57
void
PHG4IonGun::UpdateParticle
()
58
{
59
ion
->set_A(
A
);
60
ion
->set_Z(
Z
);
61
ion
->set_NumCharge(
ioncharge
);
62
ion
->set_ExcitEnergy(
excitEnergy
);
63
ion
->set_px(
mom
[0]);
64
ion
->set_py(
mom
[1]);
65
ion
->set_pz(
mom
[2]);
66
G4ParticleDefinition
*iondef =
G4IonTable::GetIonTable
()->
GetIon
(
Z
,
A
,
excitEnergy
);
67
ion
->set_name(iondef->
GetParticleName
());
68
ion
->set_pid(iondef->
GetPDGEncoding
());
69
return
;
70
}
71
72
void
PHG4IonGun::Print
(
const
string
&
/*what*/
)
const
73
{
74
cout <<
"PHG4IonGun, using ions of"
<< endl;
75
cout <<
"A: "
<<
A
<<
", Z: "
<<
Z
<<
", charge: "
<<
ioncharge
76
<<
", excitation Energy: "
<<
excitEnergy
<< endl;
77
cout <<
"px: "
<<
mom
[0] /
GeV
<<
" GeV, py: "
<<
mom
[1] /
GeV
<<
" GeV, pz: "
<<
mom
[2] /
GeV
<<
" GeV"
<< endl;
78
}
coresoftware
blob
master
simulation
g4simulation
g4main
PHG4IonGun.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:24:44
using
1.8.2 with
ECCE GitHub integration