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 ] [ 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 /geometry/biasing/src/G4WeightWindowStore.cc (Version 11.3.0) and /geometry/biasing/src/G4WeightWindowStore.cc (Version 5.0.p1)


  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 // G4WeightWindowStore implementation             
 27 //                                                
 28 // Author: Michael Dressel (CERN), 2003           
 29 // Modified: Alex Howard (CERN), 2013 - Change    
 30 // -------------------------------------------    
 31                                                   
 32 #include "G4WeightWindowStore.hh"                 
 33 #include "G4VPhysicalVolume.hh"                   
 34 #include "G4LogicalVolume.hh"                     
 35 #include "G4GeometryCellStepStream.hh"            
 36 #include "G4TransportationManager.hh"             
 37                                                   
 38 // *******************************************    
 39 // Static class variable: ptr to single instan    
 40 // *******************************************    
 41 G4ThreadLocal G4WeightWindowStore* G4WeightWin    
 42                                                   
 43 G4WeightWindowStore::                             
 44 G4WeightWindowStore()                             
 45  : fWorldVolume(G4TransportationManager::GetTr    
 46                 ->GetNavigatorForTracking()->G    
 47    fCurrentIterator(fCellToUpEnBoundLoWePairsM    
 48 {                                                 
 49 }                                                 
 50                                                   
 51 G4WeightWindowStore::                             
 52 G4WeightWindowStore(const G4String& ParallelWo    
 53  : fWorldVolume(G4TransportationManager::GetTr    
 54                 ->GetParallelWorld(ParallelWor    
 55    fCurrentIterator(fCellToUpEnBoundLoWePairsM    
 56 {                                                 
 57 }                                                 
 58                                                   
 59 G4WeightWindowStore::~G4WeightWindowStore() =     
 60                                                   
 61 G4double G4WeightWindowStore::                    
 62 GetLowerWeight(const G4GeometryCell& gCell,       
 63                      G4double partEnergy) cons    
 64 {                                                 
 65   SetInternalIterator(gCell);                     
 66   auto gCellIterator = fCurrentIterator;          
 67   if (gCellIterator == fCellToUpEnBoundLoWePai    
 68   {                                               
 69     Error("GetLowerWitgh() - Cell does not exi    
 70     return 0.;                                    
 71   }                                               
 72   G4UpperEnergyToLowerWeightMap upEnLoWeiPairs    
 73   G4double lowerWeight = -1;                      
 74   G4bool found = false;                           
 75   for (const auto & upEnLoWeiPair : upEnLoWeiP    
 76   {                                               
 77     if (partEnergy < upEnLoWeiPair.first)         
 78     {                                             
 79       lowerWeight = upEnLoWeiPair.second;         
 80       found = true;                               
 81       break;                                      
 82     }                                             
 83   }                                               
 84   if (!found)                                     
 85   {                                               
 86     std::ostringstream err_mess;                  
 87     err_mess << "GetLowerWitgh() - Couldn't fi    
 88              << "Energy: " << partEnergy << ".    
 89     Error(err_mess.str());                        
 90   }                                               
 91   return lowerWeight;                             
 92 }                                                 
 93                                                   
 94 void G4WeightWindowStore::                        
 95 SetInternalIterator(const G4GeometryCell& gCel    
 96 {                                                 
 97   fCurrentIterator = fCellToUpEnBoundLoWePairs    
 98 }                                                 
 99                                                   
100 G4bool G4WeightWindowStore::                      
101 IsInWorld(const G4VPhysicalVolume& aVolume) co    
102 {                                                 
103   G4bool isIn(true);                              
104   if (!(aVolume == *fWorldVolume))                
105   {                                               
106     isIn = fWorldVolume->GetLogicalVolume()->I    
107   }                                               
108   return isIn;                                    
109 }                                                 
110                                                   
111 G4bool G4WeightWindowStore::                      
112 IsKnown(const G4GeometryCell& gCell) const        
113 {                                                 
114   G4bool inWorldKnown(IsInWorld(gCell.GetPhysi    
115                                                   
116   if ( inWorldKnown )                             
117   {                                               
118     SetInternalIterator(gCell);                   
119     inWorldKnown = (fCurrentIterator!=fCellToU    
120   }                                               
121   return inWorldKnown;                            
122 }                                                 
123                                                   
124 void G4WeightWindowStore::Clear()                 
125 {                                                 
126   fCellToUpEnBoundLoWePairsMap.clear();           
127 }                                                 
128                                                   
129 void G4WeightWindowStore::SetWorldVolume()        
130 {                                                 
131   G4cout << " G4IStore:: SetWorldVolume " << G    
132   fWorldVolume = G4TransportationManager::GetT    
133                  ->GetNavigatorForTracking()->    
134   G4cout << " World volume is: " << fWorldVolu    
135   // fGeometryCelli = new G4GeometryCellImport    
136 }                                                 
137                                                   
138 void G4WeightWindowStore::SetParallelWorldVolu    
139 {                                                 
140   fWorldVolume = G4TransportationManager::GetT    
141                  ->GetParallelWorld(paraName);    
142   // fGeometryCelli = new G4GeometryCellImport    
143 }                                                 
144                                                   
145 const G4VPhysicalVolume &G4WeightWindowStore::    
146 {                                                 
147   return *fWorldVolume;                           
148 }                                                 
149                                                   
150 const G4VPhysicalVolume* G4WeightWindowStore::    
151 GetParallelWorldVolumePointer() const             
152 {                                                 
153   return fWorldVolume;                            
154 }                                                 
155                                                   
156 void G4WeightWindowStore::                        
157 AddLowerWeights(const G4GeometryCell& gCell,      
158                 const std::vector<G4double>& l    
159 {                                                 
160   if (fGeneralUpperEnergyBounds.empty())          
161   {                                               
162     Error("AddLowerWeights() - No general uppe    
163   }                                               
164   if (IsKnown(gCell))                             
165   {                                               
166     Error("AddLowerWeights() - Cell already in    
167   }                                               
168   if (lowerWeights.size() != fGeneralUpperEner    
169   {                                               
170     std::ostringstream err_mess;                  
171     err_mess << "AddLowerWeights() - Mismatch     
172              << "number of lower weights (" <<    
173              << ") and energy bounds (" << fGe    
174              << ")!";                             
175     Error(err_mess.str());                        
176   }                                               
177   G4UpperEnergyToLowerWeightMap map;              
178   G4int i = 0;                                    
179   for (G4double fGeneralUpperEnergyBound : fGe    
180   {                                               
181     map[fGeneralUpperEnergyBound] = lowerWeigh    
182     ++i;                                          
183   }                                               
184   fCellToUpEnBoundLoWePairsMap[gCell] = std::m    
185 }                                                 
186                                                   
187 void G4WeightWindowStore::                        
188 AddUpperEboundLowerWeightPairs(const G4Geometr    
189                                const G4UpperEn    
190 {                                                 
191   if (IsKnown(gCell))                             
192   {                                               
193     Error("AddUpperEboundLowerWeightPairs() -     
194   }                                               
195   if (IsKnown(gCell))                             
196   {                                               
197     Error("AddUpperEboundLowerWeightPairs() -     
198   }                                               
199   fCellToUpEnBoundLoWePairsMap[gCell] = enWeMa    
200                                                   
201 }                                                 
202                                                   
203 void G4WeightWindowStore::                        
204 SetGeneralUpperEnergyBounds(const std::set<G4d    
205                             std::less<G4double    
206 {                                                 
207   if (!fGeneralUpperEnergyBounds.empty())         
208   {                                               
209     Error("SetGeneralUpperEnergyBounds() - Ene    
210   }                                               
211   fGeneralUpperEnergyBounds = enBounds;           
212 }                                                 
213                                                   
214 void G4WeightWindowStore::Error(const G4String    
215 {                                                 
216   G4Exception("G4WeightWindowStore::Error()",     
217               "GeomBias0002", FatalException,     
218 }                                                 
219                                                   
220 // *******************************************    
221 // Returns the instance of the singleton.         
222 // Creates it in case it's called for the firs    
223 // *******************************************    
224 //                                                
225 G4WeightWindowStore* G4WeightWindowStore::GetI    
226 {                                                 
227   if (fInstance == nullptr)                       
228   {                                               
229     fInstance = new G4WeightWindowStore();        
230   }                                               
231   return fInstance;                               
232 }                                                 
233                                                   
234 // *******************************************    
235 // Returns the instance of the singleton.         
236 // Creates it in case it's called for the firs    
237 // *******************************************    
238 //                                                
239 G4WeightWindowStore* G4WeightWindowStore::        
240 GetInstance(const G4String& ParallelWorldName)    
241 {                                                 
242   if (fInstance == nullptr)                       
243   {                                               
244 #ifdef G4VERBOSE                                  
245     G4cout << "G4IStore:: Creating new Paralle    
246            << ParallelWorldName << G4endl;        
247 #endif                                            
248     fInstance = new G4WeightWindowStore(Parall    
249   }                                               
250   return fInstance;                               
251 }                                                 
252