File indexing completed on 2025-12-15 09:31:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include "TrackingAction.hh"
0034
0035 #include "HistoManager.hh"
0036
0037 #include "G4PhysicalConstants.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4Track.hh"
0040
0041
0042
0043 TrackingAction::TrackingAction() : G4UserTrackingAction() {}
0044
0045
0046
0047 void TrackingAction::PreUserTrackingAction(const G4Track* track)
0048 {
0049 G4int pid = track->GetDynamicParticle()->GetPDGcode();
0050 G4double ekin = track->GetKineticEnergy();
0051 G4ThreeVector vertex = track->GetPosition();
0052 G4ThreeVector direction = track->GetMomentumDirection();
0053 G4double weight = track->GetWeight();
0054
0055 G4double x = vertex.x(), y = vertex.y(), z = vertex.z();
0056 G4double theta = direction.theta(), phi = direction.phi();
0057 if (phi < 0.) phi += twopi;
0058 G4double cost = std::cos(theta);
0059
0060 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0061
0062 G4double r = vertex.mag();
0063 G4double dr = analysisManager->GetH1Width(2);
0064 G4double dv = 2 * twopi * r * r * dr;
0065
0066
0067 analysisManager->FillH1(1, ekin);
0068 if (dv > 0.) analysisManager->FillH1(2, r, 1. / dv);
0069 analysisManager->FillH1(3, cost);
0070 analysisManager->FillH1(4, phi);
0071 analysisManager->FillH2(1, x, y);
0072 analysisManager->FillH2(2, y, z);
0073 analysisManager->FillH2(3, z, x);
0074 analysisManager->FillH2(4, phi, cost);
0075 analysisManager->FillH2(5, phi, theta);
0076
0077
0078 analysisManager->FillNtupleIColumn(0, pid);
0079 analysisManager->FillNtupleDColumn(1, ekin);
0080 analysisManager->FillNtupleDColumn(2, x);
0081 analysisManager->FillNtupleDColumn(3, y);
0082 analysisManager->FillNtupleDColumn(4, z);
0083 analysisManager->FillNtupleDColumn(5, theta);
0084 analysisManager->FillNtupleDColumn(6, phi);
0085 analysisManager->FillNtupleDColumn(7, weight);
0086 analysisManager->AddNtupleRow();
0087 }
0088
0089