Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExGflashEventAction.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 //
28 //
29 // Created by Joanna Weng 26.11.2004
30 
31 
32 #include "ExGflashEventAction.hh"
33 #include "ExGflashHit.hh"
34 #include "G4EventManager.hh"
35 #include "G4SDManager.hh"
36 #include "G4UImanager.hh"
37 #include "G4TrajectoryContainer.hh"
38 #include "G4Event.hh"
39 #include "G4SystemOfUnits.hh"
40 //std
41 #include <iostream>
42 #include <algorithm>
43 //Gflash
44 using namespace std;
45 
46 #include "G4Timer.hh"
47 extern G4Timer Timer;
48 extern G4Timer Timerintern;
49 
50 
51 
53 nevent(0),dtime(0.0),calorimeterCollectionId(-1)
54 {
55 }
56 
58 {
59  G4cout << "Internal Real Elapsed Time /event is: "<< dtime /nevent<< G4endl;
60 }
61 
62 
65  G4cout<<" ------ Start ExGflashEventAction ----- "<<G4endl;
66  nevent=evt->GetEventID();
67  G4cout<<" Start generating event Nr "<<nevent<<G4endl<<G4endl;
68 }
69 
71 {
72  Timerintern.Stop();
73  G4cout << G4endl;
74  G4cout << "******************************************";
75  G4cout << G4endl;
76  G4cout << "Internal Real Elapsed Time is: "<< Timerintern.GetRealElapsed();
77  G4cout << G4endl;
78  G4cout << "Internal System Elapsed Time: " << Timerintern.GetSystemElapsed();
79  G4cout << G4endl;
80  G4cout << "Internal GetUserElapsed Time: " << Timerintern.GetUserElapsed();
81  G4cout << G4endl;
82  G4cout << "******************************************"<< G4endl;
83  dtime+=Timerintern.GetRealElapsed();
84  G4cout<<" ------ ExGflashEventAction::End of event nr. "<<nevent<<" -----"<< G4endl;
85 
87  G4String colNam;
88  calorimeterCollectionId=SDman->GetCollectionID(colNam="ExGflashCollection");
89  if (calorimeterCollectionId<0) return;
90  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
91  ExGflashHitsCollection* THC = 0;
92  G4double totE = 0;
93  // Read out of the crysta ECAL
94  THC=(ExGflashHitsCollection *)(HCE->GetHC(calorimeterCollectionId));
95  if (THC) {
97  int n_hit = THC->entries();
98  G4cout<<" " << n_hit<< " hits are stored in ExGflashHitsCollection "<<G4endl;
99  G4PrimaryVertex* pvertex=evt->GetPrimaryVertex();
101  G4ThreeVector vtx=pvertex->GetPosition();
102  G4PrimaryParticle* pparticle=pvertex->GetPrimary();
103  // direction of the Shower
104  G4ThreeVector mom=pparticle->GetMomentum()/pparticle->GetMomentum().mag();
105 
106  //@@@ ExGflashEventAction: Magicnumber
107  G4double energyincrystal[100];
108  for (int i=0;i<100;i++) energyincrystal[i]=0.;
109 
110  //@@@ ExGflashEventAction: Magicnumber
112  for (int i=0;i<n_hit;i++)
113  {
114  G4double estep = (*THC)[i]->GetEdep()/GeV;
115  if (estep >0.0)
116  {
117  totE += (*THC)[i]->GetEdep()/GeV;
118  G4int num=(*THC)[i]->GetCrystalNum();
119 
120  energyincrystal[num]+=(*THC)[i]->GetEdep()/GeV;
121  //G4cout << num << G4endl;
122  // G4cout << " Crystal Nummer " << (*THC)[i]->GetCrystalNum() << G4endl;
123  // G4cout << (*THC)[i]->GetCrystalNum() /10 << " "<<(*THC)[i]->GetCrystalNum()%10 << G4endl;
124 
125  G4ThreeVector hitpos=(*THC)[i]->GetPos();
126  G4ThreeVector l (hitpos.x(), hitpos.y(), hitpos.z());
127  // distance from shower start
128  l = l - vtx;
129  // projection on shower axis = longitudinal profile
130  G4ThreeVector longitudinal = l;
131  // shower profiles (Radial)
132  G4ThreeVector radial = vtx.cross(l);
133  }
134  }
135  G4double max=0;
136  G4int index=0;
137  //Find crystal with maximum energy
138  for (int i=0;i<100;i++)
139  {
140  //G4cout << i <<" " << energyincrystal[i] << G4endl;
141  if (max <energyincrystal[i])
142  {
143  max=energyincrystal[i];
144  index = i;
145  }
146  }
147  //G4cout << index <<" NMAX " << index << G4endl;
148 
149  // 3x3 matrix of crystals around the crystal with the maximum energy deposit
150  G4double e3x3 = energyincrystal[index]+energyincrystal[index+1]+energyincrystal[index-1]+
151  energyincrystal[index-10]+energyincrystal[index-9]+energyincrystal[index-11]+
152  energyincrystal[index+10]+energyincrystal[index+11]+energyincrystal[index+9];
153 
154  // 5x5 matrix of crystals around the crystal with the maximum energy deposit
155  G4double e5x5 = energyincrystal[index]+energyincrystal[index+1]+energyincrystal[index-1]+energyincrystal[index+2]+energyincrystal[index-2]+
156  energyincrystal[index-10]+energyincrystal[index-9]+energyincrystal[index-11]+energyincrystal[index-8]+energyincrystal[index-12]+
157  energyincrystal[index+10]+energyincrystal[index+11]+energyincrystal[index+9]+energyincrystal[index+12]+energyincrystal[index+8];
158 
159  G4cout << " e1 " << energyincrystal[index] << " e3x3 " << e3x3<< " GeV e5x5 " <<e5x5 <<G4endl;
160  }
161 
162  G4cout << " Total energy deposited in the calorimeter: " << totE << " (GeV)" << G4endl;
163  G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
164  G4int n_trajectories = 0;
165  if(trajectoryContainer){ n_trajectories = trajectoryContainer->entries(); }
166  G4cout << " " << n_trajectories << " trajectories stored in this event." << G4endl;
167 }
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179