Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // This example is provided by the Geant4-DNA 26 // This example is provided by the Geant4-DNA collaboration 27 // Any report or published results obtained us << 27 // Any report or published results obtained using the Geant4-DNA software 28 // shall cite the following Geant4-DNA collabo << 28 // shall cite the following Geant4-DNA collaboration publication: 29 // Med. Phys. 45 (2018) e722-e739 << 30 // Phys. Med. 31 (2015) 861-874 << 31 // Med. Phys. 37 (2010) 4692-4708 29 // 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 30 // The Geant4-DNA web site is available at http://geant4-dna.org 35 // 31 // >> 32 // $Id$ >> 33 // 36 /// \file SteppingAction.cc 34 /// \file SteppingAction.cc 37 /// \brief Implementation of the SteppingActio 35 /// \brief Implementation of the SteppingAction class 38 36 39 #include "SteppingAction.hh" << 37 #include "Analysis.hh" 40 38 >> 39 #include "SteppingAction.hh" >> 40 #include "RunAction.hh" 41 #include "DetectorConstruction.hh" 41 #include "DetectorConstruction.hh" 42 #include "PrimaryGeneratorAction.hh" 42 #include "PrimaryGeneratorAction.hh" 43 #include "RunAction.hh" << 44 43 >> 44 #include "G4SystemOfUnits.hh" >> 45 #include "G4SteppingManager.hh" >> 46 >> 47 #include "G4Electron.hh" >> 48 #include "G4Proton.hh" >> 49 #include "G4Gamma.hh" 45 #include "G4Alpha.hh" 50 #include "G4Alpha.hh" 46 #include "G4AnalysisManager.hh" << 47 #include "G4DNAGenericIonsManager.hh" 51 #include "G4DNAGenericIonsManager.hh" 48 #include "G4Electron.hh" << 49 #include "G4Event.hh" << 50 #include "G4EventManager.hh" 52 #include "G4EventManager.hh" 51 #include "G4Gamma.hh" << 53 #include "G4Event.hh" 52 #include "G4Proton.hh" << 53 #include "G4SteppingManager.hh" << 54 #include "G4SystemOfUnits.hh" << 55 54 56 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 56 58 SteppingAction::SteppingAction() : G4UserStepp << 57 SteppingAction::SteppingAction(): G4UserSteppingAction() >> 58 {} 59 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 61 62 SteppingAction::~SteppingAction() {} << 62 SteppingAction::~SteppingAction() >> 63 {} 63 64 64 //....oooOO0OOooo........oooOO0OOooo........oo 65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 66 66 void SteppingAction::UserSteppingAction(const 67 void SteppingAction::UserSteppingAction(const G4Step* step) 67 { << 68 { 68 // Protection << 69 G4double flagParticle=-1.; 69 if (!step->GetPostStepPoint()) return; << 70 G4double flagProcess=-1.; 70 if (!step->GetPostStepPoint()->GetProcessDef << 71 G4double x,y,z,xp,yp,zp; 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 72 86 if (partDef == G4Proton::ProtonDefinition()) << 73 // Process sub-types are listed in G4PhysicsListHelper.cc 87 << 88 if (partDef == G4Alpha::AlphaDefinition()) f << 89 << 90 G4DNAGenericIonsManager* instance; << 91 instance = G4DNAGenericIonsManager::Instance << 92 74 93 // Usage example << 94 /* 75 /* 95 G4ParticleDefinition* protonDef = G4Proton:: << 76 // The following method avoids the usage of string comparison 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 77 104 if (partDef == instance->GetIon("alpha+")) f << 78 if (step->GetTrack()->GetDynamicParticle()->GetDefinition() >> 79 == G4Electron::ElectronDefinition()) >> 80 flagParticle = 1; >> 81 >> 82 if (step->GetTrack()->GetDynamicParticle()->GetDefinition() >> 83 == G4Proton::ProtonDefinition()) >> 84 flagParticle = 2; >> 85 >> 86 if (step->GetTrack()->GetDynamicParticle()->GetDefinition() >> 87 == G4Alpha::AlphaDefinition()) >> 88 flagParticle = 4; >> 89 >> 90 G4DNAGenericIonsManager *instance; >> 91 instance = G4DNAGenericIonsManager::Instance(); >> 92 G4ParticleDefinition* protonDef = G4Proton::ProtonDefinition(); >> 93 G4ParticleDefinition* hydrogenDef = instance->GetIon("hydrogen"); >> 94 G4ParticleDefinition* alphaPlusPlusDef = instance->GetIon("alpha++"); >> 95 G4ParticleDefinition* alphaPlusDef = instance->GetIon("alpha+"); >> 96 G4ParticleDefinition* heliumDef = instance->GetIon("helium"); >> 97 >> 98 if (step->GetTrack()->GetDynamicParticle()->GetDefinition() >> 99 == instance->GetIon("hydrogen")) >> 100 flagParticle = 3; >> 101 >> 102 if (step->GetTrack()->GetDynamicParticle()->GetDefinition() >> 103 == instance->GetIon("alpha+")) >> 104 flagParticle = 5; >> 105 >> 106 if (step->GetTrack()->GetDynamicParticle()->GetDefinition() >> 107 == instance->GetIon("helium")) >> 108 flagParticle = 6; >> 109 */ 105 110 106 if (partDef == instance->GetIon("helium")) f << 107 << 108 // Alternative method (based on string compa << 109 << 110 /* << 111 const G4String& particleName = step->GetTrac 111 const G4String& particleName = step->GetTrack()->GetDynamicParticle()-> 112 GetDefinition()->GetParticleName(); 112 GetDefinition()->GetParticleName(); >> 113 const G4String& processName = step->GetPostStepPoint()-> >> 114 GetProcessDefinedStep()->GetProcessName(); 113 115 114 if (particleName == "gamma") flagPar << 116 // Particle 115 else if (particleName == "e-") flagPar << 117 if (particleName == "e-") flagParticle = 1; 116 else if (particleName == "proton") flagPar 118 else if (particleName == "proton") flagParticle = 2; 117 else if (particleName == "hydrogen") flagPar 119 else if (particleName == "hydrogen") flagParticle = 3; 118 else if (particleName == "alpha") flagPar 120 else if (particleName == "alpha") flagParticle = 4; 119 else if (particleName == "alpha+") flagPar 121 else if (particleName == "alpha+") flagParticle = 5; 120 else if (particleName == "helium") flagPar 122 else if (particleName == "helium") flagParticle = 6; 121 */ << 122 123 123 // Process identification << 124 // Processes 124 << 125 if (processName=="e-_G4DNAElastic") flagProcess =11; 125 // Process sub-types are listed in G4Physics << 126 else if (processName=="e-_G4DNAExcitation") flagProcess =12; 126 // or in Geant4-DNA process class implementa << 127 else if (processName=="e-_G4DNAIonisation") flagProcess =13; 127 << 128 else if (processName=="e-_G4DNAAttachment") flagProcess =14; 128 G4StepPoint* preStep = step->GetPreStepPoint << 129 else if (processName=="e-_G4DNAVibExcitation") flagProcess =15; 129 G4StepPoint* postStep = step->GetPostStepPoi << 130 130 G4int procID = postStep->GetProcessDefinedSt << 131 else if (processName=="proton_G4DNAExcitation") flagProcess =17; 131 << 132 else if (processName=="proton_G4DNAIonisation") flagProcess =18; 132 const G4String& processName = postStep->GetP << 133 else if (processName=="proton_G4DNAChargeDecrease") flagProcess =19; 133 << 134 134 if (processName == "Capture") flagProcess = << 135 else if (processName=="hydrogen_G4DNAExcitation") flagProcess =20; 135 // (no subType and procID exists at the mome << 136 else if (processName=="hydrogen_G4DNAIonisation") flagProcess =21; 136 // used to kill ions below tracking cut << 137 else if (processName=="hydrogen_G4DNAChargeIncrease") flagProcess =22; 137 << 138 138 else if (flagParticle == 0) { << 139 else if (processName=="alpha_G4DNAExcitation") flagProcess =23; 139 if (procID == 12) << 140 else if (processName=="alpha_G4DNAIonisation") flagProcess =24; 140 flagProcess = 81; << 141 else if (processName=="alpha_G4DNAChargeDecrease") flagProcess =25; 141 else if (procID == 13) << 142 142 flagProcess = 82; << 143 else if (processName=="alpha+_G4DNAExcitation") flagProcess =26; 143 else if (procID == 14) << 144 else if (processName=="alpha+_G4DNAIonisation") flagProcess =27; 144 flagProcess = 83; << 145 else if (processName=="alpha+_G4DNAChargeDecrease") flagProcess =28; 145 else if (procID == 11) << 146 else if (processName=="alpha+_G4DNAChargeIncrease") flagProcess =29; 146 flagProcess = 84; << 147 147 } << 148 else if (processName=="helium_G4DNAExcitation") flagProcess =30; 148 << 149 else if (processName=="helium_G4DNAIonisation") flagProcess =31; 149 else if (flagParticle == 1) { << 150 else if (processName=="helium_G4DNAChargeIncrease") flagProcess =32; 150 if (procID == 58) << 151 151 flagProcess = 10; << 152 if (processName!="Transportation") 152 else if (procID == 51) << 153 { 153 flagProcess = 11; << 154 x=step->GetPreStepPoint()->GetPosition().x()/nanometer; 154 else if (procID == 52) << 155 y=step->GetPreStepPoint()->GetPosition().y()/nanometer; 155 flagProcess = 12; << 156 z=step->GetPreStepPoint()->GetPosition().z()/nanometer; 156 else if (procID == 53) << 157 xp=step->GetPostStepPoint()->GetPosition().x()/nanometer; 157 flagProcess = 13; << 158 yp=step->GetPostStepPoint()->GetPosition().y()/nanometer; 158 else if (procID == 55) << 159 zp=step->GetPostStepPoint()->GetPosition().z()/nanometer; 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 160 312 // get analysis manager 161 // get analysis manager 313 << 314 G4AnalysisManager* analysisManager = G4Ana 162 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 315 163 316 // fill ntuple 164 // fill ntuple 317 analysisManager->FillNtupleDColumn(0, flag 165 analysisManager->FillNtupleDColumn(0, flagParticle); 318 analysisManager->FillNtupleDColumn(1, flag 166 analysisManager->FillNtupleDColumn(1, flagProcess); 319 analysisManager->FillNtupleDColumn(2, xp); << 167 analysisManager->FillNtupleDColumn(2, x); 320 analysisManager->FillNtupleDColumn(3, yp); << 168 analysisManager->FillNtupleDColumn(3, y); 321 analysisManager->FillNtupleDColumn(4, zp); << 169 analysisManager->FillNtupleDColumn(4, z); 322 analysisManager->FillNtupleDColumn(5, step << 170 analysisManager->FillNtupleDColumn(5, step->GetTotalEnergyDeposit()/eV); 323 << 171 analysisManager->FillNtupleDColumn(6, 324 analysisManager->FillNtupleDColumn( << 172 std::sqrt((x-xp)*(x-xp)+ 325 6, std::sqrt((x - xp) * (x - xp) + (y - << 173 (y-yp)*(y-yp)+(z-zp)*(z-zp))/nm); 326 << 174 analysisManager->FillNtupleDColumn(7, 327 analysisManager->FillNtupleDColumn( << 175 (step->GetPreStepPoint()-> 328 7, (preStep->GetKineticEnergy() - postSt << 176 GetKineticEnergy() - 329 << 177 step->GetPostStepPoint()-> 330 analysisManager->FillNtupleDColumn(8, preS << 178 GetKineticEnergy())/eV ); 331 << 179 analysisManager->FillNtupleIColumn(8, G4EventManager::GetEventManager()-> 332 analysisManager->FillNtupleDColumn(9, preS << 180 GetConstCurrentEvent()->GetEventID()); 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(); 181 analysisManager->AddNtupleRow(); 345 } 182 } 346 } << 183 } 347 184