Geant4  10.03.p02
 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 // and the DNA geometry given in the Geom_DNA example
29 // shall cite the following Geant4-DNA collaboration publications:
30 // [1] NIM B 298 (2013) 47-54
31 // [2] Med. Phys. 37 (2010) 4692-4708
32 // The Geant4-DNA web site is available at http://geant4-dna.org
33 //
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
35 // $ID$
38 
39 #include "SteppingAction.hh"
40 
41 // G4
42 #include <globals.hh>
43 #include <G4SystemOfUnits.hh>
44 #include <G4VProcess.hh>
45 #include <G4Track.hh>
46 
47 #include "Analysis.hh"
48 #include "CommandLineParser.hh"
49 
50 using namespace G4DNAPARSER;
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 {
68  G4double flagParticle = 0.;
69  G4double flagProcess = 0.;
70  G4double flagVolume = 0.;
71  G4double x, y, z, xp, yp, zp;
72  G4double dE;
73 
74  dE = step->GetTotalEnergyDeposit() / eV;
75 
76  const G4String& particleName = step->GetTrack()->GetDynamicParticle()
78 
79  const G4String& processName =
81 
82  const G4String& volumeName =
84 
85  if (particleName == "e-") flagParticle = 10;
86  else if (particleName == "proton") flagParticle = 20;
87  else if (particleName == "hydrogen") flagParticle = 30;
88  else if (particleName == "alpha") flagParticle = 40;
89  else if (particleName == "alpha+") flagParticle = 50;
90  else if (particleName == "helium") flagParticle = 60;
91 
92  if (processName == "e-_G4DNAElastic") flagProcess = 11;
93  else if (processName == "e-_G4DNAExcitation") flagProcess = 12;
94  else if (processName == "e-_G4DNAIonisation") flagProcess = 13;
95  else if (processName == "e-_G4DNAAttachment") flagProcess = 14;
96  else if (processName == "e-_G4DNAVibExcitation") flagProcess = 15;
97  else if (processName == "eCapture") flagProcess = 16;
98 // if (step->GetPostStepPoint()->GetProcessDefinedStep()
99 // ->GetProcessName()=="msc") flagProcess =17;
100 
101  else if (processName == "proton_G4DNAExcitation") flagProcess = 21;
102  else if (processName == "proton_G4DNAIonisation") flagProcess = 22;
103  else if (processName == "proton_G4DNAChargeDecrease") flagProcess = 23;
104 
105  else if (processName == "hydrogen_G4DNAExcitation") flagProcess = 31;
106  else if (processName == "hydrogen_G4DNAIonisation") flagProcess = 32;
107  else if (processName == "hydrogen_G4DNAChargeIncrease") flagProcess = 33;
108 
109  else if (processName == "alpha_G4DNAExcitation") flagProcess = 41;
110  else if (processName == "alpha_G4DNAIonisation") flagProcess = 42;
111  else if (processName == "alpha_G4DNAChargeDecrease") flagProcess = 43;
112 
113  else if (processName == "alpha+_G4DNAExcitation") flagProcess = 51;
114  else if (processName == "alpha+_G4DNAIonisation") flagProcess = 52;
115  else if (processName == "alpha+_G4DNAChargeDecrease") flagProcess = 53;
116  else if (processName == "alpha+_G4DNAChargeIncrease") flagProcess = 54;
117 
118  else if (processName == "helium_G4DNAExcitation") flagProcess = 61;
119  else if (processName == "helium_G4DNAIonisation") flagProcess = 62;
120  else if (processName == "helium_G4DNAChargeIncrease") flagProcess = 63;
121 
122 // if (step->GetPreStepPoint()->GetProcessDefinedStep()->
123 // GetProcessName()=="hIoni") flagProcess =24;
124 // if (step->GetPreStepPoint()->GetProcessDefinedStep()->
125 // GetProcessName()=="eIoni") flagProcess =18;
126 
127  if (volumeName == "physi sugar 2") flagVolume = 1;
128  else if (volumeName == "physi sugar 4") flagVolume = 2;
129 
130  if (flagVolume != 0 && dE != 0)
131  {
132 
133  x = step->GetPreStepPoint()->GetPosition().x() / nanometer;
134  y = step->GetPreStepPoint()->GetPosition().y() / nanometer;
135  z = step->GetPreStepPoint()->GetPosition().z() / nanometer;
136  xp = step->GetPostStepPoint()->GetPosition().x() / nanometer;
137  yp = step->GetPostStepPoint()->GetPosition().y() / nanometer;
138  zp = step->GetPostStepPoint()->GetPosition().z() / nanometer;
139 
140  // The lines below could be put upper to gain time in the simulation
141  // Added here for testing that all the retrieve information are
142  // correctly working
143  CommandLineParser* parser = CommandLineParser::GetParser();
144  Command* command(0);
145  if((command = parser->GetCommandIfActive("-out"))==0) return;
146 
147  // get analysis manager
148  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
149 
150  analysisManager->FillNtupleDColumn(0, flagParticle);
151  analysisManager->FillNtupleDColumn(1, flagProcess);
152  analysisManager->FillNtupleDColumn(2, flagVolume);
153  analysisManager->FillNtupleDColumn(3, xp);
154  analysisManager->FillNtupleDColumn(4, yp);
155  analysisManager->FillNtupleDColumn(5, zp);
156  analysisManager->FillNtupleDColumn(6, dE);
157  analysisManager->FillNtupleDColumn(7,
158  std::sqrt((x - xp) * (x - xp)
159  + (y - yp) * (y - yp)
160  + (z - zp) * (z - zp)));
161 
162  analysisManager->AddNtupleRow();
163  }
164 
165 }
double x() const
const G4DynamicParticle * GetDynamicParticle() const
Command * GetCommandIfActive(const G4String &marker)
static constexpr double nanometer
Definition: G4SIunits.hh:101
G4ParticleDefinition * GetDefinition() const
tuple x
Definition: test.py:50
void UserSteppingAction(const G4Step *)
const G4String & GetParticleName() const
double z() const
G4StepPoint * GetPreStepPoint() const
static const G4double dE
G4VPhysicalVolume * GetPhysicalVolume() const
const G4String & GetName() const
const G4ThreeVector & GetPosition() const
static constexpr double eV
Definition: G4SIunits.hh:215
Definition: G4Step.hh:76
CommandLineParser * parser(0)
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
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77