ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MyKleinNishinaCompton.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MyKleinNishinaCompton.cc
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 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
32 
33 #include "MyKleinNishinaCompton.hh"
35 #include "DetectorConstruction.hh"
36 
37 #include "G4Electron.hh"
38 #include "G4Gamma.hh"
39 #include "Randomize.hh"
40 #include "G4DataVector.hh"
42 #include "G4PhysicalConstants.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
45 
46 using namespace std;
47 
49  const G4ParticleDefinition*,
50  const G4String& nam)
51  :G4KleinNishinaCompton(0,nam), fDetector(det), fMessenger(0)
52 {
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
58 
60 {
61  delete fMessenger;
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
65 
67  const G4Material* mat,
69  G4double GammaEnergy,
71 {
72  G4double xsection = G4VEmModel::CrossSectionPerVolume(mat,part,GammaEnergy);
73 
74  return xsection*fCrossSectionFactor;
75 }
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
77 
79  std::vector<G4DynamicParticle*>* fvect,
80  const G4MaterialCutsCouple*,
81  const G4DynamicParticle* aDynamicGamma,
82  G4double,
83  G4double)
84 {
85  // The scattered gamma energy is sampled according to Klein - Nishina formula.
86  // The random number techniques of Butcher & Messel are used
87  // (Nuc Phys 20(1960),15).
88  // Note : Effects due to binding of atomic electrons are negliged.
89 
90  G4double gamEnergy0 = aDynamicGamma->GetKineticEnergy();
91  G4double E0_m = gamEnergy0 / electron_mass_c2 ;
92 
93  G4ThreeVector gamDirection0 = aDynamicGamma->GetMomentumDirection();
94 
95  //
96  // sample the energy rate of the scattered gamma
97  //
98 
99  G4double epsilon, epsilonsq, onecost, sint2, greject ;
100 
101  G4double eps0 = 1./(1. + 2.*E0_m);
102  G4double eps0sq = eps0*eps0;
103  G4double alpha1 = - log(eps0);
104  G4double alpha2 = 0.5*(1.- eps0sq);
105 
106  do {
107  if ( alpha1/(alpha1+alpha2) > G4UniformRand() ) {
108  epsilon = exp(-alpha1*G4UniformRand()); // eps0**r
109  epsilonsq = epsilon*epsilon;
110 
111  } else {
112  epsilonsq = eps0sq + (1.- eps0sq)*G4UniformRand();
113  epsilon = sqrt(epsilonsq);
114  };
115 
116  onecost = (1.- epsilon)/(epsilon*E0_m);
117  sint2 = onecost*(2.-onecost);
118  greject = 1. - epsilon*sint2/(1.+ epsilonsq);
119 
120  } while (greject < G4UniformRand());
121 
122  //
123  // scattered gamma angles. ( Z - axis along the parent gamma)
124  //
125 
126  G4double cosTeta = 1. - onecost;
127  G4double sinTeta = sqrt (sint2);
128  G4double Phi = twopi * G4UniformRand();
129  G4double dirx = sinTeta*cos(Phi), diry = sinTeta*sin(Phi), dirz = cosTeta;
130 
131  //
132  // update G4VParticleChange for the scattered gamma
133  //
134  // beam regeneration trick : restore incident beam
135 
136  G4ThreeVector gamDirection1 ( dirx,diry,dirz );
137  gamDirection1.rotateUz(gamDirection0);
138  G4double gamEnergy1 = epsilon*gamEnergy0;
141 
142  //
143  // kinematic of the scattered electron
144  //
145 
146  G4double eKinEnergy = gamEnergy0 - gamEnergy1;
147 
148  if(eKinEnergy > DBL_MIN) {
149  G4ThreeVector eDirection
150  = gamEnergy0*gamDirection0 - gamEnergy1*gamDirection1;
151  eDirection = eDirection.unit();
152 
153  // create G4DynamicParticle object for the electron.
154  G4DynamicParticle* dp
155  = new G4DynamicParticle(theElectron,eDirection,eKinEnergy);
156  fvect->push_back(dp);
157  }
158 }
159 
160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
161