File indexing completed on 2026-04-09 07:52:16
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 #include "SteppingAction.hh"
0030
0031 #include "DetectorConstruction.hh"
0032 #include "HistoManager.hh"
0033
0034 #include "G4RunManager.hh"
0035 #include "G4DNAChemistryManager.hh"
0036
0037
0038 SteppingAction::SteppingAction() {
0039 fpDetector = dynamic_cast<const DetectorConstruction *>(
0040 G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0041 fRNP = fpDetector->GetNPRadius() / CLHEP::nm;
0042 fRAbs = fpDetector->GetAbsRadius() / CLHEP::nm;
0043 fTrackCut = fpDetector->GetTrackingCut() / CLHEP::eV;
0044 }
0045
0046
0047
0048 void SteppingAction::UserSteppingAction(const G4Step *aStep) {
0049
0050 fpDetector = dynamic_cast<const DetectorConstruction *>(
0051 G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0052 fRNP = fpDetector->GetNPRadius() / CLHEP::nm;
0053 fRAbs = fpDetector->GetAbsRadius() / CLHEP::nm;
0054 fTrackCut = fpDetector->GetTrackingCut() / CLHEP::eV;
0055
0056 const auto pre = aStep->GetPreStepPoint();
0057 const auto post = aStep->GetPostStepPoint();
0058
0059 const G4ThreeVector &pos = pre->GetPosition();
0060 const G4ThreeVector &postpos = post->GetPosition();
0061
0062 const G4double R = pos.mag() / CLHEP::nm;
0063
0064 G4AnalysisManager *analysisManager = G4AnalysisManager::Instance();
0065
0066
0067 if (fRNP < R) {
0068 const G4double energy = aStep->GetTotalEnergyDeposit() / CLHEP::joule;
0069 analysisManager->FillH1(1, R, energy);
0070
0071
0072 if (std::abs(pos.z()) < 10 * CLHEP::nm) {
0073 const G4double theta = std::atan2(pos.y(), pos.x()) / CLHEP::deg;
0074 if (0 <= theta) {
0075 analysisManager->FillH2(0, theta, R, energy);
0076 } else {
0077 analysisManager->FillH2(0, theta + 360, R, energy);
0078 }
0079 }
0080 }
0081
0082
0083 if (pre->GetPhysicalVolume()->GetName() != "NanoParticle") {
0084 return;
0085 }
0086 if (post->GetStepStatus() != fGeomBoundary) {
0087 return;
0088 }
0089
0090
0091 G4Track *track = aStep->GetTrack();
0092 const G4double trackE = track->GetKineticEnergy() / CLHEP::eV;
0093
0094 if (track->GetTrackID() == 1) {
0095 if (pos.x() < 0) {
0096 analysisManager->FillH1(8, trackE);
0097 } else {
0098 analysisManager->FillH1(9, trackE);
0099 }
0100 if (!G4DNAChemistryManager::IsActivated()) {
0101 track->SetTrackStatus(fStopAndKill);
0102 }
0103 return;
0104 }
0105
0106 const G4ThreeVector &dir = post->GetMomentumDirection();
0107 if (dir.dot(postpos) < 0.0) {
0108 return;
0109 }
0110
0111 if (trackE < fTrackCut) {
0112 track->SetTrackStatus(fStopAndKill);
0113 return;
0114 }
0115
0116 if (track->GetDefinition()->GetPDGCharge() != 0) {
0117 analysisManager->FillH1(4, trackE);
0118 } else {
0119 analysisManager->FillH1(5, trackE);
0120 }
0121 }
0122
0123