Geant4  10.00.p02
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 #include "G4VTouchable.hh"
43 #include "G4VPhysicalVolume.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46 
48 {}
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51 
53 {}
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56 
58 {
59  G4double flagParticle=0.;
60  G4double flagProcess=0.;
61  G4double x,y,z,xp,yp,zp;
62 
63  // Process sub-types are listed in G4PhysicsListHelper.cc
64 
65 /*
66  // The following method avoids the usage of string comparison
67 
68  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == G4Electron::ElectronDefinition())
69  flagParticle = 1;
70 
71  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == G4Proton::ProtonDefinition())
72  flagParticle = 2;
73 
74  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == G4Alpha::AlphaDefinition())
75  flagParticle = 4;
76 
77  G4DNAGenericIonsManager *instance;
78  instance = G4DNAGenericIonsManager::Instance();
79  G4ParticleDefinition* protonDef = G4Proton::ProtonDefinition();
80  G4ParticleDefinition* hydrogenDef = instance->GetIon("hydrogen");
81  G4ParticleDefinition* alphaPlusPlusDef = instance->GetIon("alpha++");
82  G4ParticleDefinition* alphaPlusDef = instance->GetIon("alpha+");
83  G4ParticleDefinition* heliumDef = instance->GetIon("helium");
84 
85  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == instance->GetIon("hydrogen"))
86  flagParticle = 3;
87 
88  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == instance->GetIon("alpha+"))
89  flagParticle = 5;
90 
91  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() == instance->GetIon("helium"))
92  flagParticle = 6;
93 */
94 
95  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "e-") flagParticle = 1;
96  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "proton") flagParticle = 2;
97  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "hydrogen") flagParticle = 3;
98  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "alpha") flagParticle = 4;
99  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "alpha+") flagParticle = 5;
100  if (step->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "helium") flagParticle = 6;
101 
102  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="msc") flagProcess =10;
103  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAElastic") flagProcess =11;
104  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAExcitation") flagProcess =12;
105  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAIonisation") flagProcess =13;
106  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAAttachment") flagProcess =14;
107  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="e-_G4DNAVibExcitation") flagProcess =15;
108  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="eCapture") flagProcess =16;
109 
110  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="proton_G4DNAExcitation") flagProcess =17;
111  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="proton_G4DNAIonisation") flagProcess =18;
112  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="proton_G4DNAChargeDecrease") flagProcess =19;
113 
114  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="hydrogen_G4DNAExcitation") flagProcess =20;
115  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="hydrogen_G4DNAIonisation") flagProcess =21;
116  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="hydrogen_G4DNAChargeIncrease")flagProcess =22;
117 
118  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha_G4DNAExcitation") flagProcess =23;
119  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha_G4DNAIonisation") flagProcess =24;
120  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha_G4DNAChargeDecrease") flagProcess =25;
121 
122  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAExcitation") flagProcess =26;
123  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAIonisation") flagProcess =27;
124  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAChargeDecrease") flagProcess =28;
125  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="alpha+_G4DNAChargeIncrease") flagProcess =29;
126 
127  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="helium_G4DNAExcitation") flagProcess =30;
128  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="helium_G4DNAIonisation") flagProcess =31;
129  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="helium_G4DNAChargeIncrease") flagProcess =32;
130 
131  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="hIoni") flagProcess =33;
132  if (step->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="eIoni") flagProcess =34;
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 }
const G4DynamicParticle * GetDynamicParticle() const
G4double z
Definition: TRTMaterials.hh:39
static const double nanometer
Definition: G4SIunits.hh:91
G4ParticleDefinition * GetDefinition() const
void UserSteppingAction(const G4Step *)
const G4String & GetParticleName() const
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
static const double eV
Definition: G4SIunits.hh:194
const G4VProcess * GetProcessDefinedStep() const
G4StepPoint * GetPostStepPoint() const
G4double GetKineticEnergy() const
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const