Geant4  10.01.p02
PurgMagSteppingAction.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 // Code developed by:
27 // S.Larsson
28 //
29 // ***********************************
30 // * *
31 // * PurgMagSteppingAction.cc *
32 // * *
33 // ***********************************
34 //
35 // $Id: PurgMagSteppingAction.cc 84366 2014-10-14 12:46:20Z gcosmo $
36 //
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
39 
40 #include "PurgMagSteppingAction.hh"
41 #include "PurgMagRunAction.hh"
43 
44 #include "G4SteppingManager.hh"
45 #include "G4VTouchable.hh"
46 #include "G4VPhysicalVolume.hh"
47 
49 #include "G4SystemOfUnits.hh"
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
52 
55 :Detector(det)
56 { }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59 
61 { }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
64 
66 
67 {
68  //Collection at SSD in N-tuples. Electrons and photons separated
69  //Prestep point in World, next volume MeasureVolume, process transportation
71  if ((aStep->GetPreStepPoint()->GetPhysicalVolume() == Detector->GetWorld())&&
72  (aStep->GetTrack()->GetNextVolume() == Detector->GetMeasureVolume())&&
73  //(aStep->GetTrack()->GetMomentumDirection().z()>0.)&& // only particles with positive momentum
74  (aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "Transportation"))
75  {
76  G4double gx, gy, gz, ge, gpx, gpy, gpz, ex, ey, ez, ee;
77  G4double epx, epy, epz, px, py, pz, pe, ppx, ppy, ppz;
78 
79 
80  // Electrons
82  == "e-")
83  {//Position
84  ex = (aStep->GetTrack()->GetPosition().x())/cm;
85  ey = (aStep->GetTrack()->GetPosition().y())/cm;
86  ez = (aStep->GetTrack()->GetPosition().z())/cm;
87  // Energy
88  ee = (aStep->GetTrack()->GetKineticEnergy())/MeV;
89  // Momentum
90  epx = aStep->GetTrack()->GetMomentum().x();
91  epy = aStep->GetTrack()->GetMomentum().y();
92  epz = aStep->GetTrack()->GetMomentum().z();
93 
94  // Fill N-tuple electrons
95  analysis->fill_Tuple_Electrons(ex, ey, ez, ee, epx, epy, epz);
96  }
97 
98  // Photons
99  if (aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->
100  GetParticleName() == "gamma")
101  {
102 
103  // Position
104  gx = (aStep->GetTrack()->GetPosition().x())/cm;
105  gy = (aStep->GetTrack()->GetPosition().y())/cm;
106  gz = (aStep->GetTrack()->GetPosition().z())/cm;
107 
108  // Energy
109  ge = (aStep->GetTrack()->GetKineticEnergy())/MeV;
110 
111  // Momentum
112  gpx = aStep->GetTrack()->GetMomentum().x();
113  gpy = aStep->GetTrack()->GetMomentum().y();
114  gpz = aStep->GetTrack()->GetMomentum().z();
115 
116  // Fill N-tuple photons
117  analysis->fill_Tuple_Gamma(gx, gy, gz, ge, gpx, gpy, gpz);
118  }
119 
120 
121  // Positrons
122  if (aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName() == "e+")
123  {
124 
125  // Position
126  px = (aStep->GetTrack()->GetPosition().x())/cm;
127  py = (aStep->GetTrack()->GetPosition().y())/cm;
128  pz = (aStep->GetTrack()->GetPosition().z())/cm;
129 
130  // Energy
131  pe = (aStep->GetTrack()->GetKineticEnergy())/MeV;
132 
133  // Momentum
134  ppx = aStep->GetTrack()->GetMomentum().x();
135  ppy = aStep->GetTrack()->GetMomentum().y();
136  ppz = aStep->GetTrack()->GetMomentum().z();
137 
138  // Fill Ntuple positrons
139  analysis->fill_Tuple_Positrons(px, py, pz, pe, ppx, ppy, ppz);
140  }
141  }
142 }
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
static const double cm
Definition: G4SIunits.hh:106
static const double MeV
Definition: G4SIunits.hh:193
PurgMagSteppingAction(const PurgMagDetectorConstruction *)
const G4DynamicParticle * GetDynamicParticle() const
const G4ThreeVector & GetPosition() const
void fill_Tuple_Gamma(G4double, G4double, G4double, G4double, G4double, G4double, G4double)
const PurgMagDetectorConstruction * Detector
G4ParticleDefinition * GetDefinition() const
const G4String & GetParticleName() const
G4VPhysicalVolume * GetNextVolume() const
G4StepPoint * GetPreStepPoint() const
G4double GetKineticEnergy() const
G4VPhysicalVolume * GetPhysicalVolume() const
Definition: G4Step.hh:76
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4ThreeVector GetMomentum() const
void fill_Tuple_Positrons(G4double, G4double, G4double, G4double, G4double, G4double, G4double)
const G4VProcess * GetProcessDefinedStep() const
Uncomment #include to switch to ROOT or XML output file.
G4StepPoint * GetPostStepPoint() const
void UserSteppingAction(const G4Step *)
void fill_Tuple_Electrons(G4double, G4double, G4double, G4double, G4double, G4double, G4double)
const G4VPhysicalVolume * GetWorld() const
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
const G4VPhysicalVolume * GetMeasureVolume() const
static PurgMagAnalysisManager * getInstance()