Back to home page

EIC code displayed by LXR

 
 

    


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

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 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "TrackingAction.hh"
0034 
0035 #include "EventAction.hh"
0036 #include "HistoManager.hh"
0037 #include "Run.hh"
0038 
0039 #include "G4IonTable.hh"
0040 #include "G4ParticleTypes.hh"
0041 #include "G4RunManager.hh"
0042 #include "G4StepStatus.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4Track.hh"
0045 #include "G4UnitsTable.hh"
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 TrackingAction::TrackingAction(EventAction* event) : fEventAction(event) {}
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 void TrackingAction::PreUserTrackingAction(const G4Track* track)
0054 {
0055   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0056 
0057   G4ParticleDefinition* particle = track->GetDefinition();
0058   G4String name = particle->GetParticleName();
0059   G4double meanLife = particle->GetPDGLifeTime();
0060   G4double ekin = track->GetKineticEnergy();
0061   fTimeBirth = track->GetGlobalTime();
0062 
0063   // count secondary particles (with meanLife > 0)
0064   if ((track->GetTrackID() > 1) && (meanLife != 0.)) run->ParticleCount(name, ekin, meanLife);
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 void TrackingAction::PostUserTrackingAction(const G4Track* track)
0070 {
0071   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0072 
0073   G4AnalysisManager* analysis = G4AnalysisManager::Instance();
0074 
0075   const G4ParticleDefinition* particle = track->GetParticleDefinition();
0076   G4String name = particle->GetParticleName();
0077   G4double meanLife = particle->GetPDGLifeTime();
0078   G4double ekin = track->GetKineticEnergy();
0079   fTimeEnd = track->GetGlobalTime();
0080   if ((particle->GetPDGStable()) && (ekin == 0.)) fTimeEnd = DBL_MAX;
0081 
0082   // count population of ions with meanLife > 0.
0083   if ((G4IonTable::IsIon(particle)) && (meanLife != 0.)) {
0084     G4int id = run->GetIonId(name);
0085     G4double unit = analysis->GetH1Unit(id);
0086     G4double tmin = analysis->GetH1Xmin(id) * unit;
0087     G4double tmax = analysis->GetH1Xmax(id) * unit;
0088     G4double binWidth = analysis->GetH1Width(id) * unit;
0089     G4double weight = track->GetWeight();
0090 
0091     G4double t1 = std::max(fTimeBirth, tmin);
0092     G4double t2 = std::min(fTimeEnd, tmax);
0093     for (G4double time = t1; time < t2; time += binWidth)
0094       analysis->FillH1(id, time, weight);
0095   }
0096 
0097   // keep only emerging particles
0098   G4StepStatus status = track->GetStep()->GetPostStepPoint()->GetStepStatus();
0099   if (status != fWorldBoundary) return;
0100 
0101   fEventAction->AddEflow(ekin);
0102   run->ParticleFlux(name, ekin);
0103 
0104   // histograms: energy flow and activities of emerging particles
0105 
0106   G4int ih1 = 0, ih2 = 0;
0107   G4String type = particle->GetParticleType();
0108   G4double charge = particle->GetPDGCharge();
0109   G4double time = track->GetGlobalTime();
0110   G4double weight = track->GetWeight();
0111   if (charge > 3.) {
0112     ih1 = 10;
0113     ih2 = 20;
0114   }
0115   else if (particle == G4Gamma::Gamma()) {
0116     ih1 = 4;
0117     ih2 = 14;
0118   }
0119   else if (particle == G4Electron::Electron()) {
0120     ih1 = 5;
0121     ih2 = 15;
0122   }
0123   else if (particle == G4Positron::Positron()) {
0124     ih1 = 5;
0125     ih2 = 15;
0126   }
0127   else if (particle == G4Neutron::Neutron()) {
0128     ih1 = 6;
0129     ih2 = 16;
0130   }
0131   else if (particle == G4Proton::Proton()) {
0132     ih1 = 7;
0133     ih2 = 17;
0134   }
0135   else if (particle == G4Deuteron::Deuteron()) {
0136     ih1 = 8;
0137     ih2 = 18;
0138   }
0139   else if (particle == G4Alpha::Alpha()) {
0140     ih1 = 9;
0141     ih2 = 19;
0142   }
0143   else if (type == "nucleus") {
0144     ih1 = 10;
0145     ih2 = 20;
0146   }
0147   else if (type == "baryon") {
0148     ih1 = 11;
0149     ih2 = 21;
0150   }
0151   else if (type == "meson") {
0152     ih1 = 12;
0153     ih2 = 22;
0154   }
0155   else if (type == "lepton") {
0156     ih1 = 13;
0157     ih2 = 23;
0158   };
0159   if (ih1 > 0) analysis->FillH1(ih1, ekin, weight);
0160   if (ih2 > 0) analysis->FillH1(ih2, time, weight);
0161 }
0162 
0163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......