Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:04

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 publication:
0029 // Med. Phys. 37 (2010) 4692-4708
0030 // and papers
0031 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507
0032 // O. Belov et al. Physica Medica 32 (2016) 1510-1520
0033 // The Geant4-DNA web site is available at http://geant4-dna.org
0034 //
0035 // -------------------------------------------------------------------
0036 // November 2016
0037 // -------------------------------------------------------------------
0038 //
0039 /// \file TrackingAction.cc
0040 /// \brief Implementation of the TrackingAction class
0041 
0042 #include "TrackingAction.hh"
0043 
0044 #include "G4Electron.hh"
0045 #include "G4Gamma.hh"
0046 #include "G4Region.hh"
0047 #include "G4RegionStore.hh"
0048 #include "G4Track.hh"
0049 #include "G4VSolid.hh"
0050 //
0051 #include "G4LogicalVolume.hh"
0052 #include "G4LogicalVolumeStore.hh"
0053 #include "G4PhysicalVolumeStore.hh"
0054 #include "G4SystemOfUnits.hh"
0055 #include "G4UnitsTable.hh"
0056 #include "G4VPhysicalVolume.hh"
0057 #include "G4ios.hh"
0058 //
0059 // Bosons
0060 #include "G4ChargedGeantino.hh"
0061 #include "G4Gamma.hh"
0062 #include "G4Geantino.hh"
0063 // leptons
0064 #include "G4AntiNeutrinoE.hh"
0065 #include "G4AntiNeutrinoMu.hh"
0066 #include "G4Electron.hh"
0067 #include "G4MuonMinus.hh"
0068 #include "G4MuonPlus.hh"
0069 #include "G4NeutrinoE.hh"
0070 #include "G4NeutrinoMu.hh"
0071 #include "G4Positron.hh"
0072 // Mesons
0073 #include "G4AntiKaonZero.hh"
0074 #include "G4Eta.hh"
0075 #include "G4EtaPrime.hh"
0076 #include "G4KaonMinus.hh"
0077 #include "G4KaonPlus.hh"
0078 #include "G4KaonZero.hh"
0079 #include "G4KaonZeroLong.hh"
0080 #include "G4KaonZeroShort.hh"
0081 #include "G4PionMinus.hh"
0082 #include "G4PionPlus.hh"
0083 #include "G4PionZero.hh"
0084 // Baryons
0085 #include "G4AntiNeutron.hh"
0086 #include "G4AntiProton.hh"
0087 #include "G4Neutron.hh"
0088 #include "G4Proton.hh"
0089 // Nuclei
0090 #include "Run.hh"
0091 
0092 #include "G4Alpha.hh"
0093 #include "G4Deuteron.hh"
0094 #include "G4GenericIon.hh"
0095 #include "G4He3.hh"
0096 #include "G4RunManager.hh"
0097 #include "G4Step.hh"
0098 #include "G4StepStatus.hh"
0099 #include "G4Triton.hh"
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 TrackingAction::TrackingAction() : G4UserTrackingAction(), RunInitObserver(), fpTargetRegion(0) {}
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 
0107 TrackingAction::~TrackingAction()
0108 {
0109   fpTargetRegion = 0;
0110 }
0111 
0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0113 
0114 void TrackingAction::PreUserTrackingAction(const G4Track* track)
0115 {
0116   // Target volumes
0117   G4VPhysicalVolume* volumeStep = track->GetTouchableHandle()->GetVolume();
0118   G4VPhysicalVolume* volumeMedium = G4PhysicalVolumeStore::GetInstance()->GetVolume("Medium");
0119   G4VPhysicalVolume* volumeSlice = G4PhysicalVolumeStore::GetInstance()->GetVolume("BoundingSlice");
0120   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0121 
0122   // count secondary particles
0123   if (track->GetTrackID() == 1) return;
0124   G4String name = track->GetDefinition()->GetParticleName();
0125   G4double energy = track->GetKineticEnergy();
0126 
0127   // outside bounding slice
0128   // if (volumeStep == volumeMedium) run->ParticleCount(name,energy);
0129   // inside bounding slice
0130   // if (volumeStep != volumeMedium) run->ParticleCountNeuron(name,energy);
0131 
0132   // particles outside neuron structure
0133   if (volumeStep == volumeMedium || volumeStep == volumeSlice) {
0134     run->ParticleCount(name, energy);
0135   }
0136   // count secondary particles in neuron
0137   else  // if (volumeStep != volumeMedium && volumeStep != volumeSlice)
0138   {
0139     run->ParticleCountNeuron(name, energy);
0140   }
0141 }
0142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0143 
0144 void TrackingAction::PostUserTrackingAction(const G4Track* track)
0145 {
0146   if (track->GetTrackID() == 1) {
0147     G4cout << "End of tracking primary particle, its final energy is :"
0148            << G4BestUnit(track->GetKineticEnergy(), "Energy") << G4endl;
0149   }
0150 
0151   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0152   G4double tracklen = track->GetTrackLength();
0153   if (track->GetTrackID() == 1) run->SetTrackLength(tracklen);
0154   // G4cout<< " track length = " << tracklen / um << G4endl;
0155 }
0156 
0157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0158 void TrackingAction::Initialize()
0159 {
0160   // fpTargetRegion = G4RegionStore::GetInstance()->GetRegion("BoundingSlice");
0161 }