source: trunk/examples/extended/medical/fanoCavity/src/SteppingAction.cc @ 1342

Last change on this file since 1342 was 1342, checked in by garnier, 14 years ago

update ti head

File size: 5.3 KB
Line 
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// $Id: SteppingAction.cc,v 1.5 2010/10/25 13:29:08 gunter Exp $
27// GEANT4 tag $Name: examples-V09-03-09 $
28//
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
32#include "SteppingAction.hh"
33#include "DetectorConstruction.hh"
34#include "RunAction.hh"
35#include "EventAction.hh"
36#include "TrackingAction.hh"
37#include "HistoManager.hh"
38
39#include "G4SteppingManager.hh"
40#include "G4Gamma.hh"
41#include "G4UnitsTable.hh"
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45SteppingAction::SteppingAction(DetectorConstruction* det, RunAction* RuAct,
46                               EventAction* EvAct,TrackingAction* TrAct,
47                               HistoManager* histo)
48:detector(det), runAction(RuAct), eventAction(EvAct), trackAction(TrAct),
49 histoManager(histo), wall(0), cavity(0)
50{ 
51  first = true;
52  trackSegm = 0.;
53  directionIn = G4ThreeVector(0.,0.,0.);
54}
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58SteppingAction::~SteppingAction()
59{ }
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
63void SteppingAction::UserSteppingAction(const G4Step* step)
64{
65 //get detector pointers
66 if (first) {
67   wall   = detector->GetWall();
68   cavity = detector->GetCavity();
69   first  = false;
70 }
71 
72 //get volume
73 //
74 G4StepPoint* point1 = step->GetPreStepPoint();
75 G4VPhysicalVolume* volume = point1->GetTouchableHandle()->GetVolume();
76 
77 // count processes
78 //
79 G4StepPoint* point2 = step->GetPostStepPoint(); 
80 const G4VProcess* process = point2->GetProcessDefinedStep();
81 if (process) runAction->CountProcesses(process->GetProcessName());
82 
83 //energy deposit in cavity
84 //
85 if (volume == cavity) { 
86   G4double edep = step->GetTotalEnergyDeposit();
87   if (edep > 0.) trackAction->AddEdepCavity(edep);     
88 }
89
90 //keep only charged particles
91 //
92 if (step->GetTrack()->GetDefinition() == G4Gamma::Gamma()) return;
93 
94 //step size of charged particles
95 //
96 G4int id;
97 G4double steplen = step->GetStepLength();
98 if (volume == wall) {runAction->StepInWall  (steplen); id = 9;}
99 else                {runAction->StepInCavity(steplen); id = 10;}
100 histoManager->FillHisto(id,steplen);
101 
102 //last step before hitting the cavity
103 //
104 if ((volume == wall) && (point2->GetStepStatus() == fGeomBoundary)) {
105   directionIn = point1->GetMomentumDirection();
106 } 
107 
108 //keep only charged particles within cavity
109 //
110 if (volume == wall) return;
111 
112 G4double ekin1 = point1->GetKineticEnergy();
113 G4double ekin2 = point2->GetKineticEnergy();
114 
115 //first step in cavity
116 //
117 if (point1->GetStepStatus() == fGeomBoundary) {
118   trackSegm = 0.;
119   G4ThreeVector vertex = step->GetTrack()->GetVertexPosition();
120   histoManager->FillHisto(4,vertex.z());         
121   runAction->FlowInCavity(0,ekin1);
122   histoManager->FillHisto(5,ekin1);
123   if (steplen>0.) {   
124     G4ThreeVector directionOut = 
125              (point2->GetPosition() - point1->GetPosition()).unit();
126     G4ThreeVector normal = point1->GetTouchableHandle()->GetSolid()
127                            ->SurfaceNormal(point1->GetPosition());
128     histoManager->FillHisto(6,std::acos(-directionIn*normal));
129     histoManager->FillHisto(7,std::acos(-directionOut*normal));
130   }               
131 }
132 
133 //within cavity
134 //
135 if (step->GetTrack()->GetCurrentStepNumber() == 1) trackSegm = 0.;
136 trackSegm += steplen;
137 if (ekin2 <= 0.) {
138   runAction->AddTrakCavity(trackSegm);
139   histoManager->FillHisto(8,trackSegm);     
140 } 
141 
142 //exit cavity
143 //
144 if (point2->GetStepStatus() == fGeomBoundary) {
145   runAction->FlowInCavity(1,ekin2);
146   runAction->AddTrakCavity(trackSegm);
147   histoManager->FillHisto(8,trackSegm);     
148 }
149}
150
151//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152
153
Note: See TracBrowser for help on using the repository browser.