Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 08:28:15

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 TrackingAction.cc
0027 /// \brief Implementation of the TrackingAction class
0028 
0029 #include "TrackingAction.hh"
0030 
0031 #include "EventAction.hh"
0032 #include "HistoManager.hh"
0033 #include "Run.hh"
0034 #include "TrackingMessenger.hh"
0035 
0036 #include "G4RunManager.hh"
0037 #include "G4StepStatus.hh"
0038 #include "G4Track.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 TrackingAction::TrackingAction(EventAction* evt) : fTrackMessenger(nullptr), fEventAct(evt)
0043 {
0044   fTrackMessenger = new TrackingMessenger(this);
0045 }
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 TrackingAction::~TrackingAction()
0050 {
0051   delete fTrackMessenger;
0052 }
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 void TrackingAction::PreUserTrackingAction(const G4Track* track)
0057 {
0058   // count secondary particles
0059   if (track->GetTrackID() == 1) return;
0060 
0061   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0062 
0063   G4int iabs = track->GetTouchableHandle()->GetCopyNumber();
0064   G4String name = track->GetDefinition()->GetParticleName();
0065   G4double meanLife = track->GetDefinition()->GetPDGLifeTime();
0066   G4double energy = track->GetKineticEnergy();
0067   if (fParticleCount && (iabs > 0)) run->ParticleCount(iabs, name, energy, meanLife);
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 void TrackingAction::PostUserTrackingAction(const G4Track* track)
0073 {
0074   // get Run
0075   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0076 
0077   // where are we ?
0078   G4StepStatus status = track->GetStep()->GetPostStepPoint()->GetStepStatus();
0079 
0080   // status of primary particle : absorbed, transmited, reflected ?
0081   if (track->GetTrackID() == 1) {
0082     G4int flag = 0;
0083     if (status == fWorldBoundary) {
0084       if (track->GetMomentumDirection().x() > 0.)
0085         flag = 1;
0086       else
0087         flag = 2;
0088     }
0089     run->AddTrackStatus(flag);
0090   }
0091 
0092   // keep only emerging particles
0093   if (status != fWorldBoundary) return;
0094 
0095   // count particles
0096   const G4ParticleDefinition* particle = track->GetParticleDefinition();
0097   G4String name = particle->GetParticleName();
0098   G4double meanLife = particle->GetPDGLifeTime();
0099   G4double energy = track->GetKineticEnergy();
0100   run->ParticleCount(0, name, energy, meanLife);
0101   fEventAct->AddEleak(energy);
0102 
0103   ////G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0104 }
0105 
0106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......