Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
extended/electromagnetic/TestEm15/src/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 //
26 /// \file electromagnetic/TestEm15/src/SteppingAction.cc
27 /// \brief Implementation of the SteppingAction class
28 //
29 // $Id: SteppingAction.cc 73022 2013-08-15 09:09:48Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "SteppingAction.hh"
35 #include "DetectorConstruction.hh"
36 #include "RunAction.hh"
37 #include "HistoManager.hh"
38 
39 #include "G4RunManager.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44  RunAction* RuAct)
45 :G4UserSteppingAction(),fDetector(det), fRunAction(RuAct)
46 { }
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
51 { }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 {
57  G4StepPoint* prePoint = aStep->GetPreStepPoint();
58 
59  // if World --> return
60  if(prePoint->GetTouchableHandle()->GetVolume()==fDetector->GetWorld()) return;
61 
62  // here we enter in the absorber Box
63  // tag the event to be killed anyway after this step
64  //
66 
67  //count processes and keep only Multiple Scattering
68  //
69  G4StepPoint* endPoint = aStep->GetPostStepPoint();
70  G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
71  fRunAction->CountProcesses(procName);
72 
73  if (procName != "msc" && procName != "muMsc" && procName != "stepMax") return;
74 
75  //below, only multiple Scattering happens
76  //
77  G4ThreeVector position = endPoint->GetPosition();
78  G4ThreeVector direction = endPoint->GetMomentumDirection();
79 
80  G4double truePathLength = aStep->GetStepLength();
81  G4double geomPathLength = position.x() + 0.5*fDetector->GetBoxSize();
82  G4double ratio = geomPathLength/truePathLength;
83  fRunAction->SumPathLength(truePathLength,geomPathLength);
84  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
85  analysisManager->FillH1(1,truePathLength);
86  analysisManager->FillH1(2,geomPathLength);
87  analysisManager->FillH1(3,ratio);
88 
89  G4double yend = position.y(), zend = position.z();
90  G4double lateralDisplacement = std::sqrt(yend*yend + zend*zend);
91  fRunAction->SumLateralDisplacement(lateralDisplacement);
92  analysisManager->FillH1(4,lateralDisplacement);
93 
94  G4double psi = std::atan(lateralDisplacement/geomPathLength);
95  fRunAction->SumPsi(psi);
96  analysisManager->FillH1(5,psi);
97 
98  G4double xdir = direction.x(), ydir = direction.y(), zdir = direction.z();
99  G4double tetaPlane = std::atan2(ydir, xdir);
100  fRunAction->SumTetaPlane(tetaPlane);
101  analysisManager->FillH1(6,tetaPlane);
102  tetaPlane = std::atan2(zdir, xdir);
103  fRunAction->SumTetaPlane(tetaPlane);
104  analysisManager->FillH1(6,tetaPlane);
105 
106  G4double phiPos = std::atan2(zend, yend);
107  analysisManager->FillH1(7,phiPos);
108  G4double phiDir = std::atan2(zdir, ydir);
109  analysisManager->FillH1(8,phiDir);
110 
111  G4double phiCorrel = 0.;
112  if (lateralDisplacement > 0.)
113  phiCorrel = (yend*ydir + zend*zdir)/lateralDisplacement;
114  fRunAction->SumPhiCorrel(phiCorrel);
115  analysisManager->FillH1(9,phiCorrel);
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
120 
G4double GetStepLength() const
double x() const
void UserSteppingAction(const G4Step *)
double z() const
G4StepPoint * GetPreStepPoint() const
const G4ThreeVector & GetMomentumDirection() const
const G4ThreeVector & GetPosition() const
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:46
Definition: G4Step.hh:76
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
const G4VProcess * GetProcessDefinedStep() const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
G4StepPoint * GetPostStepPoint() const
double y() const
virtual void AbortEvent()
void SumPathLength(G4double truepl, G4double geompl)
double G4double
Definition: G4Types.hh:76
const G4TouchableHandle & GetTouchableHandle() const