/home/cern/BDSIM_new/src/BDSLaserCompton.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 //      ------------ BDSLaserCompton physics process --------
00007 //                     by Grahame Blair, 18 October 2001
00008 #include "BDSGlobalConstants.hh" // must be first in include list
00009 
00010 #include "BDSLaserCompton.hh"
00011 #include "G4ios.hh"
00012 #include "G4UnitsTable.hh"
00013 
00014 #if G4VERSION > 8
00015 BDSLaserCompton::BDSLaserCompton(const G4String& processName)
00016   :  G4VDiscreteProcess(processName),isInitialised(false)
00017 #else
00018 BDSLaserCompton::BDSLaserCompton(const G4String& processName)
00019   :  G4VeEnergyLoss(processName)
00020 #endif
00021 {
00022   itsLaserWavelength=BDSGlobals->GetLaserwireWavelength();
00023   itsLaserDirection=BDSGlobals->GetLaserwireDir();
00024 
00025 
00026   //    if(itsLaserWavelength<=0.)
00027   //     {G4Exception("BDSLaserCompton: Invalid Wavelength");}
00028   // itsLaserEnergy=twopi*hbarc/itsLaserWavelength;
00029  // point laserwire in x:     P_x        Py Pz   E
00030  //G4LorentzVector Laser4mom(itsLaserEnergy,0,0,itsLaserEnergy);
00031  //itsComptonEngine=new BDSComptonEngine(Laser4mom);
00032   itsComptonEngine=new BDSComptonEngine();
00033 } 
00034 
00035  
00036 BDSLaserCompton::~BDSLaserCompton(){}
00037 
00038 
00039 G4VParticleChange* BDSLaserCompton::PostStepDoIt(const G4Track& trackData,
00040                                                  const G4Step& stepData)
00041 {
00042  
00043  
00044  aParticleChange.Initialize(trackData);
00045  
00046  // ensure that Laserwire can only occur once in an event
00047  if(!FireLaserCompton){
00048          #if G4VERSION > 8
00049    return G4VDiscreteProcess::PostStepDoIt(trackData,stepData);
00050    #else
00051          return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
00052          #endif
00053  }
00054  G4Material* aMaterial=trackData.GetMaterial() ;
00055  
00056  if(aMaterial==theMaterials->GetMaterial("LaserVac"))
00057    {
00058      G4LogicalVolume* lVolume = (trackData.GetVolume())->GetLogicalVolume();
00059      
00060      //     itsLaserWavelength=BDSGlobals->GetLaserwireWavelength();
00061      //     itsLaserDirection=BDSGlobals->GetLaserwireDir();
00062      itsLaserWavelength=BDSGlobals->GetLaserwireWavelength(lVolume->GetName());
00063      itsLaserDirection=BDSGlobals->GetLaserwireDir(lVolume->GetName());
00064      
00065      //G4cout << "&&&&&" << itsLaserDirection << "&&&&&\n";
00066      if(itsLaserWavelength<=0.)
00067        {G4Exception("BDSLaserCompton::PostStepDoIt - Invalid Wavelength");}
00068      itsLaserEnergy=twopi*hbarc/itsLaserWavelength;
00069      // point laserwire in x:     P_x        Py Pz   E
00070      G4LorentzVector Laser4mom(itsLaserEnergy*itsLaserDirection.unit(),itsLaserEnergy);
00071      
00072      const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle();
00073      
00074      itsComptonEngine->
00075        SetIncomingElectron4Vec(aDynamicParticle->Get4Momentum());
00076      itsComptonEngine->SetIncomingPhoton4Vec(Laser4mom);
00077      
00078      itsComptonEngine->PerformCompton();
00079      
00080      if(BDSGlobals->GetLaserwireTrackPhotons())
00081        {
00082 
00083          // create G4DynamicParticle object for the Gamma 
00084          G4LorentzVector ScatGam=itsComptonEngine->GetScatteredGamma();
00085          //      G4cout<<" Gamma Energy="<<ScatGam.e()/GeV<<" GeV"<<G4endl;
00086          G4DynamicParticle* aGamma= 
00087            new G4DynamicParticle (G4Gamma::Gamma(), 
00088                                   ScatGam.vect().unit(),// direction 
00089                                   ScatGam.e());
00090          
00091          aParticleChange.SetNumberOfSecondaries(1);
00092          aParticleChange.AddSecondary(aGamma); 
00093          if(!BDSGlobals->GetLaserwireTrackElectrons())
00094            {
00095 #if G4VERSION > 6
00096              aParticleChange.ProposeEnergy( 0. );
00097              aParticleChange.ProposeLocalEnergyDeposit (0.);
00098              aParticleChange.ProposeTrackStatus(fStopAndKill);
00099 #else
00100              aParticleChange.SetEnergyChange( 0. );
00101              aParticleChange.SetLocalEnergyDeposit (0.);
00102              aParticleChange.SetStatusChange(fStopAndKill);
00103 #endif
00104            }
00105        }
00106      else
00107        {
00108 #if G4VERSION > 6
00109          aParticleChange.SetNumberOfSecondaries(0);
00110          aParticleChange.ProposeLocalEnergyDeposit (0.);
00111 #else
00112          aParticleChange.SetNumberOfSecondaries(0);
00113          aParticleChange.SetLocalEnergyDeposit (0.);
00114 #endif
00115 
00116        }
00117      //
00118      // Update the incident particle 
00119      //
00120 
00121     
00122      G4double NewKinEnergy=
00123        itsComptonEngine->GetScatteredElectron().e()-electron_mass_c2;
00124      
00125      //  G4double NewKinEnergy=0; // tmp to track photon only
00126      
00127      G4LorentzVector ScatEl=itsComptonEngine->GetScatteredElectron();
00128      
00129      
00130      if (NewKinEnergy > 0.)
00131        {
00132 #if G4VERSION > 6
00133          aParticleChange.ProposeMomentumDirection(ScatEl.vect().unit());
00134          aParticleChange.ProposeEnergy(NewKinEnergy);
00135          aParticleChange.ProposeLocalEnergyDeposit (0.); 
00136 #else
00137          aParticleChange.SetMomentumChange(ScatEl.vect().unit());
00138          aParticleChange.SetEnergyChange(NewKinEnergy);
00139          aParticleChange.SetLocalEnergyDeposit (0.); 
00140 #endif
00141        } 
00142      else
00143        { 
00144 
00145 #if G4VERSION > 6
00146          aParticleChange.ProposeEnergy( 0. );
00147          aParticleChange.ProposeLocalEnergyDeposit (0.);
00148          G4double charge= aDynamicParticle->GetCharge();
00149          if (charge<0.) aParticleChange.ProposeTrackStatus(fStopAndKill);
00150          else       aParticleChange.ProposeTrackStatus(fStopButAlive);
00151 #else
00152          aParticleChange.SetEnergyChange( 0. );
00153          aParticleChange.SetLocalEnergyDeposit (0.);
00154          G4double charge= aDynamicParticle->GetCharge();
00155          if (charge<0.) aParticleChange.SetStatusChange(fStopAndKill);
00156          else       aParticleChange.SetStatusChange(fStopButAlive);
00157 #endif
00158 
00159        }    
00160      
00161    }
00162  //commented to allow multiple laserwires in beamline - Steve
00163  // FireLaserCompton=false;
00164  
00165  #if G4VERSION > 8
00166  return G4VDiscreteProcess::PostStepDoIt(trackData,stepData);
00167  #else
00168  return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
00169  #endif
00170 }
00171 
00172 #if G4VERSION > 8
00173 /*
00174 #include "G4LossTableManager.hh"
00175 #include "G4eBremsstrahlungModel.hh"
00176 #include "G4UniversalFluctuation.hh"
00177 
00178 void BDSLaserCompton::InitialiseEnergyLossProcess(const G4ParticleDefinition* p, const G4ParticleDefinition*)
00179 {
00180   if(!isInitialised) {
00181     particle = p;
00182     SetSecondaryParticle(G4Gamma::Gamma());
00183     SetIonisation(false);
00184     if (!EmModel()) SetEmModel(new G4eBremsstrahlungModel());
00185     EmModel()->SetLowEnergyLimit (100*eV);
00186     EmModel()->SetHighEnergyLimit(100*TeV);
00187     if (!FluctModel()) SetFluctModel(new G4UniversalFluctuation());
00188 
00189     AddEmModel(1, EmModel(), FluctModel());
00190     isInitialised = true;
00191   }
00192   G4LossTableManager* man = G4LossTableManager::Instance();
00193   dynamic_cast<G4eBremsstrahlungModel*>(EmModel())
00194     ->SetEnergyThreshold(man->BremsstrahlungTh());
00195   dynamic_cast<G4eBremsstrahlungModel*>(EmModel())
00196     ->SetLPMflag(man->LPMFlag());
00197 }
00198 
00199 void BDSLaserCompton::PrintInfo()
00200 {
00201 
00202   if(EmModel()) {
00203     G4cout << "      Total cross sections and sampling from "
00204            << EmModel()->GetName() << " model"
00205            << " (based on the EEDL data library) "
00206            << "\n      Good description from 1 KeV to 100 GeV, "
00207            << "log scale extrapolation above 100 GeV."
00208            << " LPM flag "
00209            << dynamic_cast<G4eBremsstrahlungModel*>(EmModel())->LPMflag()
00210            << G4endl;
00211     G4double eth = dynamic_cast<G4eBremsstrahlungModel*>(EmModel())->EnergyThreshold();
00212     if(eth < DBL_MIN)
00213       G4cout << "      HighEnergyThreshold(GeV)= " << eth/GeV
00214              << G4endl;
00215   }
00216 
00217 }
00218 */
00219 #endif

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