File indexing completed on 2026-05-18 07:54:43
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 #include "SteppingAction.hh"
0041 #include "SteppingMessenger.hh"
0042
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() : G4UserSteppingAction()
0061 {
0062 fSteppingMessenger = new SteppingMessenger(this);
0063 }
0064
0065
0066
0067 SteppingAction::~SteppingAction()
0068 {
0069 delete fSteppingMessenger;
0070 }
0071
0072
0073
0074 void SteppingAction::UserSteppingAction(const G4Step* step)
0075 {
0076
0077 if (!step->GetPostStepPoint()) return;
0078 if (!step->GetPostStepPoint()->GetProcessDefinedStep()) return;
0079
0080
0081 if (step->GetTrack()->GetCurrentStepNumber()>=1 && fKill)
0082 step->GetTrack()->SetTrackStatus(fKillTrackAndSecondaries);
0083
0084
0085
0086 G4double flagParticle = -1.;
0087 G4double flagProcess = -1.;
0088 G4double x, y, z, xp, yp, zp;
0089
0090
0091
0092
0093
0094 G4ParticleDefinition* partDef =
0095 step->GetTrack()->GetDynamicParticle()->GetDefinition();
0096
0097 if (partDef == G4Gamma::GammaDefinition()) flagParticle = 0;
0098
0099 if (partDef == G4Electron::ElectronDefinition()) flagParticle = 1;
0100
0101 if (partDef == G4Proton::ProtonDefinition()) flagParticle = 2;
0102
0103 if (partDef == G4Alpha::AlphaDefinition()) flagParticle = 4;
0104
0105 G4DNAGenericIonsManager* instance;
0106 instance = G4DNAGenericIonsManager::Instance();
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 if (partDef == instance->GetIon("hydrogen")) flagParticle = 3;
0118
0119 if (partDef == instance->GetIon("alpha+")) flagParticle = 5;
0120
0121 if (partDef == instance->GetIon("helium")) flagParticle = 6;
0122
0123
0124 if (partDef->GetPDGCharge()>4) flagParticle = 7;
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146 G4StepPoint* preStep = step->GetPreStepPoint();
0147 G4StepPoint* postStep = step->GetPostStepPoint();
0148 G4int procID = postStep->GetProcessDefinedStep()->GetProcessSubType();
0149
0150 const G4String& processName =
0151 postStep->GetProcessDefinedStep()->GetProcessName();
0152
0153
0154 if (flagParticle == 0) {
0155 if (procID == 12)
0156 flagProcess = 81;
0157 else if (procID == 13)
0158 flagProcess = 82;
0159 else if (procID == 14)
0160 flagProcess = 83;
0161 else if (procID == 11)
0162 flagProcess = 84;
0163 }
0164
0165
0166 else if (flagParticle == 1) {
0167 if (procID == 58)
0168 flagProcess = 10;
0169 else if (procID == 51)
0170 flagProcess = 11;
0171 else if (procID == 52)
0172 flagProcess = 12;
0173 else if (procID == 53)
0174 flagProcess = 13;
0175 else if (procID == 55)
0176 flagProcess = 14;
0177 else if (procID == 54)
0178 flagProcess = 15;
0179 else if (procID == 10)
0180 flagProcess = 110;
0181 else if (procID == 1)
0182 flagProcess = 120;
0183 else if (procID == 2)
0184 flagProcess = 130;
0185 }
0186
0187
0188 else if (flagParticle == 2) {
0189 if (procID == 51)
0190 flagProcess = 21;
0191 else if (procID == 52)
0192 flagProcess = 22;
0193 else if (procID == 53)
0194 flagProcess = 23;
0195 else if (procID == 56)
0196 flagProcess = 24;
0197 else if (procID == 10)
0198 flagProcess = 210;
0199 else if (procID == 1)
0200 flagProcess = 220;
0201 else if (procID == 2)
0202 flagProcess = 230;
0203 else if (procID == 8)
0204 flagProcess = 240;
0205 }
0206
0207
0208 else if (flagParticle == 3) {
0209 if (procID == 51)
0210 flagProcess = 31;
0211 else if (procID == 52)
0212 flagProcess = 32;
0213 else if (procID == 53)
0214 flagProcess = 33;
0215 else if (procID == 57)
0216 flagProcess = 35;
0217 }
0218
0219
0220 else if (flagParticle == 4) {
0221 if (procID == 51)
0222 flagProcess = 41;
0223 else if (procID == 52)
0224 flagProcess = 42;
0225 else if (procID == 53)
0226 flagProcess = 43;
0227 else if (procID == 56)
0228 flagProcess = 44;
0229 else if (procID == 10)
0230 flagProcess = 410;
0231 else if (procID == 1)
0232 flagProcess = 420;
0233 else if (procID == 2)
0234 flagProcess = 430;
0235 else if (procID == 8)
0236 flagProcess = 440;
0237 }
0238
0239
0240 else if (flagParticle == 5) {
0241 if (procID == 51)
0242 flagProcess = 51;
0243 else if (procID == 52)
0244 flagProcess = 52;
0245 else if (procID == 53)
0246 flagProcess = 53;
0247 else if (procID == 56)
0248 flagProcess = 54;
0249 else if (procID == 57)
0250 flagProcess = 55;
0251 else if (procID == 10)
0252 flagProcess = 510;
0253 else if (procID == 1)
0254 flagProcess = 520;
0255 else if (procID == 2)
0256 flagProcess = 530;
0257 else if (procID == 8)
0258 flagProcess = 540;
0259 }
0260
0261
0262 else if (flagParticle == 6) {
0263 if (procID == 51)
0264 flagProcess = 61;
0265 else if (procID == 52)
0266 flagProcess = 62;
0267 else if (procID == 53)
0268 flagProcess = 63;
0269 else if (procID == 57)
0270 flagProcess = 65;
0271 }
0272
0273 else if (flagParticle == 7) {
0274
0275 if (processName == "Capture")
0276 flagProcess = 1;
0277
0278
0279
0280 else if (procID == 210)
0281 flagProcess = 2;
0282
0283 else if (procID == 53)
0284 flagProcess = 73;
0285 else if (procID == 10)
0286 flagProcess = 710;
0287 else if (procID == 1)
0288 flagProcess = 720;
0289 else if (procID == 2)
0290 flagProcess = 730;
0291 else if (procID == 8)
0292 flagProcess = 740;
0293 }
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335 if (processName != "Transportation") {
0336 x = preStep->GetPosition().x() / nanometer;
0337 y = preStep->GetPosition().y() / nanometer;
0338 z = preStep->GetPosition().z() / nanometer;
0339
0340 xp = postStep->GetPosition().x() / nanometer;
0341 yp = postStep->GetPosition().y() / nanometer;
0342 zp = postStep->GetPosition().z() / nanometer;
0343
0344 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0345
0346 analysisManager->FillNtupleDColumn(0, flagParticle);
0347 analysisManager->FillNtupleDColumn(1, flagProcess);
0348 analysisManager->FillNtupleDColumn(2, xp);
0349 analysisManager->FillNtupleDColumn(3, yp);
0350 analysisManager->FillNtupleDColumn(4, zp);
0351 analysisManager->FillNtupleDColumn(5, step->GetTotalEnergyDeposit() / eV);
0352
0353 analysisManager->FillNtupleDColumn(
0354 6, std::sqrt((x - xp)*(x - xp) + (y - yp)*(y - yp) + (z - zp)*(z - zp)));
0355
0356 analysisManager->FillNtupleDColumn(
0357 7, (preStep->GetKineticEnergy() - postStep->GetKineticEnergy()) / eV);
0358
0359 analysisManager->FillNtupleDColumn(8, preStep->GetKineticEnergy() / eV);
0360
0361 analysisManager->FillNtupleDColumn(9, preStep->GetMomentumDirection()
0362 * postStep->GetMomentumDirection());
0363
0364 analysisManager->FillNtupleIColumn(
0365 10, G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID());
0366
0367 analysisManager->FillNtupleIColumn(11, step->GetTrack()->GetTrackID());
0368
0369 analysisManager->FillNtupleIColumn(12, step->GetTrack()->GetParentID());
0370
0371 analysisManager->FillNtupleIColumn(13, step->GetTrack()->GetCurrentStepNumber());
0372
0373 analysisManager->AddNtupleRow();
0374 }
0375 }