Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:54

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 TrackingAction.cc
0037 /// \brief Implementation of the TrackingAction class
0038 
0039 #include "TrackingAction.hh"
0040 
0041 #include "G4Alpha.hh"
0042 #include "G4AnalysisManager.hh"
0043 #include "G4DNAGenericIonsManager.hh"
0044 #include "G4Electron.hh"
0045 #include "G4Gamma.hh"
0046 #include "G4PhysicalConstants.hh"
0047 #include "G4Proton.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4Track.hh"
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 TrackingAction::TrackingAction() {}
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 void TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
0058 {
0059   G4double flagParticle = -1.;
0060   G4double x, y, z, dirx, diry, dirz;
0061 
0062   G4ParticleDefinition* partDef = aTrack->GetDynamicParticle()->GetDefinition();
0063 
0064   if (partDef == G4Gamma::GammaDefinition()) flagParticle = 0;
0065 
0066   if (partDef == G4Electron::ElectronDefinition()) flagParticle = 1;
0067 
0068   if (partDef == G4Proton::ProtonDefinition()) flagParticle = 2;
0069 
0070   if (partDef == G4Alpha::AlphaDefinition()) flagParticle = 4;
0071 
0072   G4DNAGenericIonsManager* instance;
0073   instance = G4DNAGenericIonsManager::Instance();
0074 
0075   if (partDef == instance->GetIon("hydrogen")) flagParticle = 3;
0076 
0077   if (partDef == instance->GetIon("alpha+")) flagParticle = 5;
0078 
0079   if (partDef == instance->GetIon("helium")) flagParticle = 6;
0080 
0081   //
0082 
0083   x = aTrack->GetPosition().x() / nanometer;
0084   y = aTrack->GetPosition().y() / nanometer;
0085   z = aTrack->GetPosition().z() / nanometer;
0086 
0087   dirx = aTrack->GetMomentumDirection().x();
0088   diry = aTrack->GetMomentumDirection().y();
0089   dirz = aTrack->GetMomentumDirection().z();
0090 
0091   // Call analysis manager
0092   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0093 
0094   // Fill track information ntuple
0095   analysisManager->FillNtupleDColumn(1, 0, flagParticle);
0096   analysisManager->FillNtupleDColumn(1, 1, x);
0097   analysisManager->FillNtupleDColumn(1, 2, y);
0098   analysisManager->FillNtupleDColumn(1, 3, z);
0099   analysisManager->FillNtupleDColumn(1, 4, dirx);
0100   analysisManager->FillNtupleDColumn(1, 5, diry);
0101   analysisManager->FillNtupleDColumn(1, 6, dirz);
0102   analysisManager->FillNtupleDColumn(1, 7, aTrack->GetKineticEnergy() / eV);
0103   analysisManager->FillNtupleIColumn(1, 8, aTrack->GetTrackID());
0104   analysisManager->FillNtupleIColumn(1, 9, aTrack->GetParentID());
0105   analysisManager->AddNtupleRow(1);
0106 }
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0109 
0110 void TrackingAction::PostUserTrackingAction(const G4Track*) {}