G4UserSpecialCuts.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4UserSpecialCuts.cc 69887 2013-05-17 08:17:02Z gcosmo $
00028 //
00029 // --------------------------------------------------------------
00030 // History
00031 //
00032 // 15-04-98 first implementation, mma
00033 // 07-04-03 migrade to cut per region (V.Ivanchenko)
00034 // 18-09-03 substitute manager for the loss tables (V.Ivanchenko)
00035 // 23-01-04 add protection for charged geantino in range cut (H.Kurashige)
00036 // 09-09-04 tracking cut applied only if Rmin or Emin > DBL_MIN
00037 // 21-01-11 changed order of checks: 1st energy tracking cut, 2nd track
00038 //          length, 3d time cut, 4th range for charged particles 
00039 //          with non-zero mass; removed string comparisons (V.Ivanchenko)
00040 // --------------------------------------------------------------
00041 
00042 #include "G4UserSpecialCuts.hh"
00043 #include "G4TransportationProcessType.hh"
00044 
00045 #include "G4PhysicalConstants.hh"
00046 #include "G4Step.hh"
00047 #include "G4UserLimits.hh"
00048 #include "G4VParticleChange.hh"
00049 #include "G4LossTableManager.hh"
00050 
00051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00052 
00053 G4UserSpecialCuts::G4UserSpecialCuts(const G4String& aName)
00054   : G4VProcess(aName, fGeneral  )
00055 {
00056   // set Process Sub Type
00057   SetProcessSubType(static_cast<int>(USER_SPECIAL_CUTS));
00058 
00059   if (verboseLevel>0)
00060     {
00061       G4cout << GetProcessName() << " is created "<< G4endl;
00062     }
00063   theLossTableManager = G4LossTableManager::Instance();
00064 }
00065 
00066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00067 
00068 G4UserSpecialCuts::~G4UserSpecialCuts()
00069 {
00070 }
00071 
00072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00073 
00074 G4UserSpecialCuts::G4UserSpecialCuts(G4UserSpecialCuts& right)
00075   : G4VProcess(right)
00076 {
00077 }
00078 
00079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00080  
00081 G4double G4UserSpecialCuts::
00082 PostStepGetPhysicalInteractionLength( const G4Track& aTrack,
00083                                             G4double, // previousStepSize
00084                                             G4ForceCondition* condition  )
00085 {
00086   // condition is set to "Not Forced"
00087   *condition = NotForced;
00088 
00089    G4double ProposedStep = DBL_MAX;
00090    G4UserLimits* pUserLimits =
00091                  aTrack.GetVolume()->GetLogicalVolume()->GetUserLimits();
00092    if (pUserLimits)
00093    {
00094      // check max kinetic energy first
00095      //
00096      G4double Ekine = aTrack.GetKineticEnergy();
00097      if(Ekine <= pUserLimits->GetUserMinEkine(aTrack)) { return 0.; }
00098 
00099      // max track length
00100      //
00101      ProposedStep = (pUserLimits->GetUserMaxTrackLength(aTrack)
00102                    - aTrack.GetTrackLength());
00103      if (ProposedStep < 0.) { return 0.; }
00104 
00105      // max time limit
00106      //
00107      G4double tlimit = pUserLimits->GetUserMaxTime(aTrack);
00108      if(tlimit < DBL_MAX) {
00109        G4double beta  = (aTrack.GetDynamicParticle()->GetTotalMomentum())
00110          /(aTrack.GetTotalEnergy());
00111        G4double dTime = (tlimit - aTrack.GetGlobalTime());
00112        G4double temp  = beta*c_light*dTime;
00113        if (temp < 0.) { return 0.; }
00114        if (ProposedStep > temp) { ProposedStep = temp; }
00115      }
00116                  
00117      // min remaining range 
00118      // (only for charged particle except for chargedGeantino)
00119      //
00120      G4double Rmin = pUserLimits->GetUserMinRange(aTrack);
00121      if (Rmin > DBL_MIN) {
00122        G4ParticleDefinition* Particle = aTrack.GetDefinition();
00123        if ( (Particle->GetPDGCharge() != 0.) && (Particle->GetPDGMass() > 0.0))
00124        {
00125          const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple();
00126          G4double RangeNow = theLossTableManager->GetRange(Particle,Ekine,couple);
00127          G4double temp = RangeNow - Rmin;
00128          if (temp < 0.) { return 0.; }
00129          if (ProposedStep > temp) { ProposedStep = temp; }
00130        }         
00131      }
00132    }
00133    return ProposedStep;
00134 }
00135 
00136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00137 
00138 G4VParticleChange*
00139 G4UserSpecialCuts::PostStepDoIt( const G4Track& aTrack,
00140                                  const G4Step&  )
00141 //
00142 // Kill the current particle, if requested by G4UserLimits
00143 //
00144 {
00145    aParticleChange.Initialize(aTrack);
00146    aParticleChange.ProposeEnergy(0.) ;
00147    aParticleChange.ProposeLocalEnergyDeposit(aTrack.GetKineticEnergy()) ;
00148    aParticleChange.ProposeTrackStatus(fStopAndKill);
00149    return &aParticleChange;
00150 }
00151 
00152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 

Generated on Mon May 27 17:50:08 2013 for Geant4 by  doxygen 1.4.7