File indexing completed on 2026-09-17 08:30:54
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 "HistoManager.hh"
0032 #include "Run.hh"
0033
0034 #include "G4RunManager.hh"
0035
0036
0037
0038 void SteppingAction::UserSteppingAction(const G4Step* aStep)
0039 {
0040 const G4StepPoint* endPoint = aStep->GetPostStepPoint();
0041 G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
0042
0043 Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0044
0045 G4bool transmit = (endPoint->GetStepStatus() <= fGeomBoundary);
0046 if (transmit) {
0047 run->CountProcesses(procName);
0048 }
0049 else {
0050
0051 G4double stepLength = aStep->GetStepLength();
0052 run->CountProcesses(procName);
0053 run->SumTrack(stepLength);
0054 }
0055
0056
0057
0058 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0059
0060
0061
0062 G4int id = 1;
0063 if (aStep->GetTrack()->GetTrackStatus() == fAlive) {
0064 G4double energy = endPoint->GetKineticEnergy();
0065 analysisManager->FillH1(id, energy);
0066
0067 id = 2;
0068 G4ThreeVector direction = endPoint->GetMomentumDirection();
0069 G4double costeta = direction.x();
0070 analysisManager->FillH1(id, costeta);
0071 }
0072
0073
0074
0075 const std::vector<const G4Track*>* secondary = aStep->GetSecondaryInCurrentStep();
0076 for (size_t lp = 0; lp < (*secondary).size(); lp++) {
0077 G4double charge = (*secondary)[lp]->GetDefinition()->GetPDGCharge();
0078 if (charge != 0.) {
0079 id = 3;
0080 }
0081 else {
0082 id = 5;
0083 }
0084 G4double energy = (*secondary)[lp]->GetKineticEnergy();
0085 analysisManager->FillH1(id, energy);
0086
0087 ++id;
0088 G4ThreeVector direction = (*secondary)[lp]->GetMomentumDirection();
0089 G4double costeta = direction.x();
0090 analysisManager->FillH1(id, costeta);
0091
0092
0093 if (charge != 0.) {
0094 run->SumeTransf(energy);
0095 }
0096 }
0097
0098
0099
0100 G4RunManager::GetRunManager()->AbortEvent();
0101 }
0102
0103