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

#include <B02Run.hh>

Inheritance diagram for B02Run:
G4Run

Public Member Functions

 B02Run (const std::vector< G4String > mfdName)
 
virtual ~B02Run ()
 
virtual void RecordEvent (const G4Event *)
 
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 ()
 
virtual void Merge (const G4Run *)
 
- 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

Definition at line 50 of file B02Run.hh.

Constructor & Destructor Documentation

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

Definition at line 70 of file B02Run.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 scorer.
91  // The collection name is given by <MFD name>/<Primitive Scorer name>.
92  G4String collectionName = scorer->GetName();
93  G4String fullCollectionName = detName+"/"+collectionName;
94  G4int collectionID = SDman->GetCollectionID(fullCollectionName);
95 
96  if ( collectionID >= 0 ){
97  G4cout << "++ "<<fullCollectionName<< " id " << collectionID
98  << G4endl;
99  // Store obtained HitsCollection information into data members.
100  // And, creates new G4THitsMap for accumulating quantities during RUN.
101  fCollName.push_back(fullCollectionName);
102  fCollID.push_back(collectionID);
103  fRunMap.push_back(new G4THitsMap<G4double>(detName
104  ,collectionName));
105  }else{
106  G4cout << "** collection " << fullCollectionName
107  << " not found. "<<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
B02Run::~B02Run ( )
virtual

Definition at line 118 of file B02Run.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 B02Run::DumpAllScorer ( )

Definition at line 197 of file B02Run.cc.

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

197  {
198 
199  // - Number of HitsMap in this RUN.
201  // - GetHitsMap and dump values.
202  for ( G4int i = 0; i < n ; i++ ){
203  G4THitsMap<G4double>* RunMap =GetHitsMap(i);
204  if ( RunMap ) {
205  G4cout << " PrimitiveScorer RUN "
206  << RunMap->GetSDname() <<","<< RunMap->GetName() << G4endl;
207  G4cout << " Number of entries " << RunMap->entries() << G4endl;
208  std::map<G4int,G4double*>::iterator itr = RunMap->GetMap()->begin();
209  for(; itr != RunMap->GetMap()->end(); itr++) {
210  G4cout << " copy no.: " << itr->first
211  << " Run Value : " << *(itr->second)
212  << G4endl;
213  }
214  }
215  }
216 }
G4THitsMap< G4double > * GetHitsMap(G4int i)
Definition: B02Run.hh:70
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
const G4int n
G4int entries() const
Definition: G4THitsMap.hh:79
G4int GetNumberOfHitsMap() const
Definition: B02Run.hh:66
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:68
#define G4endl
Definition: G4ios.hh:61
G4THitsMap<G4double>* B02Run::GetHitsMap ( G4int  i)
inline

Definition at line 70 of file B02Run.hh.

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

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

Definition at line 173 of file B02Run.cc.

References GetHitsMap().

174  {
175  G4String fullName = detName+"/"+colName;
176  return GetHitsMap(fullName);
177 }
G4THitsMap< G4double > * GetHitsMap(G4int i)
Definition: B02Run.hh:70
G4THitsMap< G4double > * B02Run::GetHitsMap ( const G4String fullName)

Definition at line 183 of file B02Run.cc.

183  {
184  G4int Ncol = fCollName.size();
185  for ( G4int i = 0; i < Ncol; i++){
186  if ( fCollName[i] == fullName ){
187  return fRunMap[i];
188  }
189  }
190  return NULL;
191 }
int G4int
Definition: G4Types.hh:78
G4int B02Run::GetNumberOfHitsMap ( ) const
inline

Definition at line 66 of file B02Run.hh.

Referenced by DumpAllScorer().

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

Reimplemented from G4Run.

Definition at line 221 of file B02Run.cc.

References G4Run::Merge().

222 {
223  const B02Run * localRun = static_cast<const B02Run *>(aRun);
224  //=======================================================
225  // Merge HitsMap of working threads
226  //=======================================================
227  G4int nCol = localRun->fCollID.size();
228  for ( G4int i = 0; i < nCol ; i++ ){ // Loop over HitsCollection
229  if ( localRun->fCollID[i] >= 0 ){
230  *fRunMap[i] += *localRun->fRunMap[i];
231  }
232  }
233 
234  G4Run::Merge(aRun);
235 }
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
Definition: B02Run.hh:50
int G4int
Definition: G4Types.hh:78
void B02Run::RecordEvent ( const G4Event aEvent)
virtual

Reimplemented from G4Run.

Definition at line 135 of file B02Run.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* HCE = aEvent->GetHCofThisEvent();
143  if (!HCE) 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 HCE
152  EvtMap = (G4THitsMap<G4double>*)(HCE->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 
163 
164 }
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: