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