Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 08:32:27

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 "DetectorConstruction.hh"
0032 #include "HistoManager.hh"
0033 #include "Run.hh"
0034 
0035 #include "G4HadronicProcessType.hh"
0036 #include "G4RunManager.hh"
0037 #include "G4SystemOfUnits.hh"
0038 #include "G4Track.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 TrackingAction::TrackingAction(DetectorConstruction* det) : fDetector(det) {}
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 void TrackingAction::PreUserTrackingAction(const G4Track* track)
0047 {
0048   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0049 
0050   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0051 
0052   // which volume ?
0053   //
0054   G4LogicalVolume* lVolume = track->GetVolume()->GetLogicalVolume();
0055   G4int iVol = 0;
0056   if (lVolume == fDetector->GetLogicTarget()) iVol = 1;
0057   if (lVolume == fDetector->GetLogicDetector()) iVol = 2;
0058 
0059   // secondary particles only
0060   if (track->GetTrackID() == 1) return;
0061 
0062   const G4ParticleDefinition* particle = track->GetParticleDefinition();
0063   G4String name = particle->GetParticleName();
0064   G4int pid = particle->GetPDGEncoding();
0065   G4int Z = particle->GetAtomicNumber();
0066   G4int A = particle->GetAtomicMass();
0067   G4double charge = particle->GetPDGCharge();
0068   G4double energy = track->GetKineticEnergy();
0069   G4double time = track->GetGlobalTime();
0070   G4double weight = track->GetWeight();
0071 
0072   run->ParticleCount(name, energy, iVol);
0073 
0074   // Radioactive decay products
0075   G4int processType = track->GetCreatorProcess()->GetProcessSubType();
0076   if (processType == fRadioactiveDecay) {
0077     // fill ntuple id = 3
0078     G4int id = 3;
0079     analysisManager->FillNtupleDColumn(id, 0, double(pid));
0080     analysisManager->FillNtupleDColumn(id, 1, double(Z));
0081     analysisManager->FillNtupleDColumn(id, 2, double(A));
0082     analysisManager->FillNtupleDColumn(id, 3, energy);
0083     analysisManager->FillNtupleDColumn(id, 4, time / s);
0084     analysisManager->FillNtupleDColumn(id, 5, weight);
0085     analysisManager->AddNtupleRow(id);
0086 
0087     if (charge < 3.) {
0088       // fill ntuple id = 0
0089       id = 0;
0090       analysisManager->FillNtupleDColumn(id, 0, double(pid));
0091       analysisManager->FillNtupleDColumn(id, 1, energy);
0092       analysisManager->FillNtupleDColumn(id, 2, time / s);
0093       analysisManager->FillNtupleDColumn(id, 3, weight);
0094       analysisManager->AddNtupleRow(id);
0095 
0096       analysisManager->FillH1(6, energy, weight);
0097       analysisManager->FillH1(7, energy, weight);
0098       analysisManager->FillH1(8, energy, weight);
0099     }
0100   }
0101 
0102   // all unstable ions produced in target
0103   G4bool unstableIon = ((charge > 2.) && !(particle->GetPDGStable()));
0104   if ((unstableIon) && (iVol == 1)) {
0105     // fill ntuple id = 1
0106     G4int id = 1;
0107     analysisManager->FillNtupleDColumn(id, 0, double(pid));
0108     analysisManager->FillNtupleDColumn(id, 1, time / s);
0109     analysisManager->FillNtupleDColumn(id, 2, weight);
0110     analysisManager->AddNtupleRow(id);
0111   }
0112 }
0113 
0114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0115 
0116 void TrackingAction::PostUserTrackingAction(const G4Track*) {}
0117 
0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......