Geant4  10.02.p01
SteppingAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publication:
29 // Med. Phys. 37 (2010) 4692-4708
30 // The Geant4-DNA web site is available at http://geant4-dna.org
31 //
32 // $Id$
33 //
36 
37 #include "Analysis.hh"
38 
39 #include "SteppingAction.hh"
40 #include "RunAction.hh"
41 #include "DetectorConstruction.hh"
42 #include "PrimaryGeneratorAction.hh"
43 
44 #include "G4SystemOfUnits.hh"
45 #include "G4SteppingManager.hh"
46 
47 #include "G4Electron.hh"
48 #include "G4Proton.hh"
49 #include "G4Gamma.hh"
50 #include "G4Alpha.hh"
52 #include "G4EventManager.hh"
53 #include "G4Event.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {}
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {}
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
69  G4double flagParticle=-1.;
70  G4double flagProcess=-1.;
71  G4double x,y,z,xp,yp,zp;
72 
73  // Process sub-types are listed in G4PhysicsListHelper.cc
74 
75  /*
76  // The following method avoids the usage of string comparison
77 
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  */
110 
111  const G4String& particleName = step->GetTrack()->GetDynamicParticle()->
112  GetDefinition()->GetParticleName();
113  const G4String& processName = step->GetPostStepPoint()->
114  GetProcessDefinedStep()->GetProcessName();
115 
116  // Particle
117  if (particleName == "e-") flagParticle = 1;
118  else if (particleName == "proton") flagParticle = 2;
119  else if (particleName == "hydrogen") flagParticle = 3;
120  else if (particleName == "alpha") flagParticle = 4;
121  else if (particleName == "alpha+") flagParticle = 5;
122  else if (particleName == "helium") flagParticle = 6;
123 
124  // Processes
125  if (processName=="e-_G4DNAElastic") flagProcess =11;
126  else if (processName=="e-_G4DNAExcitation") flagProcess =12;
127  else if (processName=="e-_G4DNAIonisation") flagProcess =13;
128  else if (processName=="e-_G4DNAAttachment") flagProcess =14;
129  else if (processName=="e-_G4DNAVibExcitation") flagProcess =15;
130 
131  else if (processName=="proton_G4DNAExcitation") flagProcess =17;
132  else if (processName=="proton_G4DNAIonisation") flagProcess =18;
133  else if (processName=="proton_G4DNAChargeDecrease") flagProcess =19;
134 
135  else if (processName=="hydrogen_G4DNAExcitation") flagProcess =20;
136  else if (processName=="hydrogen_G4DNAIonisation") flagProcess =21;
137  else if (processName=="hydrogen_G4DNAChargeIncrease") flagProcess =22;
138 
139  else if (processName=="alpha_G4DNAExcitation") flagProcess =23;
140  else if (processName=="alpha_G4DNAIonisation") flagProcess =24;
141  else if (processName=="alpha_G4DNAChargeDecrease") flagProcess =25;
142 
143  else if (processName=="alpha+_G4DNAExcitation") flagProcess =26;
144  else if (processName=="alpha+_G4DNAIonisation") flagProcess =27;
145  else if (processName=="alpha+_G4DNAChargeDecrease") flagProcess =28;
146  else if (processName=="alpha+_G4DNAChargeIncrease") flagProcess =29;
147 
148  else if (processName=="helium_G4DNAExcitation") flagProcess =30;
149  else if (processName=="helium_G4DNAIonisation") flagProcess =31;
150  else if (processName=="helium_G4DNAChargeIncrease") flagProcess =32;
151 
152  if (processName!="Transportation")
153  {
154  x=step->GetPreStepPoint()->GetPosition().x()/nanometer;
155  y=step->GetPreStepPoint()->GetPosition().y()/nanometer;
156  z=step->GetPreStepPoint()->GetPosition().z()/nanometer;
157  xp=step->GetPostStepPoint()->GetPosition().x()/nanometer;
158  yp=step->GetPostStepPoint()->GetPosition().y()/nanometer;
159  zp=step->GetPostStepPoint()->GetPosition().z()/nanometer;
160 
161  // get analysis manager
162  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
163 
164  // fill ntuple
165  analysisManager->FillNtupleDColumn(0, flagParticle);
166  analysisManager->FillNtupleDColumn(1, flagProcess);
167  analysisManager->FillNtupleDColumn(2, x);
168  analysisManager->FillNtupleDColumn(3, y);
169  analysisManager->FillNtupleDColumn(4, z);
170  analysisManager->FillNtupleDColumn(5, step->GetTotalEnergyDeposit()/eV);
171  analysisManager->FillNtupleDColumn(6,
172  std::sqrt((x-xp)*(x-xp)+
173  (y-yp)*(y-yp)+(z-zp)*(z-zp))/nm);
174  analysisManager->FillNtupleDColumn(7,
175  (step->GetPreStepPoint()->
176  GetKineticEnergy() -
177  step->GetPostStepPoint()->
178  GetKineticEnergy())/eV );
179  analysisManager->FillNtupleIColumn(8, G4EventManager::GetEventManager()->
180  GetConstCurrentEvent()->GetEventID());
181  analysisManager->AddNtupleRow();
182  }
183 }
const G4DynamicParticle * GetDynamicParticle() const
G4double z
Definition: TRTMaterials.hh:39
static const double nanometer
Definition: G4SIunits.hh:100
void UserSteppingAction(const G4Step *)
G4StepPoint * GetPreStepPoint() const
const G4ThreeVector & GetPosition() const
static const double nm
Definition: G4SIunits.hh:111
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
Definition: G4Step.hh:76
G4double GetTotalEnergyDeposit() const
static const double eV
Definition: G4SIunits.hh:212
G4StepPoint * GetPostStepPoint() const
const G4double x[NPOINTSGL]
static G4EventManager * GetEventManager()
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const