Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // This example is provided by the Geant4-DNA 27 // Any report or published results obtained us 28 // shall cite the following Geant4-DNA collabo 29 // Med. Phys. 45 (2018) e722-e739 30 // Phys. Med. 31 (2015) 861-874 31 // Med. Phys. 37 (2010) 4692-4708 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 33 // 34 // The Geant4-DNA web site is available at htt 35 // 36 /// \file SteppingAction.cc 37 /// \brief Implementation of the SteppingActio 38 39 #include "SteppingAction.hh" 40 41 #include "DetectorConstruction.hh" 42 #include "PrimaryGeneratorAction.hh" 43 #include "RunAction.hh" 44 45 #include "G4Alpha.hh" 46 #include "G4AnalysisManager.hh" 47 #include "G4DNAGenericIonsManager.hh" 48 #include "G4Electron.hh" 49 #include "G4Event.hh" 50 #include "G4EventManager.hh" 51 #include "G4Gamma.hh" 52 #include "G4Proton.hh" 53 #include "G4SteppingManager.hh" 54 #include "G4SystemOfUnits.hh" 55 56 //....oooOO0OOooo........oooOO0OOooo........oo 57 58 SteppingAction::SteppingAction() : G4UserStepp 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 61 62 SteppingAction::~SteppingAction() {} 63 64 //....oooOO0OOooo........oooOO0OOooo........oo 65 66 void SteppingAction::UserSteppingAction(const 67 { 68 // Protection 69 if (!step->GetPostStepPoint()) return; 70 if (!step->GetPostStepPoint()->GetProcessDef 71 72 // 73 G4double flagParticle = -1.; 74 G4double flagProcess = -1.; 75 G4double x, y, z, xp, yp, zp; 76 77 // Particle identification 78 79 // The following method avoids the usage of 80 G4ParticleDefinition* partDef = step->GetTra 81 82 if (partDef == G4Gamma::GammaDefinition()) f 83 84 if (partDef == G4Electron::ElectronDefinitio 85 86 if (partDef == G4Proton::ProtonDefinition()) 87 88 if (partDef == G4Alpha::AlphaDefinition()) f 89 90 G4DNAGenericIonsManager* instance; 91 instance = G4DNAGenericIonsManager::Instance 92 93 // Usage example 94 /* 95 G4ParticleDefinition* protonDef = G4Proton:: 96 G4ParticleDefinition* hydrogenDef = instance 97 G4ParticleDefinition* alphaPlusPlusDef = ins 98 G4ParticleDefinition* alphaPlusDef = instanc 99 G4ParticleDefinition* heliumDef = instance-> 100 */ 101 102 if (partDef == instance->GetIon("hydrogen")) 103 104 if (partDef == instance->GetIon("alpha+")) f 105 106 if (partDef == instance->GetIon("helium")) f 107 108 // Alternative method (based on string compa 109 110 /* 111 const G4String& particleName = step->GetTrac 112 GetDefinition()->GetParticleName(); 113 114 if (particleName == "gamma") flagPar 115 else if (particleName == "e-") flagPar 116 else if (particleName == "proton") flagPar 117 else if (particleName == "hydrogen") flagPar 118 else if (particleName == "alpha") flagPar 119 else if (particleName == "alpha+") flagPar 120 else if (particleName == "helium") flagPar 121 */ 122 123 // Process identification 124 125 // Process sub-types are listed in G4Physics 126 // or in Geant4-DNA process class implementa 127 128 G4StepPoint* preStep = step->GetPreStepPoint 129 G4StepPoint* postStep = step->GetPostStepPoi 130 G4int procID = postStep->GetProcessDefinedSt 131 132 const G4String& processName = postStep->GetP 133 134 if (processName == "Capture") flagProcess = 135 // (no subType and procID exists at the mome 136 // used to kill ions below tracking cut 137 138 else if (flagParticle == 0) { 139 if (procID == 12) 140 flagProcess = 81; 141 else if (procID == 13) 142 flagProcess = 82; 143 else if (procID == 14) 144 flagProcess = 83; 145 else if (procID == 11) 146 flagProcess = 84; 147 } 148 149 else if (flagParticle == 1) { 150 if (procID == 58) 151 flagProcess = 10; 152 else if (procID == 51) 153 flagProcess = 11; 154 else if (procID == 52) 155 flagProcess = 12; 156 else if (procID == 53) 157 flagProcess = 13; 158 else if (procID == 55) 159 flagProcess = 14; 160 else if (procID == 54) 161 flagProcess = 15; 162 else if (procID == 10) 163 flagProcess = 110; 164 else if (procID == 1) 165 flagProcess = 120; 166 else if (procID == 2) 167 flagProcess = 130; 168 } 169 170 else if (flagParticle == 2) { 171 if (procID == 51) 172 flagProcess = 21; 173 else if (procID == 52) 174 flagProcess = 22; 175 else if (procID == 53) 176 flagProcess = 23; 177 else if (procID == 56) 178 flagProcess = 24; 179 else if (procID == 10) 180 flagProcess = 210; 181 else if (procID == 1) 182 flagProcess = 220; 183 else if (procID == 2) 184 flagProcess = 230; 185 else if (procID == 8) 186 flagProcess = 240; 187 } 188 189 else if (flagParticle == 3) { 190 if (procID == 51) 191 flagProcess = 31; 192 else if (procID == 52) 193 flagProcess = 32; 194 else if (procID == 53) 195 flagProcess = 33; 196 else if (procID == 57) 197 flagProcess = 35; 198 } 199 200 else if (flagParticle == 4) { 201 if (procID == 51) 202 flagProcess = 41; 203 else if (procID == 52) 204 flagProcess = 42; 205 else if (procID == 53) 206 flagProcess = 43; 207 else if (procID == 56) 208 flagProcess = 44; 209 else if (procID == 10) 210 flagProcess = 410; 211 else if (procID == 1) 212 flagProcess = 420; 213 else if (procID == 2) 214 flagProcess = 430; 215 else if (procID == 8) 216 flagProcess = 440; 217 } 218 219 else if (flagParticle == 5) { 220 if (procID == 51) 221 flagProcess = 51; 222 else if (procID == 52) 223 flagProcess = 52; 224 else if (procID == 53) 225 flagProcess = 53; 226 else if (procID == 56) 227 flagProcess = 54; 228 else if (procID == 57) 229 flagProcess = 55; 230 else if (procID == 10) 231 flagProcess = 510; 232 else if (procID == 1) 233 flagProcess = 520; 234 else if (procID == 2) 235 flagProcess = 530; 236 else if (procID == 8) 237 flagProcess = 540; 238 } 239 240 else if (flagParticle == 6) { 241 if (procID == 51) 242 flagProcess = 61; 243 else if (procID == 52) 244 flagProcess = 62; 245 else if (procID == 53) 246 flagProcess = 63; 247 else if (procID == 57) 248 flagProcess = 65; 249 } 250 251 else if (processName == "GenericIon_G4DNAIon 252 flagProcess = 73; 253 else if (processName == "msc") 254 flagProcess = 710; 255 else if (processName == "CoulombScat") 256 flagProcess = 720; 257 else if (processName == "ionIoni") 258 flagProcess = 730; 259 else if (processName == "nuclearStopping") 260 flagProcess = 740; 261 // (for all GenericIons) 262 263 // Alternatively, using process names 264 265 /* 266 else if (processName=="e-_G4DNAElectronSolva 267 else if (processName=="e-_G4DNAElastic") 268 else if (processName=="e-_G4DNAExcitation") 269 else if (processName=="e-_G4DNAIonisation") 270 else if (processName=="e-_G4DNAAttachment") 271 else if (processName=="e-_G4DNAVibExcitation 272 273 else if (processName=="proton_G4DNAElastic") 274 else if (processName=="proton_G4DNAExcitatio 275 else if (processName=="proton_G4DNAIonisatio 276 else if (processName=="proton_G4DNAChargeDec 277 278 else if (processName=="hydrogen_G4DNAElastic 279 else if (processName=="hydrogen_G4DNAExcitat 280 else if (processName=="hydrogen_G4DNAIonisat 281 else if (processName=="hydrogen_G4DNAChargeI 282 283 else if (processName=="alpha_G4DNAElastic") 284 else if (processName=="alpha_G4DNAExcitation 285 else if (processName=="alpha_G4DNAIonisation 286 else if (processName=="alpha_G4DNAChargeDecr 287 288 else if (processName=="alpha+_G4DNAElastic") 289 else if (processName=="alpha+_G4DNAExcitatio 290 else if (processName=="alpha+_G4DNAIonisatio 291 else if (processName=="alpha+_G4DNAChargeDec 292 else if (processName=="alpha+_G4DNAChargeInc 293 294 else if (processName=="helium_G4DNAElastic") 295 else if (processName=="helium_G4DNAExcitatio 296 else if (processName=="helium_G4DNAIonisatio 297 else if (processName=="helium_G4DNAChargeInc 298 299 else if (processName=="GenericIon_G4DNAIonis 300 301 */ 302 303 if (processName != "Transportation") { 304 x = preStep->GetPosition().x() / nanometer 305 y = preStep->GetPosition().y() / nanometer 306 z = preStep->GetPosition().z() / nanometer 307 308 xp = postStep->GetPosition().x() / nanomet 309 yp = postStep->GetPosition().y() / nanomet 310 zp = postStep->GetPosition().z() / nanomet 311 312 // get analysis manager 313 314 G4AnalysisManager* analysisManager = G4Ana 315 316 // fill ntuple 317 analysisManager->FillNtupleDColumn(0, flag 318 analysisManager->FillNtupleDColumn(1, flag 319 analysisManager->FillNtupleDColumn(2, xp); 320 analysisManager->FillNtupleDColumn(3, yp); 321 analysisManager->FillNtupleDColumn(4, zp); 322 analysisManager->FillNtupleDColumn(5, step 323 324 analysisManager->FillNtupleDColumn( 325 6, std::sqrt((x - xp) * (x - xp) + (y - 326 327 analysisManager->FillNtupleDColumn( 328 7, (preStep->GetKineticEnergy() - postSt 329 330 analysisManager->FillNtupleDColumn(8, preS 331 332 analysisManager->FillNtupleDColumn(9, preS 333 * 334 335 analysisManager->FillNtupleIColumn( 336 10, G4EventManager::GetEventManager()->G 337 338 analysisManager->FillNtupleIColumn(11, ste 339 340 analysisManager->FillNtupleIColumn(12, ste 341 342 analysisManager->FillNtupleIColumn(13, ste 343 344 analysisManager->AddNtupleRow(); 345 } 346 } 347