18#include "BDSComptonEngine.hh"
21#include "G4LorentzRotation.hh"
22#include "G4ThreeVector.hh"
24#include "Randomize.hh"
25#include "CLHEP/Units/PhysicalConstants.h"
29BDSComptonEngine::BDSComptonEngine(){;}
31BDSComptonEngine::BDSComptonEngine(G4LorentzVector InGam,
32 G4LorentzVector InEl):
33 itsIncomingEl(InEl),itsIncomingGam(InGam)
35 if(itsIncomingGam.e()<=0.)
36 {G4Exception(
"BDSComptonEngine: Invalid Photon Energy",
"-1", FatalException,
"");}
39BDSComptonEngine::~BDSComptonEngine(){;}
41void BDSComptonEngine::PerformCompton()
46 G4double phi = CLHEP::twopi * G4UniformRand();
47 G4double sinphi = std::sin(phi);
48 G4double cosphi = std::cos(phi);
52 G4LorentzVector GamInLab;
55 G4double costh, costh2,sinth,sinth2;
57 Boost = itsIncomingEl.boostVector();
59 G4LorentzRotation BoostToLab(-Boost);
60 GamInLab=BoostToLab*(itsIncomingGam);
61 G4ThreeVector LabGammaDir= GamInLab.vect().unit();
63 G4double weight_CovT=0;
66 if(G4UniformRand()>0.25)
67 {costh=2.*G4UniformRand()-1.;}
70 costh=G4UniformRand();
71 G4double r1=G4UniformRand();
72 G4double r2=G4UniformRand();
77 if(G4UniformRand()<0.5)
85 x = 1/(1+ GamInLab.e()*(1-costh)/CLHEP::electron_mass_c2);
88 weight_CovT= x* x * (x+1/x-sinth2)/(1+costh2);
89 }
while(ntry<ntryMax && G4UniformRand()>weight_CovT);
92 {G4Exception(
"BDSComptonEngine:Max number of loops exceeded",
"-1", FatalException,
"");}
96 G4double Egam = x * GamInLab.e();
100 sinth=std::sqrt(sinth2);
101 itsScatteredGam.setPx(Egam*sinth*cosphi);
102 itsScatteredGam.setPy(Egam*sinth*sinphi);
103 itsScatteredGam.setPz(Egam*costh);
104 itsScatteredGam.setE(Egam);
106 itsScatteredEl.setPx(-itsScatteredGam.px());
107 itsScatteredEl.setPy(-itsScatteredGam.py());
108 itsScatteredEl.setPz(GamInLab.e()-itsScatteredGam.pz());
109 itsScatteredEl.setE( std::sqrt( std::pow(CLHEP::electron_mass_c2,2) +
110 std::pow(itsScatteredEl.px(),2)+
111 std::pow(itsScatteredEl.py(),2)+
112 std::pow(itsScatteredEl.pz(),2) ) );
115 itsScatteredGam.rotateUz(LabGammaDir);
116 itsScatteredEl.rotateUz(LabGammaDir);
119 G4LorentzRotation BoostFromLab(Boost);
120 itsScatteredGam *= BoostFromLab;
121 itsScatteredEl *= BoostFromLab;