ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SteppingAction.cc
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....
37 
38 #include "SteppingAction.hh"
39 
40 // G4
41 #include <globals.hh>
42 #include <G4SystemOfUnits.hh>
43 #include <G4VProcess.hh>
44 #include <G4Track.hh>
45 
46 #include "Analysis.hh"
47 #include "CommandLineParser.hh"
48 
49 using namespace G4DNAPARSER;
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
67  G4double flagParticle = 0.;
68  G4double flagProcess = 0.;
69  G4double flagVolume = 0.;
70  G4double x, y, z, xp, yp, zp;
71  G4double dE;
72 
73  dE = step->GetTotalEnergyDeposit() / eV;
74 
75  const G4String& particleName = step->GetTrack()->GetDynamicParticle()
77 
78  const G4String& processName =
80 
81  const G4String& volumeName =
83 
84  if (particleName == "e-") flagParticle = 10;
85  else if (particleName == "proton") flagParticle = 20;
86  else if (particleName == "hydrogen") flagParticle = 30;
87  else if (particleName == "alpha") flagParticle = 40;
88  else if (particleName == "alpha+") flagParticle = 50;
89  else if (particleName == "helium") flagParticle = 60;
90 
91  if (processName == "e-_G4DNAElastic") flagProcess = 11;
92  else if (processName == "e-_G4DNAExcitation") flagProcess = 12;
93  else if (processName == "e-_G4DNAIonisation") flagProcess = 13;
94  else if (processName == "e-_G4DNAAttachment") flagProcess = 14;
95  else if (processName == "e-_G4DNAVibExcitation") flagProcess = 15;
96  else if (processName == "eCapture") flagProcess = 16;
97 // if (step->GetPostStepPoint()->GetProcessDefinedStep()
98 // ->GetProcessName()=="msc") flagProcess =17;
99 
100  else if (processName == "proton_G4DNAExcitation") flagProcess = 21;
101  else if (processName == "proton_G4DNAIonisation") flagProcess = 22;
102  else if (processName == "proton_G4DNAChargeDecrease") flagProcess = 23;
103 
104  else if (processName == "hydrogen_G4DNAExcitation") flagProcess = 31;
105  else if (processName == "hydrogen_G4DNAIonisation") flagProcess = 32;
106  else if (processName == "hydrogen_G4DNAChargeIncrease") flagProcess = 33;
107 
108  else if (processName == "alpha_G4DNAExcitation") flagProcess = 41;
109  else if (processName == "alpha_G4DNAIonisation") flagProcess = 42;
110  else if (processName == "alpha_G4DNAChargeDecrease") flagProcess = 43;
111 
112  else if (processName == "alpha+_G4DNAExcitation") flagProcess = 51;
113  else if (processName == "alpha+_G4DNAIonisation") flagProcess = 52;
114  else if (processName == "alpha+_G4DNAChargeDecrease") flagProcess = 53;
115  else if (processName == "alpha+_G4DNAChargeIncrease") flagProcess = 54;
116 
117  else if (processName == "helium_G4DNAExcitation") flagProcess = 61;
118  else if (processName == "helium_G4DNAIonisation") flagProcess = 62;
119  else if (processName == "helium_G4DNAChargeIncrease") flagProcess = 63;
120 
121 // if (step->GetPreStepPoint()->GetProcessDefinedStep()->
122 // GetProcessName()=="hIoni") flagProcess =24;
123 // if (step->GetPreStepPoint()->GetProcessDefinedStep()->
124 // GetProcessName()=="eIoni") flagProcess =18;
125 
126  if (volumeName == "physi sugar 2") flagVolume = 1;
127  else if (volumeName == "physi sugar 4") flagVolume = 2;
128 
129  if (flagVolume != 0 && dE != 0)
130  {
131 
132  x = step->GetPreStepPoint()->GetPosition().x() / nanometer;
133  y = step->GetPreStepPoint()->GetPosition().y() / nanometer;
134  z = step->GetPreStepPoint()->GetPosition().z() / nanometer;
135  xp = step->GetPostStepPoint()->GetPosition().x() / nanometer;
136  yp = step->GetPostStepPoint()->GetPosition().y() / nanometer;
137  zp = step->GetPostStepPoint()->GetPosition().z() / nanometer;
138 
139  // The lines below could be put upper to gain time in the simulation
140  // Added here for testing that all the retrieve information are
141  // correctly working
142  CommandLineParser* parser = CommandLineParser::GetParser();
143  Command* command(0);
144  if((command = parser->GetCommandIfActive("-out"))==0) return;
145 
146  // get analysis manager
147  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
148 
149  analysisManager->FillNtupleDColumn(0, flagParticle);
150  analysisManager->FillNtupleDColumn(1, flagProcess);
151  analysisManager->FillNtupleDColumn(2, flagVolume);
152  analysisManager->FillNtupleDColumn(3, xp);
153  analysisManager->FillNtupleDColumn(4, yp);
154  analysisManager->FillNtupleDColumn(5, zp);
155  analysisManager->FillNtupleDColumn(6, dE);
156  analysisManager->FillNtupleDColumn(7,
157  std::sqrt((x - xp) * (x - xp)
158  + (y - yp) * (y - yp)
159  + (z - zp) * (z - zp)));
160 
161  analysisManager->AddNtupleRow();
162  }
163 
164 }