[807] | 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 | // |
---|
[1230] | 26 | // $Id: MyKleinNishinaCompton.cc,v 1.6 2009/10/25 19:06:26 maire Exp $ |
---|
[1337] | 27 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
[807] | 28 | // |
---|
| 29 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 30 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 31 | |
---|
| 32 | #include "MyKleinNishinaCompton.hh" |
---|
[1230] | 33 | #include "MyKleinNishinaMessenger.hh" |
---|
[807] | 34 | #include "DetectorConstruction.hh" |
---|
| 35 | |
---|
| 36 | #include "G4Electron.hh" |
---|
| 37 | #include "G4Gamma.hh" |
---|
| 38 | #include "Randomize.hh" |
---|
| 39 | #include "G4DataVector.hh" |
---|
| 40 | #include "G4ParticleChangeForGamma.hh" |
---|
| 41 | |
---|
| 42 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 43 | |
---|
| 44 | using namespace std; |
---|
| 45 | |
---|
| 46 | MyKleinNishinaCompton::MyKleinNishinaCompton(DetectorConstruction* det, |
---|
| 47 | const G4ParticleDefinition*, |
---|
| 48 | const G4String& nam) |
---|
| 49 | :G4KleinNishinaCompton(0,nam), detector(det) |
---|
| 50 | { |
---|
[1230] | 51 | CrossSectionFactor = 1.; |
---|
| 52 | pMessenger = new MyKleinNishinaMessenger(this); |
---|
[807] | 53 | } |
---|
| 54 | |
---|
| 55 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 56 | |
---|
| 57 | MyKleinNishinaCompton::~MyKleinNishinaCompton() |
---|
[1230] | 58 | { |
---|
| 59 | delete pMessenger; |
---|
| 60 | } |
---|
[807] | 61 | |
---|
| 62 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 63 | |
---|
| 64 | G4double MyKleinNishinaCompton::CrossSectionPerVolume( |
---|
| 65 | const G4Material* mat, |
---|
| 66 | const G4ParticleDefinition* part, |
---|
| 67 | G4double GammaEnergy, |
---|
| 68 | G4double, G4double) |
---|
| 69 | { |
---|
| 70 | G4double CrossSection = |
---|
| 71 | G4VEmModel::CrossSectionPerVolume(mat,part,GammaEnergy); |
---|
| 72 | |
---|
| 73 | return CrossSection*CrossSectionFactor; |
---|
| 74 | } |
---|
| 75 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 76 | |
---|
| 77 | void MyKleinNishinaCompton::SampleSecondaries( |
---|
| 78 | std::vector<G4DynamicParticle*>* fvect, |
---|
| 79 | const G4MaterialCutsCouple*, |
---|
| 80 | const G4DynamicParticle* aDynamicGamma, |
---|
| 81 | G4double, |
---|
| 82 | G4double) |
---|
| 83 | { |
---|
| 84 | // The scattered gamma energy is sampled according to Klein - Nishina formula. |
---|
| 85 | // The random number techniques of Butcher & Messel are used |
---|
| 86 | // (Nuc Phys 20(1960),15). |
---|
| 87 | // Note : Effects due to binding of atomic electrons are negliged. |
---|
| 88 | |
---|
| 89 | G4double gamEnergy0 = aDynamicGamma->GetKineticEnergy(); |
---|
| 90 | G4double E0_m = gamEnergy0 / electron_mass_c2 ; |
---|
| 91 | |
---|
| 92 | G4ThreeVector gamDirection0 = aDynamicGamma->GetMomentumDirection(); |
---|
| 93 | |
---|
| 94 | // |
---|
| 95 | // sample the energy rate of the scattered gamma |
---|
| 96 | // |
---|
| 97 | |
---|
| 98 | G4double epsilon, epsilonsq, onecost, sint2, greject ; |
---|
| 99 | |
---|
| 100 | G4double epsilon0 = 1./(1. + 2.*E0_m); |
---|
| 101 | G4double epsilon0sq = epsilon0*epsilon0; |
---|
| 102 | G4double alpha1 = - log(epsilon0); |
---|
| 103 | G4double alpha2 = 0.5*(1.- epsilon0sq); |
---|
| 104 | |
---|
| 105 | do { |
---|
| 106 | if ( alpha1/(alpha1+alpha2) > G4UniformRand() ) { |
---|
| 107 | epsilon = exp(-alpha1*G4UniformRand()); // epsilon0**r |
---|
| 108 | epsilonsq = epsilon*epsilon; |
---|
| 109 | |
---|
| 110 | } else { |
---|
| 111 | epsilonsq = epsilon0sq + (1.- epsilon0sq)*G4UniformRand(); |
---|
| 112 | epsilon = sqrt(epsilonsq); |
---|
| 113 | }; |
---|
| 114 | |
---|
| 115 | onecost = (1.- epsilon)/(epsilon*E0_m); |
---|
| 116 | sint2 = onecost*(2.-onecost); |
---|
| 117 | greject = 1. - epsilon*sint2/(1.+ epsilonsq); |
---|
| 118 | |
---|
| 119 | } while (greject < G4UniformRand()); |
---|
| 120 | |
---|
| 121 | // |
---|
| 122 | // scattered gamma angles. ( Z - axis along the parent gamma) |
---|
| 123 | // |
---|
| 124 | |
---|
| 125 | G4double cosTeta = 1. - onecost; |
---|
| 126 | G4double sinTeta = sqrt (sint2); |
---|
| 127 | G4double Phi = twopi * G4UniformRand(); |
---|
| 128 | G4double dirx = sinTeta*cos(Phi), diry = sinTeta*sin(Phi), dirz = cosTeta; |
---|
| 129 | |
---|
| 130 | // |
---|
| 131 | // update G4VParticleChange for the scattered gamma |
---|
| 132 | // |
---|
| 133 | // beam regeneration trick : restore incident beam |
---|
| 134 | |
---|
| 135 | G4ThreeVector gamDirection1 ( dirx,diry,dirz ); |
---|
| 136 | gamDirection1.rotateUz(gamDirection0); |
---|
| 137 | G4double gamEnergy1 = epsilon*gamEnergy0; |
---|
| 138 | fParticleChange->SetProposedKineticEnergy(gamEnergy0); |
---|
| 139 | fParticleChange->ProposeMomentumDirection(gamDirection0); |
---|
| 140 | |
---|
| 141 | // |
---|
| 142 | // kinematic of the scattered electron |
---|
| 143 | // |
---|
| 144 | |
---|
| 145 | G4double eKinEnergy = gamEnergy0 - gamEnergy1; |
---|
| 146 | |
---|
| 147 | if(eKinEnergy > DBL_MIN) { |
---|
| 148 | G4ThreeVector eDirection |
---|
| 149 | = gamEnergy0*gamDirection0 - gamEnergy1*gamDirection1; |
---|
| 150 | eDirection = eDirection.unit(); |
---|
| 151 | |
---|
| 152 | // create G4DynamicParticle object for the electron. |
---|
| 153 | G4DynamicParticle* dp |
---|
| 154 | = new G4DynamicParticle(theElectron,eDirection,eKinEnergy); |
---|
| 155 | fvect->push_back(dp); |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
| 160 | |
---|
| 161 | |
---|