Geant4  10.00.p01
ExG4EventAction01.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 "ExG4EventAction01.hh"
32 
33 #include "G4RunManager.hh"
34 #include "G4Run.hh"
35 #include "G4Event.hh"
36 #include "G4Trajectory.hh"
37 #include "G4TrajectoryContainer.hh"
38 #include "G4VVisManager.hh"
39 #include "Randomize.hh"
40 
41 #include <sstream>
42 
45 
46 //_____________________________________________________________________________
49  fMessenger(this),
50  fVerboseLevel(fgkDefaultVerboseLevel),
51  fPrintModulo(fgkDefaultPrintModulo),
52  fSaveRndm(false)
53 {
55 }
56 
57 //_____________________________________________________________________________
59 {
61 }
62 
63 //_____________________________________________________________________________
65 {
66  // Print event info
67  //
68  G4int eventNumber = event->GetEventID();
69  if ( eventNumber%fPrintModulo == 0 ) {
70  G4cout << "\n---> Begin of Event: " << eventNumber << G4endl;
71  }
72 
73  // Print verbose info
74  //
75  if ( fVerboseLevel > 1 ) {
76  G4cout << "<<< Event " << eventNumber << " started." << G4endl;
77  }
78 }
79 
80 //_____________________________________________________________________________
82 {
83  // Print verbose info
84  //
85  if ( fVerboseLevel > 1 ) {
86  G4cout << "<<< Event " << event->GetEventID() << " ended." << G4endl;
87  }
88 
89  // Save rndm status
90  //
91  if ( fSaveRndm ) {
93  G4int runNumber = run->GetRunID();
94  G4int eventNumber = event->GetEventID();
95  std::ostringstream fileName;
96  fileName << "run" << runNumber << "event" << eventNumber << ".rndm";
97  CLHEP::HepRandom::saveEngineStatus(fileName.str().c_str());
98 
99  if ( eventNumber%fPrintModulo == 0 ) {
100  G4cout << "\n---> End of Event: " << eventNumber << G4endl;
101  CLHEP::HepRandom::showEngineStatus();
102  }
103  }
104 }
static const G4int fgkDefaultPrintModulo
int G4int
Definition: G4Types.hh:78
const G4Run * GetCurrentRun() const
virtual void BeginOfEventAction(const G4Event *event)
virtual ~ExG4EventAction01()
G4GLOB_DLL std::ostream G4cout
Definition of the ExG4EventAction01 class.
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
static const G4int fgkDefaultVerboseLevel
virtual void EndOfEventAction(const G4Event *event)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
#define G4endl
Definition: G4ios.hh:61