Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // INCL++ intra-nuclear cascade model 26 // INCL++ intra-nuclear cascade model 27 // Alain Boudard, CEA-Saclay, France << 27 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics 28 // Joseph Cugnon, University of Liege, Belgium << 28 // Davide Mancusi, CEA 29 // Jean-Christophe David, CEA-Saclay, France << 29 // Alain Boudard, CEA 30 // Pekka Kaitaniemi, CEA-Saclay, France, and H << 30 // Sylvie Leray, CEA 31 // Sylvie Leray, CEA-Saclay, France << 31 // Joseph Cugnon, University of Liege 32 // Davide Mancusi, CEA-Saclay, France << 33 // 32 // 34 #define INCLXX_IN_GEANT4_MODE 1 33 #define INCLXX_IN_GEANT4_MODE 1 35 34 36 #include "globals.hh" 35 #include "globals.hh" 37 36 38 /* 37 /* 39 * G4INCLParticle.hh << 38 * Particle.hh 40 * 39 * 41 * \date Jun 5, 2009 40 * \date Jun 5, 2009 42 * \author Pekka Kaitaniemi 41 * \author Pekka Kaitaniemi 43 */ 42 */ 44 43 45 #ifndef PARTICLE_HH_ 44 #ifndef PARTICLE_HH_ 46 #define PARTICLE_HH_ 45 #define PARTICLE_HH_ 47 46 48 #include "G4INCLThreeVector.hh" 47 #include "G4INCLThreeVector.hh" 49 #include "G4INCLParticleTable.hh" 48 #include "G4INCLParticleTable.hh" 50 #include "G4INCLParticleType.hh" 49 #include "G4INCLParticleType.hh" 51 #include "G4INCLParticleSpecies.hh" 50 #include "G4INCLParticleSpecies.hh" 52 #include "G4INCLLogger.hh" 51 #include "G4INCLLogger.hh" 53 #include "G4INCLUnorderedVector.hh" << 52 #include <vector> 54 #include "G4INCLAllocationPool.hh" << 55 #include <sstream> 53 #include <sstream> 56 #include <string> 54 #include <string> >> 55 #include <algorithm> 57 56 58 namespace G4INCL { 57 namespace G4INCL { 59 58 60 class Particle; 59 class Particle; 61 60 62 class ParticleList : public UnorderedVector< << 61 template<class T> 63 public: << 62 class UnorderedVector : private std::vector<T> { 64 void rotatePositionAndMomentum(const G4d << 63 public: 65 void rotatePosition(const G4double angle << 64 UnorderedVector() {} 66 void rotateMomentum(const G4double angle << 65 using std::vector<T>::push_back; 67 void boost(const ThreeVector &b) const; << 66 using std::vector<T>::pop_back; 68 G4double getParticleListBias() const; << 67 using std::vector<T>::size; 69 std::vector<G4int> getParticleListBiasVe << 68 using std::vector<T>::begin; 70 }; << 69 using std::vector<T>::end; >> 70 using std::vector<T>::rbegin; >> 71 using std::vector<T>::rend; >> 72 using std::vector<T>::front; >> 73 using std::vector<T>::back; >> 74 using std::vector<T>::clear; >> 75 using std::vector<T>::empty; >> 76 using std::vector<T>::insert; >> 77 using std::vector<T>::erase; >> 78 using typename std::vector<T>::iterator; >> 79 using typename std::vector<T>::reverse_iterator; >> 80 using typename std::vector<T>::const_iterator; >> 81 using typename std::vector<T>::const_reverse_iterator; >> 82 void remove(const T &t) { >> 83 const typename std::vector<T>::iterator removeMe = std::find(begin(), end(), t); >> 84 // assert(removeMe!=end()); >> 85 *removeMe = back(); >> 86 pop_back(); >> 87 } >> 88 }; 71 89 >> 90 typedef UnorderedVector<Particle*> ParticleList; 72 typedef ParticleList::const_iterator Particl 91 typedef ParticleList::const_iterator ParticleIter; 73 typedef ParticleList::iterator Particl 92 typedef ParticleList::iterator ParticleMutableIter; 74 93 75 class Particle { 94 class Particle { 76 public: 95 public: 77 Particle(); 96 Particle(); 78 Particle(ParticleType t, G4double energy, 97 Particle(ParticleType t, G4double energy, ThreeVector const &momentum, ThreeVector const &position); 79 Particle(ParticleType t, ThreeVector const 98 Particle(ParticleType t, ThreeVector const &momentum, ThreeVector const &position); 80 virtual ~Particle() {} 99 virtual ~Particle() {} 81 100 82 /** \brief Copy constructor 101 /** \brief Copy constructor 83 * 102 * 84 * Does not copy the particle ID. 103 * Does not copy the particle ID. 85 */ 104 */ 86 Particle(const Particle &rhs) : 105 Particle(const Particle &rhs) : 87 theZ(rhs.theZ), 106 theZ(rhs.theZ), 88 theA(rhs.theA), 107 theA(rhs.theA), 89 theS(rhs.theS), << 90 theParticipantType(rhs.theParticipantTyp 108 theParticipantType(rhs.theParticipantType), 91 theType(rhs.theType), 109 theType(rhs.theType), 92 theEnergy(rhs.theEnergy), 110 theEnergy(rhs.theEnergy), 93 theFrozenEnergy(rhs.theFrozenEnergy), 111 theFrozenEnergy(rhs.theFrozenEnergy), 94 theMomentum(rhs.theMomentum), 112 theMomentum(rhs.theMomentum), 95 theFrozenMomentum(rhs.theFrozenMomentum) 113 theFrozenMomentum(rhs.theFrozenMomentum), 96 thePosition(rhs.thePosition), 114 thePosition(rhs.thePosition), 97 nCollisions(rhs.nCollisions), 115 nCollisions(rhs.nCollisions), 98 nDecays(rhs.nDecays), 116 nDecays(rhs.nDecays), 99 thePotentialEnergy(rhs.thePotentialEnerg 117 thePotentialEnergy(rhs.thePotentialEnergy), 100 rpCorrelated(rhs.rpCorrelated), 118 rpCorrelated(rhs.rpCorrelated), 101 uncorrelatedMomentum(rhs.uncorrelatedMom 119 uncorrelatedMomentum(rhs.uncorrelatedMomentum), 102 theParticleBias(rhs.theParticleBias), << 103 theNKaon(rhs.theNKaon), << 104 #ifdef INCLXX_IN_GEANT4_MODE << 105 theParentResonancePDGCode(rhs.theParentR << 106 theParentResonanceID(rhs.theParentResona << 107 #endif << 108 theHelicity(rhs.theHelicity), 120 theHelicity(rhs.theHelicity), 109 emissionTime(rhs.emissionTime), 121 emissionTime(rhs.emissionTime), 110 outOfWell(rhs.outOfWell), 122 outOfWell(rhs.outOfWell), 111 theMass(rhs.theMass) 123 theMass(rhs.theMass) 112 { 124 { 113 if(rhs.thePropagationEnergy == &(rhs.t 125 if(rhs.thePropagationEnergy == &(rhs.theFrozenEnergy)) 114 thePropagationEnergy = &theFrozenEne 126 thePropagationEnergy = &theFrozenEnergy; 115 else 127 else 116 thePropagationEnergy = &theEnergy; 128 thePropagationEnergy = &theEnergy; 117 if(rhs.thePropagationMomentum == &(rhs 129 if(rhs.thePropagationMomentum == &(rhs.theFrozenMomentum)) 118 thePropagationMomentum = &theFrozenM 130 thePropagationMomentum = &theFrozenMomentum; 119 else 131 else 120 thePropagationMomentum = &theMomentu 132 thePropagationMomentum = &theMomentum; 121 // ID intentionally not copied 133 // ID intentionally not copied 122 ID = nextID++; 134 ID = nextID++; 123 << 124 theBiasCollisionVector = rhs.theBiasCo << 125 } 135 } 126 136 127 protected: 137 protected: 128 /// \brief Helper method for the assignmen 138 /// \brief Helper method for the assignment operator 129 void swap(Particle &rhs) { 139 void swap(Particle &rhs) { 130 std::swap(theZ, rhs.theZ); 140 std::swap(theZ, rhs.theZ); 131 std::swap(theA, rhs.theA); 141 std::swap(theA, rhs.theA); 132 std::swap(theS, rhs.theS); << 133 std::swap(theParticipantType, rhs.thePar 142 std::swap(theParticipantType, rhs.theParticipantType); 134 std::swap(theType, rhs.theType); 143 std::swap(theType, rhs.theType); 135 if(rhs.thePropagationEnergy == &(rhs.the 144 if(rhs.thePropagationEnergy == &(rhs.theFrozenEnergy)) 136 thePropagationEnergy = &theFrozenEnerg 145 thePropagationEnergy = &theFrozenEnergy; 137 else 146 else 138 thePropagationEnergy = &theEnergy; 147 thePropagationEnergy = &theEnergy; 139 std::swap(theEnergy, rhs.theEnergy); 148 std::swap(theEnergy, rhs.theEnergy); 140 std::swap(theFrozenEnergy, rhs.theFrozen 149 std::swap(theFrozenEnergy, rhs.theFrozenEnergy); 141 if(rhs.thePropagationMomentum == &(rhs.t 150 if(rhs.thePropagationMomentum == &(rhs.theFrozenMomentum)) 142 thePropagationMomentum = &theFrozenMom 151 thePropagationMomentum = &theFrozenMomentum; 143 else 152 else 144 thePropagationMomentum = &theMomentum; 153 thePropagationMomentum = &theMomentum; 145 std::swap(theMomentum, rhs.theMomentum); 154 std::swap(theMomentum, rhs.theMomentum); 146 std::swap(theFrozenMomentum, rhs.theFroz 155 std::swap(theFrozenMomentum, rhs.theFrozenMomentum); 147 std::swap(thePosition, rhs.thePosition); 156 std::swap(thePosition, rhs.thePosition); 148 std::swap(nCollisions, rhs.nCollisions); 157 std::swap(nCollisions, rhs.nCollisions); 149 std::swap(nDecays, rhs.nDecays); 158 std::swap(nDecays, rhs.nDecays); 150 std::swap(thePotentialEnergy, rhs.thePot 159 std::swap(thePotentialEnergy, rhs.thePotentialEnergy); 151 // ID intentionally not swapped 160 // ID intentionally not swapped 152 161 153 #ifdef INCLXX_IN_GEANT4_MODE << 154 std::swap(theParentResonancePDGCode, rhs << 155 std::swap(theParentResonanceID, rhs.theP << 156 #endif << 157 << 158 std::swap(theHelicity, rhs.theHelicity); 162 std::swap(theHelicity, rhs.theHelicity); 159 std::swap(emissionTime, rhs.emissionTime 163 std::swap(emissionTime, rhs.emissionTime); 160 std::swap(outOfWell, rhs.outOfWell); 164 std::swap(outOfWell, rhs.outOfWell); 161 165 162 std::swap(theMass, rhs.theMass); 166 std::swap(theMass, rhs.theMass); 163 std::swap(rpCorrelated, rhs.rpCorrelated 167 std::swap(rpCorrelated, rhs.rpCorrelated); 164 std::swap(uncorrelatedMomentum, rhs.unco 168 std::swap(uncorrelatedMomentum, rhs.uncorrelatedMomentum); 165 << 166 std::swap(theParticleBias, rhs.thePartic << 167 std::swap(theBiasCollisionVector, rhs.th << 168 << 169 } 169 } 170 170 171 public: 171 public: 172 172 173 /** \brief Assignment operator 173 /** \brief Assignment operator 174 * 174 * 175 * Does not copy the particle ID. 175 * Does not copy the particle ID. 176 */ 176 */ 177 Particle &operator=(const Particle &rhs) { 177 Particle &operator=(const Particle &rhs) { 178 Particle temporaryParticle(rhs); 178 Particle temporaryParticle(rhs); 179 swap(temporaryParticle); 179 swap(temporaryParticle); 180 return *this; 180 return *this; 181 } 181 } 182 182 183 /** 183 /** 184 * Get the particle type. 184 * Get the particle type. 185 * @see G4INCL::ParticleType 185 * @see G4INCL::ParticleType 186 */ 186 */ 187 G4INCL::ParticleType getType() const { 187 G4INCL::ParticleType getType() const { 188 return theType; 188 return theType; 189 }; 189 }; 190 190 191 /// \brief Get the particle species 191 /// \brief Get the particle species 192 virtual G4INCL::ParticleSpecies getSpecies 192 virtual G4INCL::ParticleSpecies getSpecies() const { 193 return ParticleSpecies(theType); 193 return ParticleSpecies(theType); 194 }; 194 }; 195 195 196 void setType(ParticleType t) { 196 void setType(ParticleType t) { 197 theType = t; 197 theType = t; 198 switch(theType) 198 switch(theType) 199 { 199 { 200 case DeltaPlusPlus: 200 case DeltaPlusPlus: 201 theA = 1; 201 theA = 1; 202 theZ = 2; 202 theZ = 2; 203 theS = 0; << 204 break; 203 break; 205 case Proton: 204 case Proton: 206 case DeltaPlus: 205 case DeltaPlus: 207 theA = 1; 206 theA = 1; 208 theZ = 1; 207 theZ = 1; 209 theS = 0; << 210 break; 208 break; 211 case Neutron: 209 case Neutron: 212 case DeltaZero: 210 case DeltaZero: 213 theA = 1; 211 theA = 1; 214 theZ = 0; 212 theZ = 0; 215 theS = 0; << 216 break; 213 break; 217 case DeltaMinus: 214 case DeltaMinus: 218 theA = 1; 215 theA = 1; 219 theZ = -1; 216 theZ = -1; 220 theS = 0; << 221 break; 217 break; 222 case PiPlus: 218 case PiPlus: 223 theA = 0; 219 theA = 0; 224 theZ = 1; 220 theZ = 1; 225 theS = 0; << 226 break; 221 break; 227 case PiZero: 222 case PiZero: 228 case Eta: << 229 case Omega: << 230 case EtaPrime: << 231 case Photon: << 232 theA = 0; 223 theA = 0; 233 theZ = 0; 224 theZ = 0; 234 theS = 0; << 235 break; 225 break; 236 case PiMinus: 226 case PiMinus: 237 theA = 0; 227 theA = 0; 238 theZ = -1; 228 theZ = -1; 239 theS = 0; << 240 break; << 241 case Lambda: << 242 theA = 1; << 243 theZ = 0; << 244 theS = -1; << 245 break; << 246 case SigmaPlus: << 247 theA = 1; << 248 theZ = 1; << 249 theS = -1; << 250 break; << 251 case SigmaZero: << 252 theA = 1; << 253 theZ = 0; << 254 theS = -1; << 255 break; << 256 case SigmaMinus: << 257 theA = 1; << 258 theZ = -1; << 259 theS = -1; << 260 break; << 261 case antiProton: << 262 theA = -1; << 263 theZ = -1; << 264 theS = 0; << 265 break; << 266 case XiMinus: << 267 theA = 1; << 268 theZ = -1; << 269 theS = -2; << 270 break; << 271 case XiZero: << 272 theA = 1; << 273 theZ = 0; << 274 theS = -2; << 275 break; << 276 case antiNeutron: << 277 theA = -1; << 278 theZ = 0; << 279 theS = 0; << 280 break; << 281 case antiLambda: << 282 theA = -1; << 283 theZ = 0; << 284 theS = 1; << 285 break; << 286 case antiSigmaMinus: << 287 theA = -1; << 288 theZ = 1; << 289 theS = 1; << 290 break; << 291 case antiSigmaPlus: << 292 theA = -1; << 293 theZ = -1; << 294 theS = 1; << 295 break; << 296 case antiSigmaZero: << 297 theA = -1; << 298 theZ = 0; << 299 theS = 1; << 300 break; << 301 case antiXiMinus: << 302 theA = -1; << 303 theZ = 1; << 304 theS = 2; << 305 break; << 306 case antiXiZero: << 307 theA = -1; << 308 theZ = 0; << 309 theS = 2; << 310 break; << 311 case KPlus: << 312 theA = 0; << 313 theZ = 1; << 314 theS = 1; << 315 break; << 316 case KZero: << 317 theA = 0; << 318 theZ = 0; << 319 theS = 1; << 320 break; << 321 case KZeroBar: << 322 theA = 0; << 323 theZ = 0; << 324 theS = -1; << 325 break; << 326 case KShort: << 327 theA = 0; << 328 theZ = 0; << 329 // theS should not be defined << 330 break; << 331 case KLong: << 332 theA = 0; << 333 theZ = 0; << 334 // theS should not be defined << 335 break; << 336 case KMinus: << 337 theA = 0; << 338 theZ = -1; << 339 theS = -1; << 340 break; 229 break; 341 case Composite: 230 case Composite: 342 // INCL_ERROR("Trying to set particle << 231 // INCL_ERROR("Trying to set particle type to Composite! Construct a Cluster object instead" << std::endl); 343 theA = 0; 232 theA = 0; 344 theZ = 0; 233 theZ = 0; 345 theS = 0; << 234 break; 346 break; << 347 case UnknownParticle: 235 case UnknownParticle: 348 theA = 0; 236 theA = 0; 349 theZ = 0; 237 theZ = 0; 350 theS = 0; << 238 INCL_ERROR("Trying to set particle type to Unknown!" << std::endl); 351 INCL_ERROR("Trying to set particle t << 352 break; 239 break; 353 } 240 } 354 241 355 if( !isResonance() && t!=Composite ) 242 if( !isResonance() && t!=Composite ) 356 setINCLMass(); 243 setINCLMass(); 357 } 244 } 358 245 359 /** 246 /** 360 * Is this a nucleon? 247 * Is this a nucleon? 361 */ 248 */ 362 G4bool isNucleon() const { 249 G4bool isNucleon() const { 363 if(theType == G4INCL::Proton || theType 250 if(theType == G4INCL::Proton || theType == G4INCL::Neutron) 364 return true; << 251 return true; 365 else 252 else 366 return false; << 253 return false; 367 }; 254 }; 368 255 369 ParticipantType getParticipantType() const 256 ParticipantType getParticipantType() const { 370 return theParticipantType; 257 return theParticipantType; 371 } 258 } 372 259 373 void setParticipantType(ParticipantType co 260 void setParticipantType(ParticipantType const p) { 374 theParticipantType = p; 261 theParticipantType = p; 375 } 262 } 376 263 377 G4bool isParticipant() const { 264 G4bool isParticipant() const { 378 return (theParticipantType==Participant) 265 return (theParticipantType==Participant); 379 } 266 } 380 267 381 G4bool isTargetSpectator() const { 268 G4bool isTargetSpectator() const { 382 return (theParticipantType==TargetSpecta 269 return (theParticipantType==TargetSpectator); 383 } 270 } 384 271 385 G4bool isProjectileSpectator() const { 272 G4bool isProjectileSpectator() const { 386 return (theParticipantType==ProjectileSp 273 return (theParticipantType==ProjectileSpectator); 387 } 274 } 388 275 389 virtual void makeParticipant() { 276 virtual void makeParticipant() { 390 theParticipantType = Participant; 277 theParticipantType = Participant; 391 } 278 } 392 279 393 virtual void makeTargetSpectator() { 280 virtual void makeTargetSpectator() { 394 theParticipantType = TargetSpectator; 281 theParticipantType = TargetSpectator; 395 } 282 } 396 283 397 virtual void makeProjectileSpectator() { 284 virtual void makeProjectileSpectator() { 398 theParticipantType = ProjectileSpectator 285 theParticipantType = ProjectileSpectator; 399 } 286 } 400 287 401 /** \brief Is this a pion? */ 288 /** \brief Is this a pion? */ 402 G4bool isPion() const { return (theType == 289 G4bool isPion() const { return (theType == PiPlus || theType == PiZero || theType == PiMinus); } 403 290 404 /** \brief Is this an eta? */ << 405 G4bool isEta() const { return (theType == << 406 << 407 /** \brief Is this an omega? */ << 408 G4bool isOmega() const { return (theType = << 409 << 410 /** \brief Is this an etaprime? */ << 411 G4bool isEtaPrime() const { return (theTyp << 412 << 413 /** \brief Is this a photon? */ << 414 G4bool isPhoton() const { return (theType << 415 << 416 /** \brief Is it a resonance? */ 291 /** \brief Is it a resonance? */ 417 inline G4bool isResonance() const { return 292 inline G4bool isResonance() const { return isDelta(); } 418 293 419 /** \brief Is it a Delta? */ 294 /** \brief Is it a Delta? */ 420 inline G4bool isDelta() const { 295 inline G4bool isDelta() const { 421 return (theType==DeltaPlusPlus || theTyp 296 return (theType==DeltaPlusPlus || theType==DeltaPlus || 422 theType==DeltaZero || theType==Delta << 297 theType==DeltaZero || theType==DeltaMinus); 423 << 298 } 424 /** \brief Is this a Sigma? */ << 425 G4bool isSigma() const { return (theType = << 426 << 427 /** \brief Is this a Kaon? */ << 428 G4bool isKaon() const { return (theType == << 429 << 430 /** \brief Is this an antiKaon? */ << 431 G4bool isAntiKaon() const { return (theTyp << 432 << 433 /** \brief Is this a Lambda? */ << 434 G4bool isLambda() const { return (theType << 435 << 436 /** \brief Is this a Nucleon or a Lambda? << 437 G4bool isNucleonorLambda() const { return << 438 << 439 /** \brief Is this an Hyperon? */ << 440 G4bool isHyperon() const { return (isLambd << 441 << 442 /** \brief Is this a Meson? */ << 443 G4bool isMeson() const { return (isPion() << 444 << 445 /** \brief Is this a Baryon? */ << 446 G4bool isBaryon() const { return (isNucleo << 447 << 448 /** \brief Is this a Strange? */ << 449 G4bool isStrange() const { return (isKaon( << 450 << 451 /** \brief Is this a Xi? */ << 452 G4bool isXi() const { return (theType == X << 453 << 454 /** \brief Is this an antinucleon? */ << 455 G4bool isAntiNucleon() const { return (the << 456 << 457 /** \brief Is this an antiSigma? */ << 458 G4bool isAntiSigma() const { return (theTy << 459 << 460 /** \brief Is this an antiXi? */ << 461 G4bool isAntiXi() const { return (theType << 462 << 463 /** \brief Is this an antiLambda? */ << 464 G4bool isAntiLambda() const { return (theT << 465 << 466 /** \brief Is this an antiHyperon? */ << 467 G4bool isAntiHyperon() const { return (isA << 468 << 469 /** \brief Is this an antiBaryon? */ << 470 G4bool isAntiBaryon() const { return (isAn << 471 << 472 /** \brief Is this an antiNucleon or an an << 473 G4bool isAntiNucleonorAntiLambda() const { << 474 299 475 /** \brief Returns the baryon number. */ 300 /** \brief Returns the baryon number. */ 476 G4int getA() const { return theA; } 301 G4int getA() const { return theA; } 477 302 478 /** \brief Returns the charge number. */ 303 /** \brief Returns the charge number. */ 479 G4int getZ() const { return theZ; } 304 G4int getZ() const { return theZ; } 480 << 481 /** \brief Returns the strangeness number. << 482 G4int getS() const { return theS; } << 483 305 484 G4double getBeta() const { 306 G4double getBeta() const { 485 const G4double P = theMomentum.mag(); 307 const G4double P = theMomentum.mag(); 486 return P/theEnergy; 308 return P/theEnergy; 487 } 309 } 488 310 489 /** 311 /** 490 * Returns a three vector we can give to t 312 * Returns a three vector we can give to the boost() -method. 491 * 313 * 492 * In order to go to the particle rest fra 314 * In order to go to the particle rest frame you need to multiply 493 * the boost vector by -1.0. 315 * the boost vector by -1.0. 494 */ 316 */ 495 ThreeVector boostVector() const { 317 ThreeVector boostVector() const { 496 return theMomentum / theEnergy; 318 return theMomentum / theEnergy; 497 } 319 } 498 320 499 /** 321 /** 500 * Boost the particle using a boost vector 322 * Boost the particle using a boost vector. 501 * 323 * 502 * Example (go to the particle rest frame) 324 * Example (go to the particle rest frame): 503 * particle->boost(particle->boostVector() 325 * particle->boost(particle->boostVector()); 504 */ 326 */ 505 void boost(const ThreeVector &aBoostVector 327 void boost(const ThreeVector &aBoostVector) { 506 const G4double beta2 = aBoostVector.mag2 328 const G4double beta2 = aBoostVector.mag2(); 507 const G4double gamma = 1.0 / std::sqrt(1 329 const G4double gamma = 1.0 / std::sqrt(1.0 - beta2); 508 const G4double bp = theMomentum.dot(aBoo 330 const G4double bp = theMomentum.dot(aBoostVector); 509 const G4double alpha = (gamma*gamma)/(1. 331 const G4double alpha = (gamma*gamma)/(1.0 + gamma); 510 332 511 theMomentum = theMomentum + aBoostVector 333 theMomentum = theMomentum + aBoostVector * (alpha * bp - gamma * theEnergy); 512 theEnergy = gamma * (theEnergy - bp); 334 theEnergy = gamma * (theEnergy - bp); 513 } 335 } 514 336 515 /** \brief Lorentz-contract the particle p 337 /** \brief Lorentz-contract the particle position around some center 516 * 338 * 517 * Apply Lorentz contraction to the positi 339 * Apply Lorentz contraction to the position component along the 518 * direction of the boost vector. 340 * direction of the boost vector. 519 * 341 * 520 * \param aBoostVector the boost vector (v 342 * \param aBoostVector the boost vector (velocity) [c] 521 * \param refPos the reference position 343 * \param refPos the reference position 522 */ 344 */ 523 void lorentzContract(const ThreeVector &aB 345 void lorentzContract(const ThreeVector &aBoostVector, const ThreeVector &refPos) { 524 const G4double beta2 = aBoostVector.mag2 346 const G4double beta2 = aBoostVector.mag2(); 525 const G4double gamma = 1.0 / std::sqrt(1 347 const G4double gamma = 1.0 / std::sqrt(1.0 - beta2); 526 const ThreeVector theRelativePosition = 348 const ThreeVector theRelativePosition = thePosition - refPos; 527 const ThreeVector transversePosition = t 349 const ThreeVector transversePosition = theRelativePosition - aBoostVector * (theRelativePosition.dot(aBoostVector) / aBoostVector.mag2()); 528 const ThreeVector longitudinalPosition = 350 const ThreeVector longitudinalPosition = theRelativePosition - transversePosition; 529 351 530 thePosition = refPos + transversePositio 352 thePosition = refPos + transversePosition + longitudinalPosition / gamma; 531 } 353 } 532 354 533 /** \brief Get the cached particle mass. * 355 /** \brief Get the cached particle mass. */ 534 inline G4double getMass() const { return t 356 inline G4double getMass() const { return theMass; } 535 357 536 /** \brief Get the INCL particle mass. */ 358 /** \brief Get the INCL particle mass. */ 537 inline G4double getINCLMass() const { 359 inline G4double getINCLMass() const { 538 switch(theType) { 360 switch(theType) { 539 case Proton: 361 case Proton: 540 case Neutron: 362 case Neutron: 541 case PiPlus: 363 case PiPlus: 542 case PiMinus: 364 case PiMinus: 543 case PiZero: 365 case PiZero: 544 case Lambda: << 545 case SigmaPlus: << 546 case SigmaZero: << 547 case SigmaMinus: << 548 case antiProton: << 549 case XiZero: << 550 case XiMinus: << 551 case antiNeutron: << 552 case antiLambda: << 553 case antiSigmaPlus: << 554 case antiSigmaZero: << 555 case antiSigmaMinus: << 556 case antiXiZero: << 557 case antiXiMinus: << 558 case KPlus: << 559 case KZero: << 560 case KZeroBar: << 561 case KShort: << 562 case KLong: << 563 case KMinus: << 564 case Eta: << 565 case Omega: << 566 case EtaPrime: << 567 case Photon: << 568 return ParticleTable::getINCLMass(th 366 return ParticleTable::getINCLMass(theType); 569 break; 367 break; 570 368 571 case DeltaPlusPlus: 369 case DeltaPlusPlus: 572 case DeltaPlus: 370 case DeltaPlus: 573 case DeltaZero: 371 case DeltaZero: 574 case DeltaMinus: 372 case DeltaMinus: 575 return theMass; 373 return theMass; 576 break; 374 break; 577 375 578 case Composite: 376 case Composite: 579 return ParticleTable::getINCLMass(th << 377 return ParticleTable::getINCLMass(theA,theZ); 580 break; 378 break; 581 379 582 default: 380 default: 583 INCL_ERROR("Particle::getINCLMass: U << 381 INCL_ERROR("Particle::getINCLMass: Unknown particle type." << std::endl); 584 return 0.0; 382 return 0.0; 585 break; 383 break; 586 } 384 } 587 } 385 } 588 386 589 /** \brief Get the tabulated particle mass 387 /** \brief Get the tabulated particle mass. */ 590 inline virtual G4double getTableMass() con 388 inline virtual G4double getTableMass() const { 591 switch(theType) { 389 switch(theType) { 592 case Proton: 390 case Proton: 593 case Neutron: 391 case Neutron: 594 case PiPlus: 392 case PiPlus: 595 case PiMinus: 393 case PiMinus: 596 case PiZero: 394 case PiZero: 597 case Lambda: << 598 case SigmaPlus: << 599 case SigmaZero: << 600 case SigmaMinus: << 601 case antiProton: << 602 case XiZero: << 603 case XiMinus: << 604 case antiNeutron: << 605 case antiLambda: << 606 case antiSigmaPlus: << 607 case antiSigmaZero: << 608 case antiSigmaMinus: << 609 case antiXiZero: << 610 case antiXiMinus: << 611 case KPlus: << 612 case KZero: << 613 case KZeroBar: << 614 case KShort: << 615 case KLong: << 616 case KMinus: << 617 case Eta: << 618 case Omega: << 619 case EtaPrime: << 620 case Photon: << 621 return ParticleTable::getTablePartic 395 return ParticleTable::getTableParticleMass(theType); 622 break; 396 break; 623 397 624 case DeltaPlusPlus: 398 case DeltaPlusPlus: 625 case DeltaPlus: 399 case DeltaPlus: 626 case DeltaZero: 400 case DeltaZero: 627 case DeltaMinus: 401 case DeltaMinus: 628 return theMass; 402 return theMass; 629 break; 403 break; 630 404 631 case Composite: 405 case Composite: 632 return ParticleTable::getTableMass(t << 406 return ParticleTable::getTableMass(theA,theZ); 633 break; 407 break; 634 408 635 default: 409 default: 636 INCL_ERROR("Particle::getTableMass: << 410 INCL_ERROR("Particle::getTableMass: Unknown particle type." << std::endl); 637 return 0.0; 411 return 0.0; 638 break; 412 break; 639 } 413 } 640 } 414 } 641 415 642 /** \brief Get the real particle mass. */ 416 /** \brief Get the real particle mass. */ 643 inline G4double getRealMass() const { 417 inline G4double getRealMass() const { 644 switch(theType) { 418 switch(theType) { 645 case Proton: 419 case Proton: 646 case Neutron: 420 case Neutron: 647 case PiPlus: 421 case PiPlus: 648 case PiMinus: 422 case PiMinus: 649 case PiZero: 423 case PiZero: 650 case Lambda: << 651 case SigmaPlus: << 652 case SigmaZero: << 653 case SigmaMinus: << 654 case antiProton: << 655 case XiZero: << 656 case XiMinus: << 657 case antiNeutron: << 658 case antiLambda: << 659 case antiSigmaPlus: << 660 case antiSigmaZero: << 661 case antiSigmaMinus: << 662 case antiXiZero: << 663 case antiXiMinus: << 664 case KPlus: << 665 case KZero: << 666 case KZeroBar: << 667 case KShort: << 668 case KLong: << 669 case KMinus: << 670 case Eta: << 671 case Omega: << 672 case EtaPrime: << 673 case Photon: << 674 return ParticleTable::getRealMass(th 424 return ParticleTable::getRealMass(theType); 675 break; 425 break; 676 426 677 case DeltaPlusPlus: 427 case DeltaPlusPlus: 678 case DeltaPlus: 428 case DeltaPlus: 679 case DeltaZero: 429 case DeltaZero: 680 case DeltaMinus: 430 case DeltaMinus: 681 return theMass; 431 return theMass; 682 break; 432 break; 683 433 684 case Composite: 434 case Composite: 685 return ParticleTable::getRealMass(th << 435 return ParticleTable::getRealMass(theA,theZ); 686 break; 436 break; 687 437 688 default: 438 default: 689 INCL_ERROR("Particle::getRealMass: U << 439 INCL_ERROR("Particle::getRealMass: Unknown particle type." << std::endl); 690 return 0.0; 440 return 0.0; 691 break; 441 break; 692 } 442 } 693 } 443 } 694 444 695 /// \brief Set the mass of the Particle to 445 /// \brief Set the mass of the Particle to its real mass 696 void setRealMass() { setMass(getRealMass() 446 void setRealMass() { setMass(getRealMass()); } 697 447 698 /// \brief Set the mass of the Particle to 448 /// \brief Set the mass of the Particle to its table mass 699 void setTableMass() { setMass(getTableMass 449 void setTableMass() { setMass(getTableMass()); } 700 450 701 /// \brief Set the mass of the Particle to 451 /// \brief Set the mass of the Particle to its table mass 702 void setINCLMass() { setMass(getINCLMass() 452 void setINCLMass() { setMass(getINCLMass()); } 703 453 704 /**\brief Computes correction on the emiss 454 /**\brief Computes correction on the emission Q-value 705 * 455 * 706 * Computes the correction that must be ap 456 * Computes the correction that must be applied to INCL particles in 707 * order to obtain the correct Q-value for 457 * order to obtain the correct Q-value for particle emission from a given 708 * nucleus. For absorption, the correction 458 * nucleus. For absorption, the correction is obviously equal to minus 709 * the value returned by this function. 459 * the value returned by this function. 710 * 460 * 711 * \param AParent the mass number of the e 461 * \param AParent the mass number of the emitting nucleus 712 * \param ZParent the charge number of the 462 * \param ZParent the charge number of the emitting nucleus 713 * \return the correction 463 * \return the correction 714 */ 464 */ 715 G4double getEmissionQValueCorrection(const 465 G4double getEmissionQValueCorrection(const G4int AParent, const G4int ZParent) const { 716 const G4int SParent = 0; << 717 const G4int ADaughter = AParent - theA; 466 const G4int ADaughter = AParent - theA; 718 const G4int ZDaughter = ZParent - theZ; 467 const G4int ZDaughter = ZParent - theZ; 719 const G4int SDaughter = 0; << 720 468 721 // Note the minus sign here 469 // Note the minus sign here 722 G4double theQValue; 470 G4double theQValue; 723 if(isCluster()) 471 if(isCluster()) 724 theQValue = -ParticleTable::getTableQV << 472 theQValue = -ParticleTable::getTableQValue(theA, theZ, ADaughter, ZDaughter); 725 else { 473 else { 726 const G4double massTableParent = Parti << 474 const G4double massTableParent = ParticleTable::getTableMass(AParent,ZParent); 727 const G4double massTableDaughter = Par << 475 const G4double massTableDaughter = ParticleTable::getTableMass(ADaughter,ZDaughter); 728 const G4double massTableParticle = get 476 const G4double massTableParticle = getTableMass(); 729 theQValue = massTableParent - massTabl 477 theQValue = massTableParent - massTableDaughter - massTableParticle; 730 } 478 } 731 479 732 const G4double massINCLParent = Particle << 480 const G4double massINCLParent = ParticleTable::getINCLMass(AParent,ZParent); 733 const G4double massINCLDaughter = Partic << 481 const G4double massINCLDaughter = ParticleTable::getINCLMass(ADaughter,ZDaughter); 734 const G4double massINCLParticle = getINC 482 const G4double massINCLParticle = getINCLMass(); 735 483 736 // The rhs corresponds to the INCL Q-val 484 // The rhs corresponds to the INCL Q-value 737 return theQValue - (massINCLParent-massI 485 return theQValue - (massINCLParent-massINCLDaughter-massINCLParticle); 738 } 486 } 739 487 740 G4double getEmissionPbarQvalueCorrection(c << 741 G4int SParent = 0; << 742 G4int SDaughter = 0; << 743 G4int ADaughter = AParent - 1; << 744 G4int ZDaughter; << 745 G4bool isProton = Victim; << 746 if(isProton){ //proton is annihilate << 747 ZDaughter = ZParent - 1; << 748 } << 749 else { //neutron is annihilated << 750 ZDaughter = ZParent; << 751 } << 752 << 753 G4double theQValue; //same procedure as << 754 << 755 const G4double massTableParent = Particl << 756 const G4double massTableDaughter = Parti << 757 const G4double massTableParticle = getTa << 758 theQValue = massTableParent - massTableD << 759 << 760 const G4double massINCLParent = Particle << 761 const G4double massINCLDaughter = Partic << 762 const G4double massINCLParticle = getINC << 763 << 764 return theQValue - (massINCLParent-massI << 765 } << 766 << 767 /**\brief Computes correction on the trans 488 /**\brief Computes correction on the transfer Q-value 768 * 489 * 769 * Computes the correction that must be ap 490 * Computes the correction that must be applied to INCL particles in 770 * order to obtain the correct Q-value for 491 * order to obtain the correct Q-value for particle transfer from a given 771 * nucleus to another. 492 * nucleus to another. 772 * 493 * 773 * Assumes that the receving nucleus is IN 494 * Assumes that the receving nucleus is INCL's target nucleus, with the 774 * INCL separation energy. 495 * INCL separation energy. 775 * 496 * 776 * \param AFrom the mass number of the don 497 * \param AFrom the mass number of the donating nucleus 777 * \param ZFrom the charge number of the d 498 * \param ZFrom the charge number of the donating nucleus 778 * \param ATo the mass number of the recei 499 * \param ATo the mass number of the receiving nucleus 779 * \param ZTo the charge number of the rec 500 * \param ZTo the charge number of the receiving nucleus 780 * \return the correction 501 * \return the correction 781 */ 502 */ 782 G4double getTransferQValueCorrection(const 503 G4double getTransferQValueCorrection(const G4int AFrom, const G4int ZFrom, const G4int ATo, const G4int ZTo) const { 783 const G4int SFrom = 0; << 784 const G4int STo = 0; << 785 const G4int AFromDaughter = AFrom - theA << 786 const G4int ZFromDaughter = ZFrom - theZ << 787 const G4int SFromDaughter = 0; << 788 const G4int AToDaughter = ATo + theA; << 789 const G4int ZToDaughter = ZTo + theZ; << 790 const G4int SToDaughter = 0; << 791 const G4double theQValue = ParticleTable << 792 << 793 const G4double massINCLTo = ParticleTabl << 794 const G4double massINCLToDaughter = Part << 795 /* Note that here we have to use the tab << 796 * cannot use theMass, because at this s << 797 * still off-shell; and we cannot use ge << 798 * violations of global energy conservat << 799 */ << 800 const G4double massINCLParticle = getTab << 801 << 802 // The rhs corresponds to the INCL Q-val << 803 return theQValue - (massINCLToDaughter-m << 804 } << 805 << 806 /**\brief Computes correction on the emiss << 807 * << 808 * Computes the correction that must be ap << 809 * order to obtain the correct Q-value for << 810 * nucleus. For absorption, the correction << 811 * the value returned by this function. << 812 * << 813 * \param AParent the mass number of the e << 814 * \param ZParent the charge number of the << 815 * \param SParent the strangess number of << 816 * \return the correction << 817 */ << 818 G4double getEmissionQValueCorrection(const << 819 const G4int ADaughter = AParent - theA; << 820 const G4int ZDaughter = ZParent - theZ; << 821 const G4int SDaughter = SParent - theS; << 822 << 823 // Note the minus sign here << 824 G4double theQValue; << 825 if(isCluster()) << 826 theQValue = -ParticleTable::getTableQV << 827 else { << 828 const G4double massTableParent = Parti << 829 const G4double massTableDaughter = Par << 830 const G4double massTableParticle = get << 831 theQValue = massTableParent - massTabl << 832 } << 833 << 834 const G4double massINCLParent = Particle << 835 const G4double massINCLDaughter = Partic << 836 const G4double massINCLParticle = getINC << 837 << 838 // The rhs corresponds to the INCL Q-val << 839 return theQValue - (massINCLParent-massI << 840 } << 841 << 842 /**\brief Computes correction on the trans << 843 * << 844 * Computes the correction that must be ap << 845 * order to obtain the correct Q-value for << 846 * nucleus to another. << 847 * << 848 * Assumes that the receving nucleus is IN << 849 * INCL separation energy. << 850 * << 851 * \param AFrom the mass number of the don << 852 * \param ZFrom the charge number of the d << 853 * \param SFrom the strangess number of th << 854 * \param ATo the mass number of the recei << 855 * \param ZTo the charge number of the rec << 856 * \param STo the strangess number of the << 857 * \return the correction << 858 */ << 859 G4double getTransferQValueCorrection(const << 860 const G4int AFromDaughter = AFrom - theA 504 const G4int AFromDaughter = AFrom - theA; 861 const G4int ZFromDaughter = ZFrom - theZ 505 const G4int ZFromDaughter = ZFrom - theZ; 862 const G4int SFromDaughter = SFrom - theS << 863 const G4int AToDaughter = ATo + theA; 506 const G4int AToDaughter = ATo + theA; 864 const G4int ZToDaughter = ZTo + theZ; 507 const G4int ZToDaughter = ZTo + theZ; 865 const G4int SToDaughter = STo + theS; << 508 const G4double theQValue = ParticleTable::getTableQValue(AToDaughter,ZToDaughter,AFromDaughter,ZFromDaughter,AFrom,ZFrom); 866 const G4double theQValue = ParticleTable << 867 509 868 const G4double massINCLTo = ParticleTabl << 510 const G4double massINCLTo = ParticleTable::getINCLMass(ATo,ZTo); 869 const G4double massINCLToDaughter = Part << 511 const G4double massINCLToDaughter = ParticleTable::getINCLMass(AToDaughter,ZToDaughter); 870 /* Note that here we have to use the tab 512 /* Note that here we have to use the table mass in the INCL Q-value. We 871 * cannot use theMass, because at this s 513 * cannot use theMass, because at this stage the particle is probably 872 * still off-shell; and we cannot use ge 514 * still off-shell; and we cannot use getINCLMass(), because it leads to 873 * violations of global energy conservat 515 * violations of global energy conservation. 874 */ 516 */ 875 const G4double massINCLParticle = getTab 517 const G4double massINCLParticle = getTableMass(); 876 518 877 // The rhs corresponds to the INCL Q-val 519 // The rhs corresponds to the INCL Q-value for particle absorption 878 return theQValue - (massINCLToDaughter-m 520 return theQValue - (massINCLToDaughter-massINCLTo-massINCLParticle); 879 } 521 } 880 522 881 << 882 << 883 /** \brief Get the the particle invariant 523 /** \brief Get the the particle invariant mass. 884 * 524 * 885 * Uses the relativistic invariant 525 * Uses the relativistic invariant 886 * \f[ m = \sqrt{E^2 - {\vec p}^2}\f] 526 * \f[ m = \sqrt{E^2 - {\vec p}^2}\f] 887 **/ 527 **/ 888 G4double getInvariantMass() const { 528 G4double getInvariantMass() const { 889 const G4double mass = std::pow(theEnergy 529 const G4double mass = std::pow(theEnergy, 2) - theMomentum.dot(theMomentum); 890 if(mass < 0.0) { 530 if(mass < 0.0) { 891 INCL_ERROR("E*E - p*p is negative." << << 531 INCL_ERROR("E*E - p*p is negative." << std::endl); 892 return 0.0; 532 return 0.0; 893 } else { 533 } else { 894 return std::sqrt(mass); 534 return std::sqrt(mass); 895 } 535 } 896 }; 536 }; 897 537 898 /// \brief Get the particle kinetic energy 538 /// \brief Get the particle kinetic energy. 899 inline G4double getKineticEnergy() const { 539 inline G4double getKineticEnergy() const { return theEnergy - theMass; } 900 540 901 /// \brief Get the particle potential ener 541 /// \brief Get the particle potential energy. 902 inline G4double getPotentialEnergy() const 542 inline G4double getPotentialEnergy() const { return thePotentialEnergy; } 903 543 904 /// \brief Set the particle potential ener 544 /// \brief Set the particle potential energy. 905 inline void setPotentialEnergy(G4double v) 545 inline void setPotentialEnergy(G4double v) { thePotentialEnergy = v; } 906 546 907 /** 547 /** 908 * Get the energy of the particle in MeV. 548 * Get the energy of the particle in MeV. 909 */ 549 */ 910 G4double getEnergy() const 550 G4double getEnergy() const 911 { 551 { 912 return theEnergy; 552 return theEnergy; 913 }; 553 }; 914 554 915 /** 555 /** 916 * Set the mass of the particle in MeV/c^2 556 * Set the mass of the particle in MeV/c^2. 917 */ 557 */ 918 void setMass(G4double mass) 558 void setMass(G4double mass) 919 { 559 { 920 this->theMass = mass; 560 this->theMass = mass; 921 } 561 } 922 562 923 /** 563 /** 924 * Set the energy of the particle in MeV. 564 * Set the energy of the particle in MeV. 925 */ 565 */ 926 void setEnergy(G4double energy) 566 void setEnergy(G4double energy) 927 { 567 { 928 this->theEnergy = energy; 568 this->theEnergy = energy; 929 }; 569 }; 930 570 931 /** 571 /** 932 * Get the momentum vector. 572 * Get the momentum vector. 933 */ 573 */ 934 const G4INCL::ThreeVector &getMomentum() c 574 const G4INCL::ThreeVector &getMomentum() const 935 { 575 { 936 return theMomentum; 576 return theMomentum; 937 }; 577 }; 938 578 939 /** Get the angular momentum w.r.t. the or 579 /** Get the angular momentum w.r.t. the origin */ 940 virtual G4INCL::ThreeVector getAngularMome 580 virtual G4INCL::ThreeVector getAngularMomentum() const 941 { 581 { 942 return thePosition.vector(theMomentum); 582 return thePosition.vector(theMomentum); 943 }; 583 }; 944 584 945 /** 585 /** 946 * Set the momentum vector. 586 * Set the momentum vector. 947 */ 587 */ 948 virtual void setMomentum(const G4INCL::Thr 588 virtual void setMomentum(const G4INCL::ThreeVector &momentum) 949 { 589 { 950 this->theMomentum = momentum; 590 this->theMomentum = momentum; 951 }; 591 }; 952 592 953 /** 593 /** 954 * Set the position vector. 594 * Set the position vector. 955 */ 595 */ 956 const G4INCL::ThreeVector &getPosition() c 596 const G4INCL::ThreeVector &getPosition() const 957 { 597 { 958 return thePosition; 598 return thePosition; 959 }; 599 }; 960 600 961 virtual void setPosition(const G4INCL::Thr 601 virtual void setPosition(const G4INCL::ThreeVector &position) 962 { 602 { 963 this->thePosition = position; 603 this->thePosition = position; 964 }; 604 }; 965 605 966 G4double getHelicity() { return theHelicit 606 G4double getHelicity() { return theHelicity; }; 967 void setHelicity(G4double h) { theHelicity 607 void setHelicity(G4double h) { theHelicity = h; }; 968 608 969 void propagate(G4double step) { 609 void propagate(G4double step) { 970 thePosition += ((*thePropagationMomentum 610 thePosition += ((*thePropagationMomentum)*(step/(*thePropagationEnergy))); 971 }; 611 }; 972 612 973 /** \brief Return the number of collisions 613 /** \brief Return the number of collisions undergone by the particle. **/ 974 G4int getNumberOfCollisions() const { retu 614 G4int getNumberOfCollisions() const { return nCollisions; } 975 615 976 /** \brief Set the number of collisions un 616 /** \brief Set the number of collisions undergone by the particle. **/ 977 void setNumberOfCollisions(G4int n) { nCol 617 void setNumberOfCollisions(G4int n) { nCollisions = n; } 978 618 979 /** \brief Increment the number of collisi 619 /** \brief Increment the number of collisions undergone by the particle. **/ 980 void incrementNumberOfCollisions() { nColl 620 void incrementNumberOfCollisions() { nCollisions++; } 981 621 982 /** \brief Return the number of decays und 622 /** \brief Return the number of decays undergone by the particle. **/ 983 G4int getNumberOfDecays() const { return n 623 G4int getNumberOfDecays() const { return nDecays; } 984 624 985 /** \brief Set the number of decays underg 625 /** \brief Set the number of decays undergone by the particle. **/ 986 void setNumberOfDecays(G4int n) { nDecays 626 void setNumberOfDecays(G4int n) { nDecays = n; } 987 627 988 /** \brief Increment the number of decays 628 /** \brief Increment the number of decays undergone by the particle. **/ 989 void incrementNumberOfDecays() { nDecays++ 629 void incrementNumberOfDecays() { nDecays++; } 990 630 991 /** \brief Mark the particle as out of its 631 /** \brief Mark the particle as out of its potential well 992 * 632 * 993 * This flag is used to control pions crea 633 * This flag is used to control pions created outside their potential well 994 * in delta decay. The pion potential chec 634 * in delta decay. The pion potential checks it and returns zero if it is 995 * true (necessary in order to correctly e 635 * true (necessary in order to correctly enforce energy conservation). The 996 * Nucleus::applyFinalState() method uses 636 * Nucleus::applyFinalState() method uses it to determine whether new 997 * avatars should be generated for the par 637 * avatars should be generated for the particle. 998 */ 638 */ 999 void setOutOfWell() { outOfWell = true; } 639 void setOutOfWell() { outOfWell = true; } 1000 640 1001 /// \brief Check if the particle is out o 641 /// \brief Check if the particle is out of its potential well 1002 G4bool isOutOfWell() const { return outOf 642 G4bool isOutOfWell() const { return outOfWell; } 1003 643 1004 void setEmissionTime(G4double t) { emissi 644 void setEmissionTime(G4double t) { emissionTime = t; } 1005 G4double getEmissionTime() { return emiss 645 G4double getEmissionTime() { return emissionTime; }; 1006 646 1007 /** \brief Transverse component of the po 647 /** \brief Transverse component of the position w.r.t. the momentum. */ 1008 ThreeVector getTransversePosition() const 648 ThreeVector getTransversePosition() const { 1009 return thePosition - getLongitudinalPos 649 return thePosition - getLongitudinalPosition(); 1010 } 650 } 1011 651 1012 /** \brief Longitudinal component of the 652 /** \brief Longitudinal component of the position w.r.t. the momentum. */ 1013 ThreeVector getLongitudinalPosition() con 653 ThreeVector getLongitudinalPosition() const { 1014 return *thePropagationMomentum * (thePo 654 return *thePropagationMomentum * (thePosition.dot(*thePropagationMomentum)/thePropagationMomentum->mag2()); 1015 } 655 } 1016 656 1017 /** \brief Rescale the momentum to match 657 /** \brief Rescale the momentum to match the total energy. */ 1018 const ThreeVector &adjustMomentumFromEner 658 const ThreeVector &adjustMomentumFromEnergy(); 1019 659 1020 /** \brief Recompute the energy to match 660 /** \brief Recompute the energy to match the momentum. */ 1021 G4double adjustEnergyFromMomentum(); 661 G4double adjustEnergyFromMomentum(); 1022 662 >> 663 /** \brief Check if the particle belongs to a given list **/ >> 664 G4bool isInList(ParticleList const &l) const { >> 665 return (std::find(l.begin(), l.end(), this)!=l.end()); >> 666 } >> 667 1023 G4bool isCluster() const { 668 G4bool isCluster() const { 1024 return (theType == Composite); 669 return (theType == Composite); 1025 } 670 } 1026 671 1027 /// \brief Set the frozen particle moment 672 /// \brief Set the frozen particle momentum 1028 void setFrozenMomentum(const ThreeVector 673 void setFrozenMomentum(const ThreeVector &momentum) { theFrozenMomentum = momentum; } 1029 674 1030 /// \brief Set the frozen particle moment 675 /// \brief Set the frozen particle momentum 1031 void setFrozenEnergy(const G4double energ 676 void setFrozenEnergy(const G4double energy) { theFrozenEnergy = energy; } 1032 677 1033 /// \brief Get the frozen particle moment 678 /// \brief Get the frozen particle momentum 1034 ThreeVector getFrozenMomentum() const { r 679 ThreeVector getFrozenMomentum() const { return theFrozenMomentum; } 1035 680 1036 /// \brief Get the frozen particle moment 681 /// \brief Get the frozen particle momentum 1037 G4double getFrozenEnergy() const { return 682 G4double getFrozenEnergy() const { return theFrozenEnergy; } 1038 683 1039 /// \brief Get the propagation velocity o 684 /// \brief Get the propagation velocity of the particle 1040 ThreeVector getPropagationVelocity() cons 685 ThreeVector getPropagationVelocity() const { return (*thePropagationMomentum)/(*thePropagationEnergy); } 1041 686 1042 /** \brief Freeze particle propagation 687 /** \brief Freeze particle propagation 1043 * 688 * 1044 * Make the particle use theFrozenMomentu 689 * Make the particle use theFrozenMomentum and theFrozenEnergy for 1045 * propagation. The normal state can be r 690 * propagation. The normal state can be restored by calling the 1046 * thawPropagation() method. 691 * thawPropagation() method. 1047 */ 692 */ 1048 void freezePropagation() { 693 void freezePropagation() { 1049 thePropagationMomentum = &theFrozenMome 694 thePropagationMomentum = &theFrozenMomentum; 1050 thePropagationEnergy = &theFrozenEnergy 695 thePropagationEnergy = &theFrozenEnergy; 1051 } 696 } 1052 697 1053 /** \brief Unfreeze particle propagation 698 /** \brief Unfreeze particle propagation 1054 * 699 * 1055 * Make the particle use theMomentum and 700 * Make the particle use theMomentum and theEnergy for propagation. Call 1056 * this method to restore the normal prop 701 * this method to restore the normal propagation if the 1057 * freezePropagation() method has been ca 702 * freezePropagation() method has been called. 1058 */ 703 */ 1059 void thawPropagation() { 704 void thawPropagation() { 1060 thePropagationMomentum = &theMomentum; 705 thePropagationMomentum = &theMomentum; 1061 thePropagationEnergy = &theEnergy; 706 thePropagationEnergy = &theEnergy; 1062 } 707 } 1063 708 1064 /** \brief Rotate the particle position a 709 /** \brief Rotate the particle position and momentum 1065 * 710 * 1066 * \param angle the rotation angle 711 * \param angle the rotation angle 1067 * \param axis a unit vector representing 712 * \param axis a unit vector representing the rotation axis 1068 */ 713 */ 1069 virtual void rotatePositionAndMomentum(co << 714 virtual void rotate(const G4double angle, const ThreeVector &axis) { 1070 rotatePosition(angle, axis); << 1071 rotateMomentum(angle, axis); << 1072 } << 1073 << 1074 /** \brief Rotate the particle position << 1075 * << 1076 * \param angle the rotation angle << 1077 * \param axis a unit vector representing << 1078 */ << 1079 virtual void rotatePosition(const G4doubl << 1080 thePosition.rotate(angle, axis); 715 thePosition.rotate(angle, axis); 1081 } << 1082 << 1083 /** \brief Rotate the particle momentum << 1084 * << 1085 * \param angle the rotation angle << 1086 * \param axis a unit vector representing << 1087 */ << 1088 virtual void rotateMomentum(const G4doubl << 1089 theMomentum.rotate(angle, axis); 716 theMomentum.rotate(angle, axis); 1090 theFrozenMomentum.rotate(angle, axis); 717 theFrozenMomentum.rotate(angle, axis); 1091 } 718 } 1092 719 1093 std::string print() const { 720 std::string print() const { 1094 std::stringstream ss; 721 std::stringstream ss; 1095 ss << "Particle (ID = " << ID << ") typ 722 ss << "Particle (ID = " << ID << ") type = "; 1096 ss << ParticleTable::getName(theType); 723 ss << ParticleTable::getName(theType); 1097 ss << '\n' << 724 ss << std::endl 1098 << " energy = " << theEnergy << '\n << 725 << " energy = " << theEnergy << std::endl 1099 << " momentum = " 726 << " momentum = " 1100 << theMomentum.print() 727 << theMomentum.print() 1101 << '\n' << 728 << std::endl 1102 << " position = " 729 << " position = " 1103 << thePosition.print() 730 << thePosition.print() 1104 << '\n'; << 731 << std::endl; 1105 return ss.str(); 732 return ss.str(); 1106 }; 733 }; 1107 734 1108 std::string dump() const { 735 std::string dump() const { 1109 std::stringstream ss; 736 std::stringstream ss; 1110 ss << "(particle " << ID << " "; 737 ss << "(particle " << ID << " "; 1111 ss << ParticleTable::getName(theType); 738 ss << ParticleTable::getName(theType); 1112 ss << '\n' << 739 ss << std::endl 1113 << thePosition.dump() 740 << thePosition.dump() 1114 << '\n' << 741 << std::endl 1115 << theMomentum.dump() 742 << theMomentum.dump() 1116 << '\n' << 743 << std::endl 1117 << theEnergy << ")" << '\n'; << 744 << theEnergy << ")" << std::endl; 1118 return ss.str(); 745 return ss.str(); 1119 }; 746 }; 1120 747 1121 long getID() const { return ID; }; 748 long getID() const { return ID; }; 1122 749 1123 /** 750 /** 1124 * Return a NULL pointer 751 * Return a NULL pointer 1125 */ 752 */ 1126 ParticleList const *getParticles() const 753 ParticleList const *getParticles() const { 1127 INCL_WARN("Particle::getParticles() met << 754 INCL_WARN("Particle::getParticles() method was called on a Particle object" << std::endl); 1128 return 0; 755 return 0; 1129 } 756 } 1130 757 1131 /** \brief Return the reflection momentum 758 /** \brief Return the reflection momentum 1132 * 759 * 1133 * The reflection momentum is used by cal 760 * The reflection momentum is used by calls to getSurfaceRadius to compute 1134 * the radius of the sphere where the nuc 761 * the radius of the sphere where the nucleon moves. It is necessary to 1135 * introduce fuzzy r-p correlations. 762 * introduce fuzzy r-p correlations. 1136 */ 763 */ 1137 G4double getReflectionMomentum() const { 764 G4double getReflectionMomentum() const { 1138 if(rpCorrelated) 765 if(rpCorrelated) 1139 return theMomentum.mag(); 766 return theMomentum.mag(); 1140 else 767 else 1141 return uncorrelatedMomentum; 768 return uncorrelatedMomentum; 1142 } 769 } 1143 770 1144 /// \brief Set the uncorrelated momentum 771 /// \brief Set the uncorrelated momentum 1145 void setUncorrelatedMomentum(const G4doub 772 void setUncorrelatedMomentum(const G4double p) { uncorrelatedMomentum = p; } 1146 773 1147 /// \brief Make the particle follow a str 774 /// \brief Make the particle follow a strict r-p correlation 1148 void rpCorrelate() { rpCorrelated = true; 775 void rpCorrelate() { rpCorrelated = true; } 1149 776 1150 /// \brief Make the particle not follow a 777 /// \brief Make the particle not follow a strict r-p correlation 1151 void rpDecorrelate() { rpCorrelated = fal 778 void rpDecorrelate() { rpCorrelated = false; } 1152 779 1153 /// \brief Get the cosine of the angle be 780 /// \brief Get the cosine of the angle between position and momentum 1154 G4double getCosRPAngle() const { 781 G4double getCosRPAngle() const { 1155 const G4double norm = thePosition.mag2( 782 const G4double norm = thePosition.mag2()*thePropagationMomentum->mag2(); 1156 if(norm>0.) 783 if(norm>0.) 1157 return thePosition.dot(*thePropagatio 784 return thePosition.dot(*thePropagationMomentum) / std::sqrt(norm); 1158 else 785 else 1159 return 1.; 786 return 1.; 1160 } 787 } 1161 788 1162 /// \brief General bias vector function << 1163 static G4double getTotalBias(); << 1164 static void setINCLBiasVector(std::vector << 1165 static void FillINCLBiasVector(G4double n << 1166 static G4double getBiasFromVector(std::ve << 1167 << 1168 static std::vector<G4int> MergeVectorBias << 1169 static std::vector<G4int> MergeVectorBias << 1170 << 1171 /// \brief Get the particle bias. << 1172 G4double getParticleBias() const { return << 1173 << 1174 /// \brief Set the particle bias. << 1175 void setParticleBias(G4double ParticleBia << 1176 << 1177 /// \brief Get the vector list of biased << 1178 std::vector<G4int> getBiasCollisionVector << 1179 << 1180 /// \brief Set the vector list of biased << 1181 void setBiasCollisionVector(std::vector<G << 1182 this->theBiasCollisionVector = BiasCollis << 1183 this->setParticleBias(Particle::getBiasFr << 1184 } << 1185 << 1186 /** \brief Number of Kaon inside de nucle << 1187 * << 1188 * Put in the Particle class in order to << 1189 * "correct" mass of composit particle. << 1190 * << 1191 */ << 1192 << 1193 G4int getNumberOfKaon() const { return th << 1194 void setNumberOfKaon(const G4int NK) { th << 1195 << 1196 #ifdef INCLXX_IN_GEANT4_MODE << 1197 G4int getParentResonancePDGCode() const { << 1198 void setParentResonancePDGCode(const G4in << 1199 G4int getParentResonanceID() const { retu << 1200 void setParentResonanceID(const G4int par << 1201 #endif << 1202 << 1203 public: << 1204 /** \brief Time ordered vector of all bia << 1205 * << 1206 * /!\ Caution /!\ << 1207 * methods Assotiated to G4VectorCache<T> << 1208 * Push_back(…), << 1209 * operator[], << 1210 * Begin(), << 1211 * End(), << 1212 * Clear(), << 1213 * Size() and << 1214 * Pop_back() << 1215 * << 1216 */ << 1217 #ifdef INCLXX_IN_GEANT4_MODE << 1218 static std::vector<G4double> INCLBiasVe << 1219 //static G4VectorCache<G4double> INCLBi << 1220 #else << 1221 static G4ThreadLocal std::vector<G4doub << 1222 //static G4VectorCache<G4double> INCLBi << 1223 #endif << 1224 static G4ThreadLocal G4int nextBiasedColl << 1225 << 1226 protected: 789 protected: 1227 G4int theZ, theA, theS; << 790 G4int theZ, theA; 1228 ParticipantType theParticipantType; 791 ParticipantType theParticipantType; 1229 G4INCL::ParticleType theType; 792 G4INCL::ParticleType theType; 1230 G4double theEnergy; 793 G4double theEnergy; 1231 G4double *thePropagationEnergy; 794 G4double *thePropagationEnergy; 1232 G4double theFrozenEnergy; 795 G4double theFrozenEnergy; 1233 G4INCL::ThreeVector theMomentum; 796 G4INCL::ThreeVector theMomentum; 1234 G4INCL::ThreeVector *thePropagationMoment 797 G4INCL::ThreeVector *thePropagationMomentum; 1235 G4INCL::ThreeVector theFrozenMomentum; 798 G4INCL::ThreeVector theFrozenMomentum; 1236 G4INCL::ThreeVector thePosition; 799 G4INCL::ThreeVector thePosition; 1237 G4int nCollisions; 800 G4int nCollisions; 1238 G4int nDecays; 801 G4int nDecays; 1239 G4double thePotentialEnergy; 802 G4double thePotentialEnergy; 1240 long ID; 803 long ID; 1241 804 1242 G4bool rpCorrelated; 805 G4bool rpCorrelated; 1243 G4double uncorrelatedMomentum; 806 G4double uncorrelatedMomentum; 1244 << 1245 G4double theParticleBias; << 1246 /// \brief The number of Kaons inside the << 1247 G4int theNKaon; << 1248 << 1249 #ifdef INCLXX_IN_GEANT4_MODE << 1250 G4int theParentResonancePDGCode; << 1251 G4int theParentResonanceID; << 1252 #endif << 1253 807 1254 private: 808 private: 1255 G4double theHelicity; 809 G4double theHelicity; 1256 G4double emissionTime; 810 G4double emissionTime; 1257 G4bool outOfWell; 811 G4bool outOfWell; 1258 << 1259 /// \brief Time ordered vector of all bia << 1260 std::vector<G4int> theBiasCollisionVector << 1261 812 1262 G4double theMass; 813 G4double theMass; 1263 static G4ThreadLocal long nextID; 814 static G4ThreadLocal long nextID; 1264 815 1265 INCL_DECLARE_ALLOCATION_POOL(Particle) << 1266 }; 816 }; 1267 } 817 } 1268 818 1269 #endif /* PARTICLE_HH_ */ 819 #endif /* PARTICLE_HH_ */ 1270 820