source: trunk/examples/extended/parameterisations/gflash/src/ExGflashEventAction.cc@ 1337

Last change on this file since 1337 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

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