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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/runAndEvent/RE02/src/RE02Run.cc (Version 11.3.0) and /examples/extended/runAndEvent/RE02/src/RE02Run.cc (Version ReleaseNotes)


** Warning: Cannot open xref database.

  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 /// \file runAndEvent/RE02/src/RE02Run.cc         
 27 /// \brief Implementation of the RE02Run class    
 28 //                                                
 29 //                                                
 30 //                                                
 31                                                   
 32 //============================================    
 33 //                                                
 34 //  (Description)                                 
 35 //    RE02Run Class is for accumulating scored    
 36 //  scored using G4MutiFunctionalDetector and     
 37 //  Accumulation is done using G4THitsMap obje    
 38 //                                                
 39 //    The constructor RE02Run(const std::vecto    
 40 //  needs a vector filled with MultiFunctional    
 41 //  was assigned at instantiation of MultiFunc    
 42 //  Then RE02Run constructor automatically sca    
 43 //  in the MFD, and obtains collectionIDs of a    
 44 //  to those primitive scorers. Futhermore, th    
 45 //  for accumulating during a RUN are automati    
 46 //  (*) Collection Name is same as primitive s    
 47 //                                                
 48 //    The resultant information is kept inside    
 49 //  data members.                                 
 50 //  std::vector<G4String> fCollName;              
 51 //  std::vector<G4int> fCollID;                   
 52 //  std::vector<G4THitsMap<G4double>*> fRunMap    
 53 //                                                
 54 //  The resualtant HitsMap objects are obtain     
 55 //  GetHitsMap(..).                               
 56 //                                                
 57 //============================================    
 58                                                   
 59 #include "RE02Run.hh"                             
 60                                                   
 61 #include "G4MultiFunctionalDetector.hh"           
 62 #include "G4SDManager.hh"                         
 63 #include "G4VPrimitiveScorer.hh"                  
 64                                                   
 65 //....oooOO0OOooo........oooOO0OOooo........oo    
 66 //                                                
 67 //  Constructor.                                  
 68 //   (The vector of MultiFunctionalDetector na    
 69 RE02Run::RE02Run(const std::vector<G4String> m    
 70 {                                                 
 71   G4SDManager* pSDman = G4SDManager::GetSDMpoi    
 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++) {     
 78     G4String detName = mfdName[idet];             
 79     //--- Seek and Obtain MFD objects from SDm    
 80     G4MultiFunctionalDetector* mfd =              
 81       (G4MultiFunctionalDetector*)(pSDman->Fin    
 82     //                                            
 83     if (mfd) {                                    
 84       //--- Loop over the registered primitive    
 85       for (G4int icol = 0; icol < mfd->GetNumb    
 86         // Get Primitive Scorer object.           
 87         G4VPrimitiveScorer* scorer = mfd->GetP    
 88         // collection name and collectionID fo    
 89         // where type of HitsCollection is G4T    
 90         // scorer.                                
 91         // The collection name is given by <MF    
 92         G4String collectionName = scorer->GetN    
 93         G4String fullCollectionName = detName     
 94         G4int collectionID = pSDman->GetCollec    
 95         //                                        
 96         if (collectionID >= 0) {                  
 97           G4cout << "++ " << fullCollectionNam    
 98           // Store obtained HitsCollection inf    
 99           // And, creates new G4THitsMap for a    
100           fCollName.push_back(fullCollectionNa    
101           fCollID.push_back(collectionID);        
102           fRunMap.push_back(new G4THitsMap<G4d    
103         }                                         
104         else {                                    
105           G4cout << "** collection " << fullCo    
106         }                                         
107       }                                           
108     }                                             
109   }                                               
110 }                                                 
111                                                   
112 //....oooOO0OOooo........oooOO0OOooo........oo    
113 //                                                
114 // Destructor                                     
115 //    clear all data members.                     
116 RE02Run::~RE02Run()                               
117 {                                                 
118   //--- Clear HitsMap for RUN                     
119   G4int nMap = fRunMap.size();                    
120   for (G4int i = 0; i < nMap; i++) {              
121     if (fRunMap[i]) fRunMap[i]->clear();          
122   }                                               
123   fCollName.clear();                              
124   fCollID.clear();                                
125   fRunMap.clear();                                
126 }                                                 
127                                                   
128 //....oooOO0OOooo........oooOO0OOooo........oo    
129 //                                                
130 //  RecordEvent is called at end of event.        
131 //  For scoring purpose, the resultant quantit    
132 //  is accumulated during a Run.                  
133 void RE02Run::RecordEvent(const G4Event* aEven    
134 {                                                 
135   numberOfEvent++;  // This is an original lin    
136                                                   
137   //=============================                 
138   // HitsCollection of This Event                 
139   //============================                  
140   G4HCofThisEvent* pHCE = aEvent->GetHCofThisE    
141   if (!pHCE) return;                              
142                                                   
143   //==========================================    
144   // Sum up HitsMap of this Event  into HitsMa    
145   //==========================================    
146   G4int nCol = fCollID.size();                    
147   for (G4int i = 0; i < nCol; i++) {  // Loop     
148     G4THitsMap<G4double>* evtMap = 0;             
149     if (fCollID[i] >= 0) {  // Collection is a    
150       evtMap = (G4THitsMap<G4double>*)(pHCE->G    
151     }                                             
152     else {                                        
153       G4cout << " Error evtMap Not Found " <<     
154     }                                             
155     if (evtMap) {                                 
156       //=== Sum up HitsMap of this event to Hi    
157       *fRunMap[i] += *evtMap;                     
158       //======================================    
159     }                                             
160   }                                               
161 }                                                 
162                                                   
163 //....oooOO0OOooo........oooOO0OOooo........oo    
164 void RE02Run::Merge(const G4Run* aRun)            
165 {                                                 
166   const RE02Run* localRun = static_cast<const     
167                                                   
168   //==========================================    
169   // Merge HitsMap of working threads             
170   //==========================================    
171   G4int nCol = localRun->fCollID.size();          
172   for (G4int i = 0; i < nCol; i++) {  // Loop     
173     if (localRun->fCollID[i] >= 0) {              
174       *fRunMap[i] += *localRun->fRunMap[i];       
175     }                                             
176   }                                               
177                                                   
178   G4Run::Merge(aRun);                             
179 }                                                 
180                                                   
181 //....oooOO0OOooo........oooOO0OOooo........oo    
182 //                                                
183 //  Access method for HitsMap of the RUN          
184 //                                                
185 //-----                                           
186 // Access HitsMap.                                
187 //  By  MultiFunctionalDetector name and Colle    
188 G4THitsMap<G4double>* RE02Run::GetHitsMap(cons    
189 {                                                 
190   G4String fullName = detName + "/" + colName;    
191   return GetHitsMap(fullName);                    
192 }                                                 
193                                                   
194 //....oooOO0OOooo........oooOO0OOooo........oo    
195 //                                                
196 //-----                                           
197 // Access HitsMap.                                
198 //  By full description of collection name, th    
199 //    <MultiFunctional Detector Name>/<Primiti    
200 G4THitsMap<G4double>* RE02Run::GetHitsMap(cons    
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 }                                                 
210                                                   
211 //....oooOO0OOooo........oooOO0OOooo........oo    
212 //                                                
213 //-----                                           
214 // - Dump All HitsMap of this RUN. (for debugi    
215 //   This method calls G4THisMap::PrintAll() f    
216 void RE02Run::DumpAllScorer()                     
217 {                                                 
218   // - Number of HitsMap in this RUN.             
219   G4int n = GetNumberOfHitsMap();                 
220   // - GetHitsMap and dump values.                
221   for (G4int i = 0; i < n; i++) {                 
222     G4THitsMap<G4double>* runMap = GetHitsMap(    
223     if (runMap) {                                 
224       G4cout << " PrimitiveScorer RUN " << run    
225              << G4endl;                           
226       G4cout << " Number of entries " << runMa    
227       ////      std::map<G4int,G4double*>::ite    
228       ////      for(; itr != runMap->GetMap()-    
229       ////        G4cout << "  copy no.: " <<     
230       ////               << "  Run Value : " <    
231       ////               << G4endl;               
232       ////      }                                 
233     }                                             
234   }                                               
235 }                                                 
236