Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SteppingAction.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 //
28 //
29 // $Id: SteppingAction.cc 95740 2016-02-23 09:34:37Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "SteppingAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "EventAction.hh"
37 #include "Run.hh"
38 #include "HistoManager.hh"
39 
40 #include "G4SteppingManager.hh"
41 #include "G4RunManager.hh"
42 #include "Randomize.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 :G4UserSteppingAction(),fDetector(det), fEventAction(event)
48 { }
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 { }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {
59  // count processes
60  //
61  const G4StepPoint* endPoint = step->GetPostStepPoint();
62  const G4VProcess* process = endPoint->GetProcessDefinedStep();
63  Run* run = static_cast<Run*>(
65  run->CountProcesses(process);
66 
67  G4double edep = step->GetTotalEnergyDeposit();
68  if (edep <= 0.) return;
69 
70  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
71 
72  //longitudinal profile of deposited energy
73  //randomize point of energy deposition
74  //
75  G4StepPoint* prePoint = step->GetPreStepPoint();
76  G4StepPoint* postPoint = step->GetPostStepPoint();
77  G4ThreeVector P1 = prePoint ->GetPosition();
78  G4ThreeVector P2 = postPoint->GetPosition();
79  G4ThreeVector point = P1 + G4UniformRand()*(P2 - P1);
80  G4double x = point.x();
81  G4double xshifted = x + 0.5*fDetector->GetAbsorSizeX();
82  analysisManager->FillH1(10, xshifted, edep);
83 
84  //total energy deposit in absorbers
85  //
86  G4int iabs = prePoint->GetTouchableHandle()->GetCopyNumber(0);
87  if (iabs > 0) fEventAction->AddEdep(iabs, edep);
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
void AddEdep(G4double Edep)
Definition: EventAction.hh:53
void CountProcesses(G4String procName)
Definition: Run.cc:72
static const G4double * P1[nN]
double x() const
tuple x
Definition: test.py:50
Event action class.
Definition: EventAction.hh:45
G4int GetCopyNumber(G4int depth=0) const
void UserSteppingAction(const G4Step *)
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
#define G4UniformRand()
Definition: Randomize.hh:97
const G4ThreeVector & GetPosition() const
Definition: G4Step.hh:76
G4double GetTotalEnergyDeposit() const
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
const G4VProcess * GetProcessDefinedStep() const
G4StepPoint * GetPostStepPoint() const
static const G4double * P2[nN]
Detector construction class to define materials and geometry.
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const
const G4TouchableHandle & GetTouchableHandle() const