Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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=="Capture"||processName=="e-_G4DNAElectronSolvation") flagProcess =1;
126  else if (processName=="e-_G4DNAElastic") flagProcess =11;
127  else if (processName=="e-_G4DNAExcitation") flagProcess =12;
128  else if (processName=="e-_G4DNAIonisation") flagProcess =13;
129  else if (processName=="e-_G4DNAAttachment") flagProcess =14;
130  else if (processName=="e-_G4DNAVibExcitation") flagProcess =15;
131 
132  else if (processName=="proton_G4DNAExcitation") flagProcess =17;
133  else if (processName=="proton_G4DNAIonisation") flagProcess =18;
134  else if (processName=="proton_G4DNAChargeDecrease") flagProcess =19;
135 
136  else if (processName=="hydrogen_G4DNAExcitation") flagProcess =20;
137  else if (processName=="hydrogen_G4DNAIonisation") flagProcess =21;
138  else if (processName=="hydrogen_G4DNAChargeIncrease") flagProcess =22;
139 
140  else if (processName=="alpha_G4DNAExcitation") flagProcess =23;
141  else if (processName=="alpha_G4DNAIonisation") flagProcess =24;
142  else if (processName=="alpha_G4DNAChargeDecrease") flagProcess =25;
143 
144  else if (processName=="alpha+_G4DNAExcitation") flagProcess =26;
145  else if (processName=="alpha+_G4DNAIonisation") flagProcess =27;
146  else if (processName=="alpha+_G4DNAChargeDecrease") flagProcess =28;
147  else if (processName=="alpha+_G4DNAChargeIncrease") flagProcess =29;
148 
149  else if (processName=="helium_G4DNAExcitation") flagProcess =30;
150  else if (processName=="helium_G4DNAIonisation") flagProcess =31;
151  else if (processName=="helium_G4DNAChargeIncrease") flagProcess =32;
152 
153  if (processName!="Transportation")
154  {
155  x=step->GetPreStepPoint()->GetPosition().x()/nanometer;
156  y=step->GetPreStepPoint()->GetPosition().y()/nanometer;
157  z=step->GetPreStepPoint()->GetPosition().z()/nanometer;
158  xp=step->GetPostStepPoint()->GetPosition().x()/nanometer;
159  yp=step->GetPostStepPoint()->GetPosition().y()/nanometer;
160  zp=step->GetPostStepPoint()->GetPosition().z()/nanometer;
161 
162  // get analysis manager
163  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
164 
165  // fill ntuple
166  analysisManager->FillNtupleDColumn(0, flagParticle);
167  analysisManager->FillNtupleDColumn(1, flagProcess);
168  analysisManager->FillNtupleDColumn(2, x);
169  analysisManager->FillNtupleDColumn(3, y);
170  analysisManager->FillNtupleDColumn(4, z);
171  analysisManager->FillNtupleDColumn(5, step->GetTotalEnergyDeposit()/eV);
172  analysisManager->FillNtupleDColumn(6,
173  std::sqrt((x-xp)*(x-xp)+
174  (y-yp)*(y-yp)+(z-zp)*(z-zp))/nm);
175  analysisManager->FillNtupleDColumn(7,
176  (step->GetPreStepPoint()->
177  GetKineticEnergy() -
178  step->GetPostStepPoint()->
179  GetKineticEnergy())/eV );
180  analysisManager->FillNtupleIColumn(8, G4EventManager::GetEventManager()->
181  GetConstCurrentEvent()->GetEventID());
182  analysisManager->AddNtupleRow();
183  }
184 }
double x() const
const G4DynamicParticle * GetDynamicParticle() const
static constexpr double nanometer
Definition: G4SIunits.hh:101
tuple x
Definition: test.py:50
void UserSteppingAction(const G4Step *)
double z() const
G4StepPoint * GetPreStepPoint() const
const G4ThreeVector & GetPosition() const
static constexpr double eV
Definition: G4SIunits.hh:215
Definition: G4Step.hh:76
G4double GetTotalEnergyDeposit() const
static constexpr double nm
Definition: G4SIunits.hh:112
G4StepPoint * GetPostStepPoint() const
double y() const
static G4EventManager * GetEventManager()
tuple z
Definition: test.py:28
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77