Geant4_10
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 
33 #include "Analysis.hh"
34 
35 #include "SteppingAction.hh"
36 #include "RunAction.hh"
37 #include "DetectorConstruction.hh"
38 #include "PrimaryGeneratorAction.hh"
39 
40 #include "G4SystemOfUnits.hh"
41 #include "G4SteppingManager.hh"
42 
43 #include "G4Electron.hh"
44 #include "G4Proton.hh"
45 #include "G4Gamma.hh"
46 #include "G4Alpha.hh"
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50 
52 {}
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57 {}
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60 
62 {
63  G4double flagParticle=-1.;
64  G4double flagProcess=-1.;
65  G4double x,y,z,xp,yp,zp;
66 
67  // Process sub-types are listed in G4PhysicsListHelper.cc
68 
69 /*
70  // The following method avoids the usage of string comparison
71 
72  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == G4Electron::ElectronDefinition())
73  flagParticle = 1;
74 
75  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == G4Proton::ProtonDefinition())
76  flagParticle = 2;
77 
78  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == G4Alpha::AlphaDefinition())
79  flagParticle = 4;
80 
81  G4DNAGenericIonsManager *instance;
82  instance = G4DNAGenericIonsManager::Instance();
83  G4ParticleDefinition* protonDef = G4Proton::ProtonDefinition();
84  G4ParticleDefinition* hydrogenDef = instance->GetIon("hydrogen");
85  G4ParticleDefinition* alphaPlusPlusDef = instance->GetIon("alpha++");
86  G4ParticleDefinition* alphaPlusDef = instance->GetIon("alpha+");
87  G4ParticleDefinition* heliumDef = instance->GetIon("helium");
88 
89  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == instance->GetIon("hydrogen"))
90  flagParticle = 3;
91 
92  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == instance->GetIon("alpha+"))
93  flagParticle = 5;
94 
95  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == instance->GetIon("helium"))
96  flagParticle = 6;
97 */
98 
99  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "e-") flagParticle = 1;
100  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "proton") flagParticle = 2;
101  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "hydrogen") flagParticle = 3;
102  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "alpha") flagParticle = 4;
103  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "alpha+") flagParticle = 5;
104  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "helium") flagParticle = 6;
105 
106 
107  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAElastic") flagProcess =11;
108  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAExcitation") flagProcess =12;
109  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAIonisation") flagProcess =13;
110  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAAttachment") flagProcess =14;
111  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAVibExcitation") flagProcess =15;
112 
113  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="proton_G4DNAExcitation") flagProcess =17;
114  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="proton_G4DNAIonisation") flagProcess =18;
115  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="proton_G4DNAChargeDecrease") flagProcess =19;
116 
117  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="hydrogen_G4DNAExcitation") flagProcess =20;
118  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="hydrogen_G4DNAIonisation") flagProcess =21;
119  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="hydrogen_G4DNAChargeIncrease") flagProcess =22;
120 
121  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha_G4DNAExcitation") flagProcess =23;
122  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha_G4DNAIonisation") flagProcess =24;
123  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha_G4DNAChargeDecrease") flagProcess =25;
124 
125  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAExcitation") flagProcess =26;
126  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAIonisation") flagProcess =27;
127  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAChargeDecrease") flagProcess =28;
128  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAChargeIncrease") flagProcess =29;
129 
130  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="helium_G4DNAExcitation") flagProcess =30;
131  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="helium_G4DNAIonisation") flagProcess =31;
132  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="helium_G4DNAChargeIncrease") flagProcess =32;
133 
134  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()!="Transportation")
135  {
136  x=step->GetPreStepPoint()->GetPosition().x()/nanometer;
137  y=step->GetPreStepPoint()->GetPosition().y()/nanometer;
138  z=step->GetPreStepPoint()->GetPosition().z()/nanometer;
139  xp=step->GetPostStepPoint()->GetPosition().x()/nanometer;
140  yp=step->GetPostStepPoint()->GetPosition().y()/nanometer;
141  zp=step->GetPostStepPoint()->GetPosition().z()/nanometer;
142 
143  // get analysis manager
144  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
145 
146  // fill ntuple
147  analysisManager->FillNtupleDColumn(0, flagParticle);
148  analysisManager->FillNtupleDColumn(1, flagProcess);
149  analysisManager->FillNtupleDColumn(2, x);
150  analysisManager->FillNtupleDColumn(3, y);
151  analysisManager->FillNtupleDColumn(4, z);
152  analysisManager->FillNtupleDColumn(5, step->GetTotalEnergyDeposit()/eV);
153  analysisManager->FillNtupleDColumn(6, std::sqrt((x-xp)*(x-xp)+(y-yp)*(y-yp)+(z-zp)*(z-zp))/nm);
154  analysisManager->FillNtupleDColumn(7, (step->GetPreStepPoint()->GetKineticEnergy() - step->GetPostStepPoint()->GetKineticEnergy())/eV );
155  analysisManager->AddNtupleRow();
156  }
157 }
double x() const
const G4DynamicParticle * GetDynamicParticle() const
G4ParticleDefinition * GetDefinition() const
tuple x
Definition: test.py:50
void UserSteppingAction(const G4Step *)
const G4String & GetParticleName() const
double z() const
int nanometer
Definition: hepunit.py:35
Double_t y
Definition: plot.C:279
G4StepPoint * GetPreStepPoint() const
const G4ThreeVector & GetPosition() const
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
Definition: G4Step.hh:76
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4double GetTotalEnergyDeposit() const
const G4VProcess * GetProcessDefinedStep() const
G4StepPoint * GetPostStepPoint() const
double y() const
tuple z
Definition: test.py:28
G4double GetKineticEnergy() const
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const