Geant4 11.2.2
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__ &)
 
 ~G4PVParameterised () override
 
G4bool IsParameterised () const override
 
EVolume VolumeType () const final
 
G4VPVParameterisationGetParameterisation () const override
 
void GetReplicationData (EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const override
 
void SetRegularStructureId (G4int code) override
 
G4bool CheckOverlaps (G4int res=1000, G4double tol=0., G4bool verbose=true, G4int maxErr=1) override
 
- 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
 
 ~G4PVReplica () override
 
EVolume VolumeType () const override
 
G4bool IsMany () const override
 
G4bool IsReplicated () const override
 
G4int GetCopyNo () const override
 
void SetCopyNo (G4int CopyNo) override
 
G4bool IsParameterised () const override
 
G4VPVParameterisationGetParameterisation () const override
 
G4int GetMultiplicity () const override
 
void GetReplicationData (EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const override
 
G4bool IsRegularStructure () const override
 
G4int GetRegularStructureId () const override
 
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)
 
 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 != nullptr )
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) override
G4PVReplica(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0.)
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 != nullptr ? pMotherPhysical->GetLogicalVolume() : nullptr ),
50 fparam(pParam)
51{
52 G4LogicalVolume* motherLogical= pMotherPhysical != nullptr ?
53 pMotherPhysical->GetLogicalVolume() : nullptr;
54
55 SetMotherLogical( motherLogical );
56 if( motherLogical != nullptr )
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)
#define G4endl
Definition G4ios.hh:67

◆ G4PVParameterised() [3/3]

G4PVParameterised::G4PVParameterised ( __void__ & a)

Definition at line 107 of file G4PVParameterised.cc.

108 : G4PVReplica(a)
109{
110}

◆ ~G4PVParameterised()

G4PVParameterised::~G4PVParameterised ( )
overridedefault

Member Function Documentation

◆ CheckOverlaps()

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

Reimplemented from G4VPhysicalVolume.

Definition at line 172 of file G4PVParameterised.cc.

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

Referenced by G4PVParameterised(), and G4PVParameterised().

◆ GetParameterisation()

G4VPVParameterisation * G4PVParameterised::GetParameterisation ( ) const
overridevirtual

◆ GetReplicationData()

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

Implements G4VPhysicalVolume.

Definition at line 144 of file G4PVParameterised.cc.

149{
150 axis = faxis;
151 nReplicas = fnReplicas;
152 width = fwidth;
153 offset = foffset;
154 consuming = false;
155}
G4double fwidth
G4double foffset

Referenced by G4tgbGeometryDumper::DumpPVParameterised().

◆ IsParameterised()

G4bool G4PVParameterised::IsParameterised ( ) const
overridevirtual

Implements G4VPhysicalVolume.

Definition at line 128 of file G4PVParameterised.cc.

129{
130 return true;
131}

◆ SetRegularStructureId()

void G4PVParameterised::SetRegularStructureId ( G4int code)
overridevirtual

Reimplemented from G4PVReplica.

Definition at line 160 of file G4PVParameterised.cc.

161{
163 // To undertake additional preparation, a derived volume must
164 // redefine this method, while calling also the above method
165}
virtual void SetRegularStructureId(G4int code)

◆ VolumeType()

EVolume G4PVParameterised::VolumeType ( ) const
finalvirtual

Implements G4VPhysicalVolume.

Definition at line 136 of file G4PVParameterised.cc.

137{
138 return kParameterised;
139}
@ kParameterised
Definition geomdefs.hh:86

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