Geant4_10
ExG4RunAction01.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 "ExG4RunAction01.hh"
32 
33 #include "G4Run.hh"
34 #include "G4RunManager.hh"
35 #include "G4UImanager.hh"
36 #include "G4VVisManager.hh"
37 //#include "G4ios.hh"
38 //#include <iomanip>
39 
40 #include "Randomize.hh"
41 
42 const G4String ExG4RunAction01::fgkDefaultRndmFileName = "run0.rndm";
43 
44 //_____________________________________________________________________________
46  : G4UserRunAction(),
47  fMessenger(this),
48  fRndmFileName(fgkDefaultRndmFileName),
49  fVerboseLevel(1),
50  fSaveRndm(false),
51  fReadRndm(false),
52  fAutoSeed(false)
53 {
55 }
56 
57 //_____________________________________________________________________________
59 {
61 }
62 
63 //_____________________________________________________________________________
65 {
66  if ( fVerboseLevel > 0 ) {
67  G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
68  }
69 
70  // read Rndm status
71  if ( fReadRndm ) {
72  G4cout << "\n---> rndm status restored from file: " << fRndmFileName << G4endl;
75  }
76 
77  // automatic (time-based) random seeds for each run
78  if ( fAutoSeed ) {
81 
82  G4cout << "*******************" << G4endl;
83  G4cout << "*** AUTOSEED ON ***" << G4endl;
84  G4cout << "*******************" << G4endl;
85 
86  long seeds[2];
87  time_t systime = time(NULL);
88  seeds[0] = (long) systime;
89  seeds[1] = (long) (systime*G4UniformRand());
92  }
93 
94  // save Rndm status
95  if ( fSaveRndm ) {
96  G4int runNumber = run->GetRunID();
97  std::ostringstream fileName;
98  fileName << "run" << runNumber << ".rndm";
99  CLHEP::HepRandom::saveEngineStatus(fileName.str().c_str());
101  }
102 
104  G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
105  }
106 }
107 
108 //_____________________________________________________________________________
110 {
111  // save Rndm status
112  if ( fSaveRndm ) {
113  G4int runNumber = run->GetRunID();
114  std::ostringstream fileName;
115  fileName << "run" << runNumber << "end.rndm";
116  CLHEP::HepRandom::saveEngineStatus(fileName.str().c_str());
118  }
119 
121  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
122  }
123 }
static void restoreEngineStatus(const char filename[]="Config.conf")
Definition: Random.cc:180
virtual void BeginOfRunAction(const G4Run *run)
static G4VVisManager * GetConcreteInstance()
static void setTheSeeds(const long *seeds, int aux=-1)
Definition: Random.cc:141
void SetRandomNumberStore(G4bool flag)
virtual void EndOfRunAction(const G4Run *run)
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
#define G4UniformRand()
Definition: Randomize.hh:87
G4GLOB_DLL std::ostream G4cout
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
static void showEngineStatus()
Definition: Random.cc:203
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
static void saveEngineStatus(const char filename[]="Config.conf")
Definition: Random.cc:175
#define G4endl
Definition: G4ios.hh:61
Definition of the ExG4RunAction01 class.
void SetRandomNumberStoreDir(const G4String &dir)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419