Geant4  10.02.p01
F04RunAction.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: F04RunAction.cc 78002 2013-12-02 08:25:49Z gcosmo $
27 //
30 //
31 
32 #include "F04RunAction.hh"
33 #include "F04RunActionMessenger.hh"
34 
35 #include "G4Run.hh"
36 #include "G4RunManager.hh"
37 
38 #include "Randomize.hh"
39 
40 #include <ctime>
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45  : fSaveRndm(0), fAutoSeed(false)
46 {
48 }
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 {
54  delete fRunMessenger;
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 #include "G4Threading.hh"
59 
61 {
62  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
63 
66 
67  if (fAutoSeed) {
68  // automatic (time-based) random seeds for each run
69  G4cout << "*******************" << G4endl;
70  G4cout << "*** AUTOSEED ON ***" << G4endl;
71  G4cout << "*******************" << G4endl;
72  long seeds[2];
73  time_t systime = time(NULL);
74  seeds[0] = (long) systime;
75  seeds[1] = (long) (systime*G4UniformRand());
76  G4Random::setTheSeeds(seeds);
77  G4Random::showEngineStatus();
78  } else {
79  G4Random::showEngineStatus();
80  }
81 
82  if (fSaveRndm > 0)
83  {
84  std::ostringstream os;
85  os<<"beginOfRun_"<<G4Threading::G4GetThreadId()<<".rndm";
86  G4Random::saveEngineStatus(os.str().c_str());
87  }
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  if (fSaveRndm == 1) {
95  G4Random::showEngineStatus();
96  std::ostringstream os;
97  os<<"endOfRun_"<<G4Threading::G4GetThreadId()<<".rndm";
98  G4Random::saveEngineStatus(os.str().c_str());
99  }
100 }
101 
102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual ~F04RunAction()
Definition: F04RunAction.cc:52
virtual void BeginOfRunAction(const G4Run *)
Definition: F04RunAction.cc:60
void SetRandomNumberStore(G4bool flag)
Definition of the F04RunActionMessenger class.
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
virtual void EndOfRunAction(const G4Run *)
Definition: F04RunAction.cc:92
G4int GetRunID() const
Definition: G4Run.hh:76
Definition: G4Run.hh:46
Definition of the F04RunAction class.
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
F04RunActionMessenger * fRunMessenger
Definition: F04RunAction.hh:61
#define G4endl
Definition: G4ios.hh:61
void SetRandomNumberStoreDir(const G4String &dir)
G4int G4GetThreadId()
Definition: G4Threading.cc:128
G4bool fAutoSeed
Definition: F04RunAction.hh:64