Geant4  10.02.p03
G4GeometryWorkspace Class Reference

#include <G4GeometryWorkspace.hh>

Collaboration diagram for G4GeometryWorkspace:

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 *)
 

Private Attributes

G4LVManagerfpLogicalVolumeSIM
 
G4PVManagerfpPhysicalVolumeSIM
 
G4PVRManagerfpReplicaSIM
 
G4RegionManagerfpRegionSIM
 
G4LVDatafLogicalVolumeOffset
 
G4PVDatafPhysicalVolumeOffset
 
G4ReplicaDatafReplicaOffset
 
G4RegionDatafRegionOffset
 
G4bool fVerbose
 

Detailed Description

Definition at line 62 of file G4GeometryWorkspace.hh.

Constructor & Destructor Documentation

◆ G4GeometryWorkspace()

G4GeometryWorkspace::G4GeometryWorkspace ( )

Definition at line 56 of file G4GeometryWorkspace.cc.

57  : fVerbose(false)
58 {
67 
68  // Create a work area for Logical Volumes in this thread
69  // then capture its address
71 
73 
75 
77 
79 }
G4LVManager * fpLogicalVolumeSIM
static const G4LVManager & GetSubInstanceManager()
G4ReplicaData * fReplicaOffset
G4RegionData * fRegionOffset
static const G4PVRManager & GetSubInstanceManager()
Definition: G4PVReplica.cc:260
static const G4PVManager & GetSubInstanceManager()
G4PVManager * fpPhysicalVolumeSIM
G4PVRManager * fpReplicaSIM
G4RegionManager * fpRegionSIM
static const G4RegionManager & GetSubInstanceManager()
Definition: G4Region.cc:58
Here is the call graph for this function:

◆ ~G4GeometryWorkspace()

G4GeometryWorkspace::~G4GeometryWorkspace ( )

Definition at line 83 of file G4GeometryWorkspace.cc.

84 {
85 }

Member Function Documentation

◆ CloneParameterisedSolids()

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
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
virtual G4VSolid * Clone() const
Definition: G4VSolid.cc:324
G4LogicalVolume * GetLogicalVolume() const
G4VSolid * GetSolid() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloneReplicaSolid()

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
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
virtual G4VSolid * Clone() const
Definition: G4VSolid.cc:324
G4LogicalVolume * GetLogicalVolume() const
G4VSolid * GetSolid() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DestroyWorkspace()

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  }
354 }
G4LVManager * fpLogicalVolumeSIM
void TerminateWorker(G4PVReplica *pMasterObject)
Definition: G4PVReplica.cc:316
static G4PhysicalVolumeStore * GetInstance()
G4PVManager * fpPhysicalVolumeSIM
void TerminateWorker(G4LogicalVolume *ptrMasterObject)
G4PVRManager * fpReplicaSIM
G4LogicalVolume * GetLogicalVolume() const
G4RegionManager * fpRegionSIM
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVerbose()

G4bool G4GeometryWorkspace::GetVerbose ( )
inline

Definition at line 77 of file G4GeometryWorkspace.hh.

77 { return fVerbose; }
Here is the call graph for this function:

◆ InitialisePhysicalVolumes()

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 }
void InitialiseWorker(G4LogicalVolume *ptrMasterObject, G4VSolid *pSolid, G4VSensitiveDetector *pSDetector)
virtual G4bool IsParameterised() const
Definition: G4PVReplica.cc:215
static G4PhysicalVolumeStore * GetInstance()
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
G4bool CloneParameterisedSolids(G4PVParameterised *paramVol)
G4VSolid * GetMasterSolid() const
#define G4endl
Definition: G4ios.hh:61
G4LogicalVolume * GetLogicalVolume() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitialiseWorkspace()

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  //
308 
310 
311  if( fVerbose )
312  {
313  G4cout << "G4GeometryWorkspace::InitialiseWorkspace: "
314  << "Copying geometry - Done!" << G4endl;
315  }
316 }
G4LVManager * fpLogicalVolumeSIM
G4GLOB_DLL std::ostream G4cout
void SlaveCopySubInstanceArray()
G4PVManager * fpPhysicalVolumeSIM
G4PVRManager * fpReplicaSIM
#define G4endl
Definition: G4ios.hh:61
G4RegionManager * fpRegionSIM
void SlaveInitializeSubInstance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReleaseWorkspace()

void G4GeometryWorkspace::ReleaseWorkspace ( )

Definition at line 122 of file G4GeometryWorkspace.cc.

123 {
126 
129 }
G4LVManager * fpLogicalVolumeSIM
G4PVManager * fpPhysicalVolumeSIM
G4PVRManager * fpReplicaSIM
void UseWorkArea(T *newOffset)
G4RegionManager * fpRegionSIM
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetVerbose()

void G4GeometryWorkspace::SetVerbose ( G4bool  v)
inline

Definition at line 76 of file G4GeometryWorkspace.hh.

◆ UseWorkspace()

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
105 
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 }
G4LVManager * fpLogicalVolumeSIM
G4ReplicaData * fReplicaOffset
G4RegionData * fRegionOffset
G4GLOB_DLL std::ostream G4cout
G4PVManager * fpPhysicalVolumeSIM
G4PVRManager * fpReplicaSIM
#define G4endl
Definition: G4ios.hh:61
void UseWorkArea(T *newOffset)
G4RegionManager * fpRegionSIM
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fLogicalVolumeOffset

G4LVData* G4GeometryWorkspace::fLogicalVolumeOffset
private

Definition at line 96 of file G4GeometryWorkspace.hh.

◆ fPhysicalVolumeOffset

G4PVData* G4GeometryWorkspace::fPhysicalVolumeOffset
private

Definition at line 97 of file G4GeometryWorkspace.hh.

◆ fpLogicalVolumeSIM

G4LVManager* G4GeometryWorkspace::fpLogicalVolumeSIM
private

Definition at line 87 of file G4GeometryWorkspace.hh.

◆ fpPhysicalVolumeSIM

G4PVManager* G4GeometryWorkspace::fpPhysicalVolumeSIM
private

Definition at line 88 of file G4GeometryWorkspace.hh.

◆ fpRegionSIM

G4RegionManager* G4GeometryWorkspace::fpRegionSIM
private

Definition at line 90 of file G4GeometryWorkspace.hh.

◆ fpReplicaSIM

G4PVRManager* G4GeometryWorkspace::fpReplicaSIM
private

Definition at line 89 of file G4GeometryWorkspace.hh.

◆ fRegionOffset

G4RegionData* G4GeometryWorkspace::fRegionOffset
private

Definition at line 99 of file G4GeometryWorkspace.hh.

◆ fReplicaOffset

G4ReplicaData* G4GeometryWorkspace::fReplicaOffset
private

Definition at line 98 of file G4GeometryWorkspace.hh.

◆ fVerbose

G4bool G4GeometryWorkspace::fVerbose
private

Definition at line 101 of file G4GeometryWorkspace.hh.


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