ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CCalSteppingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CCalSteppingAction.cc
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 
32 #include "CCalSteppingAction.hh"
33 #include "CCalRunAction.hh"
34 #include "CCalAnalysis.hh"
35 
36 #include "G4SystemOfUnits.hh"
37 #include "G4SDManager.hh"
38 #include "G4StepPoint.hh"
39 #include "G4ThreeVector.hh"
40 #include "G4RunManager.hh"
41 
42 #include "CCalAnalysis.hh"
43 
45 {
46  timeHistoMaxBin = 200;
47  for (G4int i=0; i<200; i++) {timeDeposit[i] = 0.f;}
48  for (G4int i=0; i<70; i++) {LateralProfile[i] = 0.f;}
49 }
50 
52 }
53 
55 {
56  G4double de = aStep->GetTotalEnergyDeposit();
57  if(de < CLHEP::eV) { return; }
58 
59  const G4StepPoint* PostStepPoint= aStep->GetPostStepPoint();
60  const G4StepPoint* PreStepPoint= aStep->GetPreStepPoint();
61  G4double time =
62  (PostStepPoint) ? PostStepPoint->GetGlobalTime()/nanosecond : 0.;
63 
64  G4int it = (G4int)time;
65  it = std::min(it, 10000);
66  //G4cout << "## time= " << time << " it= " << it << G4endl;
67  G4int TSliceID = std::max(0,std::min(it,timeHistoMaxBin-1));
68 
69  G4float fde = (G4float)(de/CLHEP::GeV);
70  //G4cout << " TSliceID= " << TSliceID << " de= " << fde << G4endl;
71 
72  timeDeposit[TSliceID] += fde;
73 
74  G4ThreeVector HitPoint = 0.5*(PostStepPoint->GetPosition()+
75  PreStepPoint->GetPosition());
76  // Because the beam axis has been defined as the x-axis,
77  // the lateral displacement is given in terms of the y and z positions.
78  G4double perp =
79  std::sqrt(HitPoint.y()*HitPoint.y()+HitPoint.z()*HitPoint.z())/cm;
80  G4int ir = (G4int)perp;
81  //G4cout << " perp= " << perp << " ir= " << ir << G4endl;
82  G4int radialPosition = std::max(0,std::min(69,ir));
83  LateralProfile[radialPosition] += fde;
84  //G4cout << " done " << G4endl;
85 }
86 
88 
90  G4double totalFilledProfileHcal = 0.0;
91 
92  static G4int IDlateralProfile = -1;
93  if (IDlateralProfile < 0) {
94  IDlateralProfile = man->GetH1Id("h500");
95  }
96  for (G4int i=0; i<70; ++i) {
97  man->FillH1(IDlateralProfile+i,LateralProfile[i]);
98 #ifdef debug
99  G4cout << "Fill Profile Hcal histo " << i << " with " << LateralProfile[i] << G4endl;
100 #endif
101  totalFilledProfileHcal += LateralProfile[i];
102  }
103 
104 #ifdef debug
105  G4cout << "CCalAnalysis::InsertLateralProfile: Total filled Profile Hcal"
106  << " histo " << totalFilledProfileHcal << G4endl;
107 #endif
108 
109  static G4int IDTimeHist = -1;
110  if (IDTimeHist < 0) {
111  IDTimeHist = man->GetH1Id("h300");
112  }
113  static G4int IDTimeProfile = -1;
114  if (IDTimeProfile < 0) {
115  IDTimeProfile = man->GetH1Id("h901");
116  }
117  G4double totalFilledTimeProfile = 0.0;
118  for (G4int j=0; j<timeHistoMaxBin; ++j) {
119  man->FillH1(IDTimeHist+j,timeDeposit[j]);
120 #ifdef debug
121  G4cout << "Fill Time slice histo " << j << " with " << timeDeposit[j] << G4endl;
122 #endif
123  totalFilledTimeProfile += timeDeposit[j];
124 
125  G4double t = j + 0.5;
126  man->FillH1(IDTimeProfile+1,t,timeDeposit[j]);
127 #ifdef debug
128  G4cout << "Fill Time profile histo 1 with " << t << " " << timeDeposit[j] << G4endl;
129 #endif
130  }
131 #ifdef debug
132  G4cout << "CCalAnalysis::InsertTime: Total filled Time profile histo "
133  << totalFilledTimeProfile << G4endl;
134 #endif
135 
136  for (G4int i=0; i<70; i++){LateralProfile[i] = 0.f;}
137  for (G4int i=0; i<200; i++){timeDeposit[i] = 0.f;}
138 
139  G4cout << " --- End of event --- " << G4endl;
140 
141 }