Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B4bEventAction.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 // $Id$
27 //
30 
31 #include "B4bEventAction.hh"
32 #include "B4bRunData.hh"
33 
34 #include "G4RunManager.hh"
35 #include "G4Event.hh"
36 #include "G4GenericMessenger.hh"
37 #include "G4UnitsTable.hh"
38 
39 #include "Randomize.hh"
40 #include <iomanip>
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
46  fMessenger(0),
47  fPrintModulo(1)
48 {
49  // Define /B4/event commands using generic messenger class
50  fMessenger = new G4GenericMessenger(this, "/B4/event/", "Event control");
51 
52  // Define /B4/event/setPrintModulo command
53  G4GenericMessenger::Command& setPrintModulo
54  = fMessenger->DeclareProperty("setPrintModulo",
55  fPrintModulo,
56  "Print events modulo n");
57  setPrintModulo.SetRange("value>0");
58 }
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {
64  delete fMessenger;
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
69 void B4bEventAction::PrintEventStatistics(
70  G4double absoEdep, G4double absoTrackLength,
71  G4double gapEdep, G4double gapTrackLength) const
72 {
73  // print event statistics
74  G4cout
75  << " Absorber: total energy: "
76  << std::setw(7) << G4BestUnit(absoEdep, "Energy")
77  << " total track length: "
78  << std::setw(7) << G4BestUnit(absoTrackLength, "Length")
79  << G4endl
80  << " Gap: total energy: "
81  << std::setw(7) << G4BestUnit(gapEdep, "Energy")
82  << " total track length: "
83  << std::setw(7) << G4BestUnit(gapTrackLength, "Length")
84  << G4endl;
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 
90 {
91 
92  G4int eventID = evt->GetEventID();
93  if ( eventID % fPrintModulo == 0 ) {
94  G4cout << "\n---> Begin of event: " << eventID << G4endl;
95  //CLHEP::HepRandom::showEngineStatus();
96  }
97 
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102 
104 {
105  //accumulates statistic
106  //
108 
109  //print per event (modulo n)
110  //
111  G4int eventID = event->GetEventID();
112  if ( eventID % fPrintModulo == 0) {
113  G4cout << "---> End of event: " << eventID << G4endl;
114 
115  PrintEventStatistics(
116  B4bRunData::GetInstance()->GetEdep(kAbs),
117  B4bRunData::GetInstance()->GetTrackLength(kAbs),
118  B4bRunData::GetInstance()->GetEdep(kGap),
119  B4bRunData::GetInstance()->GetTrackLength(kGap));
120  }
121 }
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......