source: trunk/examples/extended/electromagnetic/TestEm10/src/Em10EventAction.cc@ 1345

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

tag geant4.9.4 beta 1 + modifs locales

File size: 6.8 KB
RevLine 
[807]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//
[1337]27// $Id: Em10EventAction.cc,v 1.7 2010/06/06 04:33:02 perl Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
[807]29//
30//
31
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34
35#include "Em10EventAction.hh"
36
37#include "Em10RunAction.hh"
38
39#include "Em10CalorHit.hh"
40#include "Em10EventActionMessenger.hh"
41
42#include "G4Event.hh"
43#include "G4EventManager.hh"
44#include "G4HCofThisEvent.hh"
45#include "G4VHitsCollection.hh"
46#include "G4SDManager.hh"
47#include "G4UImanager.hh"
48#include "G4ios.hh"
49#include "G4UnitsTable.hh"
50#include "Randomize.hh"
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53
54Em10EventAction::Em10EventAction(Em10RunAction* Em10RA)
55:calorimeterCollID(-1),eventMessenger(0),
56 runaction(Em10RA),verboselevel(0),drawFlag("all"),printModulo(10000)
57{
58 eventMessenger = new Em10EventActionMessenger(this);
59}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
63Em10EventAction::~Em10EventAction()
64{
65 delete eventMessenger;
66}
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
69
70void Em10EventAction::BeginOfEventAction(const G4Event* evt)
71{
72 G4int evtNb = evt->GetEventID();
73 if (evtNb%printModulo == 0)
74 G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
75
76 if(verboselevel>1)
77 G4cout << "<<< Event " << evtNb << " started." << G4endl;
78
79 if (calorimeterCollID==-1)
80 {
81 G4SDManager * SDman = G4SDManager::GetSDMpointer();
82 calorimeterCollID = SDman->GetCollectionID("CalCollection");
83 }
84
85 nstep = 0. ;
86 nstepCharged = 0. ;
87 nstepNeutral = 0. ;
88 Nch = 0. ;
89 Nne = 0. ;
90 NE=0.;
91 NP=0.;
92 Transmitted=0.;
93 Reflected =0.;
94}
95
96//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
97
98void Em10EventAction::EndOfEventAction(const G4Event* evt)
99{
100 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
101 Em10CalorHitsCollection* CHC = 0;
102 if (HCE)
103 CHC = (Em10CalorHitsCollection*)(HCE->GetHC(calorimeterCollID));
104
105 if (CHC)
106 {
107 int n_hit = CHC->entries();
108 // if(verboselevel==2)
109 // G4cout << " " << n_hit
110 // << " hits are stored in Em10CalorHitsCollection." << G4endl;
111
112 G4double totEAbs=0, totLAbs=0;
113 for (int i=0;i<n_hit;i++)
114 { totEAbs += (*CHC)[i]->GetEdepAbs();
115 totLAbs += (*CHC)[i]->GetTrakAbs();
116 }
117 if(verboselevel==2)
118 G4cout
119 << " Absorber: total energy: " << std::setw(7) <<
120 G4BestUnit(totEAbs,"Energy")
121 << " total track length: " << std::setw(7) <<
122 G4BestUnit(totLAbs,"Length")
123 << G4endl;
124
125 // count event, add deposits to the sum ...
126 runaction->CountEvent() ;
127 runaction->AddTrackLength(totLAbs) ;
128 runaction->AddnStepsCharged(nstepCharged) ;
129 runaction->AddnStepsNeutral(nstepNeutral) ;
130 if(verboselevel==2)
131 G4cout << " Ncharged=" << Nch << " , Nneutral=" << Nne << G4endl;
132 runaction->CountParticles(Nch,Nne);
133 runaction->AddEP(NE,NP);
134 runaction->AddTrRef(Transmitted,Reflected) ;
135 runaction->AddEdeps(totEAbs) ;
136 runaction->FillEn(totEAbs) ;
137
138 nstep=nstepCharged+nstepNeutral ;
139 runaction->FillNbOfSteps(nstep);
140 }
141
142 if(verboselevel>0)
143 G4cout << "<<< Event " << evt->GetEventID() << " ended." << G4endl;
144
145
146 //save rndm status
147 if (runaction->GetRndmFreq() == 2)
148 {
149 CLHEP::HepRandom::saveEngineStatus("endOfEvent.rndm");
150 G4int evtNb = evt->GetEventID();
151 if (evtNb%printModulo == 0)
152 {
153 G4cout << "\n---> End of Event: " << evtNb << G4endl;
154 CLHEP::HepRandom::showEngineStatus();
155 }
156 }
157}
158
159//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
160
161G4int Em10EventAction::GetEventno()
162{
163 G4int evno = fpEventManager->GetConstCurrentEvent()->GetEventID() ;
164 return evno ;
165}
166
167//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
168
169void Em10EventAction::setEventVerbose(G4int level)
170{
171 verboselevel = level ;
172}
173
174//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
175
176void Em10EventAction::CountStepsCharged()
177{
178 nstepCharged += 1. ;
179}
180
181//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
182
183void Em10EventAction::CountStepsNeutral()
184{
185 nstepNeutral += 1. ;
186}
187
188//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
189
190void Em10EventAction::AddCharged()
191{
192 Nch += 1.;
193}
194
195//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
196
197void Em10EventAction::AddNeutral()
198{
199 Nne += 1.;
200}
201
202//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
203
204void Em10EventAction::AddE()
205{
206 NE += 1.;
207}
208
209//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
210
211void Em10EventAction::AddP()
212{
213 NP += 1.;
214}
215
216//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
217
218void Em10EventAction::SetTr()
219{
220 Transmitted = 1.;
221}
222
223//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
224
225void Em10EventAction::SetRef()
226{
227 Reflected = 1.;
228}
229
230//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
231
232
233
Note: See TracBrowser for help on using the repository browser.