Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CCalSteppingAction.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 //
27 // File: CCalSeppingAction.cc
28 // Description: Study profiling during the steps
30 #include <iostream>
31 #include <cmath>
32 
33 #include "CCalSteppingAction.hh"
34 
35 #include "G4SystemOfUnits.hh"
36 #include "G4SDManager.hh"
37 #include "G4StepPoint.hh"
38 #include "G4ThreeVector.hh"
39 
40 #ifdef G4ANALYSIS_USE
41 #include "CCalAnalysis.hh"
42 #endif
43 
44 
45 CCalSteppingAction::CCalSteppingAction(){
46 
47 #ifdef G4ANALYSIS_USE
48  CCalAnalysis* analysis = CCalAnalysis::getInstance();
49  timeHistoMaxBin=analysis->maxbin();
50 #else
51  timeHistoMaxBin=1;
52 #endif
53 
54  int i;
55  for (i=0; i<200; i++) {timeDeposit[i] = 0.;}
56  for (i=0; i<70; i++) {LateralProfile[i] = 0.;}
57 
58 }
59 
60 
62  G4cout << "CCalSteppingAction deleted" << G4endl;
63 }
64 
65 
67 
68  G4StepPoint* PostStepPoint= aStep->GetPostStepPoint();
69  G4StepPoint* PreStepPoint= aStep->GetPreStepPoint();
70  int TSliceID;
71 
72  if ( PostStepPoint->GetGlobalTime() / nanosecond > 1.0E9 ) TSliceID = 999999999;
73  else TSliceID = static_cast<int>( PostStepPoint->GetGlobalTime() / nanosecond );
74  TSliceID = TSliceID<timeHistoMaxBin ? TSliceID : timeHistoMaxBin-1;
75  timeDeposit[TSliceID] += aStep->GetTotalEnergyDeposit() / GeV;
76 
77  G4ThreeVector HitPoint = 0.5*(PostStepPoint->GetPosition()+
78  PreStepPoint->GetPosition());
79  // Because the beam axis has been defined as the x-axis,
80  // the lateral displacement is given in terms of the y and z positions.
81  double perp = std::sqrt(HitPoint.y()*HitPoint.y()+HitPoint.z()*HitPoint.z());
82  int radialPosition = std::min(69,int(perp/cm));
83  LateralProfile[radialPosition] += aStep->GetTotalEnergyDeposit() / GeV;
84 
85 }
86 
87 
88 void CCalSteppingAction::endOfEvent(){
89 
90 #ifdef G4ANALYSIS_USE
91  CCalAnalysis* analysis = CCalAnalysis::getInstance();
92  analysis->InsertLateralProfile(LateralProfile);
93  analysis->InsertTime(timeDeposit);
94 #endif
95 
96  int i=0;
97  for (i=0; i<70; i++){LateralProfile[i] = 0.;}
98  for (i=0; i<200; i++){timeDeposit[i] = 0.;}
99 
100  G4cout << " --- End of event --- " << G4endl;
101 
102 }