Geant4  10.03
TSRun.hh
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 //
28 //
29 //
30 // $Id: TSRun.hh 93110 2015-11-05 08:37:42Z jmadsen $
31 //
32 //
50 //
51 //
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
55 
56 #ifndef tsrun_h
57 #define tsrun_h 1
58 
59 #include "globals.hh"
60 
61 #include "G4Run.hh"
62 #include "G4Event.hh"
63 #include "G4THitsMap.hh"
64 #include "G4TAtomicHitsMap.hh"
65 
66 #include <vector>
67 
68 class G4Event;
69 
70 class TSRun : public G4Run
71 {
72 public:
73  typedef std::map<G4int, G4double> MutexHitsMap_t;
74  typedef std::vector<G4atomic<G4double>*> AtomicHitsSum_t;
75 
76 public:
77  TSRun(const G4String&);
78  virtual ~TSRun();
79 
80  // virtual method from G4Run.
81  // The method is overriden in this class for scoring.
82  virtual void RecordEvent(const G4Event*);
83 
84  // Access methods for scoring information.
85  // - Get HitsMap of this RUN.
86  G4THitsMap<G4double>* GetHitsMap(const G4String& collname) const;
88  MutexHitsMap_t* GetMutexHitsMap(const G4String&) const;
89 
90  void ConstructMFD(const G4String&);
91 
92  virtual void Merge(const G4Run*);
93 
94 private:
95  std::vector<G4String> fCollNames;
96  std::vector<G4int> fCollIDs;
97  std::vector<G4THitsMap<G4double>*> fRunMaps;
98  static AtomicHitsSum_t fAtomicRunSums;
99  static std::vector<G4TAtomicHitsMap<G4double>*> fAtomicRunMaps;
100  static std::map<G4String, MutexHitsMap_t> fMutexRunMaps;
101 
102 };
103 
104 #endif
std::vector< G4atomic< G4double > * > AtomicHitsSum_t
Definition: TSRun.hh:74
MutexHitsMap_t * GetMutexHitsMap(const G4String &) const
Definition: TSRun.cc:250
virtual void RecordEvent(const G4Event *)
Definition: TSRun.cc:147
Definition: TSRun.hh:70
std::vector< G4String > fCollNames
Definition: TSRun.hh:95
G4THitsMap< G4double > * GetHitsMap(const G4String &collname) const
Definition: TSRun.cc:212
TSRun(const G4String &)
Definition: TSRun.cc:70
static std::map< G4String, MutexHitsMap_t > fMutexRunMaps
Definition: TSRun.hh:100
virtual ~TSRun()
Definition: TSRun.cc:78
std::map< G4int, G4double > MutexHitsMap_t
Definition: TSRun.hh:73
virtual void Merge(const G4Run *)
Definition: TSRun.cc:197
static std::vector< G4TAtomicHitsMap< G4double > * > fAtomicRunMaps
TSRun contains three collections of hits maps: a thread-local hits map, a global atomic hits map (imp...
Definition: TSRun.hh:99
Definition: G4Run.hh:46
Definition of the G4TAtomicHitsMap class.
void ConstructMFD(const G4String &)
Definition: TSRun.cc:93
std::vector< G4THitsMap< G4double > * > fRunMaps
Definition: TSRun.hh:97
This is an implementation of G4THitsMap where the underlying type is G4atomic, not just T. A static assert is provided to ensure that T is fundamental. This class should be used in lieu of G4THitsMap when memory is a concern. Atomics are thread-safe and generally faster that mutexes (as long as the STL implementation is lock-free) but the synchronization does not come without a cost. If performance is the primary concern, use G4THitsMap in thread-local instances.
std::vector< G4int > fCollIDs
Definition: TSRun.hh:96
static AtomicHitsSum_t fAtomicRunSums
Definition: TSRun.hh:98
G4TAtomicHitsMap< G4double > * GetAtomicHitsMap(const G4String &) const
Definition: TSRun.cc:231