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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/G4IStore.cc (Version 11.3.0) and /geometry/biasing/src/G4IStore.cc (Version 8.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4IStore implementation                     << 
 27 //                                                 26 //
 28 // Author: Michael Dressel (CERN), 2002        <<  27 // $Id: G4IStore.cc,v 1.14 2006/06/29 18:17:18 gunter Exp $
 29 // Modified: Alex Howard (CERN), 2013 - Change <<  28 // GEANT4 tag $Name: geant4-08-02 $
                                                   >>  29 //
                                                   >>  30 // ----------------------------------------------------------------------
                                                   >>  31 // GEANT 4 class source file
                                                   >>  32 //
                                                   >>  33 // G4IStore.cc
                                                   >>  34 //
 30 // -------------------------------------------     35 // ----------------------------------------------------------------------
 31                                                    36 
 32 #include "G4IStore.hh"                             37 #include "G4IStore.hh"
 33 #include "G4VPhysicalVolume.hh"                    38 #include "G4VPhysicalVolume.hh"
 34 #include "G4GeometryCell.hh"                       39 #include "G4GeometryCell.hh"
 35 #include "G4GeometryCellStepStream.hh"             40 #include "G4GeometryCellStepStream.hh"
 36 #include "G4LogicalVolume.hh"                      41 #include "G4LogicalVolume.hh"
 37 #include "G4TransportationManager.hh"          << 
 38                                                << 
 39 #include "G4AutoLock.hh"                       << 
 40                                                << 
 41 namespace                                      << 
 42 {                                              << 
 43   G4Mutex IStoreMutex = G4MUTEX_INITIALIZER;   << 
 44 }                                              << 
 45                                                << 
 46 // ******************************************* << 
 47 // Static class variable: ptr to single instan << 
 48 // ******************************************* << 
 49 G4ThreadLocal G4IStore* G4IStore::fInstance =  << 
 50                                                << 
 51 G4IStore::G4IStore()                           << 
 52   : fWorldVolume(G4TransportationManager::GetT << 
 53                  ->GetNavigatorForTracking()-> << 
 54 {                                              << 
 55 }                                              << 
 56                                                << 
 57 G4IStore::G4IStore(const G4String& ParallelWor << 
 58   : fWorldVolume(G4TransportationManager::GetT << 
 59                  ->GetParallelWorld(ParallelWo << 
 60 {                                              << 
 61 #ifdef G4VERBOSE                               << 
 62   G4cout << " G4IStore:: ParallelWorldName = " << 
 63          << ParallelWorldName << G4endl;       << 
 64   G4cout << " G4IStore:: fParallelWorldVolume  << 
 65          << fWorldVolume->GetName() << G4endl; << 
 66 #endif                                         << 
 67 }                                              << 
 68                                                << 
 69 G4IStore::~G4IStore() = default;               << 
 70                                                << 
 71 void G4IStore::Clear()                         << 
 72 {                                              << 
 73   fGeometryCelli.clear();                      << 
 74 }                                              << 
 75                                                << 
 76 void G4IStore::SetWorldVolume()                << 
 77 {                                              << 
 78   G4cout << " G4IStore:: SetWorldVolume " << G << 
 79   fWorldVolume = G4TransportationManager::GetT << 
 80                  ->GetNavigatorForTracking()-> << 
 81   G4cout << " World volume is: " << fWorldVolu << 
 82   // fGeometryCelli = new G4GeometryCellImport << 
 83 }                                              << 
 84                                                    42 
 85 void G4IStore::SetParallelWorldVolume(const G4 <<  43 G4IStore::G4IStore(const G4VPhysicalVolume &worldvolume) :
 86 {                                              <<  44   fWorldVolume(worldvolume)
 87   G4cout << " G4IStore:: SetParallelWorldVolum <<  45 {}
 88   fWorldVolume = G4TransportationManager::GetT << 
 89                  ->GetParallelWorld(paraName); << 
 90   G4cout << " ParallelWorld volume is: " << fW << 
 91   // fGeometryCelli = new G4GeometryCellImport << 
 92 }                                              << 
 93                                                    46 
 94 const G4VPhysicalVolume& G4IStore::GetWorldVol <<  47 G4IStore::~G4IStore()
 95 {                                              <<  48 {}
 96   return *fWorldVolume;                        << 
 97 }                                              << 
 98                                                    49 
 99 const G4VPhysicalVolume* G4IStore::GetParallel <<  50 const G4VPhysicalVolume &G4IStore::GetWorldVolume() const 
100 {                                                  51 {
101   return fWorldVolume;                             52   return fWorldVolume;
102 }                                                  53 }
103                                                    54 
104 void G4IStore::SetInternalIterator(const G4Geo <<  55 void G4IStore::SetInternalIterator(const G4GeometryCell &gCell) const
105 {                                                  56 {
106   fCurrentIterator = fGeometryCelli.find(gCell     57   fCurrentIterator = fGeometryCelli.find(gCell);
107 }                                                  58 }
108                                                    59 
109 void G4IStore::AddImportanceGeometryCell(G4dou     60 void G4IStore::AddImportanceGeometryCell(G4double importance,
110                                          const <<  61        const G4GeometryCell &gCell){
111 {                                              <<  62   if (importance < 0 ) {
112   if (importance < 0 )                         <<  63     Error("AddImportanceGeometryCell: invalid importance value given");
113   {                                            << 
114     Error("AddImportanceGeometryCell() - Inval << 
115   }                                                64   }  
116   if (!IsInWorld(gCell.GetPhysicalVolume()) )  <<  65   if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
117   {                                            <<  66     Error("AddImportanceGeometryCell: physical volume not in this World");
118     Error("AddImportanceGeometryCell() - Physi << 
119   }                                                67   }
120   SetInternalIterator(gCell);                      68   SetInternalIterator(gCell);
121   if (fCurrentIterator != fGeometryCelli.cend( <<  69   if (fCurrentIterator!=fGeometryCelli.end()) {
122   {                                            <<  70     Error("AddImportanceGeometryCell: Region allready exists");
123     Error("AddImportanceGeometryCell() - Regio << 
124   }                                                71   }
125   fGeometryCelli[gCell] = importance;              72   fGeometryCelli[gCell] = importance;
126 }                                                  73 }
127                                                    74 
128 void G4IStore::AddImportanceGeometryCell(G4dou     75 void G4IStore::AddImportanceGeometryCell(G4double importance,
129                                          const <<  76            const G4VPhysicalVolume &aVolume,
130                                          G4int <<  77            G4int aRepNum)
131 {                                                  78 {
132   AddImportanceGeometryCell(importance, G4Geom <<  79   AddImportanceGeometryCell(importance,
                                                   >>  80           G4GeometryCell(aVolume, aRepNum));
133 }                                                  81 }
134                                                    82 
135 void G4IStore::ChangeImportance(G4double impor     83 void G4IStore::ChangeImportance(G4double importance,
136                                 const G4Geomet <<  84         const G4GeometryCell &gCell){
137 {                                              <<  85   if (importance < 0 ) {
138   if (importance < 0 )                         <<  86     Error("ChangeImportance: Invalid importance value given");
139   {                                            <<  87   }
140     Error("ChangeImportance() - Invalid import <<  88   if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
141   }                                            <<  89     Error("ChangeImportance: physical volume not in this World");
142   if (!IsInWorld(gCell.GetPhysicalVolume()))   << 
143   {                                            << 
144     Error("ChangeImportance() - Physical volum << 
145   }                                                90   }
146   SetInternalIterator(gCell);                      91   SetInternalIterator(gCell);
147   if (fCurrentIterator == fGeometryCelli.cend( <<  92   if (fCurrentIterator==fGeometryCelli.end()) {
148   {                                            <<  93     Error("ChangeImportance: Region does not exist");
149     Error("ChangeImportance() - Region does no << 
150   }                                                94   }
151   fGeometryCelli[gCell] = importance;              95   fGeometryCelli[gCell] = importance;
152                                                    96 
153 }                                                  97 }
154                                                << 
155 void G4IStore::ChangeImportance(G4double impor     98 void G4IStore::ChangeImportance(G4double importance,
156                                 const G4VPhysi <<  99         const G4VPhysicalVolume &aVolume,
157                                 G4int aRepNum) << 100         G4int aRepNum)
158 {                                                 101 {
159   ChangeImportance(importance, G4GeometryCell(    102   ChangeImportance(importance, G4GeometryCell(aVolume, aRepNum));
160 }                                                 103 }
161                                                   104 
162 G4double G4IStore::GetImportance(const G4VPhys << 105 G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
163                                  G4int aRepNum << 106          G4int aRepNum) const
164 {                                                 107 {  
165   G4AutoLock l(&IStoreMutex);                  << 
166   SetInternalIterator(G4GeometryCell(aVolume,     108   SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
167   auto gCellIterator = fCurrentIterator;       << 109   if (fCurrentIterator==fGeometryCelli.end()) {
168   if (gCellIterator == fGeometryCelli.cend())  << 110     Error("GetImportance: Region does not exist");
169   {                                            << 
170     Error("GetImportance() - Region does not e << 
171     return 0.;                                 << 
172   }                                               111   }
173   G4double importance_value = (*fCurrentIterat << 112   return (*fCurrentIterator).second;
174   l.unlock();                                  << 
175                                                << 
176   return importance_value;                     << 
177 }                                                 113 }
178                                                   114 
179 G4double G4IStore::GetImportance(const G4Geome << 115 
                                                   >> 116 G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
180 {                                                 117 {
181   G4AutoLock l(&IStoreMutex);                  << 
182   SetInternalIterator(gCell);                     118   SetInternalIterator(gCell);
183   auto gCellIterator = fCurrentIterator;       << 119   if (fCurrentIterator==fGeometryCelli.end()) {
184   if (gCellIterator == fGeometryCelli.cend())  << 120     G4cout << "PGeometryCell gCell: " << gCell << G4endl;
185   {                                            << 121     G4cout << "Not found in: " << G4endl;
186     std::ostringstream err_mess;               << 122     G4cout << fGeometryCelli << G4endl;
187     err_mess << "GetImportance() - Region does << 123     Error("GetImportance(gCell): Region does not exist");
188              << "Geometry cell, " << gCell     << 
189              << ", not found in: " << fGeometr << 
190     Error(err_mess.str());                     << 
191     return 0.;                                 << 
192   }                                               124   }
193   G4double importance_value = (*fCurrentIterat << 125   return (*fCurrentIterator).second;
194   l.unlock();                                  << 
195                                                << 
196   return importance_value;                     << 
197 }                                                 126 }
198                                                   127 
199 G4bool G4IStore::IsKnown(const G4GeometryCell& << 128 G4bool G4IStore::IsKnown(const G4GeometryCell &gCell) const {
200 {                                              << 
201   G4AutoLock l(&IStoreMutex);                  << 
202   G4bool inWorldKnown(IsInWorld(gCell.GetPhysi    129   G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
203                                                << 130           
204   if ( inWorldKnown )                          << 131   if ( inWorldKnown ) {
205   {                                            << 
206     SetInternalIterator(gCell);                   132     SetInternalIterator(gCell);
207     inWorldKnown = (fCurrentIterator != fGeome << 133     inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
208   }                                               134   }
209   l.unlock();                                  << 
210                                                << 
211   return inWorldKnown;                            135   return inWorldKnown;
212 }                                                 136 }
213                                                   137 
214 G4bool G4IStore::IsInWorld(const G4VPhysicalVo << 138 G4bool G4IStore::IsInWorld(const G4VPhysicalVolume &aVolume) const
215 {                                                 139 {
216   G4bool isIn(true);                              140   G4bool isIn(true);
217   if (!(aVolume == *fWorldVolume))             << 141   if (!(aVolume == fWorldVolume)) {
218   {                                            << 142     isIn = fWorldVolume.GetLogicalVolume()->IsAncestor(&aVolume);
219     isIn = fWorldVolume->GetLogicalVolume()->I << 
220   }                                               143   }
221   return isIn;                                    144   return isIn;
222 }                                                 145 }
223                                                   146 
224 void G4IStore::Error(const G4String& msg) cons << 
225 {                                              << 
226   G4Exception("G4IStore::Error()", "GeomBias00 << 
227 }                                              << 
228                                                   147 
229 // ******************************************* << 148 
230 // Returns the instance of the singleton.      << 149 void G4IStore::Error(const G4String &m) const
231 // Creates it in case it's called for the firs << 
232 // ******************************************* << 
233 //                                             << 
234 G4IStore* G4IStore::GetInstance()              << 
235 {                                              << 
236   if (fInstance == nullptr)                    << 
237   {                                            << 
238 #ifdef G4VERBOSE                               << 
239     G4cout << "G4IStore:: Creating new MASS IS << 
240 #endif                                         << 
241     fInstance = new G4IStore();                << 
242   }                                            << 
243   return fInstance;                            << 
244 }                                              << 
245                                                << 
246 // ******************************************* << 
247 // Returns the instance of the singleton.      << 
248 // Creates it in case it's called for the firs << 
249 // ******************************************* << 
250 //                                             << 
251 G4IStore* G4IStore::GetInstance(const G4String << 
252 {                                                 150 {
253   if (fInstance == nullptr)                    << 151   G4cerr << "ERROR - G4IStore::" << m << G4endl;
254   {                                            << 152   G4Exception("G4IStore::Error()", "FatalException", FatalException, m);
255 #ifdef G4VERBOSE                               << 
256     G4cout << "G4IStore:: Creating new Paralle << 
257            << ParallelWorldName << G4endl;     << 
258 #endif                                         << 
259     fInstance = new G4IStore(ParallelWorldName << 
260   }                                            << 
261   return fInstance;                            << 
262 }                                                 153 }
263                                                   154