Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 07:56:39

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 //---------------------------------------------------------------------------
0030 //
0031 // ClassName:   G4ElectronCapture
0032 //
0033 // Description: The process to kill particles to save CPU
0034 //
0035 // Author:      V.Ivanchenko 31 August 2010
0036 //
0037 //----------------------------------------------------------------------------
0038 //
0039 // This example is provided by the Geant4-DNA collaboration
0040 // Any report or published results obtained using the Geant4-DNA software
0041 // and the DNA geometry given in the Geom_DNA example
0042 // shall cite the following Geant4-DNA collaboration publications:
0043 // [1] NIM B 298 (2013) 47-54
0044 // [2] Med. Phys. 37 (2010) 4692-4708
0045 // The Geant4-DNA web site is available at http://geant4-dna.org
0046 //
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 //
0049 
0050 #include "G4ElectronCapture.hh"
0051 
0052 #include "G4Electron.hh"
0053 #include "G4ParticleDefinition.hh"
0054 #include "G4Region.hh"
0055 #include "G4RegionStore.hh"
0056 #include "G4Step.hh"
0057 #include "G4SystemOfUnits.hh"
0058 #include "G4Track.hh"
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0061 
0062 G4ElectronCapture::G4ElectronCapture(const G4String& regName, G4double ekinlim)
0063   : G4VDiscreteProcess("eCapture", fElectromagnetic),
0064     fKinEnergyThreshold(ekinlim),
0065     fRegionName(regName),
0066     region(0)
0067 {
0068   if (regName == "" || regName == "world") {
0069     fRegionName = "DefaultRegionForTheWorld";
0070   }
0071   pParticleChange = &fParticleChange;
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 
0076 G4ElectronCapture::~G4ElectronCapture() {}
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 void G4ElectronCapture::SetKinEnergyLimit(G4double val)
0081 {
0082   fKinEnergyThreshold = val;
0083   if (verboseLevel > 0) {
0084     G4cout << "### G4ElectronCapture: Tracking cut E(MeV) = " << fKinEnergyThreshold / MeV
0085            << G4endl;
0086   }
0087 }
0088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0089 
0090 void G4ElectronCapture::BuildPhysicsTable(const G4ParticleDefinition&)
0091 {
0092   region = (G4RegionStore::GetInstance())->GetRegion(fRegionName);
0093   if (region && verboseLevel > 0) {
0094     G4cout << "### G4ElectronCapture: Tracking cut E(MeV) = " << fKinEnergyThreshold / MeV
0095            << " is assigned to " << fRegionName << G4endl;
0096   }
0097 }
0098 
0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0100 
0101 G4bool G4ElectronCapture::IsApplicable(const G4ParticleDefinition&)
0102 {
0103   return true;
0104 }
0105 
0106 G4double G4ElectronCapture::PostStepGetPhysicalInteractionLength(const G4Track& aTrack, G4double,
0107                                                                  G4ForceCondition* condition)
0108 {
0109   // condition is set to "Not Forced"
0110   *condition = NotForced;
0111 
0112   G4double limit = DBL_MAX;
0113   if (region) {
0114     if (aTrack.GetVolume()->GetLogicalVolume()->GetRegion() == region
0115         && aTrack.GetKineticEnergy() < fKinEnergyThreshold)
0116     {
0117       limit = 0.0;
0118     }
0119   }
0120   return limit;
0121 }
0122 
0123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0124 
0125 G4VParticleChange* G4ElectronCapture::PostStepDoIt(const G4Track& aTrack, const G4Step&)
0126 {
0127   pParticleChange->Initialize(aTrack);
0128   pParticleChange->ProposeTrackStatus(fStopAndKill);
0129   pParticleChange->ProposeLocalEnergyDeposit(aTrack.GetKineticEnergy());
0130   fParticleChange.SetProposedKineticEnergy(0.0);
0131   return pParticleChange;
0132 }
0133 
0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0135 
0136 G4double G4ElectronCapture::GetMeanFreePath(const G4Track&, G4double, G4ForceCondition*)
0137 {
0138   return DBL_MAX;
0139 }
0140 
0141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......