Struct RMGVertexConfinement::SampleableObject¶
Defined in File RMGVertexConfinement.hh
Nested Relationships¶
This struct is a nested type of Class RMGVertexConfinement.
Struct Documentation¶
-
struct SampleableObject
An object which we can generate position samples in. Based on either a
G4VPhysicalVolumeor geometrical volume defined by aG4VSolid. The sampling can be performed either on the surface or in the volume of the solid.This structure must contain at least a non-null pointer, between the
physical_volumeandsampling_solidarguments. The idea is that:physical volumes get always a bounding box assigned, but at later time
purely geometrical volumes only have the sampling_solid member defined
Public Functions
-
SampleableObject() = default
-
SampleableObject(const SampleableObject&) = default
-
SampleableObject(G4VPhysicalVolume *physvol, G4RotationMatrix rot, G4ThreeVector trans, G4VSolid *solid, bool is_native_sampleable = false, bool on_surface = false)
SampleableObject constructor.
- Parameters:
physvol – The physical volume.
rot – A rotation matrix for the sampling solid.
trans – A translation vector for the sampling solid.
solid – A solid for geometrical volume sampling or for generating candidate points or rejection sampling.
is_native_sampleable – A flag of whether the solid is natively sampeable.
on_surface – A flag of whether the solid should be sampled on the surface.
-
~SampleableObject() = default
-
bool IsInside(const G4ThreeVector &vertex) const
Check if the vertex is inside the solid.
- Parameters:
vertex – The sampled vertex.
- Returns:
Boolean flag of whether the vertexx is inside the solid.
-
bool Sample(G4ThreeVector &vertex, size_t max_attempts, bool force_containment_check, size_t &n_trials) const
Generate a sample from the solid.
Depending on if the solid is a basic one either sample natively, or using rejection sampling. Either samples the volume or the surface depending on the
surface_samplemember.For surface sampling mode the solid is either natively sampled (if this is implemented), or is sampled with SampleableObject::GenerateSurfacePoint
For volume sampling, if the solid is not natively sampleable, points are generated in a bounding box and then rejection sampling is used using SampleableObject::IsInside.
- Parameters:
vertex – The sampled vertex.
max_attempts – The maximum number of candidate vertices for rejection sampling.
force_containment_check – Whether to force a check on where the point is inside the solid.
n_trials – The total number of trials performed.
-
bool GenerateSurfacePoint(G4ThreeVector &vertex, size_t max_attempts, size_t max_intersections) const
Generate a point on the surface of the solid.
This follows the algorithm from https://arxiv.org/abs/0802.2960.
Produce a direction vector corresponding to a uniform flux in a bounding sphere.
Find the intersections of this line with the solid.
Pick one intersection, or repeat.
- Parameters:
vertex – The sampled vertex,
max_attempts – The maximum number of attempts to find a valid vertex.
max_intersections – The maximum number of intersections possible for the solid, can be an overestimate.
-
std::vector<G4ThreeVector> GetIntersections(G4ThreeVector start, G4ThreeVector dir) const
Get the number of intersections between the solid and the line starting at
startwith directiondir.This is used in the generic surface sampling algorithm. This function makes use of the methods
GetDistanceToIn(p,v)andGetDistanceToOut(p,v)ofG4VSolid. It continually looks for the distance to the next boundary (along the line) until this becomes zero indicating there are no more intersections.- Parameters:
start – The starting vector of the line, note this should be outside the solid.
dir – The direction vector.
- Returns:
A vector of the points of intersection.
-
void GetDirection(G4ThreeVector &dir, G4ThreeVector &pos) const
Get a position and direction for the generic surface sampling algorithm.
This generates a point on a bounding sphere, then shifts by some impact parameter, following the algorithm from https://arxiv.org/abs/0802.2960. This produces a uniform and isotropic flux inside the bounding sphere.
- Parameters:
dir – The direction vector for the point.
pos – The initial position for the point.
-
void RecalcMass(int z, int n)
Public Members
-
G4VPhysicalVolume *physical_volume = nullptr
-
G4VSolid *sampling_solid = nullptr
-
G4RotationMatrix rotation
-
G4ThreeVector translation
-
double volume = -1
-
double mass = -1
-
double surface = -1
-
bool surface_sample = false
-
bool native_sample = false
-
size_t max_num_intersections = 0