File indexing completed on 2025-02-23 09:22:33
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 #include "Par02TrackingAction.hh"
0031
0032 #include "Par02EventInformation.hh"
0033 #include "Par02Output.hh"
0034 #include "Par02PrimaryParticleInformation.hh"
0035
0036 #include "G4EventManager.hh"
0037 #include "G4RunManager.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4ThreeVector.hh"
0040 #include "G4TrackingManager.hh"
0041 #include "Randomize.hh"
0042
0043 #include <iomanip>
0044 #include <vector>
0045
0046
0047
0048 Par02TrackingAction::Par02TrackingAction() : G4UserTrackingAction() {}
0049
0050
0051
0052 Par02TrackingAction::~Par02TrackingAction() = default;
0053
0054
0055
0056 void Par02TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
0057 {
0058
0059
0060 if (aTrack->GetMomentum().perp() < 1.0 * MeV
0061 || std::abs(aTrack->GetMomentum().pseudoRapidity()) > 5.5)
0062 {
0063 ((G4Track*)aTrack)->SetTrackStatus(fStopAndKill);
0064 }
0065 }
0066
0067
0068
0069 void Par02TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
0070 {
0071 if (aTrack->GetTrackStatus() == fStopAndKill && aTrack->GetParentID() == 0) {
0072 auto info = (Par02PrimaryParticleInformation*)aTrack->GetDynamicParticle()
0073 ->GetPrimaryParticle()
0074 ->GetUserInformation();
0075
0076 Par02Output::Instance()->SaveTrack(Par02Output::eSaveMC, info->GetPartID(), info->GetPDG(),
0077 info->GetMCMomentum() / MeV);
0078 Par02Output::Instance()->SaveTrack(Par02Output::eSaveTracker, info->GetPartID(), info->GetPDG(),
0079 info->GetTrackerMomentum() / MeV,
0080 info->GetTrackerResolution(), info->GetTrackerEfficiency());
0081 Par02Output::Instance()->SaveTrack(Par02Output::eSaveEMCal, info->GetPartID(), info->GetPDG(),
0082 info->GetEMCalPosition() / mm, info->GetEMCalResolution(),
0083 info->GetEMCalEfficiency(), info->GetEMCalEnergy() / MeV);
0084 Par02Output::Instance()->SaveTrack(Par02Output::eSaveHCal, info->GetPartID(), info->GetPDG(),
0085 info->GetHCalPosition() / mm, info->GetHCalResolution(),
0086 info->GetHCalEfficiency(), info->GetHCalEnergy() / MeV);
0087 }
0088 }
0089
0090