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

#include <G4PVParameterised.hh>

+ Inheritance diagram for G4PVParameterised:

Public Member Functions

 G4PVParameterised (const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMotherLogical, const EAxis pAxis, const G4int nReplicas, G4VPVParameterisation *pParam, G4bool pSurfChk=false)
 
 G4PVParameterised (const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, G4VPVParameterisation *pParam, G4bool pSurfChk=false)
 
 G4PVParameterised (__void__ &)
 
virtual ~G4PVParameterised ()
 
G4bool IsParameterised () const
 
EVolume VolumeType () const final
 
G4VPVParameterisationGetParameterisation () const
 
void GetReplicationData (EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
 
virtual void SetRegularStructureId (G4int code)
 
G4bool CheckOverlaps (G4int res=1000, G4double tol=0., G4bool verbose=true, G4int maxErr=1)
 
- Public Member Functions inherited from G4PVReplica
 G4PVReplica (const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0.)
 
 G4PVReplica (const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0.)
 
 G4PVReplica (__void__ &)
 
 G4PVReplica (const G4PVReplica &)=delete
 
G4PVReplicaoperator= (const G4PVReplica &)=delete
 
virtual ~G4PVReplica ()
 
virtual EVolume VolumeType () const
 
G4bool IsMany () const
 
G4bool IsReplicated () const
 
virtual G4int GetCopyNo () const
 
virtual void SetCopyNo (G4int CopyNo)
 
virtual G4bool IsParameterised () const
 
virtual G4VPVParameterisationGetParameterisation () const
 
virtual G4int GetMultiplicity () const
 
virtual void GetReplicationData (EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
 
virtual void SetRegularStructureId (G4int code)
 
G4bool IsRegularStructure () const
 
G4int GetRegularStructureId () const
 
G4int GetInstanceID () const
 
void InitialiseWorker (G4PVReplica *pMasterObject)
 
void TerminateWorker (G4PVReplica *pMasterObject)
 
- Public Member Functions inherited from G4VPhysicalVolume
 G4VPhysicalVolume (G4RotationMatrix *pRot, const G4ThreeVector &tlate, const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother)
 
virtual ~G4VPhysicalVolume ()
 
 G4VPhysicalVolume (const G4VPhysicalVolume &)=delete
 
G4VPhysicalVolumeoperator= (const G4VPhysicalVolume &)=delete
 
G4bool operator== (const G4VPhysicalVolume &p) const
 
G4RotationMatrixGetObjectRotation () const
 
G4RotationMatrix GetObjectRotationValue () const
 
G4ThreeVector GetObjectTranslation () const
 
const G4RotationMatrixGetFrameRotation () const
 
G4ThreeVector GetFrameTranslation () const
 
const G4ThreeVector GetTranslation () 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 EVolume VolumeType () const =0
 
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, G4int errMax=1)
 
 G4VPhysicalVolume (__void__ &)
 
G4int GetInstanceID () const
 
EVolume DeduceVolumeType () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4PVReplica
static const G4PVRManagerGetSubInstanceManager ()
 
- Static Public Member Functions inherited from G4VPhysicalVolume
static const G4PVManagerGetSubInstanceManager ()
 
static void Clean ()
 
- Protected Member Functions inherited from G4PVReplica
 G4PVReplica (const G4String &pName, G4int nReplicas, EAxis pAxis, G4LogicalVolume *pLogical, G4LogicalVolume *pMotherLogical)
 
- Protected Member Functions inherited from G4VPhysicalVolume
void InitialiseWorker (G4VPhysicalVolume *pMasterObject, G4RotationMatrix *pRot, const G4ThreeVector &tlate)
 
void TerminateWorker (G4VPhysicalVolume *pMasterObject)
 
- Protected Attributes inherited from G4PVReplica
EAxis faxis
 
G4int fnReplicas
 
G4double fwidth
 
G4double foffset
 
- Protected Attributes inherited from G4VPhysicalVolume
G4int instanceID
 
- Static Protected Attributes inherited from G4VPhysicalVolume
static G4GEOM_DLL G4PVManager subInstanceManager
 

Detailed Description

Definition at line 42 of file G4PVParameterised.hh.

Constructor & Destructor Documentation

◆ G4PVParameterised() [1/3]

G4PVParameterised::G4PVParameterised ( const G4String pName,
G4LogicalVolume pLogical,
G4LogicalVolume pMotherLogical,
const EAxis  pAxis,
const G4int  nReplicas,
G4VPVParameterisation pParam,
G4bool  pSurfChk = false 
)

Definition at line 84 of file G4PVParameterised.cc.

91 : G4PVReplica(pName, nReplicas, pAxis, pLogical, pMotherLogical ),
92 fparam(pParam)
93{
94 SetMotherLogical( pMotherLogical );
95 if( pMotherLogical )
96 {
97 // Registration moved here to ensure that the volume is recognised as Parameterised
98 pMotherLogical->AddDaughter(this);
99 }
100 if (pSurfChk) { CheckOverlaps(); }
101}
void AddDaughter(G4VPhysicalVolume *p)
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int maxErr=1)
void SetMotherLogical(G4LogicalVolume *pMother)

◆ G4PVParameterised() [2/3]

G4PVParameterised::G4PVParameterised ( const G4String pName,
G4LogicalVolume pLogical,
G4VPhysicalVolume pMother,
const EAxis  pAxis,
const G4int  nReplicas,
G4VPVParameterisation pParam,
G4bool  pSurfChk = false 
)

Definition at line 41 of file G4PVParameterised.cc.

48: G4PVReplica(pName, nReplicas, pAxis, pLogical,
49 pMotherPhysical ? pMotherPhysical->GetLogicalVolume() : nullptr ),
50 fparam(pParam)
51{
52 G4LogicalVolume* motherLogical= pMotherPhysical ?
53 pMotherPhysical->GetLogicalVolume() : nullptr;
54
55 SetMotherLogical( motherLogical );
56 if( motherLogical )
57 {
58 // Registration moved here to ensure that the volume is recognised as Parameterised
59 motherLogical->AddDaughter(this);
60 }
61
62#ifdef G4VERBOSE
63 if ((pMotherPhysical != nullptr) && (pMotherPhysical->IsParameterised()))
64 {
65 std::ostringstream message, hint;
66 message << "A parameterised volume is being placed" << G4endl
67 << "inside another parameterised volume !";
68 hint << "To make sure that no overlaps are generated," << G4endl
69 << "you should verify the mother replicated shapes" << G4endl
70 << "are of the same type and dimensions." << G4endl
71 << " Mother physical volume: " << pMotherPhysical->GetName() << G4endl
72 << " Parameterised volume: " << pName << G4endl
73 << " (To switch this warning off, compile with G4_NO_VERBOSE)";
74 G4Exception("G4PVParameterised::G4PVParameterised()", "GeomVol1002",
75 JustWarning, message, G4String(hint.str()));
76 }
77#endif
78 if (pSurfChk) { CheckOverlaps(); }
79}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
#define G4endl
Definition: G4ios.hh:57

◆ G4PVParameterised() [3/3]

G4PVParameterised::G4PVParameterised ( __void__ &  a)

Definition at line 107 of file G4PVParameterised.cc.

108 : G4PVReplica(a)
109{
110}

◆ ~G4PVParameterised()

G4PVParameterised::~G4PVParameterised ( )
virtual

Definition at line 115 of file G4PVParameterised.cc.

116{
117}

Member Function Documentation

◆ CheckOverlaps()

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

Reimplemented from G4VPhysicalVolume.

Definition at line 174 of file G4PVParameterised.cc.

176{
177 if (res<=0) { return false; }
178
179 G4int trials = 0;
180 G4bool retval = false;
181 G4VSolid *solidA = nullptr, *solidB = nullptr;
182 G4LogicalVolume* motherLog = GetMotherLogical();
183 G4VSolid *motherSolid = motherLog->GetSolid();
184 std::vector<G4ThreeVector> points;
185
186 if (verbose)
187 {
188 G4cout << "Checking overlaps for parameterised volume "
189 << GetName() << " ... ";
190 }
191
192 for (auto i=0; i<GetMultiplicity(); ++i)
193 {
194 solidA = fparam->ComputeSolid(i, this);
195 solidA->ComputeDimensions(fparam, i, this);
196 fparam->ComputeTransformation(i, this);
197
198 // Create the transformation from daughter to mother
199 //
201
202 // Generate random points on surface according to the given resolution,
203 // transform them to the mother's coordinate system and if no overlaps
204 // with the mother volume, cache them in a vector for later use with
205 // the daughters
206 //
207 for (auto n=0; n<res; ++n)
208 {
209 G4ThreeVector mp = Tm.TransformPoint(solidA->GetPointOnSurface());
210
211 // Checking overlaps with the mother volume
212 //
213 if (motherSolid->Inside(mp)==kOutside)
214 {
215 G4double distin = motherSolid->DistanceToIn(mp);
216 if (distin > tol)
217 {
218 ++trials; retval = true;
219 std::ostringstream message;
220 message << "Overlap with mother volume !" << G4endl
221 << " Overlap is detected for volume "
222 << GetName() << ", parameterised instance: " << i << G4endl
223 << " with its mother volume "
224 << motherLog->GetName() << G4endl
225 << " at mother local point " << mp << ", "
226 << "overlapping by at least: "
227 << G4BestUnit(distin, "Length");
228 if (trials>=maxErr)
229 {
230 message << G4endl
231 << "NOTE: Reached maximum fixed number -" << maxErr
232 << "- of overlaps reports for this volume !";
233 }
234 G4Exception("G4PVParameterised::CheckOverlaps()",
235 "GeomVol1002", JustWarning, message);
236 if (trials>=maxErr) { return true; }
237 }
238 }
239 points.push_back(mp);
240 }
241
242 // Checking overlaps with each other parameterised instance
243 //
244 for (auto j=i+1; j<GetMultiplicity(); ++j)
245 {
246 solidB = fparam->ComputeSolid(j,this);
247 solidB->ComputeDimensions(fparam, j, this);
248 fparam->ComputeTransformation(j, this);
249
250 // Create the transformation for daughter volume
251 //
253
254 for (auto pos=points.cbegin(); pos!=points.cend(); ++pos)
255 {
256 // Transform each point according to daughter's frame
257 //
258 G4ThreeVector md = Td.InverseTransformPoint(*pos);
259
260 if (solidB->Inside(md)==kInside)
261 {
262 G4double distout = solidB->DistanceToOut(md);
263 if (distout > tol)
264 {
265 ++trials; retval = true;
266 std::ostringstream message;
267 message << "Overlap within parameterised volumes !" << G4endl
268 << " Overlap is detected for volume "
269 << GetName() << ", parameterised instance: " << i << G4endl
270 << " with parameterised volume instance: " << j
271 << G4endl
272 << " at local point " << md << ", "
273 << "overlapping by at least: "
274 << G4BestUnit(distout, "Length")
275 << ", related to volume instance: " << j << ".";
276 if (trials>=maxErr)
277 {
278 message << G4endl
279 << "NOTE: Reached maximum fixed number -" << maxErr
280 << "- of overlaps reports for this volume !";
281 }
282 G4Exception("G4PVParameterised::CheckOverlaps()",
283 "GeomVol1002", JustWarning, message);
284 if (trials>=maxErr) { return true; }
285 }
286 }
287 }
288 }
289 }
290 if (verbose)
291 {
292 G4cout << "OK! " << G4endl;
293 }
294
295 return retval;
296}
#define G4BestUnit(a, b)
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
G4VSolid * GetSolid() const
const G4String & GetName() const
virtual G4int GetMultiplicity() const
Definition: G4PVReplica.cc:287
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
G4LogicalVolume * GetMotherLogical() const
const G4RotationMatrix * GetRotation() const
const G4ThreeVector GetTranslation() const
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4VSolid.cc:125
virtual G4ThreeVector GetPointOnSurface() const
Definition: G4VSolid.cc:140
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
@ kInside
Definition: geomdefs.hh:70
@ kOutside
Definition: geomdefs.hh:68

Referenced by G4PVParameterised().

◆ GetParameterisation()

G4VPVParameterisation * G4PVParameterised::GetParameterisation ( ) const
virtual

Reimplemented from G4PVReplica.

Definition at line 122 of file G4PVParameterised.cc.

123{
124 return fparam;
125}

Referenced by G4LogicalVolumeModel::DescribeYourselfTo(), G4VFieldModel::DescribeYourselfTo(), and G4tgbGeometryDumper::DumpPVParameterised().

◆ GetReplicationData()

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

Reimplemented from G4PVReplica.

Definition at line 146 of file G4PVParameterised.cc.

151{
152 axis = faxis;
153 nReplicas = fnReplicas;
154 width = fwidth;
155 offset = foffset;
156 consuming = false;
157}
G4double fwidth
Definition: G4PVReplica.hh:208
G4int fnReplicas
Definition: G4PVReplica.hh:207
G4double foffset
Definition: G4PVReplica.hh:208

Referenced by G4tgbGeometryDumper::DumpPVParameterised().

◆ IsParameterised()

G4bool G4PVParameterised::IsParameterised ( ) const
virtual

Reimplemented from G4PVReplica.

Definition at line 130 of file G4PVParameterised.cc.

131{
132 return true;
133}

◆ SetRegularStructureId()

void G4PVParameterised::SetRegularStructureId ( G4int  code)
virtual

Reimplemented from G4PVReplica.

Definition at line 162 of file G4PVParameterised.cc.

163{
165 // To undertake additional preparation, a derived volume must
166 // redefine this method, while calling also the above method
167}
virtual void SetRegularStructureId(G4int code)
Definition: G4PVReplica.cc:320
Definition: inftrees.h:24

◆ VolumeType()

EVolume G4PVParameterised::VolumeType ( ) const
finalvirtual

Reimplemented from G4PVReplica.

Definition at line 138 of file G4PVParameterised.cc.

139{
140 return kParameterised;
141}
@ kParameterised
Definition: geomdefs.hh:86

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