Back to home page

EIC code displayed by LXR

 
 

    


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

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