Geant4  10.00.p02
Em10EventAction.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 //
30 // $Id: Em10EventAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
31 //
32 //
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
36 
37 #include "Em10EventAction.hh"
38 
39 #include "Em10RunAction.hh"
40 
41 #include "Em10CalorHit.hh"
43 
44 #include "G4Event.hh"
45 #include "G4EventManager.hh"
46 #include "G4HCofThisEvent.hh"
47 #include "G4VHitsCollection.hh"
48 #include "G4SDManager.hh"
49 #include "G4UImanager.hh"
50 #include "G4ios.hh"
51 #include "G4UnitsTable.hh"
52 #include "Randomize.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57 :G4UserEventAction(),calorimeterCollID(-1),eventMessenger(0),
58  runaction(Em10RA),verboselevel(0),drawFlag("all"),printModulo(10000)
59 {
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
64 
66 {
67  delete eventMessenger;
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
71 
73 {
74  G4int evtNb = evt->GetEventID();
75  if (evtNb%printModulo == 0)
76  G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
77 
78  if(verboselevel>1)
79  G4cout << "<<< Event " << evtNb << " started." << G4endl;
80 
81  if (calorimeterCollID==-1)
82  {
84  calorimeterCollID = SDman->GetCollectionID("CalCollection");
85  }
86 
87  nstep = 0. ;
88  nstepCharged = 0. ;
89  nstepNeutral = 0. ;
90  Nch = 0. ;
91  Nne = 0. ;
92  NE=0.;
93  NP=0.;
94  Transmitted=0.;
95  Reflected =0.;
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
99 
101 {
102  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
103  Em10CalorHitsCollection* CHC = 0;
104  if (HCE)
106 
107  if (CHC)
108  {
109  int n_hit = CHC->entries();
110  // if(verboselevel==2)
111  // G4cout << " " << n_hit
112  // << " hits are stored in Em10CalorHitsCollection." << G4endl;
113 
114  G4double totEAbs=0, totLAbs=0;
115  for (int i=0;i<n_hit;i++)
116  { totEAbs += (*CHC)[i]->GetEdepAbs();
117  totLAbs += (*CHC)[i]->GetTrakAbs();
118  }
119  if(verboselevel==2)
120  G4cout
121  << " Absorber: total energy: " << std::setw(7) <<
122  G4BestUnit(totEAbs,"Energy")
123  << " total track length: " << std::setw(7) <<
124  G4BestUnit(totLAbs,"Length")
125  << G4endl;
126 
127  // count event, add deposits to the sum ...
128  runaction->CountEvent() ;
129  runaction->AddTrackLength(totLAbs) ;
132  if(verboselevel==2)
133  G4cout << " Ncharged=" << Nch << " , Nneutral=" << Nne << G4endl;
135  runaction->AddEP(NE,NP);
137  runaction->AddEdeps(totEAbs) ;
138  runaction->FillEn(totEAbs) ;
139 
142  }
143 
144  if(verboselevel>0)
145  G4cout << "<<< Event " << evt->GetEventID() << " ended." << G4endl;
146 
147 
148  //save rndm status
149  if (runaction->GetRndmFreq() == 2)
150  {
151  CLHEP::HepRandom::saveEngineStatus("endOfEvent.rndm");
152  G4int evtNb = evt->GetEventID();
153  if (evtNb%printModulo == 0)
154  {
155  G4cout << "\n---> End of Event: " << evtNb << G4endl;
156  CLHEP::HepRandom::showEngineStatus();
157  }
158  }
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
162 
164 {
166  return evno ;
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
170 
172 {
173  verboselevel = level ;
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
177 
179 {
180  nstepCharged += 1. ;
181 }
182 
183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
184 
186 {
187  nstepNeutral += 1. ;
188 }
189 
190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
191 
193 {
194  Nch += 1.;
195 }
196 
197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
198 
200 {
201  Nne += 1.;
202 }
203 
204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
205 
207 {
208  NE += 1.;
209 }
210 
211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
212 
214 {
215  NP += 1.;
216 }
217 
218 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
219 
221 {
222  Transmitted = 1.;
223 }
224 
225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
226 
228 {
229  Reflected = 1.;
230 }
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
233 
234 
235 
Definition of the Em10CalorHit class.
Em10EventAction(Em10RunAction *Em10RA)
Definition of the Em10EventAction class.
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
Definition of the Em10RunAction class.
G4int entries() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void FillNbOfSteps(G4double nstep)
void setEventVerbose(G4int level)
G4int GetRndmFreq()
G4EventManager * fpEventManager
int G4int
Definition: G4Types.hh:78
void CountParticles(G4double, G4double)
G4int GetEventID() const
Definition: G4Event.hh:140
void FillEn(G4double En)
G4GLOB_DLL std::ostream G4cout
Definition of the Em10EventActionMessenger class.
Em10EventActionMessenger * eventMessenger
void AddEdeps(G4double Eabs)
void BeginOfEventAction(const G4Event *)
Em10RunAction * runaction
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
void AddTrRef(G4double tr, G4double ref)
#define G4endl
Definition: G4ios.hh:61
void AddnStepsNeutral(G4double ns)
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:174
double G4double
Definition: G4Types.hh:76
const G4Event * GetConstCurrentEvent()
void AddnStepsCharged(G4double ns)
void AddTrackLength(G4double tlabs)
void AddEP(G4double, G4double)
void EndOfEventAction(const G4Event *)