Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
RE02Run Class Reference

User run class. More...

#include <Doxymodules_runAndEvent.h>

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 ()
 

Private Attributes

std::vector< G4StringfCollName
 
std::vector< G4int > fCollID
 
std::vector< G4THitsMap< G4double > * > fRunMap
 

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 60 of file Doxymodules_runAndEvent.h.

Constructor & Destructor Documentation

◆ RE02Run()

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

Definition at line 69 of file RE02Run.cc.

69 : G4Run()
70{
71 G4SDManager* pSDman = G4SDManager::GetSDMpointer();
72 //=================================================
73 // Initalize RunMaps for accumulation.
74 // Get CollectionIDs for HitCollections.
75 //=================================================
76 G4int nMfd = mfdName.size();
77 for ( G4int idet = 0; idet < nMfd ; idet++){ // Loop for all MFD.
78 G4String detName = mfdName[idet];
79 //--- Seek and Obtain MFD objects from SDmanager.
81 (G4MultiFunctionalDetector*)(pSDman->FindSensitiveDetector(detName));
82 //
83 if ( mfd ){
84 //--- Loop over the registered primitive scorers.
85 for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); icol++){
86 // Get Primitive Scorer object.
87 G4VPrimitiveScorer* scorer=mfd->GetPrimitive(icol);
88 // collection name and collectionID for HitsCollection,
89 // where type of HitsCollection is G4THitsMap in case of primitive
90 // 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 = pSDman->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,collectionName));
104 }else{
105 G4cout << "** collection " << fullCollectionName << " not found. "
106 << G4endl;
107 }
108 }
109 }
110 }
111}
std::vector< G4String > fCollName
Definition RE02Run.hh:104
std::vector< G4THitsMap< G4double > * > fRunMap
Definition RE02Run.hh:106
std::vector< G4int > fCollID
Definition RE02Run.hh:105

◆ ~RE02Run()

RE02Run::~RE02Run ( )
virtual

Definition at line 117 of file RE02Run.cc.

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

Member Function Documentation

◆ RecordEvent()

void RE02Run::RecordEvent ( const G4Event aEvent)
virtual

Definition at line 134 of file RE02Run.cc.

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

◆ Merge()

void RE02Run::Merge ( const G4Run aRun)
virtual

Definition at line 165 of file RE02Run.cc.

165 {
166 const RE02Run * localRun = static_cast<const RE02Run *>(aRun);
167
168 //=======================================================
169 // Merge HitsMap of working threads
170 //=======================================================
171 G4int nCol = localRun->fCollID.size();
172 for ( G4int i = 0; i < nCol ; i++ ){ // Loop over HitsCollection
173 if ( localRun->fCollID[i] >= 0 ){
174 *fRunMap[i] += *localRun->fRunMap[i];
175 }
176 }
177
178 G4Run::Merge(aRun);
179}
User run class.

◆ GetNumberOfHitsMap()

G4int RE02Run::GetNumberOfHitsMap ( ) const
inline

Definition at line 91 of file RE02Run.hh.

91{return fRunMap.size();}

◆ GetHitsMap() [1/3]

G4THitsMap< G4double > * RE02Run::GetHitsMap ( G4int  i)
inline

Definition at line 95 of file RE02Run.hh.

95{return fRunMap[i];}

◆ GetHitsMap() [2/3]

G4THitsMap< G4double > * RE02Run::GetHitsMap ( const G4String detName,
const G4String colName 
)

Definition at line 188 of file RE02Run.cc.

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

◆ GetHitsMap() [3/3]

G4THitsMap< G4double > * RE02Run::GetHitsMap ( const G4String fullName)

Definition at line 200 of file RE02Run.cc.

200 {
201 G4int nCol = fCollName.size();
202 for ( G4int i = 0; i < nCol; i++){
203 if ( fCollName[i] == fullName ){
204 return fRunMap[i];
205 }
206 }
207 return NULL;
208}

◆ DumpAllScorer()

void RE02Run::DumpAllScorer ( )

Definition at line 215 of file RE02Run.cc.

215 {
216
217 // - Number of HitsMap in this RUN.
218 G4int n = GetNumberOfHitsMap();
219 // - GetHitsMap and dump values.
220 for ( G4int i = 0; i < n ; i++ ){
222 if ( runMap ) {
223 G4cout << " PrimitiveScorer RUN "
224 << runMap->GetSDname() <<","<< runMap->GetName() << G4endl;
225 G4cout << " Number of entries " << runMap->entries() << G4endl;
226//// std::map<G4int,G4double*>::iterator itr = runMap->GetMap()->begin();
227//// for(; itr != runMap->GetMap()->end(); itr++) {
228//// G4cout << " copy no.: " << itr->first
229//// << " Run Value : " << *(itr->second)
230//// << G4endl;
231//// }
232 }
233 }
234}
G4int GetNumberOfHitsMap() const
Definition RE02Run.hh:91

Member Data Documentation

◆ fCollName

std::vector<G4String> RE02Run::fCollName
private

Definition at line 104 of file RE02Run.hh.

◆ fCollID

std::vector<G4int> RE02Run::fCollID
private

Definition at line 105 of file RE02Run.hh.

◆ fRunMap

std::vector<G4THitsMap<G4double>*> RE02Run::fRunMap
private

Definition at line 106 of file RE02Run.hh.


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

Applications | User Support | Publications | Collaboration