File indexing completed on 2026-09-10 08:29:30
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 #include "SteppingAction.hh"
0040
0041
0042 #include "CommandLineParser.hh"
0043
0044 #include "G4AnalysisManager.hh"
0045
0046 #include <G4SystemOfUnits.hh>
0047 #include <G4Track.hh>
0048 #include <G4VProcess.hh>
0049 #include <globals.hh>
0050
0051 using namespace G4DNAPARSER;
0052
0053
0054
0055 SteppingAction::SteppingAction() : G4UserSteppingAction() {}
0056
0057
0058
0059 SteppingAction::~SteppingAction() {}
0060
0061
0062
0063 void SteppingAction::UserSteppingAction(const G4Step* step)
0064 {
0065 G4double flagParticle = 0.;
0066 G4double flagProcess = 0.;
0067 G4double flagVolume = 0.;
0068 G4double x, y, z, xp, yp, zp;
0069 G4double dE;
0070
0071 dE = step->GetTotalEnergyDeposit() / eV;
0072
0073 const G4String& particleName =
0074 step->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName();
0075
0076 const G4String& processName = step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
0077
0078 const G4String& volumeName = step->GetPreStepPoint()->GetPhysicalVolume()->GetName();
0079
0080 if (particleName == "e-")
0081 flagParticle = 10;
0082 else if (particleName == "proton")
0083 flagParticle = 20;
0084 else if (particleName == "hydrogen")
0085 flagParticle = 30;
0086 else if (particleName == "alpha")
0087 flagParticle = 40;
0088 else if (particleName == "alpha+")
0089 flagParticle = 50;
0090 else if (particleName == "helium")
0091 flagParticle = 60;
0092
0093 if (processName == "e-_G4DNAElastic")
0094 flagProcess = 11;
0095 else if (processName == "e-_G4DNAExcitation")
0096 flagProcess = 12;
0097 else if (processName == "e-_G4DNAIonisation")
0098 flagProcess = 13;
0099 else if (processName == "e-_G4DNAAttachment")
0100 flagProcess = 14;
0101 else if (processName == "e-_G4DNAVibExcitation")
0102 flagProcess = 15;
0103 else if (processName == "eCapture")
0104 flagProcess = 16;
0105
0106
0107
0108 else if (processName == "proton_G4DNAExcitation")
0109 flagProcess = 21;
0110 else if (processName == "proton_G4DNAIonisation")
0111 flagProcess = 22;
0112 else if (processName == "proton_G4DNAChargeDecrease")
0113 flagProcess = 23;
0114
0115 else if (processName == "hydrogen_G4DNAExcitation")
0116 flagProcess = 31;
0117 else if (processName == "hydrogen_G4DNAIonisation")
0118 flagProcess = 32;
0119 else if (processName == "hydrogen_G4DNAChargeIncrease")
0120 flagProcess = 33;
0121
0122 else if (processName == "alpha_G4DNAExcitation")
0123 flagProcess = 41;
0124 else if (processName == "alpha_G4DNAIonisation")
0125 flagProcess = 42;
0126 else if (processName == "alpha_G4DNAChargeDecrease")
0127 flagProcess = 43;
0128
0129 else if (processName == "alpha+_G4DNAExcitation")
0130 flagProcess = 51;
0131 else if (processName == "alpha+_G4DNAIonisation")
0132 flagProcess = 52;
0133 else if (processName == "alpha+_G4DNAChargeDecrease")
0134 flagProcess = 53;
0135 else if (processName == "alpha+_G4DNAChargeIncrease")
0136 flagProcess = 54;
0137
0138 else if (processName == "helium_G4DNAExcitation")
0139 flagProcess = 61;
0140 else if (processName == "helium_G4DNAIonisation")
0141 flagProcess = 62;
0142 else if (processName == "helium_G4DNAChargeIncrease")
0143 flagProcess = 63;
0144
0145
0146
0147
0148
0149
0150 if (volumeName == "physi sugar 2")
0151 flagVolume = 1;
0152 else if (volumeName == "physi sugar 4")
0153 flagVolume = 2;
0154
0155 if (flagVolume != 0 && dE != 0) {
0156 x = step->GetPreStepPoint()->GetPosition().x() / nanometer;
0157 y = step->GetPreStepPoint()->GetPosition().y() / nanometer;
0158 z = step->GetPreStepPoint()->GetPosition().z() / nanometer;
0159 xp = step->GetPostStepPoint()->GetPosition().x() / nanometer;
0160 yp = step->GetPostStepPoint()->GetPosition().y() / nanometer;
0161 zp = step->GetPostStepPoint()->GetPosition().z() / nanometer;
0162
0163
0164
0165
0166 CommandLineParser* parser = CommandLineParser::GetParser();
0167 Command* command(0);
0168 if ((command = parser->GetCommandIfActive("-out")) == 0) return;
0169
0170
0171 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0172
0173 analysisManager->FillNtupleDColumn(0, flagParticle);
0174 analysisManager->FillNtupleDColumn(1, flagProcess);
0175 analysisManager->FillNtupleDColumn(2, flagVolume);
0176 analysisManager->FillNtupleDColumn(3, xp);
0177 analysisManager->FillNtupleDColumn(4, yp);
0178 analysisManager->FillNtupleDColumn(5, zp);
0179 analysisManager->FillNtupleDColumn(6, dE);
0180 analysisManager->FillNtupleDColumn(
0181 7, std::sqrt((x - xp) * (x - xp) + (y - yp) * (y - yp) + (z - zp) * (z - zp)));
0182
0183 analysisManager->AddNtupleRow();
0184 }
0185 }