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

#include <Doxymodules_biasing.h>

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

Private Attributes

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

Detailed Description

Definition at line 39 of file Doxymodules_biasing.h.

Constructor & Destructor Documentation

◆ B02Run()

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

Definition at line 69 of file B02Run.cc.

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

◆ ~B02Run()

B02Run::~B02Run ( )
virtual

Definition at line 117 of file B02Run.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 B02Run::RecordEvent ( const G4Event aEvent)
virtual

Definition at line 134 of file B02Run.cc.

135{
136 numberOfEvent++; // This is an original line.
137
138 //=============================
139 // HitsCollection of This Event
140 //============================
141 G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
142 if (!HCE) 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 HCE
151 EvtMap = (G4THitsMap<G4double>*)(HCE->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
162}

◆ GetNumberOfHitsMap()

G4int B02Run::GetNumberOfHitsMap ( ) const
inline

Definition at line 65 of file B02Run.hh.

65{return fRunMap.size();}

◆ GetHitsMap() [1/3]

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

Definition at line 69 of file B02Run.hh.

69{return fRunMap[i];}

◆ GetHitsMap() [2/3]

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

Definition at line 171 of file B02Run.cc.

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

◆ GetHitsMap() [3/3]

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

Definition at line 181 of file B02Run.cc.

181 {
182 G4int Ncol = fCollName.size();
183 for ( G4int i = 0; i < Ncol; i++){
184 if ( fCollName[i] == fullName ){
185 return fRunMap[i];
186 }
187 }
188 return NULL;
189}

◆ DumpAllScorer()

void B02Run::DumpAllScorer ( )

Definition at line 195 of file B02Run.cc.

195 {
196
197 // - Number of HitsMap in this RUN.
198 G4int n = GetNumberOfHitsMap();
199 // - GetHitsMap and dump values.
200 for ( G4int i = 0; i < n ; i++ ){
202 if ( RunMap ) {
203 G4cout << " PrimitiveScorer RUN "
204 << RunMap->GetSDname() <<","<< RunMap->GetName() << G4endl;
205 G4cout << " Number of entries " << RunMap->entries() << G4endl;
206 std::map<G4int,G4double*>::iterator itr = RunMap->GetMap()->begin();
207 for(; itr != RunMap->GetMap()->end(); itr++) {
208 G4cout << " copy no.: " << itr->first
209 << " Run Value : " << *(itr->second)
210 << G4endl;
211 }
212 }
213 }
214}
G4int GetNumberOfHitsMap() const
Definition B02Run.hh:65

◆ Merge()

void B02Run::Merge ( const G4Run aRun)
virtual

Definition at line 218 of file B02Run.cc.

219{
220 const B02Run * localRun = static_cast<const B02Run *>(aRun);
221 //=======================================================
222 // Merge HitsMap of working threads
223 //=======================================================
224 G4int nCol = localRun->fCollID.size();
225 for ( G4int i = 0; i < nCol ; i++ ){ // Loop over HitsCollection
226 if ( localRun->fCollID[i] >= 0 ){
227 *fRunMap[i] += *localRun->fRunMap[i];
228 }
229 }
230
231 G4Run::Merge(aRun);
232}

Member Data Documentation

◆ fCollName

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

Definition at line 80 of file B02Run.hh.

◆ fCollID

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

Definition at line 81 of file B02Run.hh.

◆ fRunMap

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

Definition at line 82 of file B02Run.hh.


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

Applications | User Support | Publications | Collaboration