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 // 26 // >> 27 // $Id: G4Decay.cc,v 1.30 2008/09/19 03:19:53 kurasige Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02 $ 27 // 29 // 28 // 30 // 29 // ------------------------------------------- 31 // -------------------------------------------------------------- 30 // GEANT 4 class implementation file 32 // GEANT 4 class implementation file 31 // 33 // 32 // History: first implementation, based o 34 // History: first implementation, based on object model of 33 // 2nd December 1995, G.Cosmo 35 // 2nd December 1995, G.Cosmo 34 // 7 July 1996 H.Kurashige 36 // 7 July 1996 H.Kurashige 35 // ------------------------------------------- 37 // ------------------------------------------------------------ 36 // remove BuildPhysicsTable() 28 Nov. 1997 38 // remove BuildPhysicsTable() 28 Nov. 1997 H.Kurashige 37 // change DBL_EPSIRON to DBL_MIN 14 Dec. 19 39 // change DBL_EPSIRON to DBL_MIN 14 Dec. 1997 H.Kurashige 38 // modified for new ParticleChange 12 Mar. 1 40 // modified for new ParticleChange 12 Mar. 1998 H.Kurashige 39 // modified for "GoodForTrackingFlag" 19 Jun 41 // modified for "GoodForTrackingFlag" 19 June 1998 H.Kurashige 40 // rename thePhysicsTable to aPhyscisTable 2 42 // rename thePhysicsTable to aPhyscisTable 2 Aug. 1998 H.Kurashige 41 // modified IsApplicable in order to protect 43 // modified IsApplicable in order to protect the decay from registered 42 // to resonances 12 Dec. 1998 H.Kurashi 44 // to resonances 12 Dec. 1998 H.Kurashige 43 // remove G4ParticleMomentum 6 Feb. 99 H.Ku 45 // remove G4ParticleMomentum 6 Feb. 99 H.Kurashige 44 // modified IsApplicable to activate G4Deca 46 // modified IsApplicable to activate G4Decay for resonances 1 Mar. 00 H.Kurashige 45 // Add External Decayer 23 Feb. 2001 47 // Add External Decayer 23 Feb. 2001 H.Kurashige 46 // change LowestBinValue,HighestBinValue and 48 // change LowestBinValue,HighestBinValue and TotBin(200) 9 Feb. 2002 47 // 49 // 48 50 49 #include "G4Decay.hh" 51 #include "G4Decay.hh" 50 << 51 #include "G4PhysicalConstants.hh" << 52 #include "G4SystemOfUnits.hh" << 53 #include "G4DynamicParticle.hh" 52 #include "G4DynamicParticle.hh" 54 #include "G4DecayProducts.hh" 53 #include "G4DecayProducts.hh" 55 #include "G4DecayTable.hh" 54 #include "G4DecayTable.hh" 56 #include "G4VDecayChannel.hh" << 57 #include "G4PhysicsLogVector.hh" 55 #include "G4PhysicsLogVector.hh" 58 #include "G4ParticleChangeForDecay.hh" 56 #include "G4ParticleChangeForDecay.hh" 59 #include "G4VExtDecayer.hh" 57 #include "G4VExtDecayer.hh" 60 58 61 // constructor 59 // constructor 62 G4Decay::G4Decay(const G4String& processName) 60 G4Decay::G4Decay(const G4String& processName) 63 :G4VRestDiscret 61 :G4VRestDiscreteProcess(processName, fDecay), 64 verboseLevel(1), 62 verboseLevel(1), 65 HighestValue(2 63 HighestValue(20.0), 66 fRemainderLifeTime(-1.0), << 64 pExtDecayer(0) 67 pExtDecayer(nu << 68 { 65 { 69 // set Process Sub Type 66 // set Process Sub Type 70 SetProcessSubType(static_cast<int>(DECAY)); 67 SetProcessSubType(static_cast<int>(DECAY)); 71 68 72 #ifdef G4VERBOSE 69 #ifdef G4VERBOSE 73 if (GetVerboseLevel()>1) { 70 if (GetVerboseLevel()>1) { 74 G4cout << "G4Decay constructor " << " Na 71 G4cout << "G4Decay constructor " << " Name:" << processName << G4endl; 75 } 72 } 76 #endif 73 #endif 77 74 78 pParticleChange = &fParticleChangeForDecay; 75 pParticleChange = &fParticleChangeForDecay; 79 } 76 } 80 77 81 G4Decay::~G4Decay() 78 G4Decay::~G4Decay() 82 { 79 { 83 if (pExtDecayer != nullptr) { << 80 if (pExtDecayer) { 84 delete pExtDecayer; 81 delete pExtDecayer; 85 } 82 } 86 } 83 } 87 84 88 G4bool G4Decay::IsApplicable(const G4ParticleD 85 G4bool G4Decay::IsApplicable(const G4ParticleDefinition& aParticleType) 89 { 86 { 90 // check if the particle is stable? 87 // check if the particle is stable? 91 if (aParticleType.GetPDGLifeTime() <0.0) { 88 if (aParticleType.GetPDGLifeTime() <0.0) { 92 return false; 89 return false; 93 } else if (aParticleType.GetPDGMass() <= 0. 90 } else if (aParticleType.GetPDGMass() <= 0.0*MeV) { 94 return false; 91 return false; 95 } else { 92 } else { 96 return true; 93 return true; 97 } 94 } 98 } 95 } 99 96 100 G4double G4Decay::GetMeanLifeTime(const G4Trac 97 G4double G4Decay::GetMeanLifeTime(const G4Track& aTrack , 101 G4ForceCondi 98 G4ForceCondition*) 102 { 99 { 103 // returns the mean free path in GEANT4 int 100 // returns the mean free path in GEANT4 internal units 104 G4double meanlife; 101 G4double meanlife; 105 102 106 // get particle 103 // get particle 107 const G4DynamicParticle* aParticle = aTrack 104 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 108 const G4ParticleDefinition* aParticleDef = << 105 G4ParticleDefinition* aParticleDef = aParticle->GetDefinition(); 109 G4double aLife = aParticleDef->GetPDGLifeTi 106 G4double aLife = aParticleDef->GetPDGLifeTime(); 110 107 111 // check if the particle is stable? 108 // check if the particle is stable? 112 if (aParticleDef->GetPDGStable()) { 109 if (aParticleDef->GetPDGStable()) { 113 //1000000 times the life time of the unive << 110 meanlife = DBL_MAX; 114 meanlife = 1e24 * s; << 115 111 116 } else { 112 } else { 117 meanlife = aLife; 113 meanlife = aLife; 118 } 114 } 119 115 120 #ifdef G4VERBOSE 116 #ifdef G4VERBOSE 121 if (GetVerboseLevel()>1) { 117 if (GetVerboseLevel()>1) { 122 G4cout << "mean life time: "<< meanlife/n 118 G4cout << "mean life time: "<< meanlife/ns << "[ns]" << G4endl; 123 } 119 } 124 #endif 120 #endif 125 121 126 return meanlife; 122 return meanlife; 127 } 123 } 128 124 129 G4double G4Decay::GetMeanFreePath(const G4Trac 125 G4double G4Decay::GetMeanFreePath(const G4Track& aTrack,G4double, G4ForceCondition*) 130 { 126 { 131 // get particle 127 // get particle 132 const G4DynamicParticle* aParticle = aTrack 128 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 133 const G4ParticleDefinition* aParticleDef = << 129 G4ParticleDefinition* aParticleDef = aParticle->GetDefinition(); 134 G4double aMass = aParticle->GetMass(); 130 G4double aMass = aParticle->GetMass(); 135 G4double aLife = aParticleDef->GetPDGLifeTi 131 G4double aLife = aParticleDef->GetPDGLifeTime(); 136 132 137 133 138 // returns the mean free path in GEANT4 in 134 // returns the mean free path in GEANT4 internal units 139 G4double pathlength; 135 G4double pathlength; 140 G4double aCtau = c_light * aLife; 136 G4double aCtau = c_light * aLife; 141 137 142 // check if the particle is stable? 138 // check if the particle is stable? 143 if (aParticleDef->GetPDGStable()) { 139 if (aParticleDef->GetPDGStable()) { 144 pathlength = DBL_MAX; 140 pathlength = DBL_MAX; 145 141 146 //check if the particle has very short life 142 //check if the particle has very short life time ? 147 } else if (aCtau < DBL_MIN) { 143 } else if (aCtau < DBL_MIN) { 148 pathlength = DBL_MIN; 144 pathlength = DBL_MIN; 149 145 150 } else { 146 } else { 151 //calculate the mean free path 147 //calculate the mean free path 152 // by using normalized kinetic energy (= E 148 // by using normalized kinetic energy (= Ekin/mass) 153 G4double rKineticEnergy = aParticle->Ge 149 G4double rKineticEnergy = aParticle->GetKineticEnergy()/aMass; 154 if ( rKineticEnergy > HighestValue) { 150 if ( rKineticEnergy > HighestValue) { 155 // gamma >> 1 151 // gamma >> 1 156 pathlength = ( rKineticEnergy + 1.0)* a 152 pathlength = ( rKineticEnergy + 1.0)* aCtau; 157 } else if ( rKineticEnergy < DBL_MIN ) { 153 } else if ( rKineticEnergy < DBL_MIN ) { 158 // too slow particle 154 // too slow particle 159 #ifdef G4VERBOSE 155 #ifdef G4VERBOSE 160 if (GetVerboseLevel()>1) { 156 if (GetVerboseLevel()>1) { 161 G4cout << "G4Decay::GetMeanFreePath() !!p 157 G4cout << "G4Decay::GetMeanFreePath() !!particle stops!!"; 162 G4cout << aParticleDef->GetParticleNa 158 G4cout << aParticleDef->GetParticleName() << G4endl; 163 G4cout << "KineticEnergy:" << aParticle->Ge 159 G4cout << "KineticEnergy:" << aParticle->GetKineticEnergy()/GeV <<"[GeV]"; 164 } 160 } 165 #endif 161 #endif 166 pathlength = DBL_MIN; 162 pathlength = DBL_MIN; 167 } else { 163 } else { 168 // beta <1 164 // beta <1 169 pathlength = (aParticle->GetTotalMoment 165 pathlength = (aParticle->GetTotalMomentum())/aMass*aCtau ; 170 } 166 } 171 } 167 } 172 return pathlength; 168 return pathlength; 173 } 169 } 174 170 175 void G4Decay::BuildPhysicsTable(const G4Partic 171 void G4Decay::BuildPhysicsTable(const G4ParticleDefinition&) 176 { 172 { 177 return; 173 return; 178 } 174 } 179 175 180 G4VParticleChange* G4Decay::DecayIt(const G4Tr 176 G4VParticleChange* G4Decay::DecayIt(const G4Track& aTrack, const G4Step& ) 181 { 177 { 182 // The DecayIt() method returns by pointer a 178 // The DecayIt() method returns by pointer a particle-change object. 183 // Units are expressed in GEANT4 internal un 179 // Units are expressed in GEANT4 internal units. 184 180 185 // Initialize ParticleChange 181 // Initialize ParticleChange 186 // all members of G4VParticleChange are 182 // all members of G4VParticleChange are set to equal to 187 // corresponding member in G4Track 183 // corresponding member in G4Track 188 fParticleChangeForDecay.Initialize(aTrack); 184 fParticleChangeForDecay.Initialize(aTrack); 189 185 190 // get particle 186 // get particle 191 const G4DynamicParticle* aParticle = aTrack. 187 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 192 const G4ParticleDefinition* aParticleDef = a << 188 G4ParticleDefinition* aParticleDef = aParticle->GetDefinition(); 193 189 194 // check if the particle is stable 190 // check if the particle is stable 195 if (aParticleDef->GetPDGStable()) return &fP 191 if (aParticleDef->GetPDGStable()) return &fParticleChangeForDecay ; 196 192 197 193 198 //check if thePreAssignedDecayProducts exist 194 //check if thePreAssignedDecayProducts exists 199 const G4DecayProducts* o_products = (aPartic 195 const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts()); 200 G4bool isPreAssigned = (o_products != nullpt << 196 G4bool isPreAssigned = (o_products != 0); 201 G4DecayProducts* products = nullptr; << 197 G4DecayProducts* products = 0; 202 198 203 // decay table 199 // decay table 204 G4DecayTable *decaytable = aParticleDef->G 200 G4DecayTable *decaytable = aParticleDef->GetDecayTable(); 205 201 206 // check if external decayer exists 202 // check if external decayer exists 207 G4bool isExtDecayer = (decaytable == nullptr << 203 G4bool isExtDecayer = (decaytable == 0) && (pExtDecayer !=0); 208 204 209 // Error due to NO Decay Table 205 // Error due to NO Decay Table 210 if ( (decaytable == nullptr) && !isExtDecaye << 206 if ( (decaytable == 0) && !isExtDecayer &&!isPreAssigned ){ 211 if (GetVerboseLevel()>0) { 207 if (GetVerboseLevel()>0) { 212 G4cout << "G4Decay::DoIt : decay table 208 G4cout << "G4Decay::DoIt : decay table not defined for "; 213 G4cout << aParticle->GetDefinition()->Ge 209 G4cout << aParticle->GetDefinition()->GetParticleName()<< G4endl; 214 } 210 } 215 G4ExceptionDescription ed; << 216 ed << "For " << aParticle->GetDefinition() << 217 << " decay probability exist but decay << 218 << "- the particle will be killed;\n" << 219 << " isExtDecayer: " << isExtDecayer << 220 << "; isPreAssigned: " << isPreAssigned << 221 G4Exception( "G4Decay::DecayIt ", 211 G4Exception( "G4Decay::DecayIt ", 222 "DECAY101",JustWarning, ed); << 212 "No Decay Table",JustWarning, >> 213 "Decay table is not defined"); 223 214 224 fParticleChangeForDecay.SetNumberOfSeconda 215 fParticleChangeForDecay.SetNumberOfSecondaries(0); 225 // Kill the parent particle 216 // Kill the parent particle 226 fParticleChangeForDecay.ProposeTrackStatus 217 fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ; 227 fParticleChangeForDecay.ProposeLocalEnergy 218 fParticleChangeForDecay.ProposeLocalEnergyDeposit(0.0); 228 219 229 ClearNumberOfInteractionLengthLeft(); 220 ClearNumberOfInteractionLengthLeft(); 230 return &fParticleChangeForDecay ; 221 return &fParticleChangeForDecay ; 231 } 222 } 232 223 233 if (isPreAssigned) { 224 if (isPreAssigned) { 234 // copy decay products 225 // copy decay products 235 products = new G4DecayProducts(*o_products 226 products = new G4DecayProducts(*o_products); 236 } else if ( isExtDecayer ) { 227 } else if ( isExtDecayer ) { 237 // decay according to external decayer 228 // decay according to external decayer 238 products = pExtDecayer->ImportDecayProduct 229 products = pExtDecayer->ImportDecayProducts(aTrack); 239 } else { 230 } else { 240 // Decay according to decay table. << 231 // decay acoording to decay table 241 // Keep trying to choose a candidate decay << 232 // choose a decay channel 242 // of the decaying particle is below the s << 233 G4VDecayChannel *decaychannel = decaytable->SelectADecayChannel(); 243 // candidate daughter particles. << 234 if (decaychannel == 0 ){ 244 // This is needed because the decay table << 245 // the assumption of nominal PDG masses, b << 246 // a dynamic masses well below its nominal << 247 // some of its decay channels can be below << 248 // Note that, for simplicity, we ignore he << 249 // one or more of the candidate daughter p << 250 // wide resonance. However, if this is the << 251 // accepted, then the masses of the resona << 252 // be sampled by taking into account their << 253 G4VDecayChannel* decaychannel = nullptr; << 254 G4double massParent = aParticle->GetMass() << 255 decaychannel = decaytable->SelectADecayCha << 256 if ( decaychannel == nullptr) { << 257 // decay channel not found 235 // decay channel not found 258 G4ExceptionDescription ed; << 236 G4Exception("G4Decay::DoIt : can not determine decay channel "); 259 ed << "Can not determine decay channel f << 260 << aParticleDef->GetParticleName() << G4end << 261 << " mass of dynamic particle: " << 262 << massParent/GeV << " (GEV)" << G4endl << 263 << " dacay table has " << decaytable->entr << 264 << " entries" << G4endl; << 265 G4double checkedmass=massParent; << 266 if (massParent < 0.) { << 267 checkedmass=aParticleDef->GetPDGMass(); << 268 ed << "Using PDG mass ("<<checkedmass/GeV << 269 << "(GeV)) in IsOKWithParentMass" << G4en << 270 } << 271 for (G4int ic =0;ic <decaytable->entries << 272 G4VDecayChannel * dc= decaytable->GetDecayCh << 273 ed << ic << ": BR " << dc->GetBR() << ", IsO << 274 << dc->IsOKWithParentMass(checkedmass) << 275 << ", --> "; << 276 G4int ndaughters=dc->GetNumberOfDaughters(); << 277 for (G4int id=0;id<ndaughters;++id) { << 278 if (id>0) ed << " + "; // seperator, exc << 279 ed << dc->GetDaughterName(id); << 280 } << 281 ed << G4endl; << 282 } << 283 G4Exception("G4Decay::DoIt", "DECAY003", << 284 } else { 237 } else { 285 // execute DecayIt() 238 // execute DecayIt() 286 #ifdef G4VERBOSE 239 #ifdef G4VERBOSE 287 G4int temp = decaychannel->GetVerboseLev 240 G4int temp = decaychannel->GetVerboseLevel(); 288 if (GetVerboseLevel()>1) { 241 if (GetVerboseLevel()>1) { 289 G4cout << "G4Decay::DoIt : selected decay c << 242 G4cout << "G4Decay::DoIt : selected decay channel addr:" << decaychannel <<G4endl; 290 << decaychannel <<G4endl; << 291 decaychannel->SetVerboseLevel(GetVerboseLeve 243 decaychannel->SetVerboseLevel(GetVerboseLevel()); 292 } 244 } 293 #endif 245 #endif 294 products = decaychannel->DecayIt(aPartic 246 products = decaychannel->DecayIt(aParticle->GetMass()); 295 #ifdef G4VERBOSE 247 #ifdef G4VERBOSE 296 if (GetVerboseLevel()>1) { 248 if (GetVerboseLevel()>1) { 297 decaychannel->SetVerboseLevel(temp); 249 decaychannel->SetVerboseLevel(temp); 298 } 250 } 299 #endif 251 #endif 300 #ifdef G4VERBOSE 252 #ifdef G4VERBOSE 301 if (GetVerboseLevel()>2) { 253 if (GetVerboseLevel()>2) { 302 if (! products->IsChecked() ) products->Dump 254 if (! products->IsChecked() ) products->DumpInfo(); 303 } 255 } 304 #endif 256 #endif 305 } 257 } 306 } 258 } 307 259 308 // get parent particle information ......... 260 // get parent particle information ................................... 309 G4double ParentEnergy = aParticle->GetTot 261 G4double ParentEnergy = aParticle->GetTotalEnergy(); 310 G4double ParentMass = aParticle->GetMas 262 G4double ParentMass = aParticle->GetMass(); 311 if (ParentEnergy < ParentMass) { 263 if (ParentEnergy < ParentMass) { 312 G4ExceptionDescription ed; << 313 ed << "Total Energy is less than its mass << 314 << "\n Particle: " << aParticle->GetDef << 315 << "\n Energy:" << ParentEnergy/MeV << 316 << "\n Mass:" << ParentMass/MeV << << 317 G4Exception( "G4Decay::DecayIt ", << 318 "DECAY102",JustWarning, ed); << 319 ParentEnergy = ParentMass; 264 ParentEnergy = ParentMass; >> 265 if (GetVerboseLevel()>0) { >> 266 G4cout << "G4Decay::DoIt : Total Energy is less than its mass" << G4endl; >> 267 G4cout << " Particle: " << aParticle->GetDefinition()->GetParticleName(); >> 268 G4cout << " Energy:" << ParentEnergy/MeV << "[MeV]"; >> 269 G4cout << " Mass:" << ParentMass/MeV << "[MeV]"; >> 270 G4cout << G4endl; >> 271 } 320 } 272 } 321 273 322 G4ThreeVector ParentDirection(aParticle->Get 274 G4ThreeVector ParentDirection(aParticle->GetMomentumDirection()); 323 275 324 //boost all decay products to laboratory fra 276 //boost all decay products to laboratory frame 325 G4double energyDeposit = 0.0; 277 G4double energyDeposit = 0.0; 326 G4double finalGlobalTime = aTrack.GetGlobalT 278 G4double finalGlobalTime = aTrack.GetGlobalTime(); 327 G4double finalLocalTime = aTrack.GetLocalTim << 328 if (aTrack.GetTrackStatus() == fStopButAlive 279 if (aTrack.GetTrackStatus() == fStopButAlive ){ 329 // AtRest case 280 // AtRest case 330 finalGlobalTime += fRemainderLifeTime; 281 finalGlobalTime += fRemainderLifeTime; 331 finalLocalTime += fRemainderLifeTime; << 332 energyDeposit += aParticle->GetKineticEner 282 energyDeposit += aParticle->GetKineticEnergy(); 333 if (isPreAssigned) products->Boost( Parent 283 if (isPreAssigned) products->Boost( ParentEnergy, ParentDirection); 334 } else { 284 } else { 335 // PostStep case 285 // PostStep case 336 if (!isExtDecayer) products->Boost( Parent 286 if (!isExtDecayer) products->Boost( ParentEnergy, ParentDirection); 337 } 287 } >> 288 338 // set polarization for daughter particles 289 // set polarization for daughter particles 339 DaughterPolarization(aTrack, products); 290 DaughterPolarization(aTrack, products); 340 291 341 292 342 //add products in fParticleChangeForDecay 293 //add products in fParticleChangeForDecay 343 G4int numberOfSecondaries = products->entrie 294 G4int numberOfSecondaries = products->entries(); 344 fParticleChangeForDecay.SetNumberOfSecondari 295 fParticleChangeForDecay.SetNumberOfSecondaries(numberOfSecondaries); 345 #ifdef G4VERBOSE 296 #ifdef G4VERBOSE 346 if (GetVerboseLevel()>1) { 297 if (GetVerboseLevel()>1) { 347 G4cout << "G4Decay::DoIt : Decay vertex : 298 G4cout << "G4Decay::DoIt : Decay vertex :"; 348 G4cout << " Time: " << finalGlobalTime/ns 299 G4cout << " Time: " << finalGlobalTime/ns << "[ns]"; 349 G4cout << " X:" << (aTrack.GetPosition()). 300 G4cout << " X:" << (aTrack.GetPosition()).x() /cm << "[cm]"; 350 G4cout << " Y:" << (aTrack.GetPosition()). 301 G4cout << " Y:" << (aTrack.GetPosition()).y() /cm << "[cm]"; 351 G4cout << " Z:" << (aTrack.GetPosition()). 302 G4cout << " Z:" << (aTrack.GetPosition()).z() /cm << "[cm]"; 352 G4cout << G4endl; 303 G4cout << G4endl; 353 G4cout << "G4Decay::DoIt : decay products 304 G4cout << "G4Decay::DoIt : decay products in Lab. Frame" << G4endl; 354 products->DumpInfo(); 305 products->DumpInfo(); 355 } 306 } 356 #endif 307 #endif 357 G4int index; 308 G4int index; 358 G4ThreeVector currentPosition; 309 G4ThreeVector currentPosition; 359 const G4TouchableHandle thand = aTrack.GetTo 310 const G4TouchableHandle thand = aTrack.GetTouchableHandle(); 360 for (index=0; index < numberOfSecondaries; i << 311 for (index=0; index < numberOfSecondaries; index++) 361 // get current position of the track << 312 { 362 currentPosition = aTrack.GetPosition(); << 313 // get current position of the track 363 // create a new track object << 314 currentPosition = aTrack.GetPosition(); 364 G4Track* secondary = new G4Track( products << 315 // create a new track object >> 316 G4Track* secondary = new G4Track( products->PopProducts(), 365 finalGlobalTime , 317 finalGlobalTime , 366 currentPosition ); 318 currentPosition ); 367 // switch on good for tracking flag << 319 // switch on good for tracking flag 368 secondary->SetGoodForTrackingFlag(); << 320 secondary->SetGoodForTrackingFlag(); 369 secondary->SetTouchableHandle(thand); << 321 secondary->SetTouchableHandle(thand); 370 // add the secondary track in the List << 322 // add the secondary track in the List 371 fParticleChangeForDecay.AddSecondary(secon << 323 fParticleChangeForDecay.AddSecondary(secondary); 372 } 324 } 373 delete products; 325 delete products; 374 << 326 375 // Kill the parent particle 327 // Kill the parent particle 376 fParticleChangeForDecay.ProposeTrackStatus( 328 fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ; 377 fParticleChangeForDecay.ProposeLocalEnergyDe 329 fParticleChangeForDecay.ProposeLocalEnergyDeposit(energyDeposit); 378 fParticleChangeForDecay.ProposeLocalTime( fi << 330 fParticleChangeForDecay.ProposeGlobalTime( finalGlobalTime ); 379 << 380 // Clear NumberOfInteractionLengthLeft 331 // Clear NumberOfInteractionLengthLeft 381 ClearNumberOfInteractionLengthLeft(); 332 ClearNumberOfInteractionLengthLeft(); 382 << 333 383 return &fParticleChangeForDecay ; 334 return &fParticleChangeForDecay ; 384 } 335 } 385 336 386 void G4Decay::DaughterPolarization(const G4Tra 337 void G4Decay::DaughterPolarization(const G4Track& , G4DecayProducts* ) 387 { 338 { 388 // empty implementation << 389 } 339 } 390 340 391 341 392 342 393 void G4Decay::StartTracking(G4Track*) 343 void G4Decay::StartTracking(G4Track*) 394 { 344 { 395 currentInteractionLength = -1.0; 345 currentInteractionLength = -1.0; 396 ResetNumberOfInteractionLengthLeft(); 346 ResetNumberOfInteractionLengthLeft(); 397 347 398 fRemainderLifeTime = -1.0; 348 fRemainderLifeTime = -1.0; 399 } 349 } 400 350 401 void G4Decay::EndTracking() 351 void G4Decay::EndTracking() 402 { 352 { 403 // Clear NumberOfInteractionLengthLeft 353 // Clear NumberOfInteractionLengthLeft 404 ClearNumberOfInteractionLengthLeft(); 354 ClearNumberOfInteractionLengthLeft(); 405 355 406 currentInteractionLength = -1.0; 356 currentInteractionLength = -1.0; 407 } 357 } 408 358 409 359 410 G4double G4Decay::PostStepGetPhysicalInteracti 360 G4double G4Decay::PostStepGetPhysicalInteractionLength( 411 const G4Track& tr 361 const G4Track& track, 412 G4double previo 362 G4double previousStepSize, 413 G4ForceCondition* 363 G4ForceCondition* condition 414 ) 364 ) 415 { 365 { >> 366 416 // condition is set to "Not Forced" 367 // condition is set to "Not Forced" 417 *condition = NotForced; 368 *condition = NotForced; 418 369 419 // pre-assigned Decay time 370 // pre-assigned Decay time 420 G4double pTime = track.GetDynamicParticle()- 371 G4double pTime = track.GetDynamicParticle()->GetPreAssignedDecayProperTime(); 421 G4double aLife = track.GetDynamicParticle()- 372 G4double aLife = track.GetDynamicParticle()->GetDefinition()->GetPDGLifeTime(); 422 373 423 if (pTime < 0.) { 374 if (pTime < 0.) { 424 // normal case 375 // normal case 425 if ( previousStepSize > 0.0){ 376 if ( previousStepSize > 0.0){ 426 // subtract NumberOfInteractionLengthLef 377 // subtract NumberOfInteractionLengthLeft 427 SubtractNumberOfInteractionLengthLeft(pr 378 SubtractNumberOfInteractionLengthLeft(previousStepSize); 428 if(theNumberOfInteractionLengthLeft<0.){ 379 if(theNumberOfInteractionLengthLeft<0.){ 429 theNumberOfInteractionLengthLeft=perMillion; 380 theNumberOfInteractionLengthLeft=perMillion; 430 } 381 } 431 fRemainderLifeTime = theNumberOfInteract 382 fRemainderLifeTime = theNumberOfInteractionLengthLeft*aLife; 432 } 383 } 433 // get mean free path 384 // get mean free path 434 currentInteractionLength = GetMeanFreePath 385 currentInteractionLength = GetMeanFreePath(track, previousStepSize, condition); 435 386 436 #ifdef G4VERBOSE 387 #ifdef G4VERBOSE 437 if ((currentInteractionLength <=0.0) || (v 388 if ((currentInteractionLength <=0.0) || (verboseLevel>2)){ 438 G4cout << "G4Decay::PostStepGetPhysicalI 389 G4cout << "G4Decay::PostStepGetPhysicalInteractionLength " << G4endl; 439 track.GetDynamicParticle()->DumpInfo(); 390 track.GetDynamicParticle()->DumpInfo(); 440 G4cout << " in Material " << track.GetM 391 G4cout << " in Material " << track.GetMaterial()->GetName() <<G4endl; 441 G4cout << "MeanFreePath = " << currentIn 392 G4cout << "MeanFreePath = " << currentInteractionLength/cm << "[cm]" <<G4endl; 442 } 393 } 443 #endif 394 #endif 444 395 445 G4double value; 396 G4double value; 446 if (currentInteractionLength <DBL_MAX) { 397 if (currentInteractionLength <DBL_MAX) { 447 value = theNumberOfInteractionLengthLeft 398 value = theNumberOfInteractionLengthLeft * currentInteractionLength; 448 //fRemainderLifeTime = theNumberOfIntera << 449 } else { 399 } else { 450 value = DBL_MAX; 400 value = DBL_MAX; 451 } 401 } 452 402 453 return value; 403 return value; 454 404 455 } else { 405 } else { 456 //pre-assigned Decay time case 406 //pre-assigned Decay time case 457 // reminder proper time 407 // reminder proper time 458 fRemainderLifeTime = pTime - track.GetProp 408 fRemainderLifeTime = pTime - track.GetProperTime(); 459 if (fRemainderLifeTime <= 0.0) fRemainderL << 409 if (fRemainderLifeTime <= 0.0) fRemainderLifeTime = DBL_MIN; 460 410 461 G4double rvalue=0.0; 411 G4double rvalue=0.0; 462 // use pre-assigned Decay time to determin 412 // use pre-assigned Decay time to determine PIL 463 if (aLife>0.0) { 413 if (aLife>0.0) { 464 // ordinary particle 414 // ordinary particle 465 rvalue = (fRemainderLifeTime/aLife)*GetM 415 rvalue = (fRemainderLifeTime/aLife)*GetMeanFreePath(track, previousStepSize, condition); 466 } else { 416 } else { 467 // shortlived particle 417 // shortlived particle 468 rvalue = c_light * fRemainderLifeTime; 418 rvalue = c_light * fRemainderLifeTime; 469 // by using normalized kinetic energy (= 419 // by using normalized kinetic energy (= Ekin/mass) 470 G4double aMass = track.GetDynamicParti 420 G4double aMass = track.GetDynamicParticle()->GetMass(); 471 rvalue *= track.GetDynamicParticle()->Get 421 rvalue *= track.GetDynamicParticle()->GetTotalMomentum()/aMass; 472 } 422 } 473 return rvalue; 423 return rvalue; 474 } 424 } 475 } 425 } 476 426 477 G4double G4Decay::AtRestGetPhysicalInteraction 427 G4double G4Decay::AtRestGetPhysicalInteractionLength( 478 const G4Track& tr 428 const G4Track& track, 479 G4ForceCondition* 429 G4ForceCondition* condition 480 ) 430 ) 481 { 431 { 482 // condition is set to "Not Forced" 432 // condition is set to "Not Forced" 483 *condition = NotForced; 433 *condition = NotForced; 484 434 485 G4double pTime = track.GetDynamicParticle()- 435 G4double pTime = track.GetDynamicParticle()->GetPreAssignedDecayProperTime(); 486 if (pTime >= 0.) { 436 if (pTime >= 0.) { 487 fRemainderLifeTime = pTime - track.GetProp 437 fRemainderLifeTime = pTime - track.GetProperTime(); 488 if (fRemainderLifeTime <= 0.0) fRemainderL 438 if (fRemainderLifeTime <= 0.0) fRemainderLifeTime = DBL_MIN; 489 } else { 439 } else { 490 fRemainderLifeTime = 440 fRemainderLifeTime = 491 theNumberOfInteractionLengthLeft * GetMe 441 theNumberOfInteractionLengthLeft * GetMeanLifeTime(track, condition); 492 } 442 } 493 return fRemainderLifeTime; 443 return fRemainderLifeTime; 494 } 444 } 495 445 496 446 497 void G4Decay::SetExtDecayer(G4VExtDecayer* val 447 void G4Decay::SetExtDecayer(G4VExtDecayer* val) 498 { 448 { 499 pExtDecayer = val; 449 pExtDecayer = val; 500 450 501 // set Process Sub Type 451 // set Process Sub Type 502 if ( pExtDecayer !=0 ) { 452 if ( pExtDecayer !=0 ) { 503 SetProcessSubType(static_cast<int>(DECAY_E 453 SetProcessSubType(static_cast<int>(DECAY_External)); 504 } 454 } 505 } << 506 << 507 G4VParticleChange* G4Decay::PostStepDoIt( << 508 const G4Track& aTrack, << 509 const G4Step& aStep << 510 ) << 511 { << 512 if ( (aTrack.GetTrackStatus() == fStopButAli << 513 (aTrack.GetTrackStatus() == fStopAndKil << 514 fParticleChangeForDecay.Initialize(aTrack) << 515 return &fParticleChangeForDecay; << 516 } else { << 517 return DecayIt(aTrack, aStep); << 518 } << 519 } << 520 << 521 void G4Decay::ProcessDescription(std::ostream& << 522 { << 523 outFile << GetProcessName() << ": Decay of p << 524 << "kinematics of daughters are dertermine << 525 << " or by PreAssignedDecayProducts\ << 526 } 455 } 527 456