Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-08 07:53:43

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file G4ElectronCapture.cc
0027 /// \brief Implementation of the G4ElectronCapture class
0028 
0029 // This example is provided by the Geant4-DNA collaboration
0030 // Any report or published results obtained using the Geant4-DNA software
0031 // shall cite the following Geant4-DNA collaboration publication:
0032 // Med. Phys. 37 (2010) 4692-4708
0033 // The Geant4-DNA web site is available at http://geant4-dna.org
0034 //
0035 //---------------------------------------------------------------------------
0036 //
0037 // ClassName:   G4ElectronCapture
0038 //
0039 // Description: The process to kill particles to save CPU
0040 //
0041 // Author:      V.Ivanchenko 31 August 2010
0042 //
0043 //----------------------------------------------------------------------------
0044 //
0045 
0046 #include "G4ElectronCapture.hh"
0047 
0048 #include "G4Electron.hh"
0049 #include "G4ParticleDefinition.hh"
0050 #include "G4Region.hh"
0051 #include "G4RegionStore.hh"
0052 #include "G4Step.hh"
0053 #include "G4SystemOfUnits.hh"
0054 #include "G4Track.hh"
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 G4ElectronCapture::G4ElectronCapture(const G4String& regName, G4double ekinlim)
0059   : G4VDiscreteProcess("eCapture", fElectromagnetic),
0060     fKinEnergyThreshold(ekinlim),
0061     fRegionName(regName),
0062     fpRegion(0)
0063 {
0064   if (regName == "" || regName == "world") {
0065     fRegionName = "DefaultRegionForTheWorld";
0066   }
0067   pParticleChange = &fParticleChange;
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 G4ElectronCapture::~G4ElectronCapture() {}
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 
0076 void G4ElectronCapture::SetKinEnergyLimit(G4double val)
0077 {
0078   fKinEnergyThreshold = val;
0079   if (verboseLevel > 0) {
0080     G4cout << "### G4ElectronCapture: Tracking cut E(MeV) = " << fKinEnergyThreshold / MeV
0081            << G4endl;
0082   }
0083 }
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 void G4ElectronCapture::BuildPhysicsTable(const G4ParticleDefinition&)
0088 {
0089   fpRegion = (G4RegionStore::GetInstance())->GetRegion(fRegionName);
0090   if (fpRegion && verboseLevel > 0) {
0091     G4cout << "### G4ElectronCapture: Tracking cut E(MeV) = " << fKinEnergyThreshold / MeV
0092            << " is assigned to " << fRegionName << G4endl;
0093   }
0094 }
0095 
0096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0097 
0098 G4bool G4ElectronCapture::IsApplicable(const G4ParticleDefinition&)
0099 {
0100   return true;
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 
0105 G4double G4ElectronCapture::PostStepGetPhysicalInteractionLength(const G4Track& aTrack, G4double,
0106                                                                  G4ForceCondition* condition)
0107 {
0108   // condition is set to "Not Forced"
0109   *condition = NotForced;
0110 
0111   G4double limit = DBL_MAX;
0112   if (fpRegion) {
0113     if (aTrack.GetVolume()->GetLogicalVolume()->GetRegion() == fpRegion
0114         && aTrack.GetKineticEnergy() < fKinEnergyThreshold)
0115     {
0116       limit = 0.0;
0117     }
0118   }
0119   return limit;
0120 }
0121 
0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0123 
0124 G4VParticleChange* G4ElectronCapture::PostStepDoIt(const G4Track& aTrack, const G4Step&)
0125 {
0126   pParticleChange->Initialize(aTrack);
0127   pParticleChange->ProposeTrackStatus(fStopAndKill);
0128   pParticleChange->ProposeLocalEnergyDeposit(aTrack.GetKineticEnergy());
0129   fParticleChange.SetProposedKineticEnergy(0.0);
0130   return pParticleChange;
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0134 
0135 G4double G4ElectronCapture::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*)
0136 {
0137   return DBL_MAX;
0138 }