00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "BDSComptonEngine.hh"
00010 #include "G4ios.hh"
00011 #include "G4UnitsTable.hh"
00012 #include "Randomize.hh"
00013 #include "G4LorentzRotation.hh"
00014
00015 BDSComptonEngine::BDSComptonEngine(){}
00016
00017
00018 BDSComptonEngine::BDSComptonEngine(G4LorentzVector InGam,
00019 G4LorentzVector InEl )
00020 : itsIncomingEl(InEl),itsIncomingGam(InGam)
00021 {
00022 if(itsIncomingGam.e()<=0.)
00023 {G4Exception("BDSComptonEngine: Invalid Photon Energy");}
00024 }
00025
00026
00027 BDSComptonEngine::~BDSComptonEngine(){}
00028
00029
00030 void BDSComptonEngine::PerformCompton()
00031 {
00032
00033
00034
00035
00036 G4double phi=twopi * G4UniformRand() ;
00037 G4double sinphi=sin(phi);
00038 G4double cosphi=cos(phi);
00039
00040
00041 G4int ntry=0;
00042
00043 G4LorentzVector GamInLab;
00044 G4double x;
00045 G4ThreeVector Boost;
00046 G4double costh, costh2,sinth,sinth2;
00047
00048 Boost=itsIncomingEl.boostVector();
00049
00050 G4LorentzRotation BoostToLab(-Boost);
00051 GamInLab=BoostToLab*(itsIncomingGam);
00052 G4ThreeVector LabGammaDir= GamInLab.vect().unit();
00053
00054 G4double weight_CovT=0;
00055 do {ntry++;
00056
00057 if(G4UniformRand()>0.25){costh=2.*G4UniformRand()-1.;}
00058 else
00059 {
00060 costh=G4UniformRand();
00061 G4double r1=G4UniformRand();
00062 G4double r2=G4UniformRand();
00063 if(r1>costh)costh=r1;
00064 if(r2>costh)costh=r2;;
00065 if(G4UniformRand()<0.5)costh=-costh;
00066 }
00067
00068 costh2=costh*costh;
00069 sinth2=1.-costh2;
00070
00071
00072 x = 1/(1+ GamInLab.e()*(1-costh)/electron_mass_c2);
00073
00074
00075 weight_CovT= x* x * (x+1/x-sinth2)/(1+costh2);
00076 } while(ntry<ntryMax && G4UniformRand()>weight_CovT);
00077
00078 if(ntry==ntryMax)
00079 G4Exception("BDSComptonEngine:Max number of loops exceeded");
00080
00081
00082
00083 G4double Egam = x * GamInLab.e();
00084
00085
00086
00087 sinth=sqrt(sinth2);
00088 itsScatteredGam.setPx(Egam*sinth*cosphi);
00089 itsScatteredGam.setPy(Egam*sinth*sinphi);
00090 itsScatteredGam.setPz(Egam*costh);
00091 itsScatteredGam.setE(Egam);
00092
00093 itsScatteredEl.setPx(-itsScatteredGam.px());
00094 itsScatteredEl.setPy(-itsScatteredGam.py());
00095 itsScatteredEl.setPz(GamInLab.e()-itsScatteredGam.pz());
00096 itsScatteredEl.setE( sqrt( pow(electron_mass_c2,2) +
00097 pow(itsScatteredEl.px(),2)+
00098 pow(itsScatteredEl.py(),2)+
00099 pow(itsScatteredEl.pz(),2) ) );
00100
00101
00102 itsScatteredGam.rotateUz(LabGammaDir);
00103 itsScatteredEl.rotateUz(LabGammaDir);
00104
00105
00106 G4LorentzRotation BoostFromLab(Boost);
00107 itsScatteredGam *= BoostFromLab;
00108 itsScatteredEl *= BoostFromLab;
00109
00110 }
00111
00112