Geant4.10
 All Data Structures 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 67971 2013-03-13 10:13:24Z 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  delete theParticle;
71  theParticle = 0;
72  }
73  if(nextVertex != 0) {
74  delete nextVertex;
75  nextVertex =0;
76  }
77  if(userInfo != 0) {
78  delete userInfo;
79  userInfo = 0;
80  }
81 }
82 
84 {
85  if (this != &right) {
86  X0 = right.X0;
87  Y0 = right.Y0;
88  Z0 = right.Z0;
89  T0 = right.T0;
90  Weight0 = right.Weight0;
91 
92  numberOfParticle = 0;
93  if (theParticle !=0) delete theParticle;
94  theParticle =0;
95  theTail =0;
96  if (right.theParticle !=0 ) {
97  theParticle = new G4PrimaryParticle(*(right.theParticle));
98  numberOfParticle += 1;
99  theTail = theParticle;
100  G4PrimaryParticle * np = theParticle->GetNext();
101  while (np !=0) {
102  numberOfParticle += 1;
103  theTail = np;
104  np = np->GetNext();
105  }
106  }
107 
108  if (nextVertex !=0 ) delete nextVertex;
109  nextVertex = 0;
110  tailVertex =0;
111  if (right.nextVertex !=0 ) {
112  nextVertex = new G4PrimaryVertex(*(right.nextVertex));
113  tailVertex = nextVertex;
114  G4PrimaryVertex* nv = nextVertex->GetNext();
115  while (nv !=0) {
116  tailVertex = nv;
117  nv = nv->GetNext();
118  }
119  }
120 
121  // userInfo can not be copied
122  userInfo = 0;
123  }
124  return *this;
125 }
126 
128 { return (this==&right); }
129 
131 { return (this!=&right); }
132 
134 {
135  if( i >= 0 && i < numberOfParticle ) {
136  G4PrimaryParticle* particle = theParticle;
137  for( G4int j=0; j<i; j++ ){
138  if( particle == 0 ) return 0;
139  particle = particle->GetNext();
140  }
141  return particle;
142  } else {
143  return 0; }
144 }
145 
147 {
148  G4cout << "Vertex ( "
149  << X0/mm << "[mm], "
150  << Y0/mm << "[mm], "
151  << Z0/mm << "[mm], "
152  << T0/ns << "[ns] )"
153  << " Weight " << Weight0 << G4endl;
154  if(userInfo!=0) userInfo->Print();
155  G4cout << " -- Primary particles :: "
156  << " # of primaries =" << numberOfParticle << G4endl;
157  if( theParticle != 0) theParticle->Print();
158  if (nextVertex !=0 ) {
159  G4cout << "Next Vertex " << G4endl;
160  nextVertex->Print();
161  }
162 }
G4PrimaryVertex & operator=(const G4PrimaryVertex &right)
G4int operator==(const G4PrimaryVertex &right) const
double x() const
void Print() const
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
double z() const
G4ThreadLocal G4Allocator< G4PrimaryVertex > * aPrimaryVertexAllocator
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
#define G4endl
Definition: G4ios.hh:61
G4int operator!=(const G4PrimaryVertex &right) const
double G4double
Definition: G4Types.hh:76
#define ns
Definition: xmlparse.cc:597