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 // 27 // 28 // 28 // 29 // ------------------------------------------- 29 // -------------------------------------------------------------- 30 // GEANT 4 class implementation file 30 // GEANT 4 class implementation file 31 // 31 // 32 // ------------------------------------------- 32 // ------------------------------------------------------------ 33 // 33 // 34 34 35 #include "G4UnknownDecay.hh" 35 #include "G4UnknownDecay.hh" 36 36 37 #include "G4PhysicalConstants.hh" 37 #include "G4PhysicalConstants.hh" 38 #include "G4SystemOfUnits.hh" 38 #include "G4SystemOfUnits.hh" 39 #include "G4DynamicParticle.hh" 39 #include "G4DynamicParticle.hh" 40 #include "G4DecayProducts.hh" 40 #include "G4DecayProducts.hh" 41 #include "G4PhysicsLogVector.hh" 41 #include "G4PhysicsLogVector.hh" 42 #include "G4ParticleChangeForDecay.hh" 42 #include "G4ParticleChangeForDecay.hh" 43 #include "G4DecayProcessType.hh" 43 #include "G4DecayProcessType.hh" 44 44 45 // constructor 45 // constructor 46 G4UnknownDecay::G4UnknownDecay(const G4String& 46 G4UnknownDecay::G4UnknownDecay(const G4String& processName) 47 :G4VDiscretePro 47 :G4VDiscreteProcess(processName, fDecay), 48 verboseLevel(1), 48 verboseLevel(1), 49 HighestValue(2 49 HighestValue(20.0) 50 { 50 { 51 // set Process Sub Type 51 // set Process Sub Type 52 SetProcessSubType(static_cast<int>(DECAY_Unk 52 SetProcessSubType(static_cast<int>(DECAY_Unknown)); 53 53 54 #ifdef G4VERBOSE 54 #ifdef G4VERBOSE 55 if (GetVerboseLevel()>1) { 55 if (GetVerboseLevel()>1) { 56 G4cout << "G4UnknownDecay constructor " < 56 G4cout << "G4UnknownDecay constructor " << " Name:" << processName << G4endl; 57 } 57 } 58 #endif 58 #endif 59 pParticleChange = &fParticleChangeForDecay; 59 pParticleChange = &fParticleChangeForDecay; 60 } 60 } 61 61 62 G4UnknownDecay::~G4UnknownDecay() 62 G4UnknownDecay::~G4UnknownDecay() 63 { 63 { 64 } 64 } 65 65 66 G4bool G4UnknownDecay::IsApplicable(const G4Pa 66 G4bool G4UnknownDecay::IsApplicable(const G4ParticleDefinition& aParticleType) 67 { 67 { 68 if(aParticleType.GetParticleName()=="unknown 68 if(aParticleType.GetParticleName()=="unknown") return true; 69 return false; 69 return false; 70 } 70 } 71 71 72 G4double G4UnknownDecay::GetMeanFreePath(const 72 G4double G4UnknownDecay::GetMeanFreePath(const G4Track& /*aTrack*/,G4double, G4ForceCondition*) 73 { 73 { 74 return 0.0; 74 return 0.0; 75 } 75 } 76 76 77 void G4UnknownDecay::BuildPhysicsTable(const G 77 void G4UnknownDecay::BuildPhysicsTable(const G4ParticleDefinition&) 78 { 78 { 79 return; 79 return; 80 } 80 } 81 81 82 G4VParticleChange* G4UnknownDecay::DecayIt(con 82 G4VParticleChange* G4UnknownDecay::DecayIt(const G4Track& aTrack, const G4Step& ) 83 { 83 { 84 // The DecayIt() method returns by pointer a 84 // The DecayIt() method returns by pointer a particle-change object. 85 // Units are expressed in GEANT4 internal un 85 // Units are expressed in GEANT4 internal units. 86 86 87 // Initialize ParticleChange 87 // Initialize ParticleChange 88 // all members of G4VParticleChange are 88 // all members of G4VParticleChange are set to equal to 89 // corresponding member in G4Track 89 // corresponding member in G4Track 90 fParticleChangeForDecay.Initialize(aTrack); 90 fParticleChangeForDecay.Initialize(aTrack); 91 91 92 // get particle 92 // get particle 93 const G4DynamicParticle* aParticle = aTrack. 93 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 94 94 95 //check if thePreAssignedDecayProducts exist 95 //check if thePreAssignedDecayProducts exists 96 const G4DecayProducts* o_products = (aPartic 96 const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts()); 97 G4bool isPreAssigned = (o_products != nullpt 97 G4bool isPreAssigned = (o_products != nullptr); 98 G4DecayProducts* products = nullptr; 98 G4DecayProducts* products = nullptr; 99 99 100 if (!isPreAssigned ){ 100 if (!isPreAssigned ){ 101 fParticleChangeForDecay.SetNumberOfSeconda 101 fParticleChangeForDecay.SetNumberOfSecondaries(0); 102 // Kill the parent particle 102 // Kill the parent particle 103 fParticleChangeForDecay.ProposeTrackStatus 103 fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ; 104 fParticleChangeForDecay.ProposeLocalEnergy 104 fParticleChangeForDecay.ProposeLocalEnergyDeposit(0.0); 105 105 106 ClearNumberOfInteractionLengthLeft(); 106 ClearNumberOfInteractionLengthLeft(); 107 return &fParticleChangeForDecay ; 107 return &fParticleChangeForDecay ; 108 } 108 } 109 109 110 // copy decay products 110 // copy decay products 111 products = new G4DecayProducts(*o_products); 111 products = new G4DecayProducts(*o_products); 112 112 113 // get parent particle information ......... 113 // get parent particle information ................................... 114 G4double ParentEnergy = aParticle->GetTot 114 G4double ParentEnergy = aParticle->GetTotalEnergy(); 115 G4double ParentMass = aParticle->GetMas 115 G4double ParentMass = aParticle->GetMass(); 116 if (ParentEnergy < ParentMass) { 116 if (ParentEnergy < ParentMass) { 117 ParentEnergy = ParentMass; 117 ParentEnergy = ParentMass; 118 #ifdef G4VERBOSE 118 #ifdef G4VERBOSE 119 if (GetVerboseLevel()>1) { 119 if (GetVerboseLevel()>1) { 120 G4cout << "G4UnknownDecay::DoIt : Total 120 G4cout << "G4UnknownDecay::DoIt : Total Energy is less than its mass" << G4endl; 121 G4cout << " Particle: " << aParticle->Ge 121 G4cout << " Particle: " << aParticle->GetDefinition()->GetParticleName(); 122 G4cout << " Energy:" << ParentEnergy/ 122 G4cout << " Energy:" << ParentEnergy/MeV << "[MeV]"; 123 G4cout << " Mass:" << ParentMass/MeV 123 G4cout << " Mass:" << ParentMass/MeV << "[MeV]"; 124 G4cout << G4endl; 124 G4cout << G4endl; 125 } 125 } 126 #endif 126 #endif 127 } 127 } 128 G4ThreeVector ParentDirection(aParticle->Get 128 G4ThreeVector ParentDirection(aParticle->GetMomentumDirection()); 129 129 130 G4double energyDeposit = 0.0; 130 G4double energyDeposit = 0.0; 131 G4double finalGlobalTime = aTrack.GetGlobalT 131 G4double finalGlobalTime = aTrack.GetGlobalTime(); 132 //boost all decay products to laboratory fra 132 //boost all decay products to laboratory frame 133 //if the particle has traveled 133 //if the particle has traveled 134 if(aParticle->GetPreAssignedDecayProperTime( 134 if(aParticle->GetPreAssignedDecayProperTime()>=0.) { 135 products->Boost( ParentEnergy, ParentDirec 135 products->Boost( ParentEnergy, ParentDirection); 136 } 136 } 137 137 138 //add products in fParticleChangeForDecay 138 //add products in fParticleChangeForDecay 139 G4int numberOfSecondaries = products->entrie 139 G4int numberOfSecondaries = products->entries(); 140 fParticleChangeForDecay.SetNumberOfSecondari 140 fParticleChangeForDecay.SetNumberOfSecondaries(numberOfSecondaries); 141 #ifdef G4VERBOSE 141 #ifdef G4VERBOSE 142 if (GetVerboseLevel()>1) { 142 if (GetVerboseLevel()>1) { 143 G4cout << "G4UnknownDecay::DoIt : Decay v 143 G4cout << "G4UnknownDecay::DoIt : Decay vertex :"; 144 G4cout << " Time: " << finalGlobalTime/ns 144 G4cout << " Time: " << finalGlobalTime/ns << "[ns]"; 145 G4cout << " X:" << (aTrack.GetPosition()). 145 G4cout << " X:" << (aTrack.GetPosition()).x() /cm << "[cm]"; 146 G4cout << " Y:" << (aTrack.GetPosition()). 146 G4cout << " Y:" << (aTrack.GetPosition()).y() /cm << "[cm]"; 147 G4cout << " Z:" << (aTrack.GetPosition()). 147 G4cout << " Z:" << (aTrack.GetPosition()).z() /cm << "[cm]"; 148 G4cout << G4endl; 148 G4cout << G4endl; 149 G4cout << "G4UnknownDecay::DoIt : decay p 149 G4cout << "G4UnknownDecay::DoIt : decay products in Lab. Frame" << G4endl; 150 products->DumpInfo(); 150 products->DumpInfo(); 151 } 151 } 152 #endif 152 #endif 153 G4int index; 153 G4int index; 154 G4ThreeVector currentPosition; 154 G4ThreeVector currentPosition; 155 const G4TouchableHandle thand = aTrack.GetTo 155 const G4TouchableHandle thand = aTrack.GetTouchableHandle(); 156 for (index=0; index < numberOfSecondaries; i 156 for (index=0; index < numberOfSecondaries; index++){ 157 // get current position of the track 157 // get current position of the track 158 currentPosition = aTrack.GetPosition(); 158 currentPosition = aTrack.GetPosition(); 159 // create a new track object 159 // create a new track object 160 G4Track* secondary = new G4Track( products 160 G4Track* secondary = new G4Track( products->PopProducts(), 161 finalGlobalTime , 161 finalGlobalTime , 162 currentPosition ); 162 currentPosition ); 163 // switch on good for tracking flag 163 // switch on good for tracking flag 164 secondary->SetGoodForTrackingFlag(); 164 secondary->SetGoodForTrackingFlag(); 165 secondary->SetTouchableHandle(thand); 165 secondary->SetTouchableHandle(thand); 166 // add the secondary track in the List 166 // add the secondary track in the List 167 fParticleChangeForDecay.AddSecondary(secon 167 fParticleChangeForDecay.AddSecondary(secondary); 168 } 168 } 169 delete products; 169 delete products; 170 170 171 // Kill the parent particle 171 // Kill the parent particle 172 fParticleChangeForDecay.ProposeTrackStatus( 172 fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ; 173 fParticleChangeForDecay.ProposeLocalEnergyDe 173 fParticleChangeForDecay.ProposeLocalEnergyDeposit(energyDeposit); 174 fParticleChangeForDecay.ProposeGlobalTime( f 174 fParticleChangeForDecay.ProposeGlobalTime( finalGlobalTime ); 175 // reset NumberOfInteractionLengthLeft 175 // reset NumberOfInteractionLengthLeft 176 ClearNumberOfInteractionLengthLeft(); 176 ClearNumberOfInteractionLengthLeft(); 177 177 178 return &fParticleChangeForDecay ; 178 return &fParticleChangeForDecay ; 179 } 179 } 180 180 181 void G4UnknownDecay::ProcessDescription(std::o 181 void G4UnknownDecay::ProcessDescription(std::ostream& outFile) const 182 { 182 { 183 outFile << GetProcessName() 183 outFile << GetProcessName() 184 << ": Decay of 'unknown' particles. \n" 184 << ": Decay of 'unknown' particles. \n" 185 << "kinematics of daughters are dertermine 185 << "kinematics of daughters are dertermined " 186 << "by PreAssignedDecayProducts. \n"; 186 << "by PreAssignedDecayProducts. \n"; 187 } 187 } 188 188 189 189 190 190 191 191 192 192 193 193