Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:06:48

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 // This example is provided by the Geant4-DNA collaboration
0027 // Any report or published results obtained using the Geant4-DNA software
0028 // shall cite the following Geant4-DNA collaboration publications:
0029 // Med. Phys. 45 (2018) e722-e739
0030 // Phys. Med. 31 (2015) 861-874
0031 // Med. Phys. 37 (2010) 4692-4708
0032 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
0033 //
0034 // The Geant4-DNA web site is available at http://geant4-dna.org
0035 //
0036 /// \file SteppingAction.cc
0037 /// \brief Implementation of the SteppingAction class
0038 
0039 #include "SteppingAction.hh"
0040 
0041 #include "G4DNAGenericIonsManager.hh"
0042 #include "G4Electron.hh"
0043 #include "G4Gamma.hh"
0044 #include "G4Proton.hh"
0045 #include "G4RunManager.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 SteppingAction::SteppingAction() : G4UserSteppingAction()
0050 {
0051   fSumOfStepLength = 0;
0052   fLength = 0;
0053   fDeltaE = -7;
0054   fTotalStoppingPower = -8;
0055   fTotalNumberOfSteps = 0;
0056   fNumberOfSteps = 0;
0057   fDepositedEnergy = 0;
0058 }
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0061 
0062 SteppingAction::~SteppingAction() {}
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 void SteppingAction::UserSteppingAction(const G4Step* step)
0067 {
0068   //*** WARNING: this line will kill all secondary e- and gammas ***
0069 
0070   if (step->GetTrack()->GetDefinition() == G4Electron::ElectronDefinition()
0071       && step->GetTrack()->GetTrackID() != 1)
0072     step->GetTrack()->SetTrackStatus(fStopAndKill);
0073 
0074   if (step->GetTrack()->GetDefinition() == G4Gamma::GammaDefinition())
0075     step->GetTrack()->SetTrackStatus(fStopAndKill);
0076 
0077   //
0078 
0079   G4double charge = step->GetTrack()->GetDefinition()->GetPDGCharge();
0080   G4double steplen = step->GetStepLength();
0081   G4double edep = step->GetTotalEnergyDeposit();
0082   G4int maxNumberOfSteps = -1;
0083 
0084   G4DNAGenericIonsManager* instance;
0085   instance = G4DNAGenericIonsManager::Instance();
0086 
0087   if (
0088     // ELECTRONS
0089     (step->GetTrack()->GetTrackID() == 1
0090      && step->GetTrack()->GetParticleDefinition() == G4Electron::ElectronDefinition())
0091 
0092     ||
0093 
0094     // PROTONS, HYDROGEN, ALPHA PARTICLES AND CHARGED STATES, IONS
0095     (charge != -1. && step->GetTrack()->GetParticleDefinition() != G4Gamma::GammaDefinition())
0096 
0097   )
0098   {
0099     fSumOfStepLength = fSumOfStepLength + steplen;
0100     fDepositedEnergy = fDepositedEnergy + edep;
0101     fNumberOfSteps = fNumberOfSteps + 1;
0102 
0103     // G4cout << fSumOfStepLength << " " << fDepositedEnergy << " " << fNumberOfSteps << G4endl;
0104 
0105     // ELECTRONS
0106 
0107     if (step->GetTrack()->GetParticleDefinition() == G4Electron::ElectronDefinition())
0108       maxNumberOfSteps = 1000;
0109 
0110     // PROTONS, HYDROGEN
0111 
0112     if (step->GetTrack()->GetParticleDefinition() == G4Proton::ProtonDefinition()
0113         || step->GetTrack()->GetParticleDefinition() == instance->GetIon("hydrogen"))
0114       maxNumberOfSteps = 1000;
0115 
0116     // He0, He+, He2+
0117 
0118     if (step->GetTrack()->GetParticleDefinition() == instance->GetIon("alpha++")
0119         || step->GetTrack()->GetParticleDefinition() == instance->GetIon("alpha+")
0120         || step->GetTrack()->GetParticleDefinition() == instance->GetIon("helium"))
0121       maxNumberOfSteps = 10000;
0122 
0123     // IONS (above helium)
0124     if (charge > 2) maxNumberOfSteps = 10000;
0125 
0126     // ALL
0127 
0128     if (fNumberOfSteps > maxNumberOfSteps) {
0129       fLength = fSumOfStepLength;
0130 
0131       fTotalStoppingPower = fDepositedEnergy / fLength;
0132       // G4cout << fTotalStoppingPower/(MeV/cm) << G4endl;
0133 
0134       G4RunManager::GetRunManager()->AbortEvent();
0135       fSumOfStepLength = 0.;
0136       fDepositedEnergy = 0;
0137       fNumberOfSteps = 0;
0138     };
0139   };
0140 }