Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TSRun Class Reference

#include <TSRun.hh>

Inheritance diagram for TSRun:
Collaboration diagram for TSRun:

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
 

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
 

Detailed Description

Definition at line 70 of file TSRun.hh.

Member Typedef Documentation

typedef std::vector<G4atomic<G4double>*> TSRun::AtomicHitsSum_t

Definition at line 74 of file TSRun.hh.

typedef std::map<G4int, G4double> TSRun::MutexHitsMap_t

Definition at line 73 of file TSRun.hh.

Constructor & Destructor Documentation

TSRun::TSRun ( const G4String &  mfd_name)

Definition at line 70 of file TSRun.cc.

71 : G4Run()
72 {
73  ConstructMFD(mfd_name);
74 }
G4Run()
Definition: G4Run.cc:34
void ConstructMFD(const G4String &)
Definition: TSRun.cc:93

Here is the call graph for this function:

TSRun::~TSRun ( )
virtual

Definition at line 78 of file TSRun.cc.

79 {
80  //--- Clear HitsMap for RUN
81  for(unsigned i = 0; i < fRunMaps.size(); ++i)
82  fRunMaps[i]->clear();
83 
85  for(unsigned i = 0; i < fAtomicRunMaps.size(); ++i)
86  fAtomicRunMaps[i]->clear();
87 
88 }
G4bool IsWorkerThread()
Definition: G4Threading.cc:145

Here is the call graph for this function:

Member Function Documentation

void TSRun::ConstructMFD ( const G4String &  mfdName)

Definition at line 93 of file TSRun.cc.

94 {
95 
97  //=================================================
98  // Initalize RunMaps for accumulation.
99  // Get CollectionIDs for HitCollections.
100  //=================================================
103  //
104  if ( mfd )
105  {
106  //--- Loop over the registered primitive scorers.
107  for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); icol++){
108  // Get Primitive Scorer object.
109  G4VPrimitiveScorer* scorer = mfd->GetPrimitive(icol);
110  // collection name and collectionID for HitsCollection,
111  // where type of HitsCollection is G4THitsMap in case
112  // of primitive scorer.
113  // The collection name is given by <MFD name>/<Primitive
114  // Scorer name>.
115  G4String collectionName = scorer->GetName();
116  G4String fullCollectionName = mfdName+"/"+collectionName;
117  G4int collectionID = SDman->GetCollectionID(fullCollectionName);
118  //
119  if ( collectionID >= 0 ){
120  G4cout << "++ " << fullCollectionName<< " id " << collectionID
121  << G4endl;
122  // Store obtained HitsCollection information into data members.
123  // And, creates new G4THitsMap for accumulating quantities during RUN.
124  fCollNames.push_back(fullCollectionName);
125  fCollIDs.push_back(collectionID);
126  fRunMaps.push_back(new G4THitsMap<G4double>(mfdName,
127  collectionName));
129  {
130  fAtomicRunMaps.push_back(new G4TAtomicHitsMap<G4double>
131  (mfdName, collectionName));
132  }
133  } else {
134  G4cout << "** collection " << fullCollectionName << " not found. "
135  <<G4endl;
136  }
137  }
138  }
139 
140 }
G4String GetName() const
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4VPrimitiveScorer * GetPrimitive(G4int id) const
G4VSensitiveDetector * FindSensitiveDetector(G4String dName, G4bool warning=true)
Definition: G4SDManager.cc:128
G4bool IsWorkerThread()
Definition: G4Threading.cc:145
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4TAtomicHitsMap< G4double > * TSRun::GetAtomicHitsMap ( const G4String &  collName) const

Definition at line 231 of file TSRun.cc.

232 {
233  for(unsigned i = 0; i < fCollNames.size(); ++i)
234  {
235  if(collName == fCollNames[i])
236  return fAtomicRunMaps[i];
237  }
238 
239  G4Exception("TSRun", collName.c_str(), JustWarning,
240  "GetHitsMap failed to locate the requested AtomicHitsMap");
241  return nullptr;
242 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

G4THitsMap< G4double > * TSRun::GetHitsMap ( const G4String &  collname) const

Definition at line 212 of file TSRun.cc.

213 {
214  for(unsigned i = 0; i < fCollNames.size(); ++i)
215  {
216  if(collName == fCollNames[i])
217  return fRunMaps[i];
218  }
219 
220  G4Exception("TSRun", collName.c_str(), JustWarning,
221  "GetHitsMap failed to locate the requested HitsMap");
222  return nullptr;
223 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

TSRun::MutexHitsMap_t * TSRun::GetMutexHitsMap ( const G4String &  collName) const

Definition at line 250 of file TSRun.cc.

251 {
252  if(fMutexRunMaps.find(collName) != fMutexRunMaps.end())
253  return &fMutexRunMaps[collName];
254 
255  G4Exception("TSRun", collName.c_str(), JustWarning,
256  "GetHitsMap failed to locate the requested MutexHitsMap");
257  return nullptr;
258 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

void TSRun::Merge ( const G4Run *  aTSRun)
virtual

Reimplemented from G4Run.

Definition at line 197 of file TSRun.cc.

198 {
199  const TSRun* localTSRun = static_cast<const TSRun*>(aTSRun);
200 
201  for(unsigned i = 0; i < fRunMaps.size(); ++i)
202  *fRunMaps[i] += *localTSRun->fRunMaps[i];
203 
204  G4Run::Merge(aTSRun);
205 }
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
Definition: TSRun.hh:70

Here is the call graph for this function:

void TSRun::RecordEvent ( const G4Event *  aEvent)
virtual

Reimplemented from G4Run.

Definition at line 147 of file TSRun.cc.

148 {
149  numberOfEvent++; // This is an original line.
150 
151  //=============================
152  // HitsCollection of This Event
153  //============================
154  G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
155  if (!HCE) return;
156 
157  for(unsigned i = 0; i < fCollIDs.size(); ++i)
158  {
159  G4int fCollID = fCollIDs.at(i);
160  //=======================================================
161  // Sum up HitsMap of this Event into HitsMap of this RUN
162  //=======================================================
163  G4THitsMap<G4double>* EvtMap = 0;
164  if ( fCollID >= 0 ) // Collection is attached to HCE
165  EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID));
166  else
167  G4cout <<" Error EvtMap Not Found " << G4endl;
168 
169  if ( EvtMap )
170  {
171  //=== Sum up HitsMap of this event to HitsMap of RUN.===
172  *fRunMaps[fCollID] += *EvtMap;
173  // atomic run map
174  *fAtomicRunMaps[fCollID] += *EvtMap;
175  // mutex run map
176  static G4Mutex mtx = G4MUTEX_INITIALIZER;
177  {
178  G4AutoLock lock(&mtx);
179  auto itr = EvtMap->GetMap()->begin();
180  for(; itr != EvtMap->GetMap()->end(); itr++)
181  {
182  fMutexRunMaps[fCollNames[fCollID]][itr->first] += *itr->second;
183  }
184  }
185  //----------------------------------------------------------------//
186  }
187 
188  }
189 
190  G4Run::RecordEvent(aEvent);
191 
192 }
G4int numberOfEvent
Definition: G4Run.hh:59
G4VHitsCollection * GetHC(G4int i)
int G4int
Definition: G4Types.hh:78
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:175
G4GLOB_DLL std::ostream G4cout
G4int G4Mutex
Definition: G4Threading.hh:173
virtual void RecordEvent(const G4Event *)
Definition: G4Run.cc:51
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:99
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185

Here is the call graph for this function:


The documentation for this class was generated from the following files: