ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AdjointeIonisationModel.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4AdjointeIonisationModel.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 //
26 //
28 #include "G4AdjointCSManager.hh"
29 
30 #include "G4PhysicalConstants.hh"
31 #include "G4Integrator.hh"
32 #include "G4TrackStatus.hh"
33 #include "G4ParticleChange.hh"
34 #include "G4AdjointElectron.hh"
35 #include "G4Gamma.hh"
36 #include "G4AdjointGamma.hh"
37 
38 
40 //
42  G4VEmAdjointModel("Inv_eIon_model")
43 
44 {
45 
46  UseMatrix =true;
47  UseMatrixPerElement = true;
48  ApplyCutInRange = true;
51  WithRapidSampling = false;
52 
57 }
59 //
61 {;}
63 //
65  G4bool IsScatProjToProjCase,
66  G4ParticleChange* fParticleChange)
67 {
68 
69 
70  const G4DynamicParticle* theAdjointPrimary =aTrack.GetDynamicParticle();
71 
72  //Elastic inverse scattering
73  //---------------------------------------------------------
74  G4double adjointPrimKinEnergy = theAdjointPrimary->GetKineticEnergy();
75  G4double adjointPrimP =theAdjointPrimary->GetTotalMomentum();
76 
77  if (adjointPrimKinEnergy>HighEnergyLimit*0.999){
78  return;
79  }
80 
81  //Sample secondary energy
82  //-----------------------
83  G4double projectileKinEnergy;
84  if (!WithRapidSampling ) { //used by default
85  projectileKinEnergy = SampleAdjSecEnergyFromCSMatrix(adjointPrimKinEnergy, IsScatProjToProjCase);
86 
87  CorrectPostStepWeight(fParticleChange,
88  aTrack.GetWeight(),
89  adjointPrimKinEnergy,
90  projectileKinEnergy,
91  IsScatProjToProjCase); //Caution !!!this weight correction should be always applied
92  }
93  else { //only for test at the moment
94 
96  if (IsScatProjToProjCase) {
98  Emax=GetSecondAdjEnergyMaxForScatProjToProjCase(adjointPrimKinEnergy);
99  }
100  else {
101  Emin=GetSecondAdjEnergyMinForProdToProjCase(adjointPrimKinEnergy);
102  Emax=GetSecondAdjEnergyMaxForProdToProjCase(adjointPrimKinEnergy);
103  }
104  projectileKinEnergy = Emin*std::pow(Emax/Emin,G4UniformRand());
105 
106 
107 
109  if ( !IsScatProjToProjCase) lastCS=lastAdjointCSForProdToProjCase;
110 
111  G4double new_weight=aTrack.GetWeight();
112  G4double used_diffCS=lastCS*std::log(Emax/Emin)/projectileKinEnergy;
113  G4double needed_diffCS=adjointPrimKinEnergy/projectileKinEnergy;
114  if (!IsScatProjToProjCase) needed_diffCS *=DiffCrossSectionPerVolumePrimToSecond(currentMaterial,projectileKinEnergy,adjointPrimKinEnergy);
115  else needed_diffCS *=DiffCrossSectionPerVolumePrimToScatPrim(currentMaterial,projectileKinEnergy,adjointPrimKinEnergy);
116  new_weight*=needed_diffCS/used_diffCS;
117  fParticleChange->SetParentWeightByProcess(false);
118  fParticleChange->SetSecondaryWeightByProcess(false);
119  fParticleChange->ProposeParentWeight(new_weight);
120 
121 
122  }
123 
124 
125 
126  //Kinematic:
127  //we consider a two body elastic scattering for the forward processes where the projectile knock on an e- at rest and gives
128  // him part of its energy
129  //----------------------------------------------------------------------------------------
130 
132  G4double projectileTotalEnergy = projectileM0+projectileKinEnergy;
133  G4double projectileP2 = projectileTotalEnergy*projectileTotalEnergy - projectileM0*projectileM0;
134 
135 
136 
137  //Companion
138  //-----------
140  if (IsScatProjToProjCase) {
142  }
143  G4double companionTotalEnergy =companionM0+ projectileKinEnergy-adjointPrimKinEnergy;
144  G4double companionP2 = companionTotalEnergy*companionTotalEnergy - companionM0*companionM0;
145 
146 
147  //Projectile momentum
148  //--------------------
149  G4double P_parallel = (adjointPrimP*adjointPrimP + projectileP2 - companionP2)/(2.*adjointPrimP);
150  G4double P_perp = std::sqrt( projectileP2 - P_parallel*P_parallel);
151  G4ThreeVector dir_parallel=theAdjointPrimary->GetMomentumDirection();
152  G4double phi =G4UniformRand()*2.*3.1415926;
153  G4ThreeVector projectileMomentum = G4ThreeVector(P_perp*std::cos(phi),P_perp*std::sin(phi),P_parallel);
154  projectileMomentum.rotateUz(dir_parallel);
155 
156 
157 
158  if (!IsScatProjToProjCase ){ //kill the primary and add a secondary
159  fParticleChange->ProposeTrackStatus(fStopAndKill);
160  fParticleChange->AddSecondary(new G4DynamicParticle(theAdjEquivOfDirectPrimPartDef,projectileMomentum));
161  //G4cout<<"projectileMomentum "<<projectileMomentum<<G4endl;
162  }
163  else {
164  fParticleChange->ProposeEnergy(projectileKinEnergy);
165  fParticleChange->ProposeMomentumDirection(projectileMomentum.unit());
166  }
167 
168 
169 
170 
171 }
173 //
174 //The implementation here is correct for energy loss process, for the photoelectric and compton scattering the method should be redefine
176  G4double kinEnergyProj,
177  G4double kinEnergyProd,
178  G4double Z,
179  G4double )
180 {
181  G4double dSigmadEprod=0;
182  G4double Emax_proj = GetSecondAdjEnergyMaxForProdToProjCase(kinEnergyProd);
183  G4double Emin_proj = GetSecondAdjEnergyMinForProdToProjCase(kinEnergyProd);
184 
185 
186  if (kinEnergyProj>Emin_proj && kinEnergyProj<=Emax_proj){ //the produced particle should have a kinetic energy smaller than the projectile
187  dSigmadEprod=Z*DiffCrossSectionMoller(kinEnergyProj,kinEnergyProd);
188  }
189  return dSigmadEprod;
190 
191 
192 
193 }
194 
196 //
198 
199  G4double energy = kinEnergyProj + electron_mass_c2;
200  G4double x = kinEnergyProd/kinEnergyProj;
201  G4double gam = energy/electron_mass_c2;
202  G4double gamma2 = gam*gam;
203  G4double beta2 = 1.0 - 1.0/gamma2;
204 
205  G4double gg = (2.0*gam - 1.0)/gamma2;
206  G4double y = 1.0 - x;
208  G4double dCS = fac*( 1.-gg + ((1.0 - gg*x)/(x*x))
209  + ((1.0 - gg*y)/(y*y)))/(beta2*(gam-1));
210  return dCS/kinEnergyProj;
211 
212 
213 
214 }
215