Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GeometryWorkspace Class Reference

#include <G4GeometryWorkspace.hh>

Public Member Functions

 G4GeometryWorkspace ()
 
 ~G4GeometryWorkspace ()
 
void UseWorkspace ()
 
void ReleaseWorkspace ()
 
void DestroyWorkspace ()
 
void InitialiseWorkspace ()
 
void SetVerbose (G4bool v)
 
G4bool GetVerbose ()
 

Protected Member Functions

void InitialisePhysicalVolumes ()
 
G4bool CloneParameterisedSolids (G4PVParameterised *paramVol)
 
G4bool CloneReplicaSolid (G4PVReplica *)
 

Detailed Description

Definition at line 62 of file G4GeometryWorkspace.hh.

Constructor & Destructor Documentation

G4GeometryWorkspace::G4GeometryWorkspace ( )

Definition at line 56 of file G4GeometryWorkspace.cc.

57  : fVerbose(false)
58 {
59  fpLogicalVolumeSIM=
61  fpPhysicalVolumeSIM=
63  fpReplicaSIM=
65  fpRegionSIM=
67 
68  // Create a work area for Logical Volumes in this thread
69  // then capture its address
71 
72  fLogicalVolumeOffset= fpLogicalVolumeSIM->GetOffset();
73 
74  fPhysicalVolumeOffset= fpPhysicalVolumeSIM->GetOffset();
75 
76  fReplicaOffset= fpReplicaSIM->GetOffset();
77 
78  fRegionOffset= fpRegionSIM->GetOffset();
79 }
static const G4LVManager & GetSubInstanceManager()
static const G4PVRManager & GetSubInstanceManager()
Definition: G4PVReplica.cc:260
static const G4PVManager & GetSubInstanceManager()
static const G4RegionManager & GetSubInstanceManager()
Definition: G4Region.cc:58

Here is the call graph for this function:

G4GeometryWorkspace::~G4GeometryWorkspace ( )

Definition at line 83 of file G4GeometryWorkspace.cc.

84 {
85 }

Member Function Documentation

G4bool G4GeometryWorkspace::CloneParameterisedSolids ( G4PVParameterised paramVol)
protected

Definition at line 229 of file G4GeometryWorkspace.cc.

230 {
231  // Check whether it is a simple parameterisation or not
232  //
233  // G4VPVParameterisation *param= paramVol->GetParameterisation();
234  // unsigned int numCopies= paramVol->GetMultiplicity();
235  // unsigned int numDifferent= 0;
236 
237  G4LogicalVolume *logicalV= paramVol->GetLogicalVolume();
238  G4VSolid *solid= logicalV->GetSolid();
239 
240  // for( unsigned int i=0; i< numCopies; i++)
241  // {
242  // G4VSolid *solidChk= param->ComputeSolid(i, paramVol);
243  // if( solidChk != solid)
244  // {
245  // numDifferent++;
246  // }
247  // }
248  // if( numDifferent>0 )
249  // {
250  // G4ExceptionDescription ed;
251  // ed << "ERROR - Parameterisation using several instances of Solids \n"
252  // << "potentially to support different types of solids. \n"
253  // << "Geant4-MT currently does not support this type of \n"
254  // << "parameterisation, sorry !";
255  // G4Exception("G4GeometryWorkspace::CloneParameterisedVolume()",
256  // "GeomVol0001", FatalException, ed);
257  // }
258 
259  // Threads may attempt to clone a solids simultaneously.
260  // Those cloned solids will be registered into a shared solid
261  // store (C++ container). Need a lock to guarantee thread safety
262  //
263  G4AutoLock aLock(&solidclone);
264  G4VSolid *workerSolid = solid->Clone();
265  aLock.unlock();
266  if( workerSolid )
267  {
268  logicalV->InitialiseWorker(logicalV,workerSolid,0);
269  }
270  else
271  {
272  // In the case that not all solids support(ed) the Clone()
273  // method, we do similar thing here to dynamically cast
274  // and then get the clone method
275  //
277  ed << "ERROR - Unable to initialise geometry for worker node. \n"
278  << "A solid lacks the Clone() method - or Clone() failed. \n"
279  << " Type of solid: " << solid->GetEntityType() << "\n"
280  << " Parameters: " << *solid;
281  G4Exception("G4GeometryWorkspace::CloneParameterisedVolume()",
282  "GeomVol0003", FatalException, ed);
283  }
284  return true; // It Worked
285 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4VSolid * GetSolid() const
virtual G4GeometryType GetEntityType() const =0
void InitialiseWorker(G4LogicalVolume *ptrMasterObject, G4VSolid *pSolid, G4VSensitiveDetector *pSDetector)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4LogicalVolume * GetLogicalVolume() const
virtual G4VSolid * Clone() const
Definition: G4VSolid.cc:325

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4GeometryWorkspace::CloneReplicaSolid ( G4PVReplica replicaPV)
protected

Definition at line 186 of file G4GeometryWorkspace.cc.

187 {
188  // The solid Ptr is in the Logical Volume
189  //
190  G4LogicalVolume *logicalV= replicaPV ->GetLogicalVolume();
191  G4VSolid *solid= logicalV->GetSolid();
192 
193  G4AutoLock aLock(&solidclone);
194  G4VSolid *workerSolid = solid->Clone();
195  aLock.unlock();
196 
197  if( workerSolid )
198  {
199  logicalV->InitialiseWorker(logicalV,workerSolid,0);
200  }
201  else
202  {
203  // In the case that not all solids support(ed) the Clone()
204  // method, we do similar thing here to dynamically cast
205  // and then get the clone method.
206  //
208  ed << "ERROR - Unable to initialise geometry for worker node." << "\n"
209  << "A solid lacks the Clone() method - or Clone() failed." << "\n"
210  << " Type of solid: " << solid->GetEntityType() << "\n"
211  << " Parameters: " << *solid;
212  G4Exception("G4GeometryWorkspace::CloneParameterisedVolume()",
213  "GeomVol0003", FatalException, ed);
214  return false;
215  }
216  return true; // It Worked
217 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4VSolid * GetSolid() const
virtual G4GeometryType GetEntityType() const =0
void InitialiseWorker(G4LogicalVolume *ptrMasterObject, G4VSolid *pSolid, G4VSensitiveDetector *pSDetector)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4LogicalVolume * GetLogicalVolume() const
virtual G4VSolid * Clone() const
Definition: G4VSolid.cc:325

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GeometryWorkspace::DestroyWorkspace ( )

Definition at line 320 of file G4GeometryWorkspace.cc.

321 {
323  for (size_t ip=0; ip<physVolStore->size(); ip++)
324  {
325  G4VPhysicalVolume* physVol = (*physVolStore)[ip];
326  G4LogicalVolume *logicalVol = physVol->GetLogicalVolume();
327  G4PVReplica *g4PVReplica = 0;
328  g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
329  if (g4PVReplica)
330  {
331  g4PVReplica->TerminateWorker(g4PVReplica);
332  G4PVParameterised *paramVol = 0;
333  paramVol = dynamic_cast<G4PVParameterised*>(physVol);
334  if (paramVol)
335  {
336  // G4VSolid *solid = logicalVol->fSolid;
337  logicalVol->TerminateWorker(logicalVol);
338  // if( solid->IsClone() ) delete solid;
339  }
340  else
341  {
342  logicalVol->TerminateWorker(logicalVol);
343  }
344  }
345  else
346  {
347  logicalVol->TerminateWorker(logicalVol);
348  }
349  }
350  fpLogicalVolumeSIM->FreeSlave();
351  fpPhysicalVolumeSIM->FreeSlave();
352  fpReplicaSIM->FreeSlave();
353  fpRegionSIM->FreeSlave();
354 }
void TerminateWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:316
static G4PhysicalVolumeStore * GetInstance()
void TerminateWorker(G4LogicalVolume *ptrMasterObject)
G4LogicalVolume * GetLogicalVolume() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4GeometryWorkspace::GetVerbose ( )
inline

Definition at line 77 of file G4GeometryWorkspace.hh.

77 { return fVerbose; }
void G4GeometryWorkspace::InitialisePhysicalVolumes ( )
protected

Definition at line 133 of file G4GeometryWorkspace.cc.

134 {
136  for (size_t ip=0; ip<physVolStore->size(); ip++)
137  {
138  G4VPhysicalVolume* physVol = (*physVolStore)[ip];
139  G4LogicalVolume *logicalVol = physVol->GetLogicalVolume();
140 
141  // Use shadow pointer
142  //
143  G4VSolid *solid = logicalVol->GetMasterSolid();
144  G4PVReplica *g4PVReplica = 0;
145  g4PVReplica = dynamic_cast<G4PVReplica*>(physVol);
146  if (!g4PVReplica)
147  {
148  // Placement volume
149  logicalVol->InitialiseWorker(logicalVol,solid,0);
150  }
151  else
152  {
153  g4PVReplica->InitialiseWorker(g4PVReplica);
154  if( ! g4PVReplica->IsParameterised() )
155  {
156  logicalVol->InitialiseWorker(logicalVol,solid,0);
157 
158  // If the replica's solid (in LV) is changed during navigation,
159  // it must be thread-private
160  //
161  CloneReplicaSolid( g4PVReplica );
162  }
163  else
164  {
165  G4PVParameterised *paramVol = dynamic_cast<G4PVParameterised*>(physVol);
166  if (!paramVol)
167  {
168  G4Exception("G4GeometryWorkspace::CreateAndUseWorkspace()",
169  "GeomVol0003", FatalException,
170  "Cannot find Parameterisation for parameterised volume.");
171  }
172  CloneParameterisedSolids( paramVol );
173  }
174  }
175  }
176  if( fVerbose )
177  {
178  G4cout << "G4GeometryWorkspace::InitialisePhysicalVolumes: "
179  << "Copying geometry - Done!" << G4endl;
180  }
181 }
G4VSolid * GetMasterSolid() const
void InitialiseWorker(G4LogicalVolume *ptrMasterObject, G4VSolid *pSolid, G4VSensitiveDetector *pSDetector)
static G4PhysicalVolumeStore * GetInstance()
virtual G4bool IsParameterised() const
Definition: G4PVReplica.cc:215
G4GLOB_DLL std::ostream G4cout
void InitialiseWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:271
G4bool CloneReplicaSolid(G4PVReplica *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4LogicalVolume * GetLogicalVolume() const
G4bool CloneParameterisedSolids(G4PVParameterised *paramVol)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GeometryWorkspace::InitialiseWorkspace ( )

Definition at line 289 of file G4GeometryWorkspace.cc.

290 {
291  if( fVerbose )
292  {
293  G4cout << "G4GeometryWorkspace::InitialiseWorkspace():"
294  << " Copying geometry - Start " << G4endl;
295  }
296 
297  // Implementation originally in:
298  // G4WorkerThread::BuildGeometryAndPhysicsVector()
299  // and improved for G4PVParamaterised
300 
301  // Geometry related, split classes mechanism:
302  // Do *NOT* instantiate sub-instance for this thread, just copy the contents!
303  //
304  fpLogicalVolumeSIM->SlaveCopySubInstanceArray();
305  fpPhysicalVolumeSIM->SlaveCopySubInstanceArray();
306  fpReplicaSIM->SlaveCopySubInstanceArray();
307  fpRegionSIM->SlaveInitializeSubInstance();
308 
310 
311  if( fVerbose )
312  {
313  G4cout << "G4GeometryWorkspace::InitialiseWorkspace: "
314  << "Copying geometry - Done!" << G4endl;
315  }
316 }
G4GLOB_DLL std::ostream G4cout
void SlaveCopySubInstanceArray()
#define G4endl
Definition: G4ios.hh:61
void SlaveInitializeSubInstance()

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GeometryWorkspace::ReleaseWorkspace ( )

Definition at line 122 of file G4GeometryWorkspace.cc.

123 {
124  fpLogicalVolumeSIM->UseWorkArea(0);
125  fpPhysicalVolumeSIM->UseWorkArea(0);
126 
127  fpReplicaSIM->UseWorkArea(0);
128  fpRegionSIM->UseWorkArea(0);
129 }
void UseWorkArea(T *newOffset)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4GeometryWorkspace::SetVerbose ( G4bool  v)
inline

Definition at line 76 of file G4GeometryWorkspace.hh.

76 { fVerbose=v; }
tuple v
Definition: test.py:18
void G4GeometryWorkspace::UseWorkspace ( )

Definition at line 90 of file G4GeometryWorkspace.cc.

91 {
92  if( fVerbose )
93  {
94  G4cout << "G4GeometryWorkspace::UseWorkspace: Start " << G4endl;
95  }
96 
97  // Implementation originally in:
98  // G4WorkerThread::BuildGeometryAndPhysicsVector()
99  // and improved for G4PVParamaterised
100 
101  // Geometry related, split classes mechanism: instantiate sub-instance
102  // for this thread
103  fpLogicalVolumeSIM->UseWorkArea(fLogicalVolumeOffset);
104  fpPhysicalVolumeSIM->UseWorkArea(fPhysicalVolumeOffset);
105 
106  fpReplicaSIM->UseWorkArea(fReplicaOffset);
107  fpRegionSIM->UseWorkArea(fRegionOffset);
108 
109  // When recycling a workspace
110  // - it must be a lightweight operation, to reuse a valid work area
111  // - so it must NOT Initialise anything!
112  // Do not call InitialisePhysicalVolumes();
113 
114  if( fVerbose )
115  {
116  G4cout << "G4GeometryWorkspace::UseWorkspace: End " << G4endl;
117  }
118 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void UseWorkArea(T *newOffset)

Here is the call graph for this function:

Here is the caller graph for this function:


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