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

G4PVParameterised represents many touchable detector elements differing in their positioning and dimensions. Both are calculated by means of a G4VParameterisation object. The positioning is assumed to be dominant along a specified Cartesian axis. More...

#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=default
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

Detailed Description

G4PVParameterised represents many touchable detector elements differing in their positioning and dimensions. Both are calculated by means of a G4VParameterisation object. The positioning is assumed to be dominant along a specified Cartesian axis.

Definition at line 49 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 )

Replicates the volume 'nReplicas' times using the paramaterisation 'pParam', within the mother volume 'pMotherLogical'. The positioning of the replicas is dominant along the specified axis.

Parameters
[in]pNameThe volume name.
[in]pLogicalPointer to the logical volume of the replica.
[in]pMotherLogicalPointer to the logical volume of the mother.
[in]pAxisThe axis along which do the replication.
[in]nReplicasThe number of copies to replicate.
[in]pParamPointer to the provided parameterisation algorithm.
[in]pSurfChkBoolean flag, if true activates check for overlaps with existing volumes (false by default).

Definition at line 85 of file G4PVParameterised.cc.

92 : G4PVReplica(pName, nReplicas, pAxis, pLogical, pMotherLogical ),
93 fparam(pParam)
94{
95 SetMotherLogical( pMotherLogical );
96 if( pMotherLogical != nullptr )
97 {
98 // Registration moved here to ensure that the volume is recognised as Parameterised
99 pMotherLogical->AddDaughter(this);
100 }
101 if (pSurfChk) { CheckOverlaps(); }
102}
G4VDivisionParameterisation * fparam
G4PVReplica(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0.)
G4PVReplica represents many touchable detector elements differing only in their positioning....
void AddDaughter(G4VPhysicalVolume *p)
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int maxErr=1) override

◆ G4PVParameterised() [2/3]

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

Similar to the constructor above, except for the mother pointer's type being here a G4VPhysicalVolume.

Parameters
[in]pNameThe volume name.
[in]pLogicalPointer to the logical volume of the replica.
[in]pMotherPointer to the physical volume of the mother.
[in]pAxisThe axis along which do the replication.
[in]nReplicasThe number of copies to replicate.
[in]pParamPointer to the provided parameterisation algorithm.
[in]pSurfChkBoolean flag, if true activates check for overlaps with existing volumes (false by default).

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;
66 std::ostringstream hint;
67 message << "A parameterised volume is being placed" << G4endl
68 << "inside another parameterised volume !";
69 hint << "To make sure that no overlaps are generated," << G4endl
70 << "you should verify the mother replicated shapes" << G4endl
71 << "are of the same type and dimensions." << G4endl
72 << " Mother physical volume: " << pMotherPhysical->GetName() << G4endl
73 << " Parameterised volume: " << pName << G4endl
74 << " (To switch this warning off, compile with G4_NO_VERBOSE)";
75 G4Exception("G4PVParameterised::G4PVParameterised()", "GeomVol1002",
76 JustWarning, message, G4String(hint.str()));
77 }
78#endif
79 if (pSurfChk) { CheckOverlaps(); }
80}
@ 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)

Fake default constructor for usage restricted to direct object persistency for clients requiring preallocation of memory for persistifiable objects.

Definition at line 108 of file G4PVParameterised.cc.

109 : G4PVReplica(a)
110{
111}

◆ ~G4PVParameterised()

G4PVParameterised::~G4PVParameterised ( )
overridedefault

Default Destructor.

Member Function Documentation

◆ CheckOverlaps()

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

Verifies if each instance of the parameterised volume is overlapping with other instances or with the mother volume. Provides default resolution for the number of points to be generated and verified. A tolerance for the precision of the overlap check can be specified, by default it is set to maximum precision. Reports a maximum of overlaps errors according to parameter in input.

Parameters
[in]resThe number of points to generate on volume's surface.
[in]tolThe precision tolerance for the overlap check, below which to ignore overlaps (deafult is maximim precision).
[in]verboseVerbosity mode (default is true).
[in]maxErrMaximum of overlaps errors to report (default is 1).
Returns
True if an overlap occurs.

Definition at line 168 of file G4PVParameterised.cc.

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

Referenced by G4PVParameterised(), G4PVParameterised(), and ~G4PVParameterised().

◆ GetParameterisation()

G4VPVParameterisation * G4PVParameterised::GetParameterisation ( ) const
override

Returns the current pointer to the parameterisation algorithm.

Definition at line 116 of file G4PVParameterised.cc.

117{
118 return fparam;
119}

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

◆ GetReplicationData()

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

Fills arguments with the attributes from the base replica.

Parameters
[in,out]axisAxis of parameterisation returned.
[in,out]nReplicasThe number of replica copies.
[in,out]widthWidth of the replica object.
[in,out]offsetPotential offset in replication.
[in,out]consumingFlag of replica characterisation (always false for parameterisations).

Definition at line 140 of file G4PVParameterised.cc.

145{
146 axis = faxis;
147 nReplicas = fnReplicas;
148 width = fwidth;
149 offset = foffset;
150 consuming = false;
151}
G4ThreadLocal T * G4GeomSplitter< T >::offset
EAxis faxis
G4int fnReplicas
G4double fwidth
G4double foffset
const axis_t axis_to_type< N >::axis
Definition pugixml.cc:9668

Referenced by G4tgbGeometryDumper::DumpPVParameterised(), and ~G4PVParameterised().

◆ IsParameterised()

G4bool G4PVParameterised::IsParameterised ( ) const
override

Returns true to identify if it is a parameterised physical volume.

Definition at line 124 of file G4PVParameterised.cc.

125{
126 return true;
127}

◆ SetRegularStructureId()

void G4PVParameterised::SetRegularStructureId ( G4int code)
override

Sets code and can prepare for special type of regular volumes.

Definition at line 156 of file G4PVParameterised.cc.

157{
158 G4PVReplica::SetRegularStructureId( code );
159 // To undertake additional preparation, a derived volume must
160 // redefine this method, while calling also the above method
161}

Referenced by ~G4PVParameterised().

◆ VolumeType()

EVolume G4PVParameterised::VolumeType ( ) const
final

Returns the volume type characterisation.

Definition at line 132 of file G4PVParameterised.cc.

133{
134 return kParameterised;
135}
@ kParameterised
Definition geomdefs.hh:86

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