Geant4  10.03.p02
 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 //
26 // $Id: SteppingAction.cc 83010 2014-07-24 14:53:07Z gcosmo $
27 //
28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 
31 #include "SteppingAction.hh"
32 
33 #include "DetectorConstruction.hh"
34 #include "EventAction.hh"
35 
36 #include "G4Step.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41 :G4UserSteppingAction(),detector(det),eventAct(evt)
42 {
43  first = true;
44  lvol_world = lvol_module = lvol_layer = lvol_fiber = 0;
45 }
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50 {}
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 {
56  //some initialisation
57  //
58  if (first) {
59  lvol_world = detector->GetLvolWorld();
60  lvol_module = detector->GetLvolModule();
61  lvol_layer = detector->GetLvolLayer();
62  lvol_fiber = detector->GetLvolFiber();
63  first = false;
64  }
65 
66  //if no edep, return
67  //
68  G4double edep = step->GetTotalEnergyDeposit();
70 
71  //locate point in geometry
72  //
73  G4int iModule = 0;
74  G4int iLayer = 0;
75  G4int iFiber = 0;
76 
78  G4LogicalVolume* lvol = touch1->GetVolume()->GetLogicalVolume();
79 
80  if (lvol == lvol_world) return;
81  else if (lvol == lvol_module) { iModule = touch1->GetCopyNumber(0);}
82  else if (lvol == lvol_layer) { iLayer = touch1->GetCopyNumber(0);
83  iModule = touch1->GetCopyNumber(1);}
84  else if (lvol == lvol_fiber) { iFiber = touch1->GetCopyNumber(0);
85  iLayer = touch1->GetCopyNumber(1);
86  iModule = touch1->GetCopyNumber(2);}
87 
88  // sum edep
89  //
90  eventAct->SumDeStep(iModule, iLayer, iFiber, edep);
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
96 {
97  //Example of Birk attenuation law in organic scintillators.
98  //adapted from Geant3 PHYS337. See MIN 80 (1970) 239-244
99  //
100  G4Material* material = aStep->GetTrack()->GetMaterial();
101  G4double birk1 = material->GetIonisation()->GetBirksConstant();
102  G4double destep = aStep->GetTotalEnergyDeposit();
103  G4double stepl = aStep->GetStepLength();
104  G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
105  //
106  G4double response = destep;
107  if (birk1*destep*stepl*charge != 0.)
108  {
109  response = destep/(1. + birk1*destep/stepl);
110  }
111  return response;
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
G4LogicalVolume * GetLvolModule()
G4ParticleDefinition * GetDefinition() const
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
G4double GetStepLength() const
void SumDeStep(G4int, G4int, G4int, G4double)
Definition: EventAction.cc:74
G4LogicalVolume * GetLvolLayer()
G4LogicalVolume * GetLvolFiber()
Event action class.
Definition: EventAction.hh:45
G4int GetCopyNumber(G4int depth=0) const
void UserSteppingAction(const G4Step *)
int G4int
Definition: G4Types.hh:78
G4double GetBirksConstant() const
string material
Definition: eplot.py:19
G4StepPoint * GetPreStepPoint() const
Definition: G4Step.hh:76
G4double GetTotalEnergyDeposit() const
G4Material * GetMaterial() const
G4double BirksAttenuation(const G4Step *)
G4LogicalVolume * GetLogicalVolume() const
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
Detector construction class to define materials and geometry.
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
G4double GetPDGCharge() const
const G4TouchableHandle & GetTouchableHandle() const
G4LogicalVolume * GetLvolWorld()