Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4PrimaryVertex << 27 // 23 // 28 // Authors: G.Cosmo, 2 December 1995 - Design, << 24 // $Id: G4PrimaryVertex.cc,v 1.1 2005/03/25 00:40:32 asaim Exp $ 29 // M.Asai, 29 January 1996 - First im << 25 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 30 // ------------------------------------------- << 26 // 31 27 32 #include "G4PrimaryVertex.hh" 28 #include "G4PrimaryVertex.hh" 33 << 34 #include "G4SystemOfUnits.hh" << 35 #include "G4VUserPrimaryVertexInformation.hh" 29 #include "G4VUserPrimaryVertexInformation.hh" 36 #include "G4ios.hh" 30 #include "G4ios.hh" 37 31 38 G4Allocator<G4PrimaryVertex>*& aPrimaryVertexA << 32 G4Allocator<G4PrimaryVertex> aPrimaryVertexAllocator; 39 { << 40 G4ThreadLocalStatic G4Allocator<G4PrimaryVer << 41 return _instance; << 42 } << 43 << 44 G4PrimaryVertex::G4PrimaryVertex(G4double x0, << 45 : X0(x0), Y0(y0), Z0(z0), T0(t0) << 46 {} << 47 << 48 G4PrimaryVertex::G4PrimaryVertex(G4ThreeVector << 49 : X0(xyz0.x()), Y0(xyz0.y()), Z0(xyz0.z()), << 50 {} << 51 33 52 G4PrimaryVertex::G4PrimaryVertex(const G4Prima << 34 G4PrimaryVertex::G4PrimaryVertex() 53 { << 35 :X0(0.),Y0(0.),Z0(0.),T0(0.),theParticle(0),theTail(0), 54 *this = right; << 36 nextVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0) >> 37 {;} >> 38 >> 39 G4PrimaryVertex::G4PrimaryVertex( >> 40 G4double x0,G4double y0,G4double z0,G4double t0) >> 41 :X0(x0),Y0(y0),Z0(z0),T0(t0),theParticle(0),theTail(0), >> 42 nextVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0) >> 43 {;} >> 44 >> 45 G4PrimaryVertex::G4PrimaryVertex(G4ThreeVector xyz0,G4double t0) >> 46 :T0(t0),theParticle(0),theTail(0), >> 47 nextVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0) >> 48 { >> 49 X0=xyz0.x(); >> 50 Y0=xyz0.y(); >> 51 Z0=xyz0.z(); 55 } 52 } 56 53 57 G4PrimaryVertex::~G4PrimaryVertex() 54 G4PrimaryVertex::~G4PrimaryVertex() 58 { 55 { 59 if (theParticle != nullptr) { << 56 if(theParticle != 0) 60 G4PrimaryParticle* theNext = theParticle; << 57 { delete theParticle; } 61 while (theNext != nullptr) { << 58 if(nextVertex != 0) 62 G4PrimaryParticle* thisPrimary = theNext << 59 { delete nextVertex; } 63 theNext = thisPrimary->GetNext(); << 60 if(userInfo != 0) 64 thisPrimary->ClearNext(); << 61 { delete userInfo; } 65 delete thisPrimary; << 66 } << 67 theParticle = nullptr; << 68 } << 69 delete nextVertex; << 70 nextVertex = nullptr; << 71 << 72 theTail = nullptr; << 73 tailVertex = nullptr; << 74 << 75 delete userInfo; << 76 userInfo = nullptr; << 77 } << 78 << 79 G4PrimaryVertex& G4PrimaryVertex::operator=(co << 80 { << 81 if (this != &right) { << 82 X0 = right.X0; << 83 Y0 = right.Y0; << 84 Z0 = right.Z0; << 85 T0 = right.T0; << 86 Weight0 = right.Weight0; << 87 numberOfParticle = right.numberOfParticle; << 88 << 89 delete theParticle; << 90 theParticle = nullptr; << 91 theTail = nullptr; << 92 if (right.theParticle != nullptr) { << 93 theParticle = new G4PrimaryParticle(*(ri << 94 theTail = theParticle; << 95 G4PrimaryParticle* np = theParticle->Get << 96 while (np != nullptr) // Loop checking, << 97 { << 98 theTail = np; << 99 np = np->GetNext(); << 100 } << 101 } << 102 << 103 delete nextVertex; << 104 nextVertex = nullptr; << 105 tailVertex = nullptr; << 106 if (right.nextVertex != nullptr) { << 107 nextVertex = new G4PrimaryVertex(*(right << 108 tailVertex = nextVertex; << 109 G4PrimaryVertex* nv = nextVertex->GetNex << 110 while (nv != nullptr) // Loop checking, << 111 { << 112 tailVertex = nv; << 113 nv = nv->GetNext(); << 114 } << 115 } << 116 << 117 // userInfo cannot be copied << 118 userInfo = nullptr; << 119 } << 120 return *this; << 121 } << 122 << 123 G4bool G4PrimaryVertex::operator==(const G4Pri << 124 { << 125 return (this == &right); << 126 } << 127 << 128 G4bool G4PrimaryVertex::operator!=(const G4Pri << 129 { << 130 return (this != &right); << 131 } 62 } 132 63 133 G4PrimaryParticle* G4PrimaryVertex::GetPrimary << 64 const G4PrimaryVertex & 134 { << 65 G4PrimaryVertex::operator=(const G4PrimaryVertex &) 135 if (i >= 0 && i < numberOfParticle) { << 66 { return *this; } 136 G4PrimaryParticle* particle = theParticle; << 67 G4int G4PrimaryVertex::operator==(const G4PrimaryVertex &right) const 137 for (G4int j = 0; j < i; ++j) { << 68 { return (this==&right); } 138 if (particle == nullptr) return nullptr; << 69 G4int G4PrimaryVertex::operator!=(const G4PrimaryVertex &right) const 139 particle = particle->GetNext(); << 70 { return (this!=&right); } 140 } << 141 return particle; << 142 } << 143 << 144 return nullptr; << 145 } << 146 71 147 void G4PrimaryVertex::Print() const 72 void G4PrimaryVertex::Print() const 148 { 73 { 149 G4cout << "Vertex ( " << X0 / mm << "[mm], << 74 G4cout << "Vertex ( " 150 << T0 / ns << "[ns] )" << 75 << X0 << ", " << Y0 << ", " << Z0 << ", " << T0 << " )" 151 << " Weight " << Weight0 << G4endl; << 76 << " Weight " << Weight0 << G4endl; 152 if (userInfo != nullptr) userInfo->Print(); << 77 if(userInfo!=0) userInfo->Print(); 153 G4cout << " -- Primary particles :: " << 78 G4cout << "#### Primary particles" << G4endl; 154 << " # of primaries =" << numberOfP << 79 G4PrimaryParticle* aPrim = theParticle; 155 if (theParticle != nullptr) theParticle->Pri << 80 if(aPrim != 0) 156 if (nextVertex != nullptr) { << 81 { 157 G4cout << "Next Vertex " << G4endl; << 82 aPrim->Print(); 158 nextVertex->Print(); << 83 aPrim = aPrim->GetNext(); 159 } 84 } 160 } 85 } 161 86