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