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$
35 
36 #include "Analysis.hh"
37 
38 #include "SteppingAction.hh"
39 #include "RunAction.hh"
40 #include "DetectorConstruction.hh"
41 #include "PrimaryGeneratorAction.hh"
42 
43 #include "G4SystemOfUnits.hh"
44 #include "G4SteppingManager.hh"
45 #include "G4VTouchable.hh"
46 #include "G4VPhysicalVolume.hh"
47 #include "CommandLineParser.hh"
48 
49 using namespace G4DNAPARSER;
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {}
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {
65  G4double flagParticle=0.;
66  G4double flagProcess=0.;
67  G4double x,y,z,xp,yp,zp;
68 
69  // Process sub-types are listed in G4PhysicsListHelper.cc
70 
71  /*
72  // The following method avoids the usage of string comparison
73 
74  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
75  G4Electron::ElectronDefinition())
76  flagParticle = 1;
77 
78  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
79  G4Proton::ProtonDefinition())
80  flagParticle = 2;
81 
82  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
83  G4Alpha::AlphaDefinition())
84  flagParticle = 4;
85 
86  G4DNAGenericIonsManager *instance;
87  instance = G4DNAGenericIonsManager::Instance();
88  G4ParticleDefinition* protonDef = G4Proton::ProtonDefinition();
89  G4ParticleDefinition* hydrogenDef = instance->GetIon("hydrogen");
90  G4ParticleDefinition* alphaPlusPlusDef = instance->GetIon("alpha++");
91  G4ParticleDefinition* alphaPlusDef = instance->GetIon("alpha+");
92  G4ParticleDefinition* heliumDef = instance->GetIon("helium");
93 
94  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
95  instance->GetIon("hydrogen"))
96  flagParticle = 3;
97 
98  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
99  instance->GetIon("alpha+"))
100  flagParticle = 5;
101 
102  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ==
103  instance->GetIon("helium"))
104  flagParticle = 6;
105  */
106 
107  const G4String& particleName = step->GetTrack()->GetDynamicParticle()->
108  GetDefinition()->GetParticleName();
109  const G4String& processName = step->GetPostStepPoint()->
110  GetProcessDefinedStep()->GetProcessName();
111 
112  if (particleName == "e-") flagParticle = 1;
113  else if (particleName == "proton") flagParticle = 2;
114  else if (particleName == "hydrogen") flagParticle = 3;
115  else if (particleName == "alpha") flagParticle = 4;
116  else if (particleName == "alpha+") flagParticle = 5;
117  else if (particleName == "helium") flagParticle = 6;
118 
119  if (processName=="msc") flagProcess =10;
120  else if (processName=="e-_G4DNAElastic") flagProcess =11;
121  else if (processName=="e-_G4DNAExcitation") flagProcess =12;
122  else if (processName=="e-_G4DNAIonisation") flagProcess =13;
123  else if (processName=="e-_G4DNAAttachment") flagProcess =14;
124  else if (processName=="e-_G4DNAVibExcitation") flagProcess =15;
125  else if (processName=="eCapture") flagProcess =16;
126 
127  else if (processName=="proton_G4DNAExcitation") flagProcess =17;
128  else if (processName=="proton_G4DNAIonisation") flagProcess =18;
129  else if (processName=="proton_G4DNAChargeDecrease") flagProcess =19;
130 
131  else if (processName=="hydrogen_G4DNAExcitation") flagProcess =20;
132  else if (processName=="hydrogen_G4DNAIonisation") flagProcess =21;
133  else if (processName=="hydrogen_G4DNAChargeIncrease")flagProcess =22;
134 
135  else if (processName=="alpha_G4DNAExcitation") flagProcess =23;
136  else if (processName=="alpha_G4DNAIonisation") flagProcess =24;
137  else if (processName=="alpha_G4DNAChargeDecrease") flagProcess =25;
138 
139  else if (processName=="alpha+_G4DNAExcitation") flagProcess =26;
140  else if (processName=="alpha+_G4DNAIonisation") flagProcess =27;
141  else if (processName=="alpha+_G4DNAChargeDecrease") flagProcess =28;
142  else if (processName=="alpha+_G4DNAChargeIncrease") flagProcess =29;
143 
144  else if (processName=="helium_G4DNAExcitation") flagProcess =30;
145  else if (processName=="helium_G4DNAIonisation") flagProcess =31;
146  else if (processName=="helium_G4DNAChargeIncrease") flagProcess =32;
147 
148  else if (processName=="hIoni") flagProcess =33;
149  else if (processName=="eIoni") flagProcess =34;
150 
151  if (processName!="Transportation")
152  {
153  x=step->GetPreStepPoint()->GetPosition().x()/nanometer;
154  y=step->GetPreStepPoint()->GetPosition().y()/nanometer;
155  z=step->GetPreStepPoint()->GetPosition().z()/nanometer;
156  xp=step->GetPostStepPoint()->GetPosition().x()/nanometer;
157  yp=step->GetPostStepPoint()->GetPosition().y()/nanometer;
158  zp=step->GetPostStepPoint()->GetPosition().z()/nanometer;
159 
160  CommandLineParser* parser = CommandLineParser::GetParser();
161  Command* command(0);
162  if((command = parser->GetCommandIfActive("-out"))==0) return;
163 
164  // get analysis manager
165  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
166 // if(!analysisManager->IsActive()) {return; }
167 
168  // fill ntuple
169  analysisManager->FillNtupleDColumn(0, flagParticle);
170  analysisManager->FillNtupleDColumn(1, flagProcess);
171  analysisManager->FillNtupleDColumn(2, x);
172  analysisManager->FillNtupleDColumn(3, y);
173  analysisManager->FillNtupleDColumn(4, z);
174  analysisManager->FillNtupleDColumn(5, step->GetTotalEnergyDeposit()/eV);
175  analysisManager->FillNtupleDColumn(6,
176  std::sqrt((x-xp)*(x-xp)+
177  (y-yp)*(y-yp)+(z-zp)*(z-zp))/nm);
178  analysisManager->FillNtupleDColumn(7, (step->GetPreStepPoint()->
179  GetKineticEnergy() - step->GetPostStepPoint()->GetKineticEnergy())/eV );
180  analysisManager->AddNtupleRow();
181  }
182 }
const G4DynamicParticle * GetDynamicParticle() const
G4double z
Definition: TRTMaterials.hh:39
static const double nanometer
Definition: G4SIunits.hh:100
Command * GetCommandIfActive(const G4String &marker)
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
CommandLineParser * parser(0)
G4double GetTotalEnergyDeposit() const
static const double eV
Definition: G4SIunits.hh:212
G4StepPoint * GetPostStepPoint() const
const G4double x[NPOINTSGL]
G4double GetKineticEnergy() const
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const