/home/cern/BDSIM_new/src/BDSComptonEngine.cc

00001 /* BDSIM code.    Version 1.0
00002    Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    Last modified 24.7.2002
00004    Copyright (c) 2002 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 */
00006 //      ------------ BDSComptonEngine physics process --------
00007 //                     by Grahame Blair, 19 October 2001
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   // Generate compton event; using method described in
00034   // H.Burkardt, SL/Note 93-73
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    //   BoostToLab.boost(-Boost);
00050   G4LorentzRotation BoostToLab(-Boost);
00051   GamInLab=BoostToLab*(itsIncomingGam);
00052   G4ThreeVector LabGammaDir= GamInLab.vect().unit();
00053   
00054   G4double weight_CovT=0;  //ratio of Compton to Thompson cross sections:
00055   do {ntry++;
00056   // 1+cos^2 theta distribution
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   // x is ratio of scattered to unscattered photon energy:
00072   x = 1/(1+ GamInLab.e()*(1-costh)/electron_mass_c2);
00073   
00074   //calculate weight of Compton relative to Thompson cross sections:
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   // G4LorentzVector ElInLab=BoostToLab*(itsIncomingEl);
00082   
00083   G4double Egam = x * GamInLab.e();
00084   
00085   // Generate final momenta:
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   // Rotates the reference frame from Uz to newUz (unit vector).
00102   itsScatteredGam.rotateUz(LabGammaDir);
00103   itsScatteredEl.rotateUz(LabGammaDir);
00104   
00105   // now boost back to the original frame:
00106   G4LorentzRotation BoostFromLab(Boost);
00107   itsScatteredGam *= BoostFromLab;
00108   itsScatteredEl *= BoostFromLab;
00109 
00110 }
00111 
00112 

Generated on Wed Mar 5 17:25:22 2008 for BDSIM by  doxygen 1.5.3