Geant4
10.02.p01
|
#include <TSRun.hh>
Public Types | |
typedef std::map< G4int, G4double > | MutexHitsMap_t |
typedef std::vector< G4atomic < G4double > * > | AtomicHitsSum_t |
Public Member Functions | |
TSRun (const G4String &) | |
virtual | ~TSRun () |
virtual void | RecordEvent (const G4Event *) |
G4THitsMap< G4double > * | GetHitsMap (const G4String &collname) const |
G4TAtomicHitsMap< G4double > * | GetAtomicHitsMap (const G4String &) const |
MutexHitsMap_t * | GetMutexHitsMap (const G4String &) const |
void | ConstructMFD (const G4String &) |
virtual void | Merge (const G4Run *) |
Public Member Functions inherited from G4Run | |
G4Run () | |
virtual | ~G4Run () |
G4int | GetRunID () const |
G4int | GetNumberOfEvent () const |
G4int | GetNumberOfEventToBeProcessed () const |
const G4HCtable * | GetHCtable () const |
const G4DCtable * | GetDCtable () const |
const G4String & | GetRandomNumberStatus () const |
void | SetRunID (G4int id) |
void | SetNumberOfEventToBeProcessed (G4int n_ev) |
void | SetHCtable (G4HCtable *HCtbl) |
void | SetDCtable (G4DCtable *DCtbl) |
void | SetRandomNumberStatus (G4String &st) |
void | StoreEvent (G4Event *evt) |
const std::vector< const G4Event * > * | GetEventVector () const |
Private Attributes | |
std::vector< G4String > | fCollNames |
std::vector< G4int > | fCollIDs |
std::vector< G4THitsMap < G4double > * > | fRunMaps |
Static Private Attributes | |
static AtomicHitsSum_t | fAtomicRunSums |
static std::vector < G4TAtomicHitsMap< G4double > * > | fAtomicRunMaps |
TSRun contains three collections of hits maps: a thread-local hits map, a global atomic hits map (implemented as a static since TSRun is implemented as a thread-local instance), and a global "mutex" hits map (also implemented as a static). The thread-local hits map is the same as you will find in many other examples. The atomics hits map is the purpose of this example. Code-wise, the implementation looks extremely similar to the thread-local version with the 3 primary exceptions: (1) construction - there should only be one instance so it should be a static member variable or a pointer/reference to a single instance elsewhere in the code (stored in ActionInitialization, for instance); (2) It does not need to, nor should be, summed in G4Run::Merge(); and (3) destruction – it should only be cleared by the master thread since there is only one instance. A "mutex" hits map is also included as reference for checking the results accumulated by the thread-local hits maps and atomic hits maps. The differences w.r.t. this hits maps are computed in TSRunAction::EndOfRunAction. More... | |
static std::map< G4String, MutexHitsMap_t > | fMutexRunMaps |
Additional Inherited Members | |
Protected Attributes inherited from G4Run | |
G4int | runID |
G4int | numberOfEvent |
G4int | numberOfEventToBeProcessed |
G4HCtable * | HCtable |
G4DCtable * | DCtable |
G4String | randomNumberStatus |
std::vector< const G4Event * > * | eventVector |
typedef std::vector<G4atomic<G4double>*> TSRun::AtomicHitsSum_t |
typedef std::map<G4int, G4double> TSRun::MutexHitsMap_t |
TSRun::TSRun | ( | const G4String & | mfd_name | ) |
Definition at line 70 of file TSRun.cc.
References ConstructMFD().
|
virtual |
Definition at line 78 of file TSRun.cc.
References fAtomicRunMaps, fRunMaps, and G4Threading::IsWorkerThread().
void TSRun::ConstructMFD | ( | const G4String & | mfdName | ) |
Definition at line 93 of file TSRun.cc.
References fAtomicRunMaps, fCollIDs, fCollNames, G4SDManager::FindSensitiveDetector(), fRunMaps, G4cout, G4endl, G4SDManager::GetCollectionID(), G4VPrimitiveScorer::GetName(), G4MultiFunctionalDetector::GetNumberOfPrimitives(), G4MultiFunctionalDetector::GetPrimitive(), G4SDManager::GetSDMpointer(), and G4Threading::IsWorkerThread().
Referenced by TSRun().
G4TAtomicHitsMap< G4double > * TSRun::GetAtomicHitsMap | ( | const G4String & | collName | ) | const |
Definition at line 231 of file TSRun.cc.
References fAtomicRunMaps, fCollNames, G4Exception(), and JustWarning.
Referenced by TSRunAction::EndOfRunAction().
G4THitsMap< G4double > * TSRun::GetHitsMap | ( | const G4String & | collname | ) | const |
Definition at line 212 of file TSRun.cc.
References fCollNames, fRunMaps, G4Exception(), and JustWarning.
Referenced by TSRunAction::EndOfRunAction().
TSRun::MutexHitsMap_t * TSRun::GetMutexHitsMap | ( | const G4String & | collName | ) | const |
Definition at line 250 of file TSRun.cc.
References fMutexRunMaps, G4Exception(), and JustWarning.
Referenced by TSRunAction::EndOfRunAction().
|
virtual |
Reimplemented from G4Run.
Definition at line 197 of file TSRun.cc.
References fRunMaps, and G4Run::Merge().
|
virtual |
Reimplemented from G4Run.
Definition at line 147 of file TSRun.cc.
References fAtomicRunMaps, fCollIDs, fCollNames, fMutexRunMaps, fRunMaps, G4cout, G4endl, G4MUTEX_INITIALIZER, G4HCofThisEvent::GetHC(), G4Event::GetHCofThisEvent(), G4THitsMap< T >::GetMap(), G4Run::numberOfEvent, and G4Run::RecordEvent().
|
staticprivate |
TSRun contains three collections of hits maps: a thread-local hits map, a global atomic hits map (implemented as a static since TSRun is implemented as a thread-local instance), and a global "mutex" hits map (also implemented as a static). The thread-local hits map is the same as you will find in many other examples. The atomics hits map is the purpose of this example. Code-wise, the implementation looks extremely similar to the thread-local version with the 3 primary exceptions: (1) construction - there should only be one instance so it should be a static member variable or a pointer/reference to a single instance elsewhere in the code (stored in ActionInitialization, for instance); (2) It does not need to, nor should be, summed in G4Run::Merge(); and (3) destruction – it should only be cleared by the master thread since there is only one instance. A "mutex" hits map is also included as reference for checking the results accumulated by the thread-local hits maps and atomic hits maps. The differences w.r.t. this hits maps are computed in TSRunAction::EndOfRunAction.
Definition at line 99 of file TSRun.hh.
Referenced by ConstructMFD(), GetAtomicHitsMap(), RecordEvent(), and ~TSRun().
|
staticprivate |
|
private |
Definition at line 96 of file TSRun.hh.
Referenced by ConstructMFD(), and RecordEvent().
|
private |
Definition at line 95 of file TSRun.hh.
Referenced by ConstructMFD(), GetAtomicHitsMap(), GetHitsMap(), and RecordEvent().
|
staticprivate |
Definition at line 100 of file TSRun.hh.
Referenced by GetMutexHitsMap(), and RecordEvent().
|
private |
Definition at line 97 of file TSRun.hh.
Referenced by ConstructMFD(), GetHitsMap(), Merge(), RecordEvent(), and ~TSRun().