ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PrimaryVertex.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4PrimaryVertex.cc
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 //
28 
29 #include "G4PrimaryVertex.hh"
30 #include "G4SystemOfUnits.hh"
32 #include "G4ios.hh"
33 
35 {
37  return _instance;
38 }
39 
41 :X0(0.),Y0(0.),Z0(0.),T0(0.),
42  theParticle(nullptr),theTail(nullptr),nextVertex(nullptr),tailVertex(nullptr),
43  numberOfParticle(0),Weight0(1.0),userInfo(nullptr)
44 {
45 }
46 
49 :X0(x0),Y0(y0),Z0(z0),T0(t0),
50  theParticle(nullptr),theTail(nullptr),nextVertex(nullptr),tailVertex(nullptr),
51  numberOfParticle(0),Weight0(1.0),userInfo(nullptr)
52 {
53 }
54 
56 :X0(xyz0.x()),Y0(xyz0.y()),Z0(xyz0.z()),T0(t0),
57  theParticle(nullptr),theTail(nullptr),nextVertex(nullptr),tailVertex(nullptr),
58  numberOfParticle(0),Weight0(1.0),userInfo(nullptr)
59 {
60 }
61 
63 :theParticle(nullptr),theTail(nullptr),nextVertex(nullptr),tailVertex(nullptr),
64  numberOfParticle(right.numberOfParticle),Weight0(right.Weight0),userInfo(nullptr)
65 {
66  *this = right;
67 }
68 
70 {
71  if(theParticle != nullptr) {
72  G4PrimaryParticle* theNext = theParticle;
73  while(theNext){
74  G4PrimaryParticle* thisPrimary = theNext;
75  theNext = thisPrimary->GetNext();
76  thisPrimary->ClearNext();
77  delete thisPrimary;
78  }
79  theParticle = nullptr;
80  }
81  if(nextVertex != nullptr) {
82  delete nextVertex;
83  nextVertex =nullptr;
84  }
85  theTail = nullptr;
86  tailVertex = nullptr;
87 
88  if(userInfo != nullptr) {
89  delete userInfo;
90  userInfo = nullptr;
91  }
92 }
93 
95 {
96  if (this != &right) {
97  X0 = right.X0;
98  Y0 = right.Y0;
99  Z0 = right.Z0;
100  T0 = right.T0;
101  Weight0 = right.Weight0;
102 
103  numberOfParticle = 0;
104  if (theParticle != nullptr) delete theParticle;
105  theParticle = nullptr;
106  theTail = nullptr;
107  if (right.theParticle != nullptr ) {
108  theParticle = new G4PrimaryParticle(*(right.theParticle));
109  numberOfParticle += 1;
112  while (np != nullptr) { // Loop checking, 09.08.2015, K.Kurashige
113  numberOfParticle += 1;
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  nextVertex = new G4PrimaryVertex(*(right.nextVertex));
126  while (nv != nullptr) { // Loop checking, 09.08.2015, K.Kurashige
127  tailVertex = nv;
128  nv = nv->GetNext();
129  }
130  }
131 
132  // userInfo can not be copied
133  userInfo = nullptr;
134  }
135  return *this;
136 }
137 
139 { return (this==&right); }
140 
142 { return (this!=&right); }
143 
145 {
146  if( i >= 0 && i < numberOfParticle ) {
148  for( G4int j=0; j<i; j++ ){
149  if( particle == nullptr ) return nullptr;
150  particle = particle->GetNext();
151  }
152  return particle;
153  } else {
154  return nullptr;
155  }
156 }
157 
159 {
160  G4cout << "Vertex ( "
161  << X0/mm << "[mm], "
162  << Y0/mm << "[mm], "
163  << Z0/mm << "[mm], "
164  << T0/ns << "[ns] )"
165  << " Weight " << Weight0 << G4endl;
166  if(userInfo != nullptr) userInfo->Print();
167  G4cout << " -- Primary particles :: "
168  << " # of primaries =" << numberOfParticle << G4endl;
169  if( theParticle != nullptr) theParticle->Print();
170  if (nextVertex != nullptr ) {
171  G4cout << "Next Vertex " << G4endl;
172  nextVertex->Print();
173  }
174 }