Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Em10SteppingAction.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 /// \file electromagnetic/TestEm10/src/Em10SteppingAction.cc
27 /// \brief Implementation of the Em10SteppingAction class
28 //
29 //
30 // $Id: Em10SteppingAction.cc 73033 2013-08-15 09:24:45Z gcosmo $
31 //
32 //
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
37 #include "G4Electron.hh"
38 #include "G4Positron.hh"
39 #include "G4Gamma.hh"
40 #include "Em10SteppingAction.hh"
41 #include "Em10EventAction.hh"
42 #include "Em10RunAction.hh"
43 #include "G4Event.hh"
44 #include "G4VPhysicalVolume.hh"
45 #include "G4PhysicalConstants.hh"
46 #include "G4ios.hh"
47 #include <iomanip>
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 
52  Em10RunAction* RA)
53  :G4UserSteppingAction(),eventaction (EA),runaction (RA),
54  IDold(-1)
55 {}
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {}
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {
66 
67  G4double Theta,Thetaback,Ttrans,Tback,Tsec,Egamma,yend,zend,rend;
68 
69  G4int evno = eventaction->GetEventno();
70 
71  const G4Track* track = aStep->GetTrack();
72  const G4StepPoint* prePoint = aStep->GetPreStepPoint();
73  G4int trackID = track->GetTrackID();
74  G4int parentID = track->GetParentID();
75 
76  const G4DynamicParticle* dynParticle = track->GetDynamicParticle();
77  const G4ParticleDefinition* particle = dynParticle->GetDefinition();
78  G4VPhysicalVolume* preVol = prePoint->GetPhysicalVolume();
80 
81  IDnow = evno+10000*trackID+100000000*parentID;
82  if(IDnow != IDold) {
83  IDold=IDnow;
84  if(trackID > 1 && (particle == G4Electron::Electron() ||
85  particle == G4Positron::Positron() ||
86  particle == G4Gamma::Gamma())) {
87  runaction->Fillvertexz(track->GetVertexPosition().z());
88 
89  if(preVol->GetName()=="Absorber") {
90  if(particle == G4Gamma::Gamma()) {
91  eventaction->AddNeutral();
92  } else {
93  eventaction->AddCharged();
94  Tsec = track->GetKineticEnergy();
95  Tsec += aStep->GetTotalEnergyDeposit();
96  runaction->FillTsec(Tsec);
97  if(particle == G4Electron::Electron()) {
98  eventaction->AddE();
99  } else {
100  eventaction->AddP();
101  }
102  }
103  }
104  }
105  }
106 
107  if(preVol->GetName()=="Absorber") {
108  if(particle == G4Electron::Electron() ||
109  particle == G4Positron::Positron()) {
110  eventaction->CountStepsCharged();
111 
112  } else if(particle == G4Gamma::Gamma()) {
113  eventaction->CountStepsNeutral();
114  }
115 
116  if(prePoint->GetStepStatus() == fGeomBoundary &&
117  preVol != postVol) {
118 
119  if(trackID == 1) {
120  if(track->GetMomentumDirection().z()>0.) {
121 
122  eventaction->SetTr();
123  Theta = std::acos(track->GetMomentumDirection().z());
124  runaction->FillTh(Theta);
125  Ttrans = track->GetKineticEnergy();
126  runaction->FillTt(Ttrans);
127  yend= aStep->GetTrack()->GetPosition().y();
128  zend= aStep->GetTrack()->GetPosition().x();
129  rend = std::sqrt(yend*yend+zend*zend);
130  runaction->FillR(rend);
131 
132  } else {
133  eventaction->SetRef();
134  Thetaback = std::acos(aStep->GetTrack()->GetMomentumDirection().z());
135  Thetaback -= 0.5*pi;
136  runaction->FillThBack(Thetaback);
137  Tback = aStep->GetTrack()->GetKineticEnergy();
138  runaction->FillTb(Tback);
139  }
140  }
141  if(track->GetMomentumDirection().z()>0. &&
142  particle == G4Gamma::Gamma()) {
143 
144  Egamma = aStep->GetTrack()->GetKineticEnergy();
145  runaction->FillGammaSpectrum(Egamma);
146  }
147  }
148  }
149 }
150 
151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Fillvertexz(G4double z)
G4int GetParentID() const
Definition of the Em10EventAction class.
Definition of the Em10RunAction class.
double x() const
const G4DynamicParticle * GetDynamicParticle() const
G4StepStatus GetStepStatus() const
const G4ThreeVector & GetPosition() const
void FillTh(G4double Th)
G4ParticleDefinition * GetDefinition() const
void FillThBack(G4double Th)
int G4int
Definition: G4Types.hh:78
double z() const
G4StepPoint * GetPreStepPoint() const
void FillR(G4double R)
G4double GetKineticEnergy() const
G4VPhysicalVolume * GetPhysicalVolume() const
const G4String & GetName() const
Definition: G4Step.hh:76
G4int GetTrackID() const
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
void FillTt(G4double Tt)
const G4ThreeVector & GetVertexPosition() const
G4double GetTotalEnergyDeposit() const
Em10SteppingAction(Em10EventAction *, Em10RunAction *)
void UserSteppingAction(const G4Step *)
static G4Positron * Positron()
Definition: G4Positron.cc:94
const G4ThreeVector & GetMomentumDirection() const
Definition of the Em10SteppingAction class.
G4StepPoint * GetPostStepPoint() const
double y() const
Definition of the Em10DetectorConstruction class.
void FillTsec(G4double T)
void FillGammaSpectrum(G4double E)
static G4Electron * Electron()
Definition: G4Electron.cc:94
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
void FillTb(G4double Tt)