Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
RE02Run Class Reference

#include <RE02Run.hh>

Inheritance diagram for RE02Run:
G4Run

Public Member Functions

 RE02Run (const std::vector< G4String > mfdName)
 
virtual ~RE02Run ()
 
virtual void RecordEvent (const G4Event *)
 
virtual void Merge (const G4Run *)
 
G4int GetNumberOfHitsMap () const
 
G4THitsMap< G4double > * GetHitsMap (G4int i)
 
G4THitsMap< G4double > * GetHitsMap (const G4String &detName, const G4String &colName)
 
G4THitsMap< G4double > * GetHitsMap (const G4String &fullName)
 
void DumpAllScorer ()
 
- Public Member Functions inherited from G4Run
 G4Run ()
 
virtual ~G4Run ()
 
G4int GetRunID () const
 
G4int GetNumberOfEvent () const
 
G4int GetNumberOfEventToBeProcessed () const
 
const G4HCtableGetHCtable () const
 
const G4DCtableGetDCtable () const
 
const G4StringGetRandomNumberStatus () 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
 
G4HCtableHCtable
 
G4DCtableDCtable
 
G4String randomNumberStatus
 
std::vector< const G4Event * > * eventVector
 

Detailed Description

User run class

(Description) An example implementation for the multi-functional-detector and primitive scorers. This RE02Run class has collections which accumulate event information into run information.

Definition at line 75 of file RE02Run.hh.

Constructor & Destructor Documentation

RE02Run::RE02Run ( const std::vector< G4String mfdName)

Definition at line 70 of file RE02Run.cc.

References G4SDManager::FindSensitiveDetector(), G4cout, G4endl, G4SDManager::GetCollectionID(), G4VPrimitiveScorer::GetName(), G4MultiFunctionalDetector::GetNumberOfPrimitives(), G4MultiFunctionalDetector::GetPrimitive(), and G4SDManager::GetSDMpointer().

70  : G4Run()
71 {
73  //=================================================
74  // Initalize RunMaps for accumulation.
75  // Get CollectionIDs for HitCollections.
76  //=================================================
77  G4int nMfd = mfdName.size();
78  for ( G4int idet = 0; idet < nMfd ; idet++){ // Loop for all MFD.
79  G4String detName = mfdName[idet];
80  //--- Seek and Obtain MFD objects from SDmanager.
83  //
84  if ( mfd ){
85  //--- Loop over the registered primitive scorers.
86  for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); icol++){
87  // Get Primitive Scorer object.
88  G4VPrimitiveScorer* scorer=mfd->GetPrimitive(icol);
89  // collection name and collectionID for HitsCollection,
90  // where type of HitsCollection is G4THitsMap in case of primitive
91  // scorer.
92  // The collection name is given by <MFD name>/<Primitive Scorer name>.
93  G4String collectionName = scorer->GetName();
94  G4String fullCollectionName = detName+"/"+collectionName;
95  G4int collectionID = pSDman->GetCollectionID(fullCollectionName);
96  //
97  if ( collectionID >= 0 ){
98  G4cout << "++ "<<fullCollectionName<< " id " << collectionID
99  << G4endl;
100  // Store obtained HitsCollection information into data members.
101  // And, creates new G4THitsMap for accumulating quantities during RUN.
102  fCollName.push_back(fullCollectionName);
103  fCollID.push_back(collectionID);
104  fRunMap.push_back(new G4THitsMap<G4double>(detName,collectionName));
105  }else{
106  G4cout << "** collection " << fullCollectionName << " not found. "
107  << G4endl;
108  }
109  }
110  }
111  }
112 }
G4String GetName() const
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
int G4int
Definition: G4Types.hh:78
G4Run()
Definition: G4Run.cc:34
G4GLOB_DLL std::ostream G4cout
G4VPrimitiveScorer * GetPrimitive(G4int id) const
G4VSensitiveDetector * FindSensitiveDetector(G4String dName, G4bool warning=true)
Definition: G4SDManager.cc:124
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
RE02Run::~RE02Run ( )
virtual

Definition at line 118 of file RE02Run.cc.

119 {
120  //--- Clear HitsMap for RUN
121  G4int nMap = fRunMap.size();
122  for ( G4int i = 0; i < nMap; i++){
123  if(fRunMap[i] ) fRunMap[i]->clear();
124  }
125  fCollName.clear();
126  fCollID.clear();
127  fRunMap.clear();
128 }
int G4int
Definition: G4Types.hh:78

Member Function Documentation

void RE02Run::DumpAllScorer ( )

Definition at line 216 of file RE02Run.cc.

References G4THitsMap< T >::entries(), G4cout, G4endl, GetHitsMap(), G4THitsMap< T >::GetMap(), G4VHitsCollection::GetName(), GetNumberOfHitsMap(), G4VHitsCollection::GetSDname(), and n.

Referenced by RE02RunAction::EndOfRunAction().

216  {
217 
218  // - Number of HitsMap in this RUN.
220  // - GetHitsMap and dump values.
221  for ( G4int i = 0; i < n ; i++ ){
222  G4THitsMap<G4double>* runMap =GetHitsMap(i);
223  if ( runMap ) {
224  G4cout << " PrimitiveScorer RUN "
225  << runMap->GetSDname() <<","<< runMap->GetName() << G4endl;
226  G4cout << " Number of entries " << runMap->entries() << G4endl;
227  std::map<G4int,G4double*>::iterator itr = runMap->GetMap()->begin();
228  for(; itr != runMap->GetMap()->end(); itr++) {
229  G4cout << " copy no.: " << itr->first
230  << " Run Value : " << *(itr->second)
231  << G4endl;
232  }
233  }
234  }
235 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4THitsMap< G4double > * GetHitsMap(G4int i)
Definition: RE02Run.hh:96
const G4int n
G4int entries() const
Definition: G4THitsMap.hh:79
G4int GetNumberOfHitsMap() const
Definition: RE02Run.hh:92
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:68
#define G4endl
Definition: G4ios.hh:61
G4THitsMap<G4double>* RE02Run::GetHitsMap ( G4int  i)
inline

Definition at line 96 of file RE02Run.hh.

Referenced by DumpAllScorer(), RE02RunAction::EndOfRunAction(), and GetHitsMap().

96 {return fRunMap[i];}
G4THitsMap< G4double > * RE02Run::GetHitsMap ( const G4String detName,
const G4String colName 
)

Definition at line 189 of file RE02Run.cc.

References GetHitsMap().

190  {
191  G4String fullName = detName+"/"+colName;
192  return GetHitsMap(fullName);
193 }
G4THitsMap< G4double > * GetHitsMap(G4int i)
Definition: RE02Run.hh:96
G4THitsMap< G4double > * RE02Run::GetHitsMap ( const G4String fullName)

Definition at line 201 of file RE02Run.cc.

201  {
202  G4int nCol = fCollName.size();
203  for ( G4int i = 0; i < nCol; i++){
204  if ( fCollName[i] == fullName ){
205  return fRunMap[i];
206  }
207  }
208  return NULL;
209 }
int G4int
Definition: G4Types.hh:78
G4int RE02Run::GetNumberOfHitsMap ( ) const
inline

Definition at line 92 of file RE02Run.hh.

Referenced by DumpAllScorer().

92 {return fRunMap.size();}
void RE02Run::Merge ( const G4Run aRun)
virtual

Reimplemented from G4Run.

Definition at line 166 of file RE02Run.cc.

References G4Run::Merge().

166  {
167  const RE02Run * localRun = static_cast<const RE02Run *>(aRun);
168 
169  //=======================================================
170  // Merge HitsMap of working threads
171  //=======================================================
172  G4int nCol = localRun->fCollID.size();
173  for ( G4int i = 0; i < nCol ; i++ ){ // Loop over HitsCollection
174  if ( localRun->fCollID[i] >= 0 ){
175  *fRunMap[i] += *localRun->fRunMap[i];
176  }
177  }
178 
179  G4Run::Merge(aRun);
180 }
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
int G4int
Definition: G4Types.hh:78
void RE02Run::RecordEvent ( const G4Event aEvent)
virtual

Reimplemented from G4Run.

Definition at line 135 of file RE02Run.cc.

References G4cout, G4endl, G4HCofThisEvent::GetHC(), G4Event::GetHCofThisEvent(), and G4Run::numberOfEvent.

136 {
137  numberOfEvent++; // This is an original line.
138 
139  //=============================
140  // HitsCollection of This Event
141  //============================
142  G4HCofThisEvent* pHCE = aEvent->GetHCofThisEvent();
143  if (!pHCE) return;
144 
145  //=======================================================
146  // Sum up HitsMap of this Event into HitsMap of this RUN
147  //=======================================================
148  G4int nCol = fCollID.size();
149  for ( G4int i = 0; i < nCol ; i++ ){ // Loop over HitsCollection
150  G4THitsMap<G4double>* evtMap=0;
151  if ( fCollID[i] >= 0 ){ // Collection is attached to pHCE
152  evtMap = (G4THitsMap<G4double>*)(pHCE->GetHC(fCollID[i]));
153  }else{
154  G4cout <<" Error evtMap Not Found "<< i << G4endl;
155  }
156  if ( evtMap ) {
157  //=== Sum up HitsMap of this event to HitsMap of RUN.===
158  *fRunMap[i] += *evtMap;
159  //======================================================
160  }
161  }
162 }
G4int numberOfEvent
Definition: G4Run.hh:59
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:174

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