[819] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4DNAProcess.icc,v 1.11 2007/12/10 16:31:19 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | // Contact Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch) |
---|
| 31 | // |
---|
| 32 | // Reference: TNS Geant4-DNA paper |
---|
| 33 | // |
---|
| 34 | |
---|
| 35 | // History: |
---|
| 36 | // ----------- |
---|
| 37 | // Date Name Modification |
---|
| 38 | // 28 Apr 2007 M.G. Pia Created in compliance with design described in TNS paper |
---|
| 39 | // |
---|
| 40 | // ------------------------------------------------------------------- |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | template <class TCrossSection,class TFinalState> |
---|
| 44 | G4double G4DNAProcess<TCrossSection,TFinalState>::GetMeanFreePath(const G4Track& track, |
---|
| 45 | G4double /* previousStepSize */, |
---|
| 46 | G4ForceCondition* /* condition */) |
---|
| 47 | { |
---|
| 48 | G4double meanFreePath = DBL_MAX; |
---|
| 49 | |
---|
| 50 | // Assume the interacting medium to be water; one of the elements must be oxygen |
---|
| 51 | G4Material* material(track.GetMaterial()); |
---|
| 52 | size_t i = material->GetNumberOfElements(); |
---|
| 53 | while (i>0) |
---|
| 54 | { |
---|
| 55 | i--; |
---|
| 56 | const G4Element* element(material->GetElement(i)); |
---|
| 57 | if (element->GetZ() == 8.) |
---|
| 58 | { |
---|
| 59 | // Number of oxygen atoms per volume = number of water molecules per volume |
---|
| 60 | G4double density = material->GetAtomicNumDensityVector()[i]; |
---|
| 61 | // G4cout << "density = " << density << G4endl; |
---|
| 62 | if (density > 0.) |
---|
| 63 | { |
---|
| 64 | G4double cross = crossSection.CrossSection(track); |
---|
| 65 | if (cross > 0.0) meanFreePath = 1. / (density*cross); |
---|
| 66 | if (meanFreePath == 0.) meanFreePath = DBL_MIN; |
---|
| 67 | return meanFreePath; |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | } // end while |
---|
| 71 | |
---|
| 72 | // If it ends up here, it means that the material is not water |
---|
| 73 | G4Exception("G4DNAProcess::GetMeanFreePath - material is not water"); |
---|
| 74 | // One does not really need a return statement here |
---|
| 75 | return DBL_MAX; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | template <class TCrossSection,class TFinalState> |
---|
| 80 | G4VParticleChange* G4DNAProcess<TCrossSection,TFinalState>::PostStepDoIt(const G4Track& track, const G4Step& step) |
---|
| 81 | { |
---|
| 82 | aParticleChange.Initialize(track); |
---|
| 83 | |
---|
| 84 | // G4cout << "Track initialized" << G4endl; |
---|
| 85 | |
---|
| 86 | // Interaction product |
---|
| 87 | const G4FinalStateProduct& product = finalState.GenerateFinalState(track,step); |
---|
| 88 | |
---|
| 89 | // Number of secondary products to be generated |
---|
| 90 | G4int nSecondaries = product.NumberOfSecondaries(); |
---|
| 91 | aParticleChange.SetNumberOfSecondaries(nSecondaries); |
---|
| 92 | |
---|
| 93 | // Secondaries |
---|
| 94 | for (G4int l = 0; l<nSecondaries; l++ ) |
---|
| 95 | { |
---|
| 96 | G4DynamicParticle* particle = product.GetSecondaries()[l]; |
---|
| 97 | if (particle != 0) |
---|
| 98 | { |
---|
| 99 | // aParticleChange.SetNumberOfSecondaries(nSecondaries); |
---|
| 100 | aParticleChange.AddSecondary(particle); |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | // Take care of incident particle to be killed, if necessary; dump its energy deposit locally |
---|
| 105 | G4double deposit = product.GetEnergyDeposit(); |
---|
| 106 | if (deposit > 0.0) aParticleChange.ProposeLocalEnergyDeposit(deposit); |
---|
| 107 | |
---|
| 108 | if (product.PrimaryParticleIsKilled()) |
---|
| 109 | { |
---|
| 110 | aParticleChange.ProposeTrackStatus(fStopAndKill); |
---|
| 111 | aParticleChange.ProposeEnergy(0.); |
---|
| 112 | aParticleChange.ProposeMomentumDirection( 0., 0., 0. ); |
---|
| 113 | aParticleChange.ProposeLocalEnergyDeposit(track.GetKineticEnergy() + deposit); |
---|
| 114 | |
---|
| 115 | } |
---|
| 116 | else |
---|
| 117 | { |
---|
| 118 | // Modify incident particle kinematics taking into account the generated products |
---|
| 119 | |
---|
| 120 | // ---- MGP ---- Temporary: assume at most one secondary product |
---|
| 121 | // Sebastien: please check if consistent with current models or generalize |
---|
| 122 | |
---|
| 123 | // Primary particle momentum and kinetic energy |
---|
| 124 | G4ThreeVector primaryMomentum = track.GetMomentum(); |
---|
| 125 | G4double primaryKineticEnergy = track.GetKineticEnergy(); |
---|
| 126 | |
---|
| 127 | // Secondary product momentum and energy |
---|
| 128 | |
---|
| 129 | G4double secondaryKineticEnergy = 0.; |
---|
| 130 | if (nSecondaries >0 ) |
---|
| 131 | { |
---|
| 132 | G4DynamicParticle* secondary = product.GetSecondaries()[0]; |
---|
| 133 | secondaryKineticEnergy = secondary->GetKineticEnergy(); |
---|
| 134 | |
---|
| 135 | // Calculate new primary particle kinetic energy |
---|
| 136 | G4double finalKineticEnergy = primaryKineticEnergy - secondaryKineticEnergy - deposit; |
---|
| 137 | |
---|
| 138 | if (finalKineticEnergy <= 0.0) |
---|
| 139 | { |
---|
| 140 | // Primary particle is stopped; kill it |
---|
| 141 | aParticleChange.ProposeTrackStatus(fStopAndKill); |
---|
| 142 | aParticleChange.ProposeEnergy(0.); |
---|
| 143 | aParticleChange.ProposeMomentumDirection( 0., 0., 0. ); |
---|
| 144 | } |
---|
| 145 | else |
---|
| 146 | { |
---|
| 147 | // Calculate new primary particle momentum: difference between original primary one and secondary |
---|
| 148 | G4ThreeVector secondaryMomentum = secondary->GetMomentum(); |
---|
| 149 | G4ThreeVector finalMomentum = primaryMomentum - secondaryMomentum; |
---|
| 150 | G4ThreeVector finalDirection = finalMomentum.unit(); |
---|
| 151 | aParticleChange.ProposeMomentumDirection(finalDirection); |
---|
| 152 | aParticleChange.ProposeEnergy(finalKineticEnergy); |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | else |
---|
| 156 | { |
---|
| 157 | // Check whether primary particle is modified |
---|
| 158 | if (product.PrimaryParticleIsModified()) |
---|
| 159 | { |
---|
| 160 | G4ThreeVector finalDirection = product.GetModifiedDirection(); |
---|
| 161 | aParticleChange.ProposeMomentumDirection(finalDirection); |
---|
| 162 | G4double finalKineticEnergy = product.GetModifiedEnergy(); |
---|
| 163 | aParticleChange.ProposeEnergy(finalKineticEnergy); |
---|
| 164 | } |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | return G4VDiscreteProcess::PostStepDoIt(track,step ); |
---|
| 170 | } |
---|