/home/cern/BDSIM_new/src/BDSUserSpecialCuts.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 
00007 // This code implementation is the intellectual property of
00008 // the GEANT4 collaboration.
00009 //
00010 // By copying, distributing or modifying the Program (or any work
00011 // based on the Program) you indicate your acceptance of this statement,
00012 // and all its terms.
00013 //
00014 // $Id: BDSUserSpecialCuts.cc,v 1.2 2005/01/27 11:35:32 agapov Exp $
00015 // GEANT4 tag $Name:  $
00016 // 
00017 // --------------------------------------------------------------
00018 // History
00019 //
00020 // 15-04-98 first implementation, mma                   
00021 // --------------------------------------------------------------
00022 
00023 #include "BDSUserSpecialCuts.hh"
00024 
00025 #include "G4Step.hh"
00026 #include "G4UserLimits.hh"
00027 #include "G4VParticleChange.hh"
00028 #include "G4EnergyLossTables.hh"
00029 
00030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00031 
00032 BDSUserSpecialCuts::BDSUserSpecialCuts(const G4String& aName)
00033   : G4VProcess(aName)
00034 {
00035    if (verboseLevel>0) {
00036      G4cout << GetProcessName() << " is created "<< G4endl;
00037    }
00038 }
00039 
00040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00041 
00042 BDSUserSpecialCuts::~BDSUserSpecialCuts()
00043 {}
00044 
00045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00046 
00047 BDSUserSpecialCuts::BDSUserSpecialCuts(BDSUserSpecialCuts& right)
00048   : G4VProcess(right)
00049 {}
00050 
00051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00052  
00053 G4double BDSUserSpecialCuts::PostStepGetPhysicalInteractionLength(
00054                              const G4Track& aTrack,
00055                              G4double   previousStepSize,
00056                              G4ForceCondition* condition
00057                             )
00058 {
00059   // condition is set to "Not Forced"
00060   *condition = NotForced;
00061 
00062    G4double ProposedStep = DBL_MAX;
00063    G4UserLimits* pUserLimits = aTrack.GetVolume()->GetLogicalVolume()->GetUserLimits();
00064    if (pUserLimits)
00065      { //max track length
00066        ProposedStep = (pUserLimits->GetUserMaxTrackLength(aTrack) - aTrack.GetTrackLength());
00067        if (ProposedStep < 0.) return 0.;
00068        //max time limit
00069        G4double beta = (aTrack.GetDynamicParticle()->GetTotalMomentum())/(aTrack.GetTotalEnergy());
00070        G4double dTime= (pUserLimits->GetUserMaxTime(aTrack) - aTrack.GetGlobalTime());
00071        G4double temp = beta*c_light*dTime;
00072        if (temp < 0.) return 0.;
00073        if (ProposedStep > temp) ProposedStep = temp;                  
00074        //min remaining range (only for charged particle)
00075        G4ParticleDefinition* Particle = aTrack.GetDefinition();
00076            if (Particle->GetPDGCharge() != 0.)
00077           {
00078           G4double              Ekine    = aTrack.GetKineticEnergy();
00079           G4Material*           Material = aTrack.GetMaterial();
00080           G4double RangeNow = G4EnergyLossTables::GetRange(Particle,Ekine,Material);
00081           temp = (RangeNow - pUserLimits->GetUserMinRange(aTrack));
00082           if (temp < 0.) return 0.;
00083           if (ProposedStep > temp) ProposedStep = temp;
00084           //min kinetic energy (only for charged particle)
00085           G4double Emin = pUserLimits->GetUserMinEkine(aTrack);
00086 
00087           //          G4cout<<"emin="<<Emin<<" ekine="<<Ekine<<G4endl;
00088           // // gab:
00089           // if(Ekine<Emin)return 0.;
00090 
00091           G4double Rmin = G4EnergyLossTables::GetRange(Particle,Emin,Material);
00092           temp = RangeNow - Rmin;
00093           if (temp < 0.) return 0.;
00094           if (ProposedStep > temp) ProposedStep = temp;
00095           }         
00096      }   
00097    return ProposedStep;
00098 }
00099 
00100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00101 
00102 G4VParticleChange* BDSUserSpecialCuts::PostStepDoIt(
00103                              const G4Track& aTrack,
00104                              const G4Step& 
00105                             )
00106 //
00107 // Kill the current particle, if requested by BDSUserLimits 
00108 //                                                                          
00109 {
00110    aParticleChange.Initialize(aTrack);
00111 
00112 #if G4VERSION > 6
00113    aParticleChange.ProposeEnergy(0.) ;
00114    aParticleChange.ProposeLocalEnergyDeposit (aTrack.GetKineticEnergy()) ;
00115 #else
00116    aParticleChange.SetEnergyChange(0.) ;
00117    aParticleChange.SetLocalEnergyDeposit (aTrack.GetKineticEnergy()) ;
00118 #endif
00119 
00120    // gab: killing now would remove positron rest mass from the total energy...
00121    //   aParticleChange.SetStatusChange(fStopAndKill);
00122    return &aParticleChange;
00123 }
00124 
00125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

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