Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // << 26 // 7 // >> 8 // $Id: G4Decay.cc,v 1.8 2001/02/22 13:29:31 kurasige Exp $ >> 9 // GEANT4 tag $Name: geant4-03-01 $ 27 // 10 // 28 // 11 // 29 // ------------------------------------------- 12 // -------------------------------------------------------------- 30 // GEANT 4 class implementation file 13 // GEANT 4 class implementation file 31 // 14 // >> 15 // For information related to this code contact: >> 16 // CERN, CN Division, ASD group 32 // History: first implementation, based o 17 // History: first implementation, based on object model of 33 // 2nd December 1995, G.Cosmo 18 // 2nd December 1995, G.Cosmo 34 // 7 July 1996 H.Kurashige 19 // 7 July 1996 H.Kurashige 35 // ------------------------------------------- 20 // ------------------------------------------------------------ 36 // remove BuildPhysicsTable() 28 Nov. 1997 21 // remove BuildPhysicsTable() 28 Nov. 1997 H.Kurashige 37 // change DBL_EPSIRON to DBL_MIN 14 Dec. 19 22 // change DBL_EPSIRON to DBL_MIN 14 Dec. 1997 H.Kurashige 38 // modified for new ParticleChange 12 Mar. 1 23 // modified for new ParticleChange 12 Mar. 1998 H.Kurashige 39 // modified for "GoodForTrackingFlag" 19 Jun 24 // modified for "GoodForTrackingFlag" 19 June 1998 H.Kurashige 40 // rename thePhysicsTable to aPhyscisTable 2 25 // rename thePhysicsTable to aPhyscisTable 2 Aug. 1998 H.Kurashige 41 // modified IsApplicable in order to protect 26 // modified IsApplicable in order to protect the decay from registered 42 // to resonances 12 Dec. 1998 H.Kurashi 27 // to resonances 12 Dec. 1998 H.Kurashige 43 // remove G4ParticleMomentum 6 Feb. 99 H.Ku 28 // remove G4ParticleMomentum 6 Feb. 99 H.Kurashige 44 // modified IsApplicable to activate G4Deca 29 // modified IsApplicable to activate G4Decay for resonances 1 Mar. 00 H.Kurashige 45 // Add External Decayer 23 Feb. 2001 30 // Add External Decayer 23 Feb. 2001 H.Kurashige 46 // change LowestBinValue,HighestBinValue and << 47 // 31 // 48 32 49 #include "G4Decay.hh" 33 #include "G4Decay.hh" 50 << 51 #include "G4PhysicalConstants.hh" << 52 #include "G4SystemOfUnits.hh" << 53 #include "G4DynamicParticle.hh" 34 #include "G4DynamicParticle.hh" 54 #include "G4DecayProducts.hh" 35 #include "G4DecayProducts.hh" 55 #include "G4DecayTable.hh" 36 #include "G4DecayTable.hh" 56 #include "G4VDecayChannel.hh" << 57 #include "G4PhysicsLogVector.hh" 37 #include "G4PhysicsLogVector.hh" 58 #include "G4ParticleChangeForDecay.hh" 38 #include "G4ParticleChangeForDecay.hh" 59 #include "G4VExtDecayer.hh" 39 #include "G4VExtDecayer.hh" 60 40 61 // constructor 41 // constructor 62 G4Decay::G4Decay(const G4String& processName) 42 G4Decay::G4Decay(const G4String& processName) 63 :G4VRestDiscret 43 :G4VRestDiscreteProcess(processName, fDecay), >> 44 HighestBinValue(10.0), >> 45 LowestBinValue(1.0e-3), >> 46 TotBin(200), 64 verboseLevel(1), 47 verboseLevel(1), 65 HighestValue(2 << 48 pExtDecayer(0), 66 fRemainderLifeTime(-1.0), << 49 aPhysicsTable(0) 67 pExtDecayer(nu << 68 { 50 { 69 // set Process Sub Type << 70 SetProcessSubType(static_cast<int>(DECAY)); << 71 << 72 #ifdef G4VERBOSE 51 #ifdef G4VERBOSE 73 if (GetVerboseLevel()>1) { 52 if (GetVerboseLevel()>1) { 74 G4cout << "G4Decay constructor " << " Na << 53 G4cerr << "G4Decay constructor " << " Name:" << processName << G4endl; 75 } 54 } 76 #endif 55 #endif 77 << 78 pParticleChange = &fParticleChangeForDecay; 56 pParticleChange = &fParticleChangeForDecay; 79 } 57 } 80 58 81 G4Decay::~G4Decay() 59 G4Decay::~G4Decay() 82 { 60 { 83 if (pExtDecayer != nullptr) { << 61 if (aPhysicsTable != 0) { >> 62 aPhysicsTable->clearAndDestroy(); >> 63 delete aPhysicsTable; >> 64 } >> 65 if (pExtDecayer) { 84 delete pExtDecayer; 66 delete pExtDecayer; 85 } 67 } 86 } 68 } 87 69 88 G4bool G4Decay::IsApplicable(const G4ParticleD 70 G4bool G4Decay::IsApplicable(const G4ParticleDefinition& aParticleType) 89 { 71 { 90 // check if the particle is stable? 72 // check if the particle is stable? 91 if (aParticleType.GetPDGLifeTime() <0.0) { 73 if (aParticleType.GetPDGLifeTime() <0.0) { 92 return false; 74 return false; 93 } else if (aParticleType.GetPDGMass() <= 0. 75 } else if (aParticleType.GetPDGMass() <= 0.0*MeV) { 94 return false; 76 return false; 95 } else { 77 } else { 96 return true; 78 return true; 97 } 79 } 98 } 80 } 99 81 100 G4double G4Decay::GetMeanLifeTime(const G4Trac << 82 G4double G4Decay::GetMeanLifeTime(const G4Track& aTrack, 101 G4ForceCondi 83 G4ForceCondition*) 102 { 84 { >> 85 // get particle type >> 86 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); >> 87 103 // returns the mean free path in GEANT4 int 88 // returns the mean free path in GEANT4 internal units 104 G4double meanlife; 89 G4double meanlife; 105 << 90 G4ParticleDefinition* aParticleDef = aParticle->GetDefinition(); 106 // get particle << 107 const G4DynamicParticle* aParticle = aTrack << 108 const G4ParticleDefinition* aParticleDef = << 109 G4double aLife = aParticleDef->GetPDGLifeTi 91 G4double aLife = aParticleDef->GetPDGLifeTime(); 110 92 >> 93 #ifdef G4VERBOSE >> 94 if (GetVerboseLevel()>1) { >> 95 G4cerr << "G4Decay::GetMeanLifeTime() "<< G4endl; >> 96 G4cerr << "KineticEnergy:" << aParticle->GetKineticEnergy()/GeV <<"[GeV]"; >> 97 G4cerr << "Mass:" << aParticle->GetMass()/GeV <<"[GeV]"; >> 98 G4cerr << "Life time: "<< aLife/ns << "[ns]" << G4endl; >> 99 } >> 100 #endif >> 101 111 // check if the particle is stable? 102 // check if the particle is stable? 112 if (aParticleDef->GetPDGStable()) { 103 if (aParticleDef->GetPDGStable()) { 113 //1000000 times the life time of the unive << 104 meanlife = DBL_MAX; 114 meanlife = 1e24 * s; << 115 105 >> 106 } else if (aLife < 0.0) { >> 107 meanlife = DBL_MAX; >> 108 116 } else { 109 } else { 117 meanlife = aLife; 110 meanlife = aLife; 118 } 111 } 119 112 120 #ifdef G4VERBOSE 113 #ifdef G4VERBOSE 121 if (GetVerboseLevel()>1) { 114 if (GetVerboseLevel()>1) { 122 G4cout << "mean life time: "<< meanlife/n << 115 G4cerr << "mean life time: "<< meanlife/ns << "[ns]" << G4endl; 123 } 116 } 124 #endif 117 #endif 125 118 126 return meanlife; 119 return meanlife; 127 } 120 } 128 121 129 G4double G4Decay::GetMeanFreePath(const G4Trac 122 G4double G4Decay::GetMeanFreePath(const G4Track& aTrack,G4double, G4ForceCondition*) 130 { 123 { >> 124 // constants >> 125 G4bool isOutRange ; >> 126 131 // get particle 127 // get particle 132 const G4DynamicParticle* aParticle = aTrack 128 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 133 const G4ParticleDefinition* aParticleDef = << 134 G4double aMass = aParticle->GetMass(); << 135 G4double aLife = aParticleDef->GetPDGLifeTi << 136 << 137 129 138 // returns the mean free path in GEANT4 in << 130 // returns the mean free path in GEANT4 internal units 139 G4double pathlength; 131 G4double pathlength; 140 G4double aCtau = c_light * aLife; << 132 G4ParticleDefinition* aParticleDef = aParticle->GetDefinition(); >> 133 G4double aCtau = c_light * aParticleDef->GetPDGLifeTime(); >> 134 G4double aMass = aParticle->GetMass(); >> 135 >> 136 #ifdef G4VERBOSE >> 137 if (GetVerboseLevel()>1) { >> 138 G4cerr << "G4Decay::GetMeanFreePath() "<< G4endl; >> 139 G4cerr << "KineticEnergy:" << aParticle->GetKineticEnergy()/GeV <<"[GeV]"; >> 140 G4cerr << "Mass:" << aMass/GeV <<"[GeV]"; >> 141 G4cerr << "c*Tau:" << aCtau/m <<"[m]" <<G4endl; >> 142 } >> 143 #endif 141 144 142 // check if the particle is stable? 145 // check if the particle is stable? 143 if (aParticleDef->GetPDGStable()) { 146 if (aParticleDef->GetPDGStable()) { 144 pathlength = DBL_MAX; 147 pathlength = DBL_MAX; 145 148 >> 149 } else if (aCtau < 0.0) { >> 150 pathlength = DBL_MAX; >> 151 146 //check if the particle has very short life 152 //check if the particle has very short life time ? 147 } else if (aCtau < DBL_MIN) { 153 } else if (aCtau < DBL_MIN) { 148 pathlength = DBL_MIN; 154 pathlength = DBL_MIN; 149 155 >> 156 //check if zero mass >> 157 } else if (aMass < DBL_MIN) { >> 158 pathlength = DBL_MAX; >> 159 #ifdef G4VERBOSE >> 160 if (GetVerboseLevel()>1) { >> 161 G4cerr << " Zero Mass particle " << G4endl; >> 162 } >> 163 #endif 150 } else { 164 } else { 151 //calculate the mean free path 165 //calculate the mean free path 152 // by using normalized kinetic energy (= E 166 // by using normalized kinetic energy (= Ekin/mass) 153 G4double rKineticEnergy = aParticle->Ge 167 G4double rKineticEnergy = aParticle->GetKineticEnergy()/aMass; 154 if ( rKineticEnergy > HighestValue) { << 168 if ( rKineticEnergy > HighestBinValue) { 155 // gamma >> 1 << 169 // beta >> 1 156 pathlength = ( rKineticEnergy + 1.0)* a 170 pathlength = ( rKineticEnergy + 1.0)* aCtau; >> 171 } else if ( rKineticEnergy > LowestBinValue) { >> 172 // check if aPhysicsTable exists >> 173 if (aPhysicsTable == NULL) BuildPhysicsTable(*aParticleDef); >> 174 // beta is in the range valid for PhysicsTable >> 175 pathlength = aCtau * >> 176 ((*aPhysicsTable)(0))-> GetValue(rKineticEnergy,isOutRange); 157 } else if ( rKineticEnergy < DBL_MIN ) { 177 } else if ( rKineticEnergy < DBL_MIN ) { 158 // too slow particle 178 // too slow particle 159 #ifdef G4VERBOSE 179 #ifdef G4VERBOSE 160 if (GetVerboseLevel()>1) { 180 if (GetVerboseLevel()>1) { 161 G4cout << "G4Decay::GetMeanFreePath() !!p << 181 G4cerr << "G4Decay::GetMeanFreePath() !!particle stops!!"; 162 G4cout << aParticleDef->GetParticleNa << 182 G4cerr << aParticleDef->GetParticleName() << G4endl; 163 G4cout << "KineticEnergy:" << aParticle->Ge << 183 G4cerr << "KineticEnergy:" << aParticle->GetKineticEnergy()/GeV <<"[GeV]"; 164 } 184 } 165 #endif 185 #endif 166 pathlength = DBL_MIN; 186 pathlength = DBL_MIN; 167 } else { 187 } else { 168 // beta <1 << 188 // beta << 1 169 pathlength = (aParticle->GetTotalMoment 189 pathlength = (aParticle->GetTotalMomentum())/aMass*aCtau ; 170 } 190 } 171 } 191 } 172 return pathlength; << 192 #ifdef G4VERBOSE >> 193 if (GetVerboseLevel()>1) { >> 194 G4cerr << "mean free path: "<< pathlength/m << "[m]" << G4endl; >> 195 } >> 196 #endif >> 197 return pathlength; 173 } 198 } 174 199 175 void G4Decay::BuildPhysicsTable(const G4Partic 200 void G4Decay::BuildPhysicsTable(const G4ParticleDefinition&) 176 { 201 { 177 return; << 202 // if aPhysicsTableis has already been created, do nothing >> 203 if (aPhysicsTable != NULL) return; >> 204 >> 205 // create aPhysicsTable >> 206 if (GetVerboseLevel()>1) G4cerr <<" G4Decay::BuildPhysicsTable() "<< G4endl; >> 207 aPhysicsTable = new G4PhysicsTable(1); >> 208 >> 209 //create physics vector >> 210 G4PhysicsLogVector* aVector = new G4PhysicsLogVector( >> 211 LowestBinValue, >> 212 HighestBinValue, >> 213 TotBin); >> 214 >> 215 G4double beta, gammainv; >> 216 // fill physics Vector >> 217 G4int i; >> 218 for ( i = 0 ; i < TotBin ; i++ ) { >> 219 gammainv = 1.0/(aVector->GetLowEdgeEnergy(i) + 1.0); >> 220 beta = sqrt((1.0 - gammainv)*(1.0 +gammainv)); >> 221 aVector->PutValue(i, beta/gammainv); >> 222 } >> 223 aPhysicsTable->insert(aVector); 178 } 224 } 179 225 180 G4VParticleChange* G4Decay::DecayIt(const G4Tr 226 G4VParticleChange* G4Decay::DecayIt(const G4Track& aTrack, const G4Step& ) 181 { 227 { 182 // The DecayIt() method returns by pointer a 228 // The DecayIt() method returns by pointer a particle-change object. 183 // Units are expressed in GEANT4 internal un 229 // Units are expressed in GEANT4 internal units. 184 230 185 // Initialize ParticleChange 231 // Initialize ParticleChange 186 // all members of G4VParticleChange are 232 // all members of G4VParticleChange are set to equal to 187 // corresponding member in G4Track 233 // corresponding member in G4Track 188 fParticleChangeForDecay.Initialize(aTrack); 234 fParticleChangeForDecay.Initialize(aTrack); 189 235 190 // get particle 236 // get particle 191 const G4DynamicParticle* aParticle = aTrack. 237 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 192 const G4ParticleDefinition* aParticleDef = a << 238 G4ParticleDefinition* aParticleDef = aParticle->GetDefinition(); 193 239 194 // check if the particle is stable 240 // check if the particle is stable 195 if (aParticleDef->GetPDGStable()) return &fP 241 if (aParticleDef->GetPDGStable()) return &fParticleChangeForDecay ; 196 242 197 243 198 //check if thePreAssignedDecayProducts exist 244 //check if thePreAssignedDecayProducts exists 199 const G4DecayProducts* o_products = (aPartic 245 const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts()); 200 G4bool isPreAssigned = (o_products != nullpt << 246 G4bool isPreAssigned = (o_products != 0); 201 G4DecayProducts* products = nullptr; << 247 G4DecayProducts* products = 0; 202 248 203 // decay table 249 // decay table 204 G4DecayTable *decaytable = aParticleDef->G 250 G4DecayTable *decaytable = aParticleDef->GetDecayTable(); 205 251 206 // check if external decayer exists 252 // check if external decayer exists 207 G4bool isExtDecayer = (decaytable == nullptr << 253 G4bool isExtDecayer = (decaytable == 0) && (pExtDecayer !=0); 208 254 209 // Error due to NO Decay Table 255 // Error due to NO Decay Table 210 if ( (decaytable == nullptr) && !isExtDecaye << 256 if ( (decaytable == 0) && !isExtDecayer &&!isPreAssigned ){ >> 257 #ifdef G4VERBOSE 211 if (GetVerboseLevel()>0) { 258 if (GetVerboseLevel()>0) { 212 G4cout << "G4Decay::DoIt : decay table << 259 G4cerr << "G4Decay::DoIt : decay table not defined for "; 213 G4cout << aParticle->GetDefinition()->Ge << 260 G4cerr << aParticle->GetDefinition()->GetParticleName()<< G4endl; 214 } 261 } 215 G4ExceptionDescription ed; << 262 #endif 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 ", << 222 "DECAY101",JustWarning, ed); << 223 << 224 fParticleChangeForDecay.SetNumberOfSeconda 263 fParticleChangeForDecay.SetNumberOfSecondaries(0); 225 // Kill the parent particle 264 // Kill the parent particle 226 fParticleChangeForDecay.ProposeTrackStatus << 265 fParticleChangeForDecay.SetStatusChange( fStopAndKill ) ; 227 fParticleChangeForDecay.ProposeLocalEnergy << 266 fParticleChangeForDecay.SetLocalEnergyDeposit(0.0); 228 267 229 ClearNumberOfInteractionLengthLeft(); 268 ClearNumberOfInteractionLengthLeft(); 230 return &fParticleChangeForDecay ; 269 return &fParticleChangeForDecay ; 231 } 270 } 232 271 233 if (isPreAssigned) { 272 if (isPreAssigned) { 234 // copy decay products 273 // copy decay products 235 products = new G4DecayProducts(*o_products 274 products = new G4DecayProducts(*o_products); 236 } else if ( isExtDecayer ) { 275 } else if ( isExtDecayer ) { 237 // decay according to external decayer 276 // decay according to external decayer 238 products = pExtDecayer->ImportDecayProduct 277 products = pExtDecayer->ImportDecayProducts(aTrack); 239 } else { 278 } else { 240 // Decay according to decay table. << 279 // decay acoording to decay table 241 // Keep trying to choose a candidate decay << 280 // choose a decay channel 242 // of the decaying particle is below the s << 281 G4VDecayChannel *decaychannel = decaytable->SelectADecayChannel(); 243 // candidate daughter particles. << 282 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 283 // decay channel not found 258 G4ExceptionDescription ed; << 284 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 { 285 } else { >> 286 G4int temp; 285 // execute DecayIt() 287 // execute DecayIt() 286 #ifdef G4VERBOSE 288 #ifdef G4VERBOSE 287 G4int temp = decaychannel->GetVerboseLev << 288 if (GetVerboseLevel()>1) { 289 if (GetVerboseLevel()>1) { 289 G4cout << "G4Decay::DoIt : selected decay c << 290 G4cerr << "G4Decay::DoIt : selected decay channel addr:" << decaychannel <<G4endl; 290 << decaychannel <<G4endl; << 291 temp = decaychannel->GetVerboseLevel(); 291 decaychannel->SetVerboseLevel(GetVerboseLeve 292 decaychannel->SetVerboseLevel(GetVerboseLevel()); 292 } 293 } 293 #endif 294 #endif 294 products = decaychannel->DecayIt(aPartic 295 products = decaychannel->DecayIt(aParticle->GetMass()); 295 #ifdef G4VERBOSE 296 #ifdef G4VERBOSE 296 if (GetVerboseLevel()>1) { 297 if (GetVerboseLevel()>1) { 297 decaychannel->SetVerboseLevel(temp); 298 decaychannel->SetVerboseLevel(temp); 298 } 299 } 299 #endif 300 #endif 300 #ifdef G4VERBOSE 301 #ifdef G4VERBOSE 301 if (GetVerboseLevel()>2) { << 302 // for debug 302 if (! products->IsChecked() ) products->Dump << 303 //if (! products->IsChecked() ) products->DumpInfo(); 303 } << 304 #endif 304 #endif 305 } 305 } 306 } 306 } 307 307 308 // get parent particle information ......... 308 // get parent particle information ................................... 309 G4double ParentEnergy = aParticle->GetTot 309 G4double ParentEnergy = aParticle->GetTotalEnergy(); 310 G4double ParentMass = aParticle->GetMas << 311 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; << 320 } << 321 << 322 G4ThreeVector ParentDirection(aParticle->Get 310 G4ThreeVector ParentDirection(aParticle->GetMomentumDirection()); 323 311 324 //boost all decay products to laboratory fra 312 //boost all decay products to laboratory frame 325 G4double energyDeposit = 0.0; 313 G4double energyDeposit = 0.0; 326 G4double finalGlobalTime = aTrack.GetGlobalT 314 G4double finalGlobalTime = aTrack.GetGlobalTime(); 327 G4double finalLocalTime = aTrack.GetLocalTim << 328 if (aTrack.GetTrackStatus() == fStopButAlive 315 if (aTrack.GetTrackStatus() == fStopButAlive ){ 329 // AtRest case 316 // AtRest case 330 finalGlobalTime += fRemainderLifeTime; 317 finalGlobalTime += fRemainderLifeTime; 331 finalLocalTime += fRemainderLifeTime; << 332 energyDeposit += aParticle->GetKineticEner 318 energyDeposit += aParticle->GetKineticEnergy(); 333 if (isPreAssigned) products->Boost( Parent << 319 if (isPreAssigned) products->Boost( ParentEnergy, ParentDirection); 334 } else { 320 } else { 335 // PostStep case 321 // PostStep case 336 if (!isExtDecayer) products->Boost( Parent << 322 if (!isExtDecayer) products->Boost( ParentEnergy, ParentDirection); 337 } 323 } 338 // set polarization for daughter particles << 339 DaughterPolarization(aTrack, products); << 340 << 341 324 342 //add products in fParticleChangeForDecay 325 //add products in fParticleChangeForDecay 343 G4int numberOfSecondaries = products->entrie 326 G4int numberOfSecondaries = products->entries(); 344 fParticleChangeForDecay.SetNumberOfSecondari 327 fParticleChangeForDecay.SetNumberOfSecondaries(numberOfSecondaries); 345 #ifdef G4VERBOSE 328 #ifdef G4VERBOSE 346 if (GetVerboseLevel()>1) { 329 if (GetVerboseLevel()>1) { 347 G4cout << "G4Decay::DoIt : Decay vertex : << 330 G4cerr << "G4Decay::DoIt : Decay vertex :"; 348 G4cout << " Time: " << finalGlobalTime/ns << 331 G4cerr << " Time: " << finalGlobalTime/ns << "[ns]"; 349 G4cout << " X:" << (aTrack.GetPosition()). << 332 G4cerr << " X:" << (aTrack.GetPosition()).x() /cm << "[cm]"; 350 G4cout << " Y:" << (aTrack.GetPosition()). << 333 G4cerr << " Y:" << (aTrack.GetPosition()).y() /cm << "[cm]"; 351 G4cout << " Z:" << (aTrack.GetPosition()). << 334 G4cerr << " Z:" << (aTrack.GetPosition()).z() /cm << "[cm]"; 352 G4cout << G4endl; << 335 G4cerr << G4endl; 353 G4cout << "G4Decay::DoIt : decay products << 336 G4cerr << "G4Decay::DoIt : decay products in Lab. Frame" << G4endl; 354 products->DumpInfo(); 337 products->DumpInfo(); 355 } 338 } 356 #endif 339 #endif 357 G4int index; 340 G4int index; 358 G4ThreeVector currentPosition; 341 G4ThreeVector currentPosition; 359 const G4TouchableHandle thand = aTrack.GetTo << 342 for (index=0; index < numberOfSecondaries; index++) 360 for (index=0; index < numberOfSecondaries; i << 343 { 361 // get current position of the track << 344 // get current position of the track 362 currentPosition = aTrack.GetPosition(); << 345 currentPosition = aTrack.GetPosition(); 363 // create a new track object << 346 // create a new track object 364 G4Track* secondary = new G4Track( products << 347 G4Track* secondary = new G4Track( products->PopProducts(), 365 finalGlobalTime , 348 finalGlobalTime , 366 currentPosition ); 349 currentPosition ); 367 // switch on good for tracking flag << 350 // switch on good for tracking flag 368 secondary->SetGoodForTrackingFlag(); << 351 secondary->SetGoodForTrackingFlag(); 369 secondary->SetTouchableHandle(thand); << 352 // add the secondary track in the List 370 // add the secondary track in the List << 353 fParticleChangeForDecay.AddSecondary(secondary); 371 fParticleChangeForDecay.AddSecondary(secon << 372 } 354 } 373 delete products; 355 delete products; 374 << 356 375 // Kill the parent particle 357 // Kill the parent particle 376 fParticleChangeForDecay.ProposeTrackStatus( << 358 fParticleChangeForDecay.SetStatusChange( fStopAndKill ) ; 377 fParticleChangeForDecay.ProposeLocalEnergyDe << 359 fParticleChangeForDecay.SetLocalEnergyDeposit(energyDeposit); 378 fParticleChangeForDecay.ProposeLocalTime( fi << 360 fParticleChangeForDecay.SetTimeChange( finalGlobalTime ); 379 << 361 // reset NumberOfInteractionLengthLeft 380 // Clear NumberOfInteractionLengthLeft << 381 ClearNumberOfInteractionLengthLeft(); 362 ClearNumberOfInteractionLengthLeft(); 382 << 363 383 return &fParticleChangeForDecay ; 364 return &fParticleChangeForDecay ; 384 } 365 } 385 366 386 void G4Decay::DaughterPolarization(const G4Tra << 387 { << 388 // empty implementation << 389 } << 390 367 391 368 392 369 393 void G4Decay::StartTracking(G4Track*) << 394 { << 395 currentInteractionLength = -1.0; << 396 ResetNumberOfInteractionLengthLeft(); << 397 << 398 fRemainderLifeTime = -1.0; << 399 } << 400 << 401 void G4Decay::EndTracking() << 402 { << 403 // Clear NumberOfInteractionLengthLeft << 404 ClearNumberOfInteractionLengthLeft(); << 405 370 406 currentInteractionLength = -1.0; << 407 } << 408 << 409 << 410 G4double G4Decay::PostStepGetPhysicalInteracti << 411 const G4Track& tr << 412 G4double previo << 413 G4ForceCondition* << 414 ) << 415 { << 416 // condition is set to "Not Forced" << 417 *condition = NotForced; << 418 << 419 // pre-assigned Decay time << 420 G4double pTime = track.GetDynamicParticle()- << 421 G4double aLife = track.GetDynamicParticle()- << 422 << 423 if (pTime < 0.) { << 424 // normal case << 425 if ( previousStepSize > 0.0){ << 426 // subtract NumberOfInteractionLengthLef << 427 SubtractNumberOfInteractionLengthLeft(pr << 428 if(theNumberOfInteractionLengthLeft<0.){ << 429 theNumberOfInteractionLengthLeft=perMillion; << 430 } << 431 fRemainderLifeTime = theNumberOfInteract << 432 } << 433 // get mean free path << 434 currentInteractionLength = GetMeanFreePath << 435 << 436 #ifdef G4VERBOSE << 437 if ((currentInteractionLength <=0.0) || (v << 438 G4cout << "G4Decay::PostStepGetPhysicalI << 439 track.GetDynamicParticle()->DumpInfo(); << 440 G4cout << " in Material " << track.GetM << 441 G4cout << "MeanFreePath = " << currentIn << 442 } << 443 #endif << 444 << 445 G4double value; << 446 if (currentInteractionLength <DBL_MAX) { << 447 value = theNumberOfInteractionLengthLeft << 448 //fRemainderLifeTime = theNumberOfIntera << 449 } else { << 450 value = DBL_MAX; << 451 } << 452 << 453 return value; << 454 << 455 } else { << 456 //pre-assigned Decay time case << 457 // reminder proper time << 458 fRemainderLifeTime = pTime - track.GetProp << 459 if (fRemainderLifeTime <= 0.0) fRemainderL << 460 << 461 G4double rvalue=0.0; << 462 // use pre-assigned Decay time to determin << 463 if (aLife>0.0) { << 464 // ordinary particle << 465 rvalue = (fRemainderLifeTime/aLife)*GetM << 466 } else { << 467 // shortlived particle << 468 rvalue = c_light * fRemainderLifeTime; << 469 // by using normalized kinetic energy (= << 470 G4double aMass = track.GetDynamicParti << 471 rvalue *= track.GetDynamicParticle()->Get << 472 } << 473 return rvalue; << 474 } << 475 } << 476 << 477 G4double G4Decay::AtRestGetPhysicalInteraction << 478 const G4Track& tr << 479 G4ForceCondition* << 480 ) << 481 { << 482 // condition is set to "Not Forced" << 483 *condition = NotForced; << 484 << 485 G4double pTime = track.GetDynamicParticle()- << 486 if (pTime >= 0.) { << 487 fRemainderLifeTime = pTime - track.GetProp << 488 if (fRemainderLifeTime <= 0.0) fRemainderL << 489 } else { << 490 fRemainderLifeTime = << 491 theNumberOfInteractionLengthLeft * GetMe << 492 } << 493 return fRemainderLifeTime; << 494 } << 495 << 496 << 497 void G4Decay::SetExtDecayer(G4VExtDecayer* val << 498 { << 499 pExtDecayer = val; << 500 << 501 // set Process Sub Type << 502 if ( pExtDecayer !=0 ) { << 503 SetProcessSubType(static_cast<int>(DECAY_E << 504 } << 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 } << 527 371