ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExGflashEventAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExGflashEventAction.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 //
26 //
29 //
30 // Created by Joanna Weng 26.11.2004
31 
32 
33 #include "ExGflashEventAction.hh"
34 #include "ExGflashHit.hh"
35 #include "G4EventManager.hh"
36 #include "G4SDManager.hh"
37 #include "G4UImanager.hh"
38 #include "G4TrajectoryContainer.hh"
39 #include "G4Event.hh"
40 #include "G4SystemOfUnits.hh"
41 //std
42 #include <iostream>
43 #include <algorithm>
44 //Gflash
45 using namespace std;
46 
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 
52  fNevent(0),fDtime(0.0),fCalorimeterCollectionId(-1)
53 {
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {
60  if ( fNevent > 0 ) {
61  G4cout << "Internal Real Elapsed Time /event is: "<< fDtime /fNevent<< G4endl;
62  }
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
70  G4cout<<" ------ Start ExGflashEventAction ----- "<<G4endl;
71  fNevent=evt->GetEventID();
72  G4cout<<" Start generating event Nr "<<fNevent<<G4endl<<G4endl;
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
80  G4cout << G4endl;
81  G4cout << "******************************************";
82  G4cout << G4endl;
83  G4cout << "Internal Real Elapsed Time is: "<< fTimerIntern.GetRealElapsed();
84  G4cout << G4endl;
85  G4cout << "Internal System Elapsed Time: " << fTimerIntern.GetSystemElapsed();
86  G4cout << G4endl;
87  G4cout << "Internal GetUserElapsed Time: " << fTimerIntern.GetUserElapsed();
88  G4cout << G4endl;
89  G4cout << "******************************************"<< G4endl;
91  G4cout<<" ------ ExGflashEventAction::End of event nr. "<<fNevent<<" -----"<< G4endl;
92 
94  G4String colNam;
95  fCalorimeterCollectionId=SDman->GetCollectionID(colNam="ExGflashCollection");
96  if (fCalorimeterCollectionId<0) return;
97  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
98  ExGflashHitsCollection* THC = 0;
99  G4double totE = 0;
100  // Read out of the crysta ECAL
102  if (THC)
103  {
105  int n_hit = THC->entries();
106  G4cout<<" " << n_hit<< " hits are stored in ExGflashHitsCollection "<<G4endl;
107  G4PrimaryVertex* pvertex=evt->GetPrimaryVertex();
109  G4ThreeVector vtx=pvertex->GetPosition();
110  G4PrimaryParticle* pparticle=pvertex->GetPrimary();
111  // direction of the Shower
112  G4ThreeVector mom=pparticle->GetMomentum()/pparticle->GetMomentum().mag();
113 
114  //@@@ ExGflashEventAction: Magicnumber
115  G4double energyincrystal[100];
116  G4int hitsincrystal[100];
117  for (int i=0;i<100;i++) energyincrystal[i]=0.;
118  for (int i=0;i<100;i++) hitsincrystal[i]=0.;
119 
120  //@@@ ExGflashEventAction: Magicnumber
122  for (int i=0;i<n_hit;i++)
123  {
124  G4double estep = (*THC)[i]->GetEdep()/GeV;
125  if (estep >0.0)
126  {
127  totE += (*THC)[i]->GetEdep()/GeV;
128  G4int num=(*THC)[i]->GetCrystalNum();
129 
130  energyincrystal[num]+=(*THC)[i]->GetEdep()/GeV;
131  hitsincrystal[num]++;
132  //G4cout << num << G4endl;
133  // G4cout << " Crystal Nummer " << (*THC)[i]->GetCrystalNum() << G4endl;
134  // G4cout << (*THC)[i]->GetCrystalNum() /10 <<
135  // " "<<(*THC)[i]->GetCrystalNum()%10 << G4endl;
136 
137  G4ThreeVector hitpos=(*THC)[i]->GetPos();
138  G4ThreeVector l (hitpos.x(), hitpos.y(), hitpos.z());
139  // distance from shower start
140  l = l - vtx;
141  // projection on shower axis = longitudinal profile
142  G4ThreeVector longitudinal = l;
143  // shower profiles (Radial)
144  G4ThreeVector radial = vtx.cross(l);
145  }
146  }
147  G4double max = 0;
148  G4int index = 0;
149  //Find crystal with maximum energy
150  for (int i=0;i<100;i++)
151  {
152  //G4cout << i <<" " << energyincrystal[i] << G4endl;
153  if (max <energyincrystal[i])
154  {
155  max=energyincrystal[i];
156  index = i;
157  }
158  }
159  //G4cout << index <<" NMAX " << index << G4endl;
160 
161  // 3x3 matrix of crystals around the crystal with the maximum energy deposit
162  G4double e3x3 =
163  energyincrystal[index]+energyincrystal[index+1]+energyincrystal[index-1]+
164  energyincrystal[index-10]+energyincrystal[index-9]+energyincrystal[index-11]+
165  energyincrystal[index+10]+energyincrystal[index+11]+energyincrystal[index+9];
166 
167  // 5x5 matrix of crystals around the crystal with the maximum energy deposit
168  G4double e5x5 =
169  energyincrystal[index]+energyincrystal[index+1]+energyincrystal[index-1]+
170  energyincrystal[index+2]+energyincrystal[index-2]+
171  energyincrystal[index-10]+energyincrystal[index-9]+energyincrystal[index-11]+
172  energyincrystal[index-8]+energyincrystal[index-12]+
173  energyincrystal[index+10]+energyincrystal[index+11]+energyincrystal[index+9]+
174  energyincrystal[index+12]+energyincrystal[index+8];
175 
176  // 3x3 matrix of crystals around the crystal with the maximum energy deposit
177  G4int num3x3 =
178  hitsincrystal[index]+hitsincrystal[index+1]+hitsincrystal[index-1]+
179  hitsincrystal[index-10]+hitsincrystal[index-9]+hitsincrystal[index-11]+
180  hitsincrystal[index+10]+hitsincrystal[index+11]+hitsincrystal[index+9];
181 
182  // 5x5 matrix of crystals around the crystal with the maximum energy deposit
183  G4int num5x5 =
184  hitsincrystal[index]+hitsincrystal[index+1]+hitsincrystal[index-1]+
185  hitsincrystal[index+2]+hitsincrystal[index-2]+
186  hitsincrystal[index-10]+hitsincrystal[index-9]+hitsincrystal[index-11]+
187  hitsincrystal[index-8]+hitsincrystal[index-12]+
188  hitsincrystal[index+10]+hitsincrystal[index+11]+hitsincrystal[index+9]+
189  hitsincrystal[index+12]+hitsincrystal[index+8];
190 
191  G4cout << " e1 " << energyincrystal[index]
192  << " e3x3 " << e3x3<< " GeV e5x5 " <<e5x5 <<G4endl;
193 
194  G4cout << " num1 " << hitsincrystal[index]
195  << " num3x3 " << num3x3<< " num5x5 " <<num5x5 <<G4endl;
196  }
197 
198  G4cout << " Total energy deposited in the calorimeter: " << totE << " (GeV)" << G4endl;
199  G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
200  G4int n_trajectories = 0;
201  if(trajectoryContainer){ n_trajectories = trajectoryContainer->entries(); }
202  G4cout << " " << n_trajectories << " trajectories stored in this event." << G4endl;
203 
204 }
205 
206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219