Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
27 // $Id: G4PrimaryVertex.cc 99159 2016-09-07 08:11:50Z gcosmo $
28 //
29 
30 #include "G4PrimaryVertex.hh"
31 #include "G4SystemOfUnits.hh"
33 #include "G4ios.hh"
34 
36 
38 :X0(0.),Y0(0.),Z0(0.),T0(0.),theParticle(0),theTail(0),
39  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
40 {
41 }
42 
45 :X0(x0),Y0(y0),Z0(z0),T0(t0),theParticle(0),theTail(0),
46  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
47 {
48 }
49 
51 :T0(t0),theParticle(0),theTail(0),
52  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
53 {
54  X0=xyz0.x();
55  Y0=xyz0.y();
56  Z0=xyz0.z();
57 }
58 
60 :theParticle(0),theTail(0),
61  nextVertex(0),tailVertex(0),userInfo(0)
62 {
63  numberOfParticle = right.numberOfParticle;
64  *this = right;
65 }
66 
68 {
69  if(theParticle != 0) {
70  G4PrimaryParticle* theNext = theParticle;
71  while(theNext)
72  {
73  G4PrimaryParticle* thisPrimary = theNext;
74  theNext = thisPrimary->GetNext();
75  thisPrimary->ClearNext();
76  delete thisPrimary;
77  }
78  theParticle = 0;
79  }
80  if(nextVertex != 0) {
81  delete nextVertex;
82  nextVertex =0;
83  }
84  if(userInfo != 0) {
85  delete userInfo;
86  userInfo = 0;
87  }
88 }
89 
91 {
92  if (this != &right) {
93  X0 = right.X0;
94  Y0 = right.Y0;
95  Z0 = right.Z0;
96  T0 = right.T0;
97  Weight0 = right.Weight0;
98 
99  numberOfParticle = 0;
100  if (theParticle !=0) delete theParticle;
101  theParticle =0;
102  theTail =0;
103  if (right.theParticle !=0 ) {
104  theParticle = new G4PrimaryParticle(*(right.theParticle));
105  numberOfParticle += 1;
106  theTail = theParticle;
107  G4PrimaryParticle * np = theParticle->GetNext();
108  while (np !=0) { // Loop checking, 09.08.2015, K.Kurashige
109  numberOfParticle += 1;
110  theTail = np;
111  np = np->GetNext();
112  }
113  }
114 
115  if (nextVertex !=0 ) delete nextVertex;
116  nextVertex = 0;
117  tailVertex =0;
118  if (right.nextVertex !=0 ) {
119  nextVertex = new G4PrimaryVertex(*(right.nextVertex));
120  tailVertex = nextVertex;
121  G4PrimaryVertex* nv = nextVertex->GetNext();
122  while (nv !=0) { // Loop checking, 09.08.2015, K.Kurashige
123  tailVertex = nv;
124  nv = nv->GetNext();
125  }
126  }
127 
128  // userInfo can not be copied
129  userInfo = 0;
130  }
131  return *this;
132 }
133 
135 { return (this==&right); }
136 
138 { return (this!=&right); }
139 
141 {
142  if( i >= 0 && i < numberOfParticle ) {
143  G4PrimaryParticle* particle = theParticle;
144  for( G4int j=0; j<i; j++ ){
145  if( particle == 0 ) return 0;
146  particle = particle->GetNext();
147  }
148  return particle;
149  } else {
150  return 0; }
151 }
152 
154 {
155  G4cout << "Vertex ( "
156  << X0/mm << "[mm], "
157  << Y0/mm << "[mm], "
158  << Z0/mm << "[mm], "
159  << T0/ns << "[ns] )"
160  << " Weight " << Weight0 << G4endl;
161  if(userInfo!=0) userInfo->Print();
162  G4cout << " -- Primary particles :: "
163  << " # of primaries =" << numberOfParticle << G4endl;
164  if( theParticle != 0) theParticle->Print();
165  if (nextVertex !=0 ) {
166  G4cout << "Next Vertex " << G4endl;
167  nextVertex->Print();
168  }
169 }
G4PrimaryVertex & operator=(const G4PrimaryVertex &right)
static constexpr double mm
Definition: G4SIunits.hh:115
G4PART_DLL G4ThreadLocal G4Allocator< G4PrimaryVertex > * aPrimaryVertexAllocator
G4int operator==(const G4PrimaryVertex &right) const
double x() const
void Print() const
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
double z() const
G4PrimaryParticle * GetPrimary(G4int i=0) const
G4GLOB_DLL std::ostream G4cout
G4PrimaryVertex * GetNext() const
virtual void Print() const =0
G4PrimaryParticle * GetNext() const
virtual ~G4PrimaryVertex()
double y() const
static const G4double T0[78]
#define G4endl
Definition: G4ios.hh:61
G4int operator!=(const G4PrimaryVertex &right) const
double G4double
Definition: G4Types.hh:76
#define ns
Definition: xmlparse.cc:614