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

#include <ElectronRun.hh>

Inheritance diagram for ElectronRun:
G4Run

Public Member Functions

 ElectronRun ()
 
virtual ~ElectronRun ()
 
virtual void RecordEvent (const G4Event *)
 
virtual void Merge (const G4Run *)
 
void DumpData (G4String &) const
 
- 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 43 of file ElectronRun.hh.

Constructor & Destructor Documentation

ElectronRun::ElectronRun ( )

Definition at line 40 of file ElectronRun.cc.

41 : G4Run(), fMap()
42 {
43  fMap[0] = new G4THitsMap<G4double>("MyDetector", "cell flux");
44  fMap[1] = new G4THitsMap<G4double>("MyDetector", "e cell flux");
45  fMap[2] = new G4THitsMap<G4double>("MyDetector", "population");
46  fMap[3] = new G4THitsMap<G4double>("MyDetector", "e population");
47 }
G4Run()
Definition: G4Run.cc:34
ElectronRun::~ElectronRun ( )
virtual

Definition at line 51 of file ElectronRun.cc.

52 {
53  // Important to clean up the map
54  std::map<G4int, G4THitsMap<G4double>* >::iterator iter = fMap.begin();
55 
56  while (iter != fMap.end()) {
57  delete iter->second;
58  iter++;
59  }
60 }

Member Function Documentation

void ElectronRun::DumpData ( G4String &  outputFileSpec) const

Definition at line 95 of file ElectronRun.cc.

References G4THitsMap< T >::GetMap(), G4VHitsCollection::GetName(), and title().

Referenced by ElectronRunAction::EndOfRunAction().

96 {
97  // Titles
98  std::vector<G4String> title;
99  title.push_back("Radius");
100 
101  // Output map - energy binning on x axis, theta on y
102  std::map< G4int, std::vector<G4double> > output;
103 
104  G4int nThetaBins = 233;
105 
106  // Energy bins depends on the number of scorers
107  G4int nEnergyBins = fMap.size();
108 
109  G4int i(0), j(0);
110 
111  // Initialise current to 0 in all bins
112  for (i=0; i<nThetaBins; i++) {
113  for (j=0; j<nEnergyBins; j++) {
114  output[i].push_back(0);
115  }
116  }
117 
118  i=0;
119 
120  // Fill the output map
121  std::map< G4int, G4THitsMap<G4double>* >::const_iterator iter = fMap.begin();
122 
123  while (iter != fMap.end()) {
124  G4THitsMap<G4double>* hitMap = iter->second;
125 
126  title.push_back(hitMap->GetName());
127 
128  std::map<G4int,G4double*>* myMap = hitMap->GetMap();
129 
130  for (j=0; j<nThetaBins; j++) {
131  G4double* current = (*myMap)[j];
132  if (0 != current) output[j][i] = (*current);
133  }
134 
135  i++;
136  iter++;
137  }
138 
139  Print(title, output, outputFileSpec);
140 }
int G4int
Definition: G4Types.hh:78
subroutine title(NA, NB, NCA, NCB)
Definition: dpm25nuc7.f:1744
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:68
double G4double
Definition: G4Types.hh:76
void Print(G4Element &ele)
Definition: pyG4Element.cc:56
void ElectronRun::Merge ( const G4Run *  aRun)
virtual

Reimplemented from G4Run.

Definition at line 198 of file ElectronRun.cc.

References G4Run::Merge().

199 {
200  // This method is called at the end of the run for each worker thread.
201  // It accumulates the worker's results into global results.
202  const ElectronRun* localRun = static_cast<const ElectronRun*>(aRun);
203  const std::map< G4int, G4THitsMap<G4double>* >& localMap = localRun->fMap;
204  std::map< G4int, G4THitsMap<G4double>* >::const_iterator iter = localMap.begin();
205  for ( ; iter != localMap.end() ; ++iter)
206  (*(fMap[iter->first])) += (*(iter->second));
207 
208  // This call lets Geant4 maintain overall summary information.
209  G4Run::Merge(aRun);
210 }
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
void ElectronRun::RecordEvent ( const G4Event *  anEvent)
virtual

Reimplemented from G4Run.

Definition at line 64 of file ElectronRun.cc.

References assert, G4HCofThisEvent::GetHC(), G4Event::GetHCofThisEvent(), and G4Run::RecordEvent().

65 {
66  // Get the hits collection
67  G4HCofThisEvent* eventHitCollection = anEvent->GetHCofThisEvent();
68 
69  if (!eventHitCollection) return;
70 
71  // Update our private fMap
72  std::map< G4int, G4THitsMap<G4double>* >::iterator iter = fMap.begin();
73 
74  while (iter != fMap.end()) {
75  G4int id = iter->first;
76 
77  // Get the hit collection corresponding to "id"
78  G4THitsMap<G4double>* eventHitsMap
79  = dynamic_cast< G4THitsMap<G4double>* >(eventHitCollection->GetHC(id));
80 
81  // Expect this to exist
82  assert (0 != eventHitsMap);
83 
84  // Accumulate event data into our G4THitsMap<G4double> map
85  *(iter->second) += *eventHitsMap;
86 
87  iter++;
88  }
89 
90  G4Run::RecordEvent(anEvent);
91 }
#define assert(x)
Definition: mymalloc.cc:1309
int G4int
Definition: G4Types.hh:78
virtual void RecordEvent(const G4Event *)
Definition: G4Run.cc:51
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:174

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