[824] | 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: G4DynamicParticle.icc,v 1.16 2007/03/11 07:17:35 kurasige Exp $ |
---|
[850] | 28 | // GEANT4 tag $Name: HEAD $ |
---|
[824] | 29 | // |
---|
| 30 | // |
---|
| 31 | // ------------------------------------------------------------ |
---|
| 32 | // GEANT 4 class header file |
---|
| 33 | // |
---|
| 34 | // History: first implementation, based on object model of |
---|
| 35 | // 17 AUg. 1999 H.Kurashige |
---|
| 36 | // ------------------------------------------------------------ |
---|
| 37 | |
---|
| 38 | #if defined G4PARTICLES_ALLOC_EXPORT |
---|
| 39 | extern G4DLLEXPORT G4Allocator<G4DynamicParticle> aDynamicParticleAllocator; |
---|
| 40 | #else |
---|
| 41 | extern G4DLLIMPORT G4Allocator<G4DynamicParticle> aDynamicParticleAllocator; |
---|
| 42 | #endif |
---|
| 43 | |
---|
| 44 | // ------------------------ |
---|
| 45 | // Inlined operators |
---|
| 46 | // ------------------------ |
---|
| 47 | |
---|
| 48 | inline void * G4DynamicParticle::operator new(size_t) |
---|
| 49 | { |
---|
| 50 | void * aDynamicParticle; |
---|
| 51 | aDynamicParticle = (void *) aDynamicParticleAllocator.MallocSingle(); |
---|
| 52 | return aDynamicParticle; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | inline void G4DynamicParticle::operator delete(void * aDynamicParticle) |
---|
| 56 | { |
---|
| 57 | aDynamicParticleAllocator.FreeSingle((G4DynamicParticle *) aDynamicParticle); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | // ------------------------ |
---|
| 61 | // Inlined functions |
---|
| 62 | // ------------------------ |
---|
| 63 | |
---|
| 64 | inline const G4ElectronOccupancy* G4DynamicParticle::GetElectronOccupancy() const |
---|
| 65 | { |
---|
| 66 | return theElectronOccupancy; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | inline G4int G4DynamicParticle::GetTotalOccupancy() const |
---|
| 70 | { |
---|
| 71 | G4int value = 0; |
---|
| 72 | if ( theElectronOccupancy != 0) { |
---|
| 73 | value = theElectronOccupancy->GetTotalOccupancy(); |
---|
| 74 | } |
---|
| 75 | return value; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | inline G4int G4DynamicParticle::GetOccupancy(G4int orbit) const |
---|
| 79 | { |
---|
| 80 | G4int value = 0; |
---|
| 81 | if ( theElectronOccupancy != 0) { |
---|
| 82 | value = theElectronOccupancy->GetOccupancy(orbit); |
---|
| 83 | } |
---|
| 84 | return value; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | inline void G4DynamicParticle::AddElectron(G4int orbit, G4int number ) |
---|
| 88 | { |
---|
| 89 | if ( theElectronOccupancy != 0) { |
---|
| 90 | G4int n = theElectronOccupancy->AddElectron(orbit, number ); |
---|
| 91 | theDynamicalCharge -= eplus * n; |
---|
| 92 | theDynamicalMass += GetElectronMass() * n; |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | inline void G4DynamicParticle::RemoveElectron(G4int orbit, G4int number) |
---|
| 97 | { |
---|
| 98 | if ( theElectronOccupancy != 0) { |
---|
| 99 | G4int n = theElectronOccupancy->RemoveElectron(orbit, number ); |
---|
| 100 | theDynamicalCharge += eplus * n; |
---|
| 101 | theDynamicalMass -= GetElectronMass() * n; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | inline G4double G4DynamicParticle::GetCharge() const |
---|
| 108 | { |
---|
| 109 | return theDynamicalCharge; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | inline void G4DynamicParticle::SetCharge(G4double newCharge) |
---|
| 113 | { |
---|
| 114 | theDynamicalCharge = newCharge; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | inline void G4DynamicParticle::SetCharge(G4int newCharge) |
---|
| 118 | { |
---|
| 119 | theDynamicalCharge = newCharge*eplus; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | inline G4double G4DynamicParticle::GetMass() const |
---|
| 123 | { |
---|
| 124 | return theDynamicalMass; |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | inline G4double G4DynamicParticle::GetSpin() const |
---|
| 129 | { |
---|
| 130 | return theDynamicalSpin; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | inline void G4DynamicParticle::SetSpin(G4double spin) |
---|
| 134 | { |
---|
| 135 | theDynamicalSpin = spin; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | inline void G4DynamicParticle::SetSpin(G4int spinInUnitOfHalfInteger) |
---|
| 139 | { |
---|
| 140 | theDynamicalSpin = spinInUnitOfHalfInteger * 0.5; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | inline G4double G4DynamicParticle::GetMagneticMoment() const |
---|
| 144 | { |
---|
| 145 | return theDynamicalMagneticMoment; |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | inline void G4DynamicParticle::SetMagneticMoment(G4double magneticMoment) |
---|
| 149 | { |
---|
| 150 | theDynamicalMagneticMoment = magneticMoment; |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | inline void G4DynamicParticle::SetMass(G4double newMass) |
---|
| 154 | { |
---|
| 155 | theDynamicalMass = newMass; |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | inline const G4ThreeVector& G4DynamicParticle::GetMomentumDirection() const |
---|
| 159 | { |
---|
| 160 | return theMomentumDirection; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | inline G4ThreeVector G4DynamicParticle::GetMomentum() const |
---|
| 164 | { |
---|
| 165 | G4double pModule = std::sqrt(theKineticEnergy*theKineticEnergy + |
---|
| 166 | 2*theKineticEnergy*theDynamicalMass); |
---|
| 167 | G4ThreeVector pMomentum(theMomentumDirection.x()*pModule, |
---|
| 168 | theMomentumDirection.y()*pModule, |
---|
| 169 | theMomentumDirection.z()*pModule); |
---|
| 170 | return pMomentum; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | inline G4LorentzVector G4DynamicParticle::Get4Momentum() const |
---|
| 174 | { |
---|
| 175 | G4double mass = theDynamicalMass; |
---|
| 176 | G4double energy = theKineticEnergy; |
---|
| 177 | G4double momentum = std::sqrt(energy*energy+2.0*mass*energy); |
---|
| 178 | G4LorentzVector p4( theMomentumDirection.x()*momentum, |
---|
| 179 | theMomentumDirection.y()*momentum, |
---|
| 180 | theMomentumDirection.z()*momentum, |
---|
| 181 | energy+mass); |
---|
| 182 | return p4; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | inline G4double G4DynamicParticle::GetTotalMomentum() const |
---|
| 186 | { |
---|
| 187 | // The momentum is returned in energy equivalent. |
---|
| 188 | return std::sqrt((theKineticEnergy + 2.*theDynamicalMass)* theKineticEnergy); |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | inline G4ParticleDefinition* G4DynamicParticle::GetDefinition() const |
---|
| 192 | { |
---|
| 193 | return theParticleDefinition; |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | inline const G4ThreeVector& G4DynamicParticle::GetPolarization() const |
---|
| 197 | { |
---|
| 198 | return thePolarization; |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | inline G4double G4DynamicParticle::GetProperTime() const |
---|
| 202 | { |
---|
| 203 | return theProperTime; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | inline G4double G4DynamicParticle::GetTotalEnergy() const |
---|
| 207 | { |
---|
| 208 | return (theKineticEnergy+theDynamicalMass); |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | inline G4double G4DynamicParticle::GetKineticEnergy() const |
---|
| 212 | { |
---|
| 213 | return theKineticEnergy; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | inline void G4DynamicParticle::SetMomentumDirection(const G4ThreeVector &aDirection) |
---|
| 217 | { |
---|
| 218 | theMomentumDirection = aDirection; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | inline void G4DynamicParticle::SetMomentumDirection(G4double px, G4double py, G4double pz) |
---|
| 222 | { |
---|
| 223 | theMomentumDirection.setX(px); |
---|
| 224 | theMomentumDirection.setY(py); |
---|
| 225 | theMomentumDirection.setZ(pz); |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | |
---|
| 229 | inline void G4DynamicParticle::SetPolarization(G4double polX, G4double polY, G4double polZ) |
---|
| 230 | { |
---|
| 231 | thePolarization.setX(polX); |
---|
| 232 | thePolarization.setY(polY); |
---|
| 233 | thePolarization.setZ(polZ); |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | inline void G4DynamicParticle::SetKineticEnergy(G4double aEnergy) |
---|
| 237 | { |
---|
| 238 | theKineticEnergy = aEnergy; |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | inline void G4DynamicParticle::SetProperTime(G4double atime) |
---|
| 242 | { |
---|
| 243 | theProperTime = atime; |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | inline const G4DecayProducts* G4DynamicParticle::GetPreAssignedDecayProducts() const |
---|
| 247 | { |
---|
| 248 | return thePreAssignedDecayProducts; |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | inline void G4DynamicParticle::SetPreAssignedDecayProducts(G4DecayProducts* aDecayProducts) |
---|
| 252 | { |
---|
| 253 | thePreAssignedDecayProducts = aDecayProducts; |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | inline G4double G4DynamicParticle::GetPreAssignedDecayProperTime() const |
---|
| 257 | { |
---|
| 258 | return thePreAssignedDecayTime; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | inline void G4DynamicParticle::SetPreAssignedDecayProperTime(G4double aTime) |
---|
| 262 | { |
---|
| 263 | thePreAssignedDecayTime = aTime; |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | inline |
---|
| 267 | void G4DynamicParticle::SetVerboseLevel(G4int value) |
---|
| 268 | { |
---|
| 269 | verboseLevel = value; |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | inline |
---|
| 273 | G4int G4DynamicParticle::GetVerboseLevel() const |
---|
| 274 | { |
---|
| 275 | return verboseLevel; |
---|
| 276 | } |
---|
| 277 | |
---|
| 278 | inline |
---|
| 279 | void G4DynamicParticle::SetPrimaryParticle(G4PrimaryParticle* p) |
---|
| 280 | { |
---|
| 281 | primaryParticle=p; |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | inline |
---|
| 285 | G4PrimaryParticle* G4DynamicParticle::GetPrimaryParticle() const |
---|
| 286 | { |
---|
| 287 | return primaryParticle; |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | inline |
---|
| 291 | G4int G4DynamicParticle::GetPDGcode() const |
---|
| 292 | { |
---|
| 293 | G4int code = theParticleDefinition->GetPDGEncoding(); |
---|
| 294 | if(code==0) code = thePDGcode; |
---|
| 295 | return code; |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | inline |
---|
| 299 | void G4DynamicParticle::SetPDGcode(G4int c) |
---|
| 300 | { |
---|
| 301 | thePDGcode = c; |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | |
---|
| 305 | |
---|
| 306 | |
---|
| 307 | |
---|
| 308 | |
---|
| 309 | |
---|