Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-03 07:52:31

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 "HistoManager.hh"
0032 #include "Run.hh"
0033 
0034 #include "G4RunManager.hh"
0035 #include "G4SystemOfUnits.hh"
0036 #include "G4Track.hh"
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 void TrackingAction::PreUserTrackingAction(const G4Track*)
0041 {
0042   fNbStep1 = fNbStep2 = 0;
0043   fTrackLen1 = fTrackLen2 = 0.;
0044   fTime1 = fTime2 = 0.;
0045 }
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 void TrackingAction::UpdateTrackInfo(G4double ekin, G4double trackl, G4double time)
0050 {
0051   const G4double thermal = 1 * eV;
0052   if (ekin > thermal) {
0053     fNbStep1++;
0054     fTrackLen1 = trackl;
0055     fTime1 = time;
0056   }
0057   else {
0058     fNbStep2++;
0059     fTrackLen2 = trackl - fTrackLen1;
0060     fTime2 = time - fTime1;
0061   }
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 void TrackingAction::PostUserTrackingAction(const G4Track* track)
0067 {
0068   // keep only primary neutron
0069   //
0070   G4int trackID = track->GetTrackID();
0071   if (trackID > 1) return;
0072 
0073   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0074   run->SumTrackLength(fNbStep1, fNbStep2, fTrackLen1, fTrackLen2, fTime1, fTime2);
0075 
0076   // histograms
0077   //
0078   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0079   analysisManager->FillH1(1, fNbStep1);
0080   analysisManager->FillH1(2, fTrackLen1);
0081   analysisManager->FillH1(3, fTime1);
0082   analysisManager->FillH1(4, fNbStep2);
0083   analysisManager->FillH1(5, fTrackLen2);
0084   analysisManager->FillH1(6, fTime2);
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......