Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4IStore.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4IStore.cc 102994 2017-03-07 16:31:28Z gcosmo $
28 //
29 // ----------------------------------------------------------------------
30 // GEANT 4 class source file
31 //
32 // G4IStore.cc
33 //
34 // ----------------------------------------------------------------------
35 
36 #include "G4IStore.hh"
37 #include "G4VPhysicalVolume.hh"
38 #include "G4GeometryCell.hh"
40 #include "G4LogicalVolume.hh"
42 
43 #ifdef G4MULTITHREADED
44 G4Mutex G4IStore::IStoreMutex = G4MUTEX_INITIALIZER;
45 #endif
46 
47 // ***************************************************************************
48 // Static class variable: ptr to single instance of class
49 // ***************************************************************************
51 
53 fWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume())
54 {}
55 
56 G4IStore::G4IStore(const G4String& ParallelWorldName) :
57 fWorldVolume(G4TransportationManager::GetTransportationManager()->GetParallelWorld(ParallelWorldName))
58 {
59  G4cout << " G4IStore:: ParallelWorldName = " << ParallelWorldName << G4endl;
60  G4cout << " G4IStore:: fParallelWorldVolume = " << fWorldVolume->GetName() << G4endl;
61 }
62 
64 {}
65 
67 {
68  fGeometryCelli.clear();
69 }
70 
72 {
73  G4cout << " G4IStore:: SetWorldVolume " << G4endl;
75  G4cout << " World volume is: " << fWorldVolume->GetName() << G4endl;
76  // fGeometryCelli = new G4GeometryCellImportance;
77 }
78 
80 {
81  G4cout << " G4IStore:: SetParallelWorldVolume " << G4endl;
83  G4cout << " ParallelWorld volume is: " << fWorldVolume->GetName() << G4endl;
84  // fGeometryCelli = new G4GeometryCellImportance;
85 }
86 
88 {
89  return *fWorldVolume;
90 }
91 
92 // const G4VPhysicalVolume& G4IStore::GetParallelWorldVolume() const
93 // {
94 // return *fParallelWorldVolume;
95 // }
96 
98 {
99  return fWorldVolume;
100 }
101 
103 {
104  fCurrentIterator = fGeometryCelli.find(gCell);
105 }
106 
108  const G4GeometryCell &gCell)
109 {
110  if (importance < 0 ) {
111  Error("AddImportanceGeometryCell() - Invalid importance value given.");
112  }
113  if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
114  Error("AddImportanceGeometryCell() - Physical volume not found!");
115  }
116  SetInternalIterator(gCell);
117  if (fCurrentIterator!=fGeometryCelli.end()) {
118  Error("AddImportanceGeometryCell() - Region already existing!");
119  }
120  fGeometryCelli[gCell] = importance;
121 }
122 
124  const G4VPhysicalVolume &aVolume,
125  G4int aRepNum)
126 {
127  AddImportanceGeometryCell(importance,
128  G4GeometryCell(aVolume, aRepNum));
129 }
130 
132  const G4GeometryCell &gCell){
133  if (importance < 0 ) {
134  Error("ChangeImportance() - Invalid importance value given.");
135  }
136  if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
137  Error("ChangeImportance() - Physical volume not found!");
138  }
139  SetInternalIterator(gCell);
140  if (fCurrentIterator==fGeometryCelli.end()) {
141  Error("ChangeImportance() - Region does not exist!");
142  }
143  fGeometryCelli[gCell] = importance;
144 
145 }
147  const G4VPhysicalVolume &aVolume,
148  G4int aRepNum)
149 {
150  ChangeImportance(importance, G4GeometryCell(aVolume, aRepNum));
151 }
152 
154  G4int aRepNum) const
155 {
156 #ifdef G4MULTITHREADED
157  G4MUTEXLOCK(&G4IStore::IStoreMutex);
158 #endif
159  SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
160  G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
161  if (gCellIterator==fGeometryCelli.end()) {
162  Error("GetImportance() - Region does not exist!");
163  return 0.;
164  }
165  G4double importance_value = (*fCurrentIterator).second;
166 #ifdef G4MULTITHREADED
167  G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
168 #endif
169  return importance_value;
170  // return (*fCurrentIterator).second;
171 }
172 
173 
175 {
176 #ifdef G4MULTITHREADED
177  G4MUTEXLOCK(&G4IStore::IStoreMutex);
178 #endif
179  SetInternalIterator(gCell);
180  G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
181  if (gCellIterator==fGeometryCelli.end()) {
182  std::ostringstream err_mess;
183  err_mess << "GetImportance() - Region does not exist!" << G4endl
184  << "Geometry cell, " << gCell
185  << ", not found in: " << fGeometryCelli << ".";
186  Error(err_mess.str());
187  return 0.;
188  }
189  G4double importance_value = (*fCurrentIterator).second;
190 #ifdef G4MULTITHREADED
191  G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
192 #endif
193  return importance_value;
194  // return (*fCurrentIterator).second;
195 }
196 
198 #ifdef G4MULTITHREADED
199  G4MUTEXLOCK(&G4IStore::IStoreMutex);
200 #endif
201  G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
202 
203  if ( inWorldKnown ) {
204  SetInternalIterator(gCell);
205  inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
206  }
207 #ifdef G4MULTITHREADED
208  G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
209 #endif
210  return inWorldKnown;
211 }
212 
214 {
215  G4bool isIn(true);
216  // G4cout << "G4IStore:: aVolume: " << aVolume.GetName() << G4endl;
217  // G4cout << "G4IStore:: fWorld: " << fWorldVolume->GetName() << G4endl;
218  if (!(aVolume == *fWorldVolume)) {
219  isIn = fWorldVolume->GetLogicalVolume()->IsAncestor(&aVolume);
220  }
221  return isIn;
222 }
223 
224 
225 
226 void G4IStore::Error(const G4String &msg) const
227 {
228  G4Exception("G4IStore::Error()", "GeomBias0002", FatalException, msg);
229 }
230 
231 // ***************************************************************************
232 // Returns the instance of the singleton.
233 // Creates it in case it's called for the first time.
234 // ***************************************************************************
235 //
237 {
238  if (!fInstance)
239  {
240  G4cout << "G4IStore:: Creating new MASS IStore " << G4endl;
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 first time.
249 // ***************************************************************************
250 //
251 G4IStore* G4IStore::GetInstance(const G4String& ParallelWorldName)
252 {
253  if (!fInstance)
254  {
255  G4cout << "G4IStore:: Creating new Parallel IStore " << ParallelWorldName << G4endl;
256  fInstance = new G4IStore(ParallelWorldName);
257  }
258  return fInstance;
259 }
260 
void Clear()
Definition: G4IStore.cc:66
void AddImportanceGeometryCell(G4double importance, const G4GeometryCell &gCell)
Definition: G4IStore.cc:107
G4LogicalVolume * GetLogicalVolume() const
G4GeometryCellImportance fGeometryCelli
Definition: G4IStore.hh:142
#define G4endl
Definition: G4ios.hh:61
G4Navigator * GetNavigatorForTracking() const
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
G4IStore()
Definition: G4IStore.cc:52
#define G4ThreadLocal
Definition: tls.hh:69
~G4IStore()
Definition: G4IStore.cc:63
G4GeometryCellImportance::const_iterator fCurrentIterator
Definition: G4IStore.hh:144
void Error(const G4String &m) const
Definition: G4IStore.cc:226
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void SetInternalIterator(const G4GeometryCell &gCell) const
Definition: G4IStore.cc:102
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:88
static G4ThreadLocal G4IStore * fInstance
Definition: G4IStore.hh:146
virtual const G4VPhysicalVolume & GetWorldVolume() const
Definition: G4IStore.cc:87
const G4VPhysicalVolume * fWorldVolume
Definition: G4IStore.hh:139
void SetParallelWorldVolume(G4String paraName)
Definition: G4IStore.cc:79
const G4VPhysicalVolume & GetPhysicalVolume() const
virtual G4bool IsKnown(const G4GeometryCell &gCell) const
Definition: G4IStore.cc:197
#define G4MUTEXUNLOCK(mutex)
Definition: G4Threading.hh:234
G4bool IsAncestor(const G4VPhysicalVolume *p) const
G4bool IsInWorld(const G4VPhysicalVolume &) const
Definition: G4IStore.cc:213
static G4TransportationManager * GetTransportationManager()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
int G4int
Definition: G4Types.hh:78
static G4IStore * GetInstance()
Definition: G4IStore.cc:236
#define G4MUTEXLOCK(mutex)
Definition: G4Threading.hh:233
G4GLOB_DLL std::ostream G4cout
void ChangeImportance(G4double importance, const G4GeometryCell &gCell)
Definition: G4IStore.cc:131
void SetWorldVolume()
Definition: G4IStore.cc:71
G4VPhysicalVolume * GetWorldVolume() const
virtual const G4VPhysicalVolume * GetParallelWorldVolumePointer() const
Definition: G4IStore.cc:97
virtual G4double GetImportance(const G4GeometryCell &gCell) const
Definition: G4IStore.cc:174
const G4String & GetName() const
std::mutex G4Mutex
Definition: G4Threading.hh:84