19#include "BDSComptonEngine.hh"
22#include "G4LorentzRotation.hh"
23#include "G4ThreeVector.hh"
25#include "Randomize.hh"
26#include "CLHEP/Units/PhysicalConstants.h"
30BDSComptonEngine::BDSComptonEngine(){;}
32BDSComptonEngine::BDSComptonEngine(G4LorentzVector InGam,
33 G4LorentzVector InEl):
34 itsIncomingEl(InEl),itsIncomingGam(InGam)
36 if(itsIncomingGam.e()<=0.)
37 {G4Exception(
"BDSComptonEngine: Invalid Photon Energy",
"-1", FatalException,
"");}
40BDSComptonEngine::~BDSComptonEngine(){;}
42void BDSComptonEngine::PerformCompton()
47 G4double phi = CLHEP::twopi * G4UniformRand();
48 G4double sinphi = std::sin(phi);
49 G4double cosphi = std::cos(phi);
53 G4LorentzVector GamInLab;
56 G4double costh, costh2,sinth,sinth2;
58 Boost = itsIncomingEl.boostVector();
60 G4LorentzRotation BoostToLab(-Boost);
61 GamInLab=BoostToLab*(itsIncomingGam);
62 G4ThreeVector LabGammaDir= GamInLab.vect().unit();
64 G4double weight_CovT=0;
67 if(G4UniformRand()>0.25)
68 {costh=2.*G4UniformRand()-1.;}
71 costh=G4UniformRand();
72 G4double r1=G4UniformRand();
73 G4double r2=G4UniformRand();
78 if(G4UniformRand()<0.5)
86 x = 1/(1+ GamInLab.e()*(1-costh)/CLHEP::electron_mass_c2);
89 weight_CovT= x* x * (x+1/x-sinth2)/(1+costh2);
90 }
while(ntry<ntryMax && G4UniformRand()>weight_CovT);
93 {G4Exception(
"BDSComptonEngine:Max number of loops exceeded",
"-1", FatalException,
"");}
97 G4double Egam = x * GamInLab.e();
101 sinth=std::sqrt(sinth2);
102 itsScatteredGam.setPx(Egam*sinth*cosphi);
103 itsScatteredGam.setPy(Egam*sinth*sinphi);
104 itsScatteredGam.setPz(Egam*costh);
105 itsScatteredGam.setE(Egam);
107 itsScatteredEl.setPx(-itsScatteredGam.px());
108 itsScatteredEl.setPy(-itsScatteredGam.py());
109 itsScatteredEl.setPz(GamInLab.e()-itsScatteredGam.pz());
110 itsScatteredEl.setE( std::sqrt( std::pow(CLHEP::electron_mass_c2,2) +
111 std::pow(itsScatteredEl.px(),2)+
112 std::pow(itsScatteredEl.py(),2)+
113 std::pow(itsScatteredEl.pz(),2) ) );
116 itsScatteredGam.rotateUz(LabGammaDir);
117 itsScatteredEl.rotateUz(LabGammaDir);
120 G4LorentzRotation BoostFromLab(Boost);
121 itsScatteredGam *= BoostFromLab;
122 itsScatteredEl *= BoostFromLab;