Geant4
11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PrimaryVertex.cc
Go to the documentation of this file.
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
// G4PrimaryVertex
27
//
28
// Authors: G.Cosmo, 2 December 1995 - Design, based on object model
29
// M.Asai, 29 January 1996 - First implementation
30
// --------------------------------------------------------------------
31
32
#include "
G4PrimaryVertex.hh
"
33
34
#include "
G4SystemOfUnits.hh
"
35
#include "
G4VUserPrimaryVertexInformation.hh
"
36
#include "
G4ios.hh
"
37
38
G4Allocator<G4PrimaryVertex>
*&
aPrimaryVertexAllocator
()
39
{
40
G4ThreadLocalStatic
G4Allocator<G4PrimaryVertex>
* _instance =
nullptr
;
41
return
_instance;
42
}
43
44
G4PrimaryVertex::G4PrimaryVertex
(
G4double
x0,
G4double
y0,
G4double
z0,
G4double
t0)
45
: X0(x0), Y0(y0), Z0(z0), T0(t0)
46
{}
47
48
G4PrimaryVertex::G4PrimaryVertex
(
G4ThreeVector
xyz0,
G4double
t0)
49
: X0(xyz0.x()), Y0(xyz0.y()), Z0(xyz0.z()), T0(t0)
50
{}
51
52
G4PrimaryVertex::G4PrimaryVertex
(
const
G4PrimaryVertex
& right)
53
{
54
*
this
= right;
55
}
56
57
G4PrimaryVertex::~G4PrimaryVertex
()
58
{
59
if
(theParticle !=
nullptr
) {
60
G4PrimaryParticle
* theNext = theParticle;
61
while
(theNext !=
nullptr
) {
62
G4PrimaryParticle
* thisPrimary = theNext;
63
theNext = thisPrimary->
GetNext
();
64
thisPrimary->
ClearNext
();
65
delete
thisPrimary;
66
}
67
theParticle =
nullptr
;
68
}
69
delete
nextVertex;
70
nextVertex =
nullptr
;
71
72
theTail =
nullptr
;
73
tailVertex =
nullptr
;
74
75
delete
userInfo;
76
userInfo =
nullptr
;
77
}
78
79
G4PrimaryVertex
&
G4PrimaryVertex::operator=
(
const
G4PrimaryVertex
& right)
80
{
81
if
(
this
!= &right) {
82
X0 = right.X0;
83
Y0 = right.Y0;
84
Z0 = right.Z0;
85
T0 = right.T0;
86
Weight0 = right.Weight0;
87
numberOfParticle = right.numberOfParticle;
88
89
delete
theParticle;
90
theParticle =
nullptr
;
91
theTail =
nullptr
;
92
if
(right.theParticle !=
nullptr
) {
93
theParticle =
new
G4PrimaryParticle
(*(right.theParticle));
94
theTail = theParticle;
95
G4PrimaryParticle
* np = theParticle->
GetNext
();
96
while
(np !=
nullptr
)
// Loop checking, 09.08.2015, K.Kurashige
97
{
98
theTail = np;
99
np = np->
GetNext
();
100
}
101
}
102
103
delete
nextVertex;
104
nextVertex =
nullptr
;
105
tailVertex =
nullptr
;
106
if
(right.nextVertex !=
nullptr
) {
107
nextVertex =
new
G4PrimaryVertex
(*(right.nextVertex));
108
tailVertex = nextVertex;
109
G4PrimaryVertex
* nv = nextVertex->
GetNext
();
110
while
(nv !=
nullptr
)
// Loop checking, 09.08.2015, K.Kurashige
111
{
112
tailVertex = nv;
113
nv = nv->
GetNext
();
114
}
115
}
116
117
// userInfo cannot be copied
118
userInfo =
nullptr
;
119
}
120
return
*
this
;
121
}
122
123
G4bool
G4PrimaryVertex::operator==
(
const
G4PrimaryVertex
& right)
const
124
{
125
return
(
this
== &right);
126
}
127
128
G4bool
G4PrimaryVertex::operator!=
(
const
G4PrimaryVertex
& right)
const
129
{
130
return
(
this
!= &right);
131
}
132
133
G4PrimaryParticle
*
G4PrimaryVertex::GetPrimary
(
G4int
i)
const
134
{
135
if
(i >= 0 && i < numberOfParticle) {
136
G4PrimaryParticle
* particle = theParticle;
137
for
(
G4int
j = 0; j < i; ++j) {
138
if
(particle ==
nullptr
)
return
nullptr
;
139
particle = particle->
GetNext
();
140
}
141
return
particle;
142
}
143
144
return
nullptr
;
145
}
146
147
void
G4PrimaryVertex::Print
()
const
148
{
149
G4cout
<<
"Vertex ( "
<< X0 / mm <<
"[mm], "
<< Y0 / mm <<
"[mm], "
<< Z0 / mm <<
"[mm], "
150
<< T0 / ns <<
"[ns] )"
151
<<
" Weight "
<< Weight0 <<
G4endl
;
152
if
(userInfo !=
nullptr
) userInfo->
Print
();
153
G4cout
<<
" -- Primary particles :: "
154
<<
" # of primaries ="
<< numberOfParticle <<
G4endl
;
155
if
(theParticle !=
nullptr
) theParticle->
Print
();
156
if
(nextVertex !=
nullptr
) {
157
G4cout
<<
"Next Vertex "
<<
G4endl
;
158
nextVertex->
Print
();
159
}
160
}
aPrimaryVertexAllocator
G4Allocator< G4PrimaryVertex > *& aPrimaryVertexAllocator()
Definition
G4PrimaryVertex.cc:38
G4PrimaryVertex.hh
G4SystemOfUnits.hh
G4double
double G4double
Definition
G4Types.hh:83
G4bool
bool G4bool
Definition
G4Types.hh:86
G4int
int G4int
Definition
G4Types.hh:85
G4VUserPrimaryVertexInformation.hh
G4ios.hh
G4endl
#define G4endl
Definition
G4ios.hh:67
G4cout
G4GLOB_DLL std::ostream G4cout
CLHEP::Hep3Vector
Definition
ThreeVector.h:36
G4Allocator
Definition
G4Allocator.hh:62
G4PrimaryParticle
Definition
G4PrimaryParticle.hh:67
G4PrimaryParticle::ClearNext
void ClearNext()
Definition
G4PrimaryParticle.hh:360
G4PrimaryParticle::Print
void Print() const
Definition
G4PrimaryParticle.cc:232
G4PrimaryParticle::GetNext
G4PrimaryParticle * GetNext() const
Definition
G4PrimaryParticle.hh:280
G4PrimaryVertex
Definition
G4PrimaryVertex.hh:51
G4PrimaryVertex::operator==
G4bool operator==(const G4PrimaryVertex &right) const
Definition
G4PrimaryVertex.cc:123
G4PrimaryVertex::Print
void Print() const
Definition
G4PrimaryVertex.cc:147
G4PrimaryVertex::~G4PrimaryVertex
virtual ~G4PrimaryVertex()
Definition
G4PrimaryVertex.cc:57
G4PrimaryVertex::GetNext
G4PrimaryVertex * GetNext() const
Definition
G4PrimaryVertex.hh:199
G4PrimaryVertex::operator=
G4PrimaryVertex & operator=(const G4PrimaryVertex &right)
Definition
G4PrimaryVertex.cc:79
G4PrimaryVertex::operator!=
G4bool operator!=(const G4PrimaryVertex &right) const
Definition
G4PrimaryVertex.cc:128
G4PrimaryVertex::G4PrimaryVertex
G4PrimaryVertex()=default
G4PrimaryVertex::GetPrimary
G4PrimaryParticle * GetPrimary(G4int i=0) const
Definition
G4PrimaryVertex.cc:133
G4VUserPrimaryVertexInformation::Print
virtual void Print() const =0
G4ThreadLocalStatic
#define G4ThreadLocalStatic
Definition
tls.hh:76
geant4-v11.2.2
source
particles
management
src
G4PrimaryVertex.cc
Generated by
1.12.0