Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
extended/medical/dna/microdosimetry/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$
35 
36 #include "Analysis.hh"
37 
38 #include "SteppingAction.hh"
39 #include "RunAction.hh"
40 #include "DetectorConstruction.hh"
41 #include "PrimaryGeneratorAction.hh"
42 
43 #include "G4SystemOfUnits.hh"
44 #include "G4SteppingManager.hh"
45 #include "G4VTouchable.hh"
46 #include "G4VPhysicalVolume.hh"
47 #include "CommandLineParser.hh"
48 
49 #include "G4Electron.hh"
50 #include "G4Proton.hh"
51 #include "G4Gamma.hh"
52 #include "G4Alpha.hh"
54 #include "G4EventManager.hh"
55 #include "G4Event.hh"
56 
57 using namespace G4DNAPARSER;
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {}
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 {}
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 {
75  G4double x,y,z,xp,yp,zp;
76 
77  // Particle identification
78 
79  // The following method avoids the usage of string comparison
80 
81  G4ParticleDefinition * partDef =
83 
84  if (partDef == G4Gamma::GammaDefinition())
85  flagParticle = 0;
86 
87  if (partDef == G4Electron::ElectronDefinition())
88  flagParticle = 1;
89 
90  if (partDef == G4Proton::ProtonDefinition())
91  flagParticle = 2;
92 
93  if (partDef == G4Alpha::AlphaDefinition())
94  flagParticle = 4;
95 
98 
99  // Usage example
100  /*
101  G4ParticleDefinition* protonDef = G4Proton::ProtonDefinition();
102  G4ParticleDefinition* hydrogenDef = instance->GetIon("hydrogen");
103  G4ParticleDefinition* alphaPlusPlusDef = instance->GetIon("alpha++");
104  G4ParticleDefinition* alphaPlusDef = instance->GetIon("alpha+");
105  G4ParticleDefinition* heliumDef = instance->GetIon("helium");
106  */
107 
108  if (partDef == instance->GetIon("hydrogen"))
109  flagParticle = 3;
110 
111  if (partDef == instance->GetIon("alpha+"))
112  flagParticle = 5;
113 
114  if (partDef == instance->GetIon("helium"))
115  flagParticle = 6;
116 
117  // Alternative method (based on string comparison)
118 
119  /*
120  const G4String& particleName = step->GetTrack()->GetDynamicParticle()->
121  GetDefinition()->GetParticleName();
122 
123  if (particleName == "gamma") flagParticle = 0;
124  else if (particleName == "e-") flagParticle = 1;
125  else if (particleName == "proton") flagParticle = 2;
126  else if (particleName == "hydrogen") flagParticle = 3;
127  else if (particleName == "alpha") flagParticle = 4;
128  else if (particleName == "alpha+") flagParticle = 5;
129  else if (particleName == "helium") flagParticle = 6;
130  */
131 
132  // Process identification
133 
134  // Process sub-types are listed in G4PhysicsListHelper.cc
135  // or in Geant4-DNA process class implementation files (*.cc)
136 
137  G4StepPoint * preStep = step->GetPreStepPoint();
138  G4StepPoint * postStep = step->GetPostStepPoint();
139  G4int procID = postStep->GetProcessDefinedStep()->GetProcessSubType();
140 
141  const G4String& processName = postStep->
142  GetProcessDefinedStep()->GetProcessName();
143 
144  if (processName=="eCapture") flagProcess =1;
145  // (no subType and procID exists at the moment for this process)
146 
147  else if (flagParticle == 1)
148 
149  {
150  if (procID==58) flagProcess =10;
151  else if (procID==51) flagProcess =11;
152  else if (procID==52) flagProcess =12;
153  else if (procID==53) flagProcess =13;
154  else if (procID==55) flagProcess =14;
155  else if (procID==54) flagProcess =15;
156  else if (procID==10) flagProcess =110;
157  else if (procID==1) flagProcess =120;
158  else if (procID==2) flagProcess =130;
159  }
160 
161  else if (flagParticle == 2)
162 
163  {
164  if (procID==51) flagProcess =21;
165  else if (procID==52) flagProcess =22;
166  else if (procID==53) flagProcess =23;
167  else if (procID==56) flagProcess =24;
168  else if (procID==10) flagProcess =210;
169  else if (procID==1) flagProcess =220;
170  else if (procID==2) flagProcess =230;
171  else if (procID==8) flagProcess =240;
172  }
173 
174  else if (flagParticle == 3)
175 
176  {
177  if (procID==51) flagProcess =31;
178  else if (procID==52) flagProcess =32;
179  else if (procID==53) flagProcess =33;
180  else if (procID==57) flagProcess =35;
181  }
182 
183  else if (flagParticle == 4)
184 
185  {
186  if (procID==51) flagProcess =41;
187  else if (procID==52) flagProcess =42;
188  else if (procID==53) flagProcess =43;
189  else if (procID==56) flagProcess =44;
190  else if (procID==10) flagProcess =410;
191  else if (procID==1) flagProcess =420;
192  else if (procID==2) flagProcess =430;
193  else if (procID==8) flagProcess =440;
194  }
195 
196  else if (flagParticle == 5)
197 
198  {
199  if (procID==51) flagProcess =51;
200  else if (procID==52) flagProcess =52;
201  else if (procID==53) flagProcess =53;
202  else if (procID==56) flagProcess =54;
203  else if (procID==57) flagProcess =55;
204  else if (procID==10) flagProcess =510;
205  else if (procID==1) flagProcess =520;
206  else if (procID==2) flagProcess =530;
207  else if (procID==8) flagProcess =540;
208  }
209 
210  else if (flagParticle == 6)
211 
212  {
213  if (procID==51) flagProcess =61;
214  else if (procID==52) flagProcess =62;
215  else if (procID==53) flagProcess =63;
216  else if (procID==57) flagProcess =65;
217  }
218 
219  else if (processName=="GenericIon_G4DNAIonisation") flagProcess =73;
220  else if (processName=="msc") flagProcess =710;
221  else if (processName=="CoulombScat") flagProcess =720;
222  else if (processName=="ionIoni") flagProcess =730;
223  else if (processName=="nuclearStopping") flagProcess =740;
224  // (for all GenericIons)
225 
226  // Alternatively, using process names
227 
228  /*
229  if (processName=="e-_G4DNAElectronSolvation") flagProcess =10;
230  else if (processName=="e-_G4DNAElastic") flagProcess =11;
231  else if (processName=="e-_G4DNAExcitation") flagProcess =12;
232  else if (processName=="e-_G4DNAIonisation") flagProcess =13;
233  else if (processName=="e-_G4DNAAttachment") flagProcess =14;
234  else if (processName=="e-_G4DNAVibExcitation") flagProcess =15;
235  else if (processName=="eCapture") flagProcess =16;
236  else if (processName=="msc") flagProcess =17;
237  else if (processName=="eIoni") flagProcess =130;
238 
239  else if (processName=="proton_G4DNAElastic") flagProcess =21;
240  else if (processName=="proton_G4DNAExcitation") flagProcess =22;
241  else if (processName=="proton_G4DNAIonisation") flagProcess =23;
242  else if (processName=="proton_G4DNAChargeDecrease") flagProcess =24;
243  else if (processName=="hIoni") flagProcess =230;
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  CommandLineParser* parser = CommandLineParser::GetParser();
282  Command* command(0);
283  if((command = parser->GetCommandIfActive("-out"))==0) return;
284 
285  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
286 
287  // fill ntuple
288  analysisManager->FillNtupleDColumn(0, flagParticle);
289  analysisManager->FillNtupleDColumn(1, flagProcess);
290  analysisManager->FillNtupleDColumn(2, x);
291  analysisManager->FillNtupleDColumn(3, y);
292  analysisManager->FillNtupleDColumn(4, z);
293  analysisManager->FillNtupleDColumn(5,
294  step->GetTotalEnergyDeposit()/eV);
295 
296  analysisManager->FillNtupleDColumn(6,
297  std::sqrt((x-xp)*(x-xp)+
298  (y-yp)*(y-yp)+(z-zp)*(z-zp)));
299 
300  analysisManager->FillNtupleDColumn(7,
301  (preStep->
302  GetKineticEnergy() -
303  postStep->
304  GetKineticEnergy())/eV );
305 
306  analysisManager->FillNtupleDColumn(8, preStep->
307  GetKineticEnergy()/eV);
308 
309  analysisManager->FillNtupleDColumn(9,
310  preStep->GetMomentumDirection()
311  *postStep->GetMomentumDirection() );
312 
313  analysisManager->FillNtupleIColumn(10,
315  GetConstCurrentEvent()->GetEventID());
316 
317  analysisManager->FillNtupleIColumn(11, step->GetTrack()->GetTrackID());
318 
319  analysisManager->FillNtupleIColumn(12, step->GetTrack()->GetParentID());
320 
321  analysisManager->FillNtupleIColumn(13,
322  step->GetTrack()->GetCurrentStepNumber());
323 
324  analysisManager->AddNtupleRow();
325  }
326 }
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
CommandLineParser * parser(0)
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
Command * GetCommandIfActive(const G4String &marker)
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