Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/medical/dna/dnaphysics/src/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 // 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$
33 //
36 
37 #include "Analysis.hh"
38 
39 #include "SteppingAction.hh"
40 #include "RunAction.hh"
41 #include "DetectorConstruction.hh"
42 #include "PrimaryGeneratorAction.hh"
43 
44 #include "G4SystemOfUnits.hh"
45 #include "G4SteppingManager.hh"
46 
47 #include "G4Electron.hh"
48 #include "G4Proton.hh"
49 #include "G4Gamma.hh"
50 #include "G4Alpha.hh"
52 #include "G4EventManager.hh"
53 #include "G4Event.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {}
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {}
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
69  // Protection
70 
71  if (!step->GetPostStepPoint()) return;
72  if (!step->GetPostStepPoint()->GetProcessDefinedStep()) return;
73 
74  //
75 
78  G4double x,y,z,xp,yp,zp;
79 
80  // Particle identification
81 
82  // The following method avoids the usage of string comparison
83 
84  G4ParticleDefinition * partDef =
86 
87  if (partDef == G4Gamma::GammaDefinition())
88  flagParticle = 0;
89 
90  if (partDef == G4Electron::ElectronDefinition())
91  flagParticle = 1;
92 
93  if (partDef == G4Proton::ProtonDefinition())
94  flagParticle = 2;
95 
96  if (partDef == G4Alpha::AlphaDefinition())
97  flagParticle = 4;
98 
101 
102  // Usage example
103  /*
104  G4ParticleDefinition* protonDef = G4Proton::ProtonDefinition();
105  G4ParticleDefinition* hydrogenDef = instance->GetIon("hydrogen");
106  G4ParticleDefinition* alphaPlusPlusDef = instance->GetIon("alpha++");
107  G4ParticleDefinition* alphaPlusDef = instance->GetIon("alpha+");
108  G4ParticleDefinition* heliumDef = instance->GetIon("helium");
109  */
110 
111  if (partDef == instance->GetIon("hydrogen"))
112  flagParticle = 3;
113 
114  if (partDef == instance->GetIon("alpha+"))
115  flagParticle = 5;
116 
117  if (partDef == instance->GetIon("helium"))
118  flagParticle = 6;
119 
120  // Alternative method (based on string comparison)
121 
122  /*
123  const G4String& particleName = step->GetTrack()->GetDynamicParticle()->
124  GetDefinition()->GetParticleName();
125 
126  if (particleName == "gamma") flagParticle = 0;
127  else if (particleName == "e-") flagParticle = 1;
128  else if (particleName == "proton") flagParticle = 2;
129  else if (particleName == "hydrogen") flagParticle = 3;
130  else if (particleName == "alpha") flagParticle = 4;
131  else if (particleName == "alpha+") flagParticle = 5;
132  else if (particleName == "helium") flagParticle = 6;
133  */
134 
135  // Process identification
136 
137  // Process sub-types are listed in G4PhysicsListHelper.cc
138  // or in Geant4-DNA process class implementation files (*.cc)
139 
140  G4StepPoint * preStep = step->GetPreStepPoint();
141  G4StepPoint * postStep = step->GetPostStepPoint();
142  G4int procID = postStep->GetProcessDefinedStep()->GetProcessSubType();
143 
144  const G4String& processName = postStep->
145  GetProcessDefinedStep()->GetProcessName();
146 
147  if (processName=="Capture") flagProcess =1;
148  // (no subType and procID exists at the moment for this process)
149 
150  else if (flagParticle == 1)
151 
152  {
153  if (procID==58) flagProcess =10;
154  else if (procID==51) flagProcess =11;
155  else if (procID==52) flagProcess =12;
156  else if (procID==53) flagProcess =13;
157  else if (procID==55) flagProcess =14;
158  else if (procID==54) flagProcess =15;
159  else if (procID==10) flagProcess =110;
160  else if (procID==1) flagProcess =120;
161  else if (procID==2) flagProcess =130;
162  }
163 
164  else if (flagParticle == 2)
165 
166  {
167  if (procID==51) flagProcess =21;
168  else if (procID==52) flagProcess =22;
169  else if (procID==53) flagProcess =23;
170  else if (procID==56) flagProcess =24;
171  else if (procID==10) flagProcess =210;
172  else if (procID==1) flagProcess =220;
173  else if (procID==2) flagProcess =230;
174  else if (procID==8) flagProcess =240;
175  }
176 
177  else if (flagParticle == 3)
178 
179  {
180  if (procID==51) flagProcess =31;
181  else if (procID==52) flagProcess =32;
182  else if (procID==53) flagProcess =33;
183  else if (procID==57) flagProcess =35;
184  }
185 
186  else if (flagParticle == 4)
187 
188  {
189  if (procID==51) flagProcess =41;
190  else if (procID==52) flagProcess =42;
191  else if (procID==53) flagProcess =43;
192  else if (procID==56) flagProcess =44;
193  else if (procID==10) flagProcess =410;
194  else if (procID==1) flagProcess =420;
195  else if (procID==2) flagProcess =430;
196  else if (procID==8) flagProcess =440;
197  }
198 
199  else if (flagParticle == 5)
200 
201  {
202  if (procID==51) flagProcess =51;
203  else if (procID==52) flagProcess =52;
204  else if (procID==53) flagProcess =53;
205  else if (procID==56) flagProcess =54;
206  else if (procID==57) flagProcess =55;
207  else if (procID==10) flagProcess =510;
208  else if (procID==1) flagProcess =520;
209  else if (procID==2) flagProcess =530;
210  else if (procID==8) flagProcess =540;
211  }
212 
213  else if (flagParticle == 6)
214 
215  {
216  if (procID==51) flagProcess =61;
217  else if (procID==52) flagProcess =62;
218  else if (procID==53) flagProcess =63;
219  else if (procID==57) flagProcess =65;
220 
221  }
222 
223  else if (processName=="GenericIon_G4DNAIonisation") flagProcess =73;
224  else if (processName=="msc") flagProcess =710;
225  else if (processName=="CoulombScat") flagProcess =720;
226  else if (processName=="ionIoni") flagProcess =730;
227  else if (processName=="nuclearStopping") flagProcess =740;
228  // (for all GenericIons)
229 
230  // Alternatively, using process names
231 
232  /*
233  else if (processName=="e-_G4DNAElectronSolvation") flagProcess =10;
234  else if (processName=="e-_G4DNAElastic") flagProcess =11;
235  else if (processName=="e-_G4DNAExcitation") flagProcess =12;
236  else if (processName=="e-_G4DNAIonisation") flagProcess =13;
237  else if (processName=="e-_G4DNAAttachment") flagProcess =14;
238  else if (processName=="e-_G4DNAVibExcitation") flagProcess =15;
239 
240  else if (processName=="proton_G4DNAElastic") flagProcess =21;
241  else if (processName=="proton_G4DNAExcitation") flagProcess =22;
242  else if (processName=="proton_G4DNAIonisation") flagProcess =23;
243  else if (processName=="proton_G4DNAChargeDecrease") flagProcess =24;
244 
245  else if (processName=="hydrogen_G4DNAElastic") flagProcess =31;
246  else if (processName=="hydrogen_G4DNAExcitation") flagProcess =32;
247  else if (processName=="hydrogen_G4DNAIonisation") flagProcess =33;
248  else if (processName=="hydrogen_G4DNAChargeIncrease") flagProcess =35;
249 
250  else if (processName=="alpha_G4DNAElastic") flagProcess =41;
251  else if (processName=="alpha_G4DNAExcitation") flagProcess =42;
252  else if (processName=="alpha_G4DNAIonisation") flagProcess =43;
253  else if (processName=="alpha_G4DNAChargeDecrease") flagProcess =44;
254 
255  else if (processName=="alpha+_G4DNAElastic") flagProcess =51;
256  else if (processName=="alpha+_G4DNAExcitation") flagProcess =52;
257  else if (processName=="alpha+_G4DNAIonisation") flagProcess =53;
258  else if (processName=="alpha+_G4DNAChargeDecrease") flagProcess =54;
259  else if (processName=="alpha+_G4DNAChargeIncrease") flagProcess =55;
260 
261  else if (processName=="helium_G4DNAElastic") flagProcess =61;
262  else if (processName=="helium_G4DNAExcitation") flagProcess =62;
263  else if (processName=="helium_G4DNAIonisation") flagProcess =63;
264  else if (processName=="helium_G4DNAChargeIncrease") flagProcess =65;
265 
266  else if (processName=="GenericIon_G4DNAIonisation") flagProcess =73;
267 
268  */
269 
270  if (processName!="Transportation")
271  {
272  x=preStep->GetPosition().x()/nanometer;
273  y=preStep->GetPosition().y()/nanometer;
274  z=preStep->GetPosition().z()/nanometer;
275 
276  xp=postStep->GetPosition().x()/nanometer;
277  yp=postStep->GetPosition().y()/nanometer;
278  zp=postStep->GetPosition().z()/nanometer;
279 
280  // get analysis manager
281 
282  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
283 
284  // fill ntuple
285  analysisManager->FillNtupleDColumn(0, flagParticle);
286  analysisManager->FillNtupleDColumn(1, flagProcess);
287  analysisManager->FillNtupleDColumn(2, x);
288  analysisManager->FillNtupleDColumn(3, y);
289  analysisManager->FillNtupleDColumn(4, z);
290  analysisManager->FillNtupleDColumn(5,
291  step->GetTotalEnergyDeposit()/eV);
292 
293  analysisManager->FillNtupleDColumn(6,
294  std::sqrt((x-xp)*(x-xp)+
295  (y-yp)*(y-yp)+(z-zp)*(z-zp)));
296 
297  analysisManager->FillNtupleDColumn(7,
298  (preStep->
299  GetKineticEnergy() -
300  postStep->
301  GetKineticEnergy())/eV );
302 
303  analysisManager->FillNtupleDColumn(8, preStep->
304  GetKineticEnergy()/eV);
305 
306  analysisManager->FillNtupleDColumn(9,
307  preStep->GetMomentumDirection()
308  *postStep->GetMomentumDirection() );
309 
310  analysisManager->FillNtupleIColumn(10,
312  GetConstCurrentEvent()->GetEventID());
313 
314  analysisManager->FillNtupleIColumn(11, step->GetTrack()->GetTrackID());
315 
316  analysisManager->FillNtupleIColumn(12, step->GetTrack()->GetParentID());
317 
318  analysisManager->FillNtupleIColumn(13,
319  step->GetTrack()->GetCurrentStepNumber());
320 
321  analysisManager->AddNtupleRow();
322  }
323 }
Float_t x
Definition: compare.C:6
G4StepPoint * GetPreStepPoint() const
Float_t y
Definition: compare.C:6
Double_t z
G4int GetTrackID() const
double z() const
G4int GetCurrentStepNumber() const
double G4double
Definition: G4Types.hh:76
G4ParticleDefinition * GetDefinition() const
static G4Proton * ProtonDefinition()
Definition: G4Proton.cc:88
const G4ThreeVector & GetPosition() const
static G4EventManager * GetEventManager()
G4Track * GetTrack() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetTotalEnergyDeposit() const
static constexpr double eV
Definition: G4SIunits.hh:215
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
Definition: G4Step.hh:76
G4StepPoint * GetPostStepPoint() const
void UserSteppingAction(const G4Step *)
static G4Electron * ElectronDefinition()
Definition: G4Electron.cc:89
static G4Alpha * AlphaDefinition()
Definition: G4Alpha.cc:84
static G4Gamma * GammaDefinition()
Definition: G4Gamma.cc:81
int G4int
Definition: G4Types.hh:78
G4ParticleDefinition * GetIon(const G4String &name)
static MCTruthManager * instance
static G4DNAGenericIonsManager * Instance(void)
double x() const
double y() const
const G4VProcess * GetProcessDefinedStep() const
const G4DynamicParticle * GetDynamicParticle() const
static constexpr double nanometer
Definition: G4SIunits.hh:101
G4int GetParentID() const
G4int GetProcessSubType() const
Definition: G4VProcess.hh:429