source: trunk/examples/extended/electromagnetic/TestEm3/src/SteppingAction.cc@ 1237

Last change on this file since 1237 was 1230, checked in by garnier, 16 years ago

update to geant4.9.3

File size: 5.8 KB
RevLine 
[807]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//
[1230]26// $Id: SteppingAction.cc,v 1.28 2008/05/29 16:59:27 vnivanch Exp $
27// GEANT4 tag $Name: geant4-09-03-cand-01 $
[807]28//
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
32#include "SteppingAction.hh"
33
34#include "DetectorConstruction.hh"
35#include "RunAction.hh"
36#include "EventAction.hh"
37#include "HistoManager.hh"
38
39#include "G4Step.hh"
40#include "G4Positron.hh"
41#include "G4RunManager.hh"
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45SteppingAction::SteppingAction(DetectorConstruction* det, RunAction* run,
46 EventAction* evt, HistoManager* hist)
47:G4UserSteppingAction(),detector(det),runAct(run),eventAct(evt),
48 histoManager(hist)
[1230]49{ }
[807]50
51//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52
53SteppingAction::~SteppingAction()
54{}
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58void SteppingAction::UserSteppingAction(const G4Step* aStep)
59{
60 //track informations
61 const G4StepPoint* prePoint = aStep->GetPreStepPoint();
62 const G4StepPoint* endPoint = aStep->GetPostStepPoint();
63 const G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition();
64
65 //if World, return
66 //
67 G4VPhysicalVolume* volume = prePoint->GetTouchableHandle()->GetVolume();
68 //if sum of absorbers do not fill exactly a layer: check material, not volume.
69 G4Material* mat = volume->GetLogicalVolume()->GetMaterial();
70 if (mat == detector->GetWorldMaterial()) return;
71
72 //here we are in an absorber. Locate it
73 //
74 G4int absorNum = prePoint->GetTouchableHandle()->GetCopyNumber(0);
75 G4int layerNum = prePoint->GetTouchableHandle()->GetCopyNumber(1);
76
77 // collect energy deposit
78 G4double edep = aStep->GetTotalEnergyDeposit();
79
80 // collect step length of charged particles
81 G4double stepl = 0.;
82 if (particle->GetPDGCharge() != 0.) stepl = aStep->GetStepLength();
[1230]83
84 // G4cout << "Nabs= " << absorNum << " edep(keV)= " << edep << G4endl;
85
[807]86 // sum up per event
87 eventAct->SumEnergy(absorNum,edep,stepl);
88
89 //longitudinal profile of edep per absorber
[1230]90 if (edep>0.) histoManager->FillHisto(MaxAbsor+absorNum,
91 G4double(layerNum+1), edep);
[807]92
93 //energy flow
94 //
95 // unique identificator of layer+absorber
96 G4int Idnow = (detector->GetNbOfAbsor())*layerNum + absorNum;
97 G4int plane;
98 //
99 //leaving the absorber ?
100 if (endPoint->GetStepStatus() == fGeomBoundary) {
101 G4ThreeVector position = endPoint->GetPosition();
102 G4ThreeVector direction = endPoint->GetMomentumDirection();
103 G4double sizeYZ = 0.5*detector->GetCalorSizeYZ();
104 G4double Eflow = endPoint->GetKineticEnergy();
105 if (particle == G4Positron::Positron()) Eflow += 2*electron_mass_c2;
106 if ((std::abs(position.y()) >= sizeYZ) || (std::abs(position.z()) >= sizeYZ))
107 runAct->sumLateralEleak(Idnow, Eflow);
108 else if (direction.x() >= 0.) runAct->sumEnergyFlow(plane=Idnow+1, Eflow);
109 else runAct->sumEnergyFlow(plane=Idnow, -Eflow);
110 }
111
112//// example of Birk attenuation
[1230]113///G4double destep = aStep->GetTotalEnergyDeposit();
114///G4double response = BirksAttenuation(aStep);
115///G4cout << " Destep: " << destep/keV << " keV"
116/// << " response after Birks: " << response/keV << " keV" << G4endl;
[807]117}
118
119//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120
[1230]121G4double SteppingAction::BirksAttenuation(const G4Step* aStep)
[807]122{
123 //Example of Birk attenuation law in organic scintillators.
124 //adapted from Geant3 PHYS337. See MIN 80 (1970) 239-244
125 //
[1230]126 G4Material* material = aStep->GetTrack()->GetMaterial();
127 G4double birk1 = material->GetIonisation()->GetBirksConstant();
[807]128 G4double destep = aStep->GetTotalEnergyDeposit();
[1230]129 G4double stepl = aStep->GetStepLength();
[807]130 G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
131 //
132 G4double response = destep;
[1230]133 if (birk1*destep*stepl*charge != 0.)
[807]134 {
[1230]135 response = destep/(1. + birk1*destep/stepl);
[807]136 }
137 return response;
138}
139
140//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
141
Note: See TracBrowser for help on using the repository browser.