Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PVPlacement Class Reference

#include <G4PVPlacement.hh>

+ Inheritance diagram for G4PVPlacement:

Public Member Functions

 G4PVPlacement (G4RotationMatrix *pRot, const G4ThreeVector &tlate, G4LogicalVolume *pCurrentLogical, const G4String &pName, G4LogicalVolume *pMotherLogical, G4bool pMany, G4int pCopyNo, G4bool pSurfChk=false)
 
 G4PVPlacement (const G4Transform3D &Transform3D, G4LogicalVolume *pCurrentLogical, const G4String &pName, G4LogicalVolume *pMotherLogical, G4bool pMany, G4int pCopyNo, G4bool pSurfChk=false)
 
 G4PVPlacement (G4RotationMatrix *pRot, const G4ThreeVector &tlate, const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother, G4bool pMany, G4int pCopyNo, G4bool pSurfChk=false)
 
 G4PVPlacement (const G4Transform3D &Transform3D, const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother, G4bool pMany, G4int pCopyNo, G4bool pSurfChk=false)
 
virtual ~G4PVPlacement ()
 
G4int GetCopyNo () const
 
void SetCopyNo (G4int CopyNo)
 
G4bool CheckOverlaps (G4int res=1000, G4double tol=0., G4bool verbose=true)
 
 G4PVPlacement (__void__ &)
 
G4bool IsMany () const
 
G4bool IsReplicated () const
 
G4bool IsParameterised () const
 
G4VPVParameterisationGetParameterisation () const
 
void GetReplicationData (EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
 
G4bool IsRegularStructure () const
 
G4int GetRegularStructureId () const
 
- Public Member Functions inherited from G4VPhysicalVolume
 G4VPhysicalVolume (G4RotationMatrix *pRot, const G4ThreeVector &tlate, const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother)
 
virtual ~G4VPhysicalVolume ()
 
G4bool operator== (const G4VPhysicalVolume &p) const
 
G4RotationMatrixGetObjectRotation () const
 
G4RotationMatrix GetObjectRotationValue () const
 
G4ThreeVector GetObjectTranslation () const
 
const G4RotationMatrixGetFrameRotation () const
 
G4ThreeVector GetFrameTranslation () const
 
const G4ThreeVectorGetTranslation () const
 
const G4RotationMatrixGetRotation () const
 
void SetTranslation (const G4ThreeVector &v)
 
G4RotationMatrixGetRotation ()
 
void SetRotation (G4RotationMatrix *)
 
G4LogicalVolumeGetLogicalVolume () const
 
void SetLogicalVolume (G4LogicalVolume *pLogical)
 
G4LogicalVolumeGetMotherLogical () const
 
void SetMotherLogical (G4LogicalVolume *pMother)
 
const G4StringGetName () const
 
void SetName (const G4String &pName)
 
virtual G4int GetMultiplicity () const
 
virtual G4bool IsMany () const =0
 
virtual G4int GetCopyNo () const =0
 
virtual void SetCopyNo (G4int CopyNo)=0
 
virtual G4bool IsReplicated () const =0
 
virtual G4bool IsParameterised () const =0
 
virtual G4VPVParameterisationGetParameterisation () const =0
 
virtual void GetReplicationData (EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
 
virtual G4bool IsRegularStructure () const =0
 
virtual G4int GetRegularStructureId () const =0
 
virtual G4bool CheckOverlaps (G4int res=1000, G4double tol=0., G4bool verbose=true)
 
 G4VPhysicalVolume (__void__ &)
 

Additional Inherited Members

- Protected Attributes inherited from G4VPhysicalVolume
G4RotationMatrixfrot
 
G4ThreeVector ftrans
 

Detailed Description

Definition at line 51 of file G4PVPlacement.hh.

Constructor & Destructor Documentation

◆ G4PVPlacement() [1/5]

G4PVPlacement::G4PVPlacement ( G4RotationMatrix pRot,
const G4ThreeVector tlate,
G4LogicalVolume pCurrentLogical,
const G4String pName,
G4LogicalVolume pMotherLogical,
G4bool  pMany,
G4int  pCopyNo,
G4bool  pSurfChk = false 
)

Definition at line 100 of file G4PVPlacement.cc.

108 : G4VPhysicalVolume(pRot,tlate,pName,pCurrentLogical,0),
109 fmany(pMany), fallocatedRotM(false), fcopyNo(pCopyNo)
110{
111 if (pCurrentLogical == pMotherLogical)
112 {
113 G4Exception("G4PVPlacement::G4PVPlacement()", "GeomVol0002",
114 FatalException, "Cannot place a volume inside itself!");
115 }
116 SetMotherLogical(pMotherLogical);
117 if (pMotherLogical) { pMotherLogical->AddDaughter(this); }
118 if ((pSurfChk) && (pMotherLogical)) { CheckOverlaps(); }
119}
@ FatalException
void AddDaughter(G4VPhysicalVolume *p)
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true)
void SetMotherLogical(G4LogicalVolume *pMother)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

◆ G4PVPlacement() [2/5]

G4PVPlacement::G4PVPlacement ( const G4Transform3D Transform3D,
G4LogicalVolume pCurrentLogical,
const G4String pName,
G4LogicalVolume pMotherLogical,
G4bool  pMany,
G4int  pCopyNo,
G4bool  pSurfChk = false 
)

Definition at line 125 of file G4PVPlacement.cc.

132 : G4VPhysicalVolume(0,Transform3D.getTranslation(),pName,pCurrentLogical,0),
133 fmany(pMany), fcopyNo(pCopyNo)
134{
135 if (pCurrentLogical == pMotherLogical)
136 {
137 G4Exception("G4PVPlacement::G4PVPlacement()", "GeomVol0002",
138 FatalException, "Cannot place a volume inside itself!");
139 }
140 SetRotation( NewPtrRotMatrix(Transform3D.getRotation().inverse()) );
141 fallocatedRotM = (GetRotation() != 0);
142 SetMotherLogical(pMotherLogical);
143 if (pMotherLogical) { pMotherLogical->AddDaughter(this); }
144 if ((pSurfChk) && (pMotherLogical)) { CheckOverlaps(); }
145}
HepRotation inverse() const
const G4RotationMatrix * GetRotation() const
void SetRotation(G4RotationMatrix *)
CLHEP::HepRotation getRotation() const
CLHEP::Hep3Vector getTranslation() const

◆ G4PVPlacement() [3/5]

G4PVPlacement::G4PVPlacement ( G4RotationMatrix pRot,
const G4ThreeVector tlate,
const G4String pName,
G4LogicalVolume pLogical,
G4VPhysicalVolume pMother,
G4bool  pMany,
G4int  pCopyNo,
G4bool  pSurfChk = false 
)

Definition at line 43 of file G4PVPlacement.cc.

51 : G4VPhysicalVolume(pRot,tlate,pName,pLogical,pMother),
52 fmany(pMany), fallocatedRotM(false), fcopyNo(pCopyNo)
53{
54 if (pMother)
55 {
56 G4LogicalVolume* motherLogical = pMother->GetLogicalVolume();
57 if (pLogical == motherLogical)
58 {
59 G4Exception("G4PVPlacement::G4PVPlacement()", "GeomVol0002",
60 FatalException, "Cannot place a volume inside itself!");
61 }
62 SetMotherLogical(motherLogical);
63 motherLogical->AddDaughter(this);
64 if (pSurfChk) { CheckOverlaps(); }
65 }
66}
G4LogicalVolume * GetLogicalVolume() const

◆ G4PVPlacement() [4/5]

G4PVPlacement::G4PVPlacement ( const G4Transform3D Transform3D,
const G4String pName,
G4LogicalVolume pLogical,
G4VPhysicalVolume pMother,
G4bool  pMany,
G4int  pCopyNo,
G4bool  pSurfChk = false 
)

Definition at line 71 of file G4PVPlacement.cc.

78 : G4VPhysicalVolume(NewPtrRotMatrix(Transform3D.getRotation().inverse()),
79 Transform3D.getTranslation(),pName,pLogical,pMother),
80 fmany(pMany), fcopyNo(pCopyNo)
81{
82 fallocatedRotM = (GetRotation() != 0);
83 if (pMother)
84 {
85 G4LogicalVolume* motherLogical = pMother->GetLogicalVolume();
86 if (pLogical == motherLogical)
87 G4Exception("G4PVPlacement::G4PVPlacement()", "GeomVol0002",
88 FatalException, "Cannot place a volume inside itself!");
89 SetMotherLogical(motherLogical);
90 motherLogical->AddDaughter(this);
91 if (pSurfChk) { CheckOverlaps(); }
92 }
93}

◆ ~G4PVPlacement()

G4PVPlacement::~G4PVPlacement ( )
virtual

Definition at line 159 of file G4PVPlacement.cc.

160{
161 if( fallocatedRotM ){ delete frot; }
162}
G4RotationMatrix * frot

◆ G4PVPlacement() [5/5]

G4PVPlacement::G4PVPlacement ( __void__ &  a)

Definition at line 151 of file G4PVPlacement.cc.

152 : G4VPhysicalVolume(a), fmany(false), fallocatedRotM(0), fcopyNo(0)
153{
154}

Member Function Documentation

◆ CheckOverlaps()

G4bool G4PVPlacement::CheckOverlaps ( G4int  res = 1000,
G4double  tol = 0.,
G4bool  verbose = true 
)
virtual

Reimplemented from G4VPhysicalVolume.

Definition at line 244 of file G4PVPlacement.cc.

245{
246 if (res<=0) { return false; }
247
248 G4VSolid* solid = GetLogicalVolume()->GetSolid();
249 G4LogicalVolume* motherLog = GetMotherLogical();
250 if (!motherLog) { return false; }
251
252 G4VSolid* motherSolid = motherLog->GetSolid();
253
254 if (verbose)
255 {
256 G4cout << "Checking overlaps for volume " << GetName() << " ... ";
257 }
258
259 // Create the transformation from daughter to mother
260 //
262
263 for (G4int n=0; n<res; n++)
264 {
265 // Generate a random point on the solid's surface
266 //
267 G4ThreeVector point = solid->GetPointOnSurface();
268
269 // Transform the generated point to the mother's coordinate system
270 //
271 G4ThreeVector mp = Tm.TransformPoint(point);
272
273 // Checking overlaps with the mother volume
274 //
275 if (motherSolid->Inside(mp)==kOutside)
276 {
277 G4double distin = motherSolid->DistanceToIn(mp);
278 if (distin > tol)
279 {
280 std::ostringstream message;
281 message << "Overlap with mother volume !" << G4endl
282 << " Overlap is detected for volume "
283 << GetName() << G4endl
284 << " with its mother volume "
285 << motherLog->GetName() << G4endl
286 << " at mother local point " << mp << ", "
287 << "overlapping by at least: "
288 << G4BestUnit(distin, "Length");
289 G4Exception("G4PVPlacement::CheckOverlaps()",
290 "GeomVol1002", JustWarning, message);
291 return true;
292 }
293 }
294
295 // Checking overlaps with each 'sister' volume
296 //
297 for (G4int i=0; i<motherLog->GetNoDaughters(); i++)
298 {
299 G4VPhysicalVolume* daughter = motherLog->GetDaughter(i);
300
301 if (daughter == this) { continue; }
302
303 // Create the transformation for daughter volume and transform point
304 //
305 G4AffineTransform Td( daughter->GetRotation(),
306 daughter->GetTranslation() );
307 G4ThreeVector md = Td.Inverse().TransformPoint(mp);
308
309 G4VSolid* daughterSolid = daughter->GetLogicalVolume()->GetSolid();
310 if (daughterSolid->Inside(md)==kInside)
311 {
312 G4double distout = daughterSolid->DistanceToOut(md);
313 if (distout > tol)
314 {
315 std::ostringstream message;
316 message << "Overlap with volume already placed !" << G4endl
317 << " Overlap is detected for volume "
318 << GetName() << G4endl
319 << " with " << daughter->GetName() << " volume's"
320 << G4endl
321 << " local point " << md << ", "
322 << "overlapping by at least: "
323 << G4BestUnit(distout,"Length");
324 G4Exception("G4PVPlacement::CheckOverlaps()",
325 "GeomVol1002", JustWarning, message);
326 return true;
327 }
328 }
329
330 // Now checking that 'sister' volume is not totally included and
331 // overlapping. Do it only once, for the first point generated
332 //
333 if (n==0)
334 {
335 // Generate a single point on the surface of the 'sister' volume
336 // and verify that the point is NOT inside the current volume
337
338 G4ThreeVector dPoint = daughterSolid->GetPointOnSurface();
339
340 // Transform the generated point to the mother's coordinate system
341 // and finally to current volume's coordinate system
342 //
343 G4ThreeVector mp2 = Td.TransformPoint(dPoint);
344 G4ThreeVector msi = Tm.Inverse().TransformPoint(mp2);
345
346 if (solid->Inside(msi)==kInside)
347 {
348 std::ostringstream message;
349 message << "Overlap with volume already placed !" << G4endl
350 << " Overlap is detected for volume "
351 << GetName() << G4endl
352 << " apparently fully encapsulating volume "
353 << daughter->GetName() << G4endl
354 << " at the same level !";
355 G4Exception("G4PVPlacement::CheckOverlaps()",
356 "GeomVol1002", JustWarning, message);
357 return true;
358 }
359 }
360 }
361 }
362
363 if (verbose)
364 {
365 G4cout << "OK! " << G4endl;
366 }
367
368 return false;
369}
@ JustWarning
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4VSolid * GetSolid() const
G4int GetNoDaughters() const
G4String GetName() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4LogicalVolume * GetMotherLogical() const
const G4String & GetName() const
const G4ThreeVector & GetTranslation() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
virtual G4ThreeVector GetPointOnSurface() const
Definition: G4VSolid.cc:152
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
@ kInside
Definition: geomdefs.hh:58
@ kOutside
Definition: geomdefs.hh:58

Referenced by G4PVPlacement().

◆ GetCopyNo()

G4int G4PVPlacement::GetCopyNo ( ) const
virtual

Implements G4VPhysicalVolume.

Definition at line 175 of file G4PVPlacement.cc.

176{
177 return fcopyNo;
178}

◆ GetParameterisation()

G4VPVParameterisation * G4PVPlacement::GetParameterisation ( ) const
virtual

Implements G4VPhysicalVolume.

Definition at line 207 of file G4PVPlacement.cc.

208{
209 return 0;
210}

◆ GetRegularStructureId()

G4int G4PVPlacement::GetRegularStructureId ( ) const
virtual

Implements G4VPhysicalVolume.

Definition at line 236 of file G4PVPlacement.cc.

237{
238 return 0;
239}

◆ GetReplicationData()

void G4PVPlacement::GetReplicationData ( EAxis axis,
G4int nReplicas,
G4double width,
G4double offset,
G4bool consuming 
) const
virtual

Implements G4VPhysicalVolume.

Definition at line 215 of file G4PVPlacement.cc.

217{
218 // No-operations
219}

◆ IsMany()

G4bool G4PVPlacement::IsMany ( ) const
virtual

Implements G4VPhysicalVolume.

Definition at line 167 of file G4PVPlacement.cc.

168{
169 return fmany;
170}

◆ IsParameterised()

G4bool G4PVPlacement::IsParameterised ( ) const
virtual

Implements G4VPhysicalVolume.

Definition at line 199 of file G4PVPlacement.cc.

200{
201 return false;
202}

◆ IsRegularStructure()

G4bool G4PVPlacement::IsRegularStructure ( ) const
virtual

Implements G4VPhysicalVolume.

Definition at line 226 of file G4PVPlacement.cc.

227{
228 return false;
229}

◆ IsReplicated()

G4bool G4PVPlacement::IsReplicated ( ) const
virtual

Implements G4VPhysicalVolume.

Definition at line 191 of file G4PVPlacement.cc.

192{
193 return false;
194}

◆ SetCopyNo()

void G4PVPlacement::SetCopyNo ( G4int  CopyNo)
virtual

Implements G4VPhysicalVolume.

Definition at line 183 of file G4PVPlacement.cc.

184{
185 fcopyNo= newCopyNo;
186}

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