Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventAction.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 //
26 //
27 // $Id$
28 //
29 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "EventAction.hh"
35 
36 #include "RunAction.hh"
37 #include "EventActionMessenger.hh"
38 
39 #include "G4RunManager.hh"
40 #include "G4Event.hh"
41 #include "G4UnitsTable.hh"
42 
43 #include "Randomize.hh"
44 #include <iomanip>
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 {
51  eventMessenger = new EventActionMessenger(this);
52  printModulo = 1;
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {
59  delete eventMessenger;
60 }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {
66  G4int evtNb = evt->GetEventID();
67  if (evtNb%printModulo == 0) {
68  G4cout << "\n---> Begin of event: " << evtNb << G4endl;
70 }
71 
72  // initialisation per event
73  EnergyAbs = EnergyGap = 0.;
74  TrackLAbs = TrackLGap = 0.;
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 {
81  //accumulates statistic
82  //
83  runAct->fillPerEvent(EnergyAbs, EnergyGap, TrackLAbs, TrackLGap);
84 
85  //print per event (modulo n)
86  //
87  G4int evtNb = evt->GetEventID();
88  if (evtNb%printModulo == 0) {
89  G4cout << "---> End of event: " << evtNb << G4endl;
90 
91  G4cout
92  << " Absorber: total energy: " << std::setw(7)
93  << G4BestUnit(EnergyAbs,"Energy")
94  << " total track length: " << std::setw(7)
95  << G4BestUnit(TrackLAbs,"Length")
96  << G4endl
97  << " Gap: total energy: " << std::setw(7)
98  << G4BestUnit(EnergyGap,"Energy")
99  << " total track length: " << std::setw(7)
100  << G4BestUnit(TrackLGap,"Length")
101  << G4endl;
102 
103  }
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......