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 // J.L. Chuma, TRIUMF, 31-Oct-1996 << 23 // 27 // last modified: 19-Dec-1996 << 24 // 28 // Modified by J.L.Chuma, 05-May-97 << 25 // J.L. Chuma, TRIUMF, 31-Oct-1996 29 // M. Kelsey 29-Aug-2011 -- Use G4Allocator fo << 26 // last modified: 19-Dec-1996 30 << 27 // Modified by J.L.Chuma, 05-May-97 >> 28 31 #include "G4ReactionProduct.hh" 29 #include "G4ReactionProduct.hh" 32 30 33 G4Allocator<G4ReactionProduct>*& aRPAllocator( << 34 { << 35 G4ThreadLocalStatic G4Allocator<G4Reaction << 36 return _instance; << 37 } << 38 << 39 G4ReactionProduct::G4ReactionProduct() : 31 G4ReactionProduct::G4ReactionProduct() : 40 theParticleDefinition(NULL), 32 theParticleDefinition(NULL), 41 formationTime(0.0), 33 formationTime(0.0), 42 hasInitialStateParton(false), 34 hasInitialStateParton(false), 43 mass(0.0), 35 mass(0.0), 44 totalEnergy(0.0), 36 totalEnergy(0.0), 45 kineticEnergy(0.0), 37 kineticEnergy(0.0), 46 timeOfFlight(0.0), 38 timeOfFlight(0.0), 47 side(0), 39 side(0), 48 theCreatorModel(-1), << 49 theParentResonanceDef(nullptr), << 50 theParentResonanceID(0), << 51 NewlyAdded(false), 40 NewlyAdded(false), 52 MayBeKilled(true) 41 MayBeKilled(true) 53 { 42 { 54 SetMomentum( 0.0, 0.0, 0.0 ); 43 SetMomentum( 0.0, 0.0, 0.0 ); 55 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 44 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 56 } 45 } 57 46 58 G4ReactionProduct::G4ReactionProduct( 47 G4ReactionProduct::G4ReactionProduct( 59 const G4ParticleDefinition *aParticleDefinit << 48 G4ParticleDefinition *aParticleDefinition ) 60 { 49 { 61 SetMomentum( 0.0, 0.0, 0.0 ); 50 SetMomentum( 0.0, 0.0, 0.0 ); 62 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 51 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 63 formationTime = 0.0; 52 formationTime = 0.0; 64 hasInitialStateParton = false; 53 hasInitialStateParton = false; 65 theParticleDefinition = aParticleDefinitio 54 theParticleDefinition = aParticleDefinition; 66 mass = aParticleDefinition->GetPDGMass(); 55 mass = aParticleDefinition->GetPDGMass(); 67 totalEnergy = mass; 56 totalEnergy = mass; 68 kineticEnergy = 0.0; 57 kineticEnergy = 0.0; 69 (aParticleDefinition->GetPDGEncoding()<0) 58 (aParticleDefinition->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0; 70 side = 0; 59 side = 0; 71 theCreatorModel = -1; << 72 theParentResonanceDef = nullptr; << 73 theParentResonanceID = 0; << 74 NewlyAdded = false; 60 NewlyAdded = false; 75 MayBeKilled = true; 61 MayBeKilled = true; 76 } 62 } 77 63 78 G4ReactionProduct::G4ReactionProduct( 64 G4ReactionProduct::G4ReactionProduct( 79 const G4ReactionProduct &right ) 65 const G4ReactionProduct &right ) 80 { 66 { 81 theParticleDefinition = right.theParticleD 67 theParticleDefinition = right.theParticleDefinition; 82 positionInNucleus = right.positionInNucleu 68 positionInNucleus = right.positionInNucleus; 83 formationTime = right.formationTime; 69 formationTime = right.formationTime; 84 hasInitialStateParton = right.hasInitialSt 70 hasInitialStateParton = right.hasInitialStateParton; 85 momentum = right.momentum; 71 momentum = right.momentum; 86 mass = right.mass; 72 mass = right.mass; 87 totalEnergy = right.totalEnergy; 73 totalEnergy = right.totalEnergy; 88 kineticEnergy = right.kineticEnergy; 74 kineticEnergy = right.kineticEnergy; 89 timeOfFlight = right.timeOfFlight; 75 timeOfFlight = right.timeOfFlight; 90 side = right.side; 76 side = right.side; 91 theCreatorModel = right.theCreatorModel; << 92 theParentResonanceDef = right.theParentRes << 93 theParentResonanceID = right.theParentReso << 94 NewlyAdded = right.NewlyAdded; 77 NewlyAdded = right.NewlyAdded; 95 MayBeKilled = right.MayBeKilled; 78 MayBeKilled = right.MayBeKilled; 96 } 79 } 97 80 98 G4ReactionProduct &G4ReactionProduct::operato 81 G4ReactionProduct &G4ReactionProduct::operator=( 99 const G4ReactionProduct &right ) 82 const G4ReactionProduct &right ) 100 { 83 { 101 if( this != &right ) { 84 if( this != &right ) { 102 theParticleDefinition = right.theParticl 85 theParticleDefinition = right.theParticleDefinition; 103 positionInNucleus = right.positionInNucl 86 positionInNucleus = right.positionInNucleus; 104 formationTime = right.formationTime; 87 formationTime = right.formationTime; 105 hasInitialStateParton = right.hasInitial 88 hasInitialStateParton = right.hasInitialStateParton; 106 momentum = right.momentum; 89 momentum = right.momentum; 107 mass = right.mass; 90 mass = right.mass; 108 totalEnergy = right.totalEnergy; 91 totalEnergy = right.totalEnergy; 109 kineticEnergy = right.kineticEnergy; 92 kineticEnergy = right.kineticEnergy; 110 timeOfFlight = right.timeOfFlight; 93 timeOfFlight = right.timeOfFlight; 111 side = right.side; 94 side = right.side; 112 theCreatorModel = right.theCreatorModel; << 113 theParentResonanceDef = right.theParentR << 114 theParentResonanceID = right.theParentRe << 115 NewlyAdded = right.NewlyAdded; 95 NewlyAdded = right.NewlyAdded; 116 MayBeKilled = right.MayBeKilled; 96 MayBeKilled = right.MayBeKilled; 117 } 97 } 118 return *this; 98 return *this; 119 } 99 } 120 100 121 G4ReactionProduct &G4ReactionProduct::operato 101 G4ReactionProduct &G4ReactionProduct::operator=( 122 const G4DynamicParticle &right ) 102 const G4DynamicParticle &right ) 123 { 103 { 124 theParticleDefinition = right.GetDefinitio 104 theParticleDefinition = right.GetDefinition(); 125 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 105 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 126 formationTime = 0.0; 106 formationTime = 0.0; 127 hasInitialStateParton = false; 107 hasInitialStateParton = false; 128 momentum = right.GetMomentum(); 108 momentum = right.GetMomentum(); 129 mass = right.GetDefinition()->GetPDGMass() 109 mass = right.GetDefinition()->GetPDGMass(); 130 totalEnergy = right.GetTotalEnergy(); 110 totalEnergy = right.GetTotalEnergy(); 131 kineticEnergy = right.GetKineticEnergy(); 111 kineticEnergy = right.GetKineticEnergy(); 132 (right.GetDefinition()->GetPDGEncoding()<0 112 (right.GetDefinition()->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0; 133 side = 0; 113 side = 0; 134 theCreatorModel = -1; << 135 theParentResonanceDef = nullptr; << 136 theParentResonanceID = 0; << 137 NewlyAdded = false; 114 NewlyAdded = false; 138 MayBeKilled = true; 115 MayBeKilled = true; 139 return *this; 116 return *this; 140 } 117 } 141 118 142 G4ReactionProduct &G4ReactionProduct::operato 119 G4ReactionProduct &G4ReactionProduct::operator=( 143 const G4HadProjectile &right ) 120 const G4HadProjectile &right ) 144 { 121 { 145 theParticleDefinition = right.GetDefinitio << 122 theParticleDefinition = const_cast<G4ParticleDefinition *>(right.GetDefinition()); 146 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 123 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 147 formationTime = 0.0; 124 formationTime = 0.0; 148 hasInitialStateParton = false; 125 hasInitialStateParton = false; 149 momentum = right.Get4Momentum().vect(); 126 momentum = right.Get4Momentum().vect(); 150 mass = right.GetDefinition()->GetPDGMass() 127 mass = right.GetDefinition()->GetPDGMass(); 151 totalEnergy = right.Get4Momentum().e(); 128 totalEnergy = right.Get4Momentum().e(); 152 kineticEnergy = right.GetKineticEnergy(); 129 kineticEnergy = right.GetKineticEnergy(); 153 (right.GetDefinition()->GetPDGEncoding()<0 130 (right.GetDefinition()->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0; 154 side = 0; 131 side = 0; 155 theCreatorModel = -1; << 156 theParentResonanceDef = nullptr; << 157 theParentResonanceID = 0; << 158 NewlyAdded = false; 132 NewlyAdded = false; 159 MayBeKilled = true; 133 MayBeKilled = true; 160 return *this; 134 return *this; 161 } 135 } 162 136 163 void G4ReactionProduct::SetDefinitionAndUpdat 137 void G4ReactionProduct::SetDefinitionAndUpdateE( 164 const G4ParticleDefinition *aParticleDefinit << 138 G4ParticleDefinition *aParticleDefinition ) 165 { G4double aKineticEnergy = GetKineticEne << 139 { >> 140 G4double aKineticEnergy = GetKineticEnergy(); 166 G4double pp = GetMomentum().mag(); 141 G4double pp = GetMomentum().mag(); 167 G4ThreeVector aMomentum = GetMomentum(); 142 G4ThreeVector aMomentum = GetMomentum(); 168 SetDefinition( aParticleDefinition ); 143 SetDefinition( aParticleDefinition ); 169 SetKineticEnergy( aKineticEnergy ); 144 SetKineticEnergy( aKineticEnergy ); 170 if( pp > DBL_MIN ) 145 if( pp > DBL_MIN ) 171 SetMomentum( aMomentum * (std::sqrt(aKin 146 SetMomentum( aMomentum * (std::sqrt(aKineticEnergy*aKineticEnergy + 172 2*aKinetic 147 2*aKineticEnergy*GetMass())/pp) ); 173 } 148 } 174 149 175 void G4ReactionProduct::SetDefinition( 150 void G4ReactionProduct::SetDefinition( 176 const G4ParticleDefinition *aParticleDefinit << 151 G4ParticleDefinition *aParticleDefinition ) 177 { 152 { 178 theParticleDefinition = aParticleDefinitio 153 theParticleDefinition = aParticleDefinition; 179 mass = aParticleDefinition->GetPDGMass(); 154 mass = aParticleDefinition->GetPDGMass(); 180 totalEnergy = mass; 155 totalEnergy = mass; 181 kineticEnergy = 0.0; 156 kineticEnergy = 0.0; 182 (aParticleDefinition->GetPDGEncoding()<0) 157 (aParticleDefinition->GetPDGEncoding()<0) ? 183 timeOfFlight=-1.0 : timeOfFlight=1.0; 158 timeOfFlight=-1.0 : timeOfFlight=1.0; 184 } 159 } 185 160 186 void G4ReactionProduct::SetMomentum( 161 void G4ReactionProduct::SetMomentum( 187 const G4double x, const G4double y, const G4 162 const G4double x, const G4double y, const G4double z ) 188 { 163 { 189 momentum.setX( x ); 164 momentum.setX( x ); 190 momentum.setY( y ); 165 momentum.setY( y ); 191 momentum.setZ( z ); 166 momentum.setZ( z ); 192 } 167 } 193 168 194 void G4ReactionProduct::SetMomentum( 169 void G4ReactionProduct::SetMomentum( 195 const G4double x, const G4double y ) 170 const G4double x, const G4double y ) 196 { 171 { 197 momentum.setX( x ); 172 momentum.setX( x ); 198 momentum.setY( y ); 173 momentum.setY( y ); 199 } 174 } 200 175 201 void G4ReactionProduct::SetMomentum( const G4 176 void G4ReactionProduct::SetMomentum( const G4double z ) 202 { 177 { 203 momentum.setZ( z ); 178 momentum.setZ( z ); 204 } 179 } 205 180 206 void G4ReactionProduct::SetZero() 181 void G4ReactionProduct::SetZero() 207 { 182 { 208 SetMomentum( 0.0, 0.0, 0.0 ); 183 SetMomentum( 0.0, 0.0, 0.0 ); 209 totalEnergy = 0.0; 184 totalEnergy = 0.0; 210 kineticEnergy = 0.0; 185 kineticEnergy = 0.0; 211 mass = 0.0; 186 mass = 0.0; 212 timeOfFlight = 0.0; 187 timeOfFlight = 0.0; 213 side = 0; 188 side = 0; 214 theCreatorModel = -1; << 215 theParentResonanceDef = nullptr; << 216 theParentResonanceID = 0; << 217 NewlyAdded = false; 189 NewlyAdded = false; 218 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 190 SetPositionInNucleus( 0.0, 0.0, 0.0 ); 219 formationTime = 0.0; 191 formationTime = 0.0; 220 hasInitialStateParton = false; 192 hasInitialStateParton = false; 221 } 193 } 222 194 223 void G4ReactionProduct::Lorentz( 195 void G4ReactionProduct::Lorentz( 224 const G4ReactionProduct &p1, const G4Reacti 196 const G4ReactionProduct &p1, const G4ReactionProduct &p2 ) 225 { 197 { 226 G4ThreeVector p1M = p1.momentum; 198 G4ThreeVector p1M = p1.momentum; 227 G4ThreeVector p2M = p2.momentum; 199 G4ThreeVector p2M = p2.momentum; 228 G4double p1x = p1M.x(); G4double p1y = p1M 200 G4double p1x = p1M.x(); G4double p1y = p1M.y(); G4double p1z = p1M.z(); 229 G4double p2x = p2M.x(); G4double p2y = p2M 201 G4double p2x = p2M.x(); G4double p2y = p2M.y(); G4double p2z = p2M.z(); 230 G4double a = ( (p1x*p2x+p1y*p2y+p1z*p2z)/( 202 G4double a = ( (p1x*p2x+p1y*p2y+p1z*p2z)/(p2.totalEnergy+p2.mass) - 231 p1.totalEnergy ) / p2.mass; 203 p1.totalEnergy ) / p2.mass; 232 G4double x = p1x+a*p2x; 204 G4double x = p1x+a*p2x; 233 G4double y = p1y+a*p2y; 205 G4double y = p1y+a*p2y; 234 G4double z = p1z+a*p2z; 206 G4double z = p1z+a*p2z; 235 G4double p = std::sqrt(x*x+y*y+z*z); 207 G4double p = std::sqrt(x*x+y*y+z*z); 236 SetMass( p1.mass ); 208 SetMass( p1.mass ); 237 SetTotalEnergy( std::sqrt( (p1.mass+p)*(p1 209 SetTotalEnergy( std::sqrt( (p1.mass+p)*(p1.mass+p) - 2.*p1.mass*p ) ); 238 //SetTotalEnergy( std::sqrt( p1.mass*p1.ma 210 //SetTotalEnergy( std::sqrt( p1.mass*p1.mass + x*x + y*y + z*z ) ); 239 SetMomentum( x, y, z ); 211 SetMomentum( x, y, z ); 240 } 212 } 241 213 242 G4double G4ReactionProduct::Angle( 214 G4double G4ReactionProduct::Angle( 243 const G4ReactionProduct& p ) const 215 const G4ReactionProduct& p ) const 244 { 216 { 245 G4ThreeVector tM = momentum; 217 G4ThreeVector tM = momentum; 246 G4ThreeVector pM = p.momentum; 218 G4ThreeVector pM = p.momentum; 247 G4double tx = tM.x(); G4double ty = tM.y() 219 G4double tx = tM.x(); G4double ty = tM.y(); G4double tz = tM.z(); 248 G4double px = pM.x(); G4double py = pM.y() 220 G4double px = pM.x(); G4double py = pM.y(); G4double pz = pM.z(); 249 G4double a = std::sqrt( ( px*px + py*py + 221 G4double a = std::sqrt( ( px*px + py*py + pz*pz ) * ( tx*tx + ty*ty + tz*tz ) ); 250 if( a == 0.0 ) { 222 if( a == 0.0 ) { 251 return 0.0; 223 return 0.0; 252 } else { 224 } else { 253 a = ( tx*px + ty*py + tz*pz ) / a; 225 a = ( tx*px + ty*py + tz*pz ) / a; 254 if( std::abs(a) > 1.0 ) { a<0.0 ? a=-1.0 << 226 if( std::fabs(a) > 1.0 ) { a<0.0 ? a=-1.0 : a=1.0; } 255 return std::acos( a ); 227 return std::acos( a ); 256 } 228 } 257 } 229 } 258 230 259 G4ReactionProduct operator+( 231 G4ReactionProduct operator+( 260 const G4ReactionProduct& p1, const G4Reactio 232 const G4ReactionProduct& p1, const G4ReactionProduct& p2 ) 261 { 233 { 262 G4double totEnergy = p1.totalEnergy + p2.t 234 G4double totEnergy = p1.totalEnergy + p2.totalEnergy; 263 G4double x = p1.momentum.x() + p2.momentum 235 G4double x = p1.momentum.x() + p2.momentum.x(); 264 G4double y = p1.momentum.y() + p2.momentum 236 G4double y = p1.momentum.y() + p2.momentum.y(); 265 G4double z = p1.momentum.z() + p2.momentum 237 G4double z = p1.momentum.z() + p2.momentum.z(); 266 G4double newMass = totEnergy*totEnergy - ( 238 G4double newMass = totEnergy*totEnergy - ( x*x + y*y + z*z ); 267 if( newMass < 0.0 ) 239 if( newMass < 0.0 ) 268 newMass = -1. * std::sqrt( -newMass ); 240 newMass = -1. * std::sqrt( -newMass ); 269 else 241 else 270 newMass = std::sqrt( newMass ); 242 newMass = std::sqrt( newMass ); 271 G4ReactionProduct result; 243 G4ReactionProduct result; 272 result.SetMass( newMass ); 244 result.SetMass( newMass ); 273 result.SetMomentum( x, y, z ); 245 result.SetMomentum( x, y, z ); 274 result.SetTotalEnergy( totEnergy ); 246 result.SetTotalEnergy( totEnergy ); 275 result.SetPositionInNucleus( 0.0, 0.0, 0.0 247 result.SetPositionInNucleus( 0.0, 0.0, 0.0 ); 276 result.SetFormationTime(0.0); 248 result.SetFormationTime(0.0); 277 result.HasInitialStateParton(false); 249 result.HasInitialStateParton(false); 278 return result; 250 return result; 279 } 251 } 280 252 281 G4ReactionProduct operator-( 253 G4ReactionProduct operator-( 282 const G4ReactionProduct& p1, const G4Reactio 254 const G4ReactionProduct& p1, const G4ReactionProduct& p2 ) 283 { 255 { 284 G4double totEnergy = p1.totalEnergy - p2.t 256 G4double totEnergy = p1.totalEnergy - p2.totalEnergy; 285 G4double x = p1.momentum.x() - p2.momentum 257 G4double x = p1.momentum.x() - p2.momentum.x(); 286 G4double y = p1.momentum.y() - p2.momentum 258 G4double y = p1.momentum.y() - p2.momentum.y(); 287 G4double z = p1.momentum.z() - p2.momentum 259 G4double z = p1.momentum.z() - p2.momentum.z(); 288 G4double newMass = totEnergy*totEnergy - ( 260 G4double newMass = totEnergy*totEnergy - ( x*x + y*y + z*z ); 289 if( newMass < 0.0 ) 261 if( newMass < 0.0 ) 290 newMass = -1. * std::sqrt( -newMass ); 262 newMass = -1. * std::sqrt( -newMass ); 291 else 263 else 292 newMass = std::sqrt( newMass ); 264 newMass = std::sqrt( newMass ); 293 G4ReactionProduct result; 265 G4ReactionProduct result; 294 result.SetMass( newMass ); 266 result.SetMass( newMass ); 295 result.SetMomentum( x, y, z ); 267 result.SetMomentum( x, y, z ); 296 result.SetTotalEnergy( totEnergy ); 268 result.SetTotalEnergy( totEnergy ); 297 result.SetPositionInNucleus( 0.0, 0.0, 0.0 269 result.SetPositionInNucleus( 0.0, 0.0, 0.0 ); 298 result.SetFormationTime(0.0); 270 result.SetFormationTime(0.0); 299 result.HasInitialStateParton(false); 271 result.HasInitialStateParton(false); 300 return result; 272 return result; 301 } 273 } 302 /* end of code */ 274 /* end of code */ 303 275 304 276