Geant4-11
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#include "G4SystemOfUnits.hh"
35#include "G4ios.hh"
36
38{
40 return _instance;
41}
42
43// --------------------------------------------------------------------
45{
46}
47
48// --------------------------------------------------------------------
51 : X0(x0), Y0(y0), Z0(z0), T0(t0)
52{
53}
54
55// --------------------------------------------------------------------
57 : X0(xyz0.x()), Y0(xyz0.y()), Z0(xyz0.z()), T0(t0)
58{
59}
60
61// --------------------------------------------------------------------
63{
64 *this = right;
65}
66
67// --------------------------------------------------------------------
69{
70 if(theParticle != nullptr)
71 {
73 while(theNext != nullptr)
74 {
75 G4PrimaryParticle* thisPrimary = theNext;
76 theNext = thisPrimary->GetNext();
77 thisPrimary->ClearNext();
78 delete thisPrimary;
79 }
80 theParticle = nullptr;
81 }
82 delete nextVertex;
83 nextVertex = nullptr;
84
85 theTail = nullptr;
86 tailVertex = nullptr;
87
88 delete userInfo;
89 userInfo = nullptr;
90}
91
92// --------------------------------------------------------------------
94{
95 if (this != &right)
96 {
97 X0 = right.X0;
98 Y0 = right.Y0;
99 Z0 = right.Z0;
100 T0 = right.T0;
101 Weight0 = right.Weight0;
103
104 if (theParticle != nullptr) delete theParticle;
105 theParticle = nullptr;
106 theTail = nullptr;
107 if (right.theParticle != nullptr )
108 {
112 while (np != nullptr) // Loop checking, 09.08.2015, K.Kurashige
113 {
114 theTail = np;
115 np = np->GetNext();
116 }
117 }
118
119 if (nextVertex != nullptr ) delete nextVertex;
120 nextVertex = nullptr;
121 tailVertex = nullptr;
122 if (right.nextVertex != nullptr )
123 {
124 nextVertex = new G4PrimaryVertex(*(right.nextVertex));
127 while (nv != nullptr) // Loop checking, 09.08.2015, K.Kurashige
128 {
129 tailVertex = nv;
130 nv = nv->GetNext();
131 }
132 }
133
134 // userInfo cannot be copied
135 userInfo = nullptr;
136 }
137 return *this;
138}
139
140// --------------------------------------------------------------------
142{
143 return (this==&right);
144}
145
146// --------------------------------------------------------------------
148{
149 return (this!=&right);
150}
151
152// --------------------------------------------------------------------
154{
155 if( i >= 0 && i < numberOfParticle )
156 {
157 G4PrimaryParticle* particle = theParticle;
158 for( G4int j=0; j<i; ++j )
159 {
160 if( particle == nullptr ) return nullptr;
161 particle = particle->GetNext();
162 }
163 return particle;
164 }
165 else
166 {
167 return nullptr;
168 }
169}
170
171// --------------------------------------------------------------------
173{
174 G4cout << "Vertex ( "
175 << X0/mm << "[mm], "
176 << Y0/mm << "[mm], "
177 << Z0/mm << "[mm], "
178 << T0/ns << "[ns] )"
179 << " Weight " << Weight0 << G4endl;
180 if(userInfo != nullptr) userInfo->Print();
181 G4cout << " -- Primary particles :: "
182 << " # of primaries =" << numberOfParticle << G4endl;
183 if( theParticle != nullptr) theParticle->Print();
184 if (nextVertex != nullptr )
185 {
186 G4cout << "Next Vertex " << G4endl;
187 nextVertex->Print();
188 }
189}
static const G4double T0[78]
G4Allocator< G4PrimaryVertex > *& aPrimaryVertexAllocator()
static constexpr double mm
Definition: G4SIunits.hh:95
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4PrimaryParticle * GetNext() const
G4bool operator==(const G4PrimaryVertex &right) const
void Print() const
virtual ~G4PrimaryVertex()
G4PrimaryParticle * theTail
G4PrimaryVertex * GetNext() const
G4PrimaryVertex & operator=(const G4PrimaryVertex &right)
G4VUserPrimaryVertexInformation * userInfo
G4bool operator!=(const G4PrimaryVertex &right) const
G4PrimaryParticle * theParticle
G4PrimaryVertex * tailVertex
G4PrimaryParticle * GetPrimary(G4int i=0) const
G4PrimaryVertex * nextVertex
virtual void Print() const =0
#define G4ThreadLocalStatic
Definition: tls.hh:76
#define ns
Definition: xmlparse.cc:614