Geant4  9.6.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$
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 
43  G4double x0,G4double y0,G4double z0,G4double t0)
44 :X0(x0),Y0(y0),Z0(z0),T0(t0),theParticle(0),theTail(0),
45  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
46 {;}
47 
49 :T0(t0),theParticle(0),theTail(0),
50  nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
51 {
52  X0=xyz0.x();
53  Y0=xyz0.y();
54  Z0=xyz0.z();
55 }
56 
58 :theParticle(0),theTail(0),
59  nextVertex(0),tailVertex(0),userInfo(0)
60 {
61  numberOfParticle = right.numberOfParticle;
62  *this = right;
63 }
64 
66 {
67  if(theParticle != 0) {
68  delete theParticle;
69  theParticle = 0;
70  }
71  if(nextVertex != 0) {
72  delete nextVertex;
73  nextVertex =0;
74  }
75  if(userInfo != 0) {
76  delete userInfo;
77  userInfo = 0;
78  }
79 }
80 
82 {
83  if (this != &right) {
84  X0 = right.X0;
85  Y0 = right.Y0;
86  Z0 = right.Z0;
87  T0 = right.T0;
88  Weight0 = right.Weight0;
89 
90  numberOfParticle = 0;
91  if (theParticle !=0) delete theParticle;
92  theParticle =0;
93  theTail =0;
94  if (right.theParticle !=0 ) {
95  theParticle = new G4PrimaryParticle(*(right.theParticle));
96  numberOfParticle += 1;
97  theTail = theParticle;
98  G4PrimaryParticle * np = theParticle->GetNext();
99  while (np !=0) {
100  numberOfParticle += 1;
101  theTail = np;
102  np = np->GetNext();
103  }
104  }
105 
106  if (nextVertex !=0 ) delete nextVertex;
107  nextVertex = 0;
108  tailVertex =0;
109  if (right.nextVertex !=0 ) {
110  nextVertex = new G4PrimaryVertex(*(right.nextVertex));
111  tailVertex = nextVertex;
112  G4PrimaryVertex* nv = nextVertex->GetNext();
113  while (nv !=0) {
114  tailVertex = nv;
115  nv = nv->GetNext();
116  }
117  }
118 
119  // userInfo can not be copied
120  userInfo = 0;
121  }
122  return *this;
123 }
124 
126 { return (this==&right); }
127 
129 { return (this!=&right); }
130 
132 {
133  if( i >= 0 && i < numberOfParticle ) {
134  G4PrimaryParticle* particle = theParticle;
135  for( G4int j=0; j<i; j++ ){
136  if( particle == 0 ) return 0;
137  particle = particle->GetNext();
138  }
139  return particle;
140  } else {
141  return 0; }
142 }
143 
145 {
146  G4cout << "Vertex ( "
147  << X0/mm << "[mm], "
148  << Y0/mm << "[mm], "
149  << Z0/mm << "[mm], "
150  << T0/ns << "[ns] )"
151  << " Weight " << Weight0 << G4endl;
152  if(userInfo!=0) userInfo->Print();
153  G4cout << " -- Primary particles :: "
154  << " # of primaries =" << numberOfParticle << G4endl;
155  if( theParticle != 0) theParticle->Print();
156  if (nextVertex !=0 ) {
157  G4cout << "Next Vertex " << G4endl;
158  nextVertex->Print();
159  }
160 }