File indexing completed on 2026-04-18 07:42:23
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
0034
0035
0036
0037
0038
0039
0040
0041 #include "SteppingAction.hh"
0042 #include "SteppingMessenger.hh"
0043 #include "DetectorConstruction.hh"
0044 #include "PrimaryGeneratorAction.hh"
0045 #include "RunAction.hh"
0046
0047 #include "G4Alpha.hh"
0048 #include "G4AnalysisManager.hh"
0049 #include "G4DNAGenericIonsManager.hh"
0050 #include "G4Electron.hh"
0051 #include "G4Event.hh"
0052 #include "G4EventManager.hh"
0053 #include "G4Gamma.hh"
0054 #include "G4Proton.hh"
0055 #include "G4SteppingManager.hh"
0056 #include "G4SystemOfUnits.hh"
0057
0058
0059
0060 SteppingAction::SteppingAction(DetectorConstruction* det) : G4UserSteppingAction(),
0061 fpDetectorConstruction(det)
0062 {
0063 fpSteppingMessenger = new SteppingMessenger(this);
0064 }
0065
0066
0067
0068 SteppingAction::~SteppingAction()
0069 {
0070 delete fpSteppingMessenger;
0071 }
0072
0073
0074
0075 void SteppingAction::UserSteppingAction(const G4Step* step)
0076 {
0077
0078 if (!step->GetPostStepPoint()) return;
0079
0080
0081
0082
0083 G4StepPoint* preStep = step->GetPreStepPoint();
0084
0085 const G4LogicalVolume* preVolume =
0086 preStep->GetPhysicalVolume()->GetLogicalVolume();
0087
0088
0089
0090 G4StepPoint* postStep = step->GetPostStepPoint();
0091
0092
0093 if (postStep->GetStepStatus() == fWorldBoundary ) return;
0094
0095
0096 const G4LogicalVolume* postVolume =
0097 postStep->GetPhysicalVolume()->GetLogicalVolume();
0098
0099
0100
0101 if ( postVolume == fpDetectorConstruction->GetLogicalScorer() &&
0102 preVolume == fpDetectorConstruction->GetLogicalScorer() )
0103 {
0104 if (fKill) step->GetTrack()->SetTrackStatus(fKillTrackAndSecondaries);
0105 }
0106
0107
0108
0109 if ( preStep->GetStepStatus() == fGeomBoundary )
0110 {
0111
0112
0113 G4double PDGCode = step->GetTrack()->GetParticleDefinition()->GetPDGEncoding();
0114
0115 G4double x = preStep->GetPosition().x() / micrometer;
0116 G4double y = preStep->GetPosition().y() / micrometer;
0117 G4double z = preStep->GetPosition().z() / micrometer;
0118
0119 G4ThreeVector direction = preStep->GetMomentumDirection();
0120 G4double xMom = direction.x();
0121 G4double yMom = direction.y();
0122 G4double zMom = direction.z();
0123
0124 G4double energy = preStep->GetKineticEnergy() / keV;
0125
0126
0127
0128 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0129
0130 analysisManager->FillNtupleDColumn(0, PDGCode);
0131 analysisManager->FillNtupleDColumn(1, x);
0132 analysisManager->FillNtupleDColumn(2, y);
0133 analysisManager->FillNtupleDColumn(3, z);
0134 analysisManager->FillNtupleDColumn(4, xMom);
0135 analysisManager->FillNtupleDColumn(5, yMom);
0136 analysisManager->FillNtupleDColumn(6, zMom);
0137 analysisManager->FillNtupleDColumn(7, energy);
0138
0139
0140 analysisManager->AddNtupleRow();
0141
0142
0143
0144
0145 }
0146
0147 }