Geant4  9.6.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$
27 //
28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 
31 #include "SteppingAction.hh"
32 
33 #include "DetectorConstruction.hh"
34 #include "RunAction.hh"
35 #include "PrimaryGeneratorAction.hh"
36 #include "EventAction.hh"
37 #include "HistoManager.hh"
38 
39 #include "G4Step.hh"
40 
41 #include "G4Geantino.hh"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
48 :G4UserSteppingAction(),detector(det),runAct(run),primary(prim),eventAct(evt),
49  histoManager(hist)
50 {
51  first = true;
52  lvol_world = lvol_module = lvol_layer = lvol_fiber = 0;
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {}
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {
64  //some initialisation
65  //
66  if (first) {
67  lvol_world = detector->GetLvolWorld();
68  lvol_module = detector->GetLvolModule();
69  lvol_layer = detector->GetLvolLayer();
70  lvol_fiber = detector->GetLvolFiber();
71 
72  calorThickness = detector->GetCalorThickness();
73  calorSizeYZ = detector->GetCalorSizeYZ();
74  moduleThickness = detector->GetModuleThickness();
75  d1Pixel = detector->GetD1Pixel();
76  d2Pixel = detector->GetD2Pixel();
77  n1pxl = detector->GetN1Pixels();
78  n2pxl = detector->GetN2Pixels();
79  n1shift = detector->GetN1Shift();
80 
81  first = false;
82  }
83 
84  //locate point in geometry
85  //
87  G4LogicalVolume* lvol = touch1->GetVolume()->GetLogicalVolume();
88 
89  //if world, return
90  //
91  if (lvol == lvol_world) return;
92 
93  //sum nb of radiation length of calorimeter with geantino
94  //
95  G4ParticleDefinition* particle = step->GetTrack()->GetDefinition();
96  if (particle == G4Geantino::Geantino()) {
97  G4double radl = lvol->GetMaterial()->GetRadlen();
98  G4double stepl = step->GetStepLength();
99  eventAct->SumNbRadLength(stepl/radl);
100  }
101 
102  //if no edep, return
103  //
105  if (edep == 0.) return;
106 
107  //locate position and compute pixel number
108  //
109  G4ThreeVector point1 = step->GetPreStepPoint()->GetPosition();
110  G4int i1Module = (int) ((point1.x() + 0.5*calorThickness)/moduleThickness);
111  G4int i1Pixel = (int) ((point1.x() + 0.5*calorThickness)/d1Pixel);
112  if (i1Pixel < 0 ) i1Pixel = 0;
113  if (i1Pixel >= n1pxl) i1Pixel = n1pxl - 1;
114  G4double point1yz = point1.y();
115  if (i1Module%2 != 0) point1yz = point1.z();
116  G4int i2Pixel = (int) ((point1yz + 0.5*calorSizeYZ)/d2Pixel);
117  if (i2Pixel < 0 ) i2Pixel = 0;
118  if (i2Pixel >= n2pxl) i2Pixel = n2pxl - 1;
119 
120  G4int iPixel = i1Pixel*n1shift + i2Pixel;
121 
122  // sum total energy deposit
123  //
124  eventAct->SumTotalEnergy(iPixel, edep);
125 
126  //in fiber ?
127  //
128  if (lvol == lvol_fiber) {
129  eventAct->SumVisibleEnergy(iPixel, edep);
130  }
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134 
136 {
137  //Example of Birk attenuation law in organic scintillators.
138  //adapted from Geant3 PHYS337. See MIN 80 (1970) 239-244
139  //
140  G4Material* material = aStep->GetTrack()->GetMaterial();
141  G4double birk1 = material->GetIonisation()->GetBirksConstant();
142  G4double destep = aStep->GetTotalEnergyDeposit();
143  G4double stepl = aStep->GetStepLength();
144  G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
145  //
146  G4double response = destep;
147  if (birk1*destep*stepl*charge != 0.)
148  {
149  response = destep/(1. + birk1*destep/stepl);
150  }
151  return response;
152 }
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
155