Vertex confinement

Vertex confinement is remage’s main vertex generator (see Event generators for the distinction between vertex and event generation). It supports generating event vertices either in the bulk or on the surface of various solids. This is essential for simulating, for example, the decay of radioactive isotopes in detector components.

To enable vertex confinement, activate the corresponding generator using /RMG/Generator/Confine (see Event generators):

/RMG/Generator/Confine Volume

Configuration is handled via commands in the /RMG/Generator/Confinement/ section.

Listing volumes

The next step is specifying a list of volumes to consider. These can be of two types: Geant4 physical volumes or user defined virtual geometrical solids.

Physical volumes

These can be added via /RMG/Generator/Confinement/Physical/AddVolume. To add a physical volume named e.g. C000RG1, do:

/RMG/Generator/Confinement/Physical/AddVolume C000RG1

C000RG1 must be part of the provided geometry implementation. An optional second argument sets the copy number. You can also use regular expressions (via std::regex) to match multiple volumes:

/RMG/Generator/Confinement/Physical/AddVolume C\w+

Geometrical solids

Virtual user-defined geometrical solids can be defined with commands in the /RMG/Generator/Confinement/Geometrical/ folder. For example, to add a sphere of radius 15 cm centered in (-1, 2, 5) cm:

/RMG/Generator/Confinement/Geometrical/AddSolid Sphere
/RMG/Generator/Confinement/Geometrical/CenterPositionX -1 cm
/RMG/Generator/Confinement/Geometrical/CenterPositionY 2 cm
/RMG/Generator/Confinement/Geometrical/CenterPositionZ 5 cm
/RMG/Generator/Confinement/Geometrical/Sphere/InnerRadius 0 m
/RMG/Generator/Confinement/Geometrical/Sphere/OuterRadius 15 cm

Other shapes, such as boxes and cylinders, are also supported.

Sampling modes

Note

In this section, sampling in the bulk of volumes is assumed. For documentation about sampling on surfaces, see next section.

Once a list of solids is defined, we need to select the sampling mode (i.e. how the list of solids will be used to generate vertices) via /RMG/Generator/Confinement/SamplingMode. Three modes are currently available:

  • UnionAll (the default)

  • IntersectPhysicalWithGeometrical

  • SubtractGeometrical

In the following, we will refer to physical volumes as \(P_i\) and geometrical volumes as \(G_i\).

../_images/confinement-modes.png

Some of the vertex confinement options, illustrated with two germanium detectors in a surrounding medium. Shown is the radial component of the sampled vertices, hence the \(1/r\) dependency in the density. From left to right: (a) bulk sampling in both detectors (UnionAll), (b) sampling from the intersection of the surrounding volume with a virtual, user-defined cylinder (IntersectPhysicalWithGeometrical), (c) the same cylinder subtracted from the surrounding volume (SubtractGeometrical), (d) sampling on the detector surfaces and (e) surface sampling with an additional depth profile applied (see Bulk versus surface and Depth profiles).

UnionAll

In this mode, vertices are sampled randomly across all defined solids (physical and geometrical), weighted by their volume to ensure uniform vertex volume density. Formally:

\[P_1 \cup \ldots P_n \cup G_1 \cup \ldots \cup G_m\]

IntersectPhysicalWithGeometrical

In this mode, vertices are sampled in the intersection between physical and geometrical volumes. Formally:

\[(P_1 \cup \ldots P_n) \cap (G_1 \cup \ldots \cup G_m)\]

As for the previous mode, uniform vertex volume density is guaranteed. The algorithm first samples a candidate vertex from the smaller group (by total volume, to improve sampling efficiency), then checks if it lies in the other group. Override the default group with /RMG/Generator/Confinement/FirstSamplingVolume.

SubtractGeometrical

This mode allows to perform subtractions between physical and geometrical volumes, formally:

\[(P_1 \cup \ldots \cup P_n) \cap (\overline{G^\prime_1} \cup \ldots \cup \overline{G^\prime_m})\]

Geometrical solids can be added to the group of solids to be subtracted with the /RMG/Generator/Confinement/Geometrical/AddExcludedSolid command.

Note

The functionality of IntersectPhysicalWithGeometrical is still available. If both physical and geometrical volumes are defined with /RMG/Generator/Confinement/Physical/AddVolume, the intersection between them will be computed before subtracting the other solids. Formally:

\[[(P_1 \cup \ldots P_n) \cap (G_1 \cup \ldots \cup G_m)] \cap (\overline{G^\prime_1} \cup \ldots \cup \overline{G^\prime_o})\]

Bulk versus surface

By default, remage will sample vertices in the bulk of solids. Activate sampling on surfaces with the /RMG/Generator/Confinement/SampleOnSurface command.

remage can exactly sample in the bulk or surface of some simple solids (G4Box, G4Sphere, G4Orb and G4Tubs, see RMGGeneratorUtil::rand()). For other volumes, Monte Carlo sampling methods are implemented. For sampling in the bulk of an arbitrary Geant4 solid, a rejection-sampling method is implementing by using Geant4’s solid extent and G4VSolid::Inside(). For sampling on the surface of an arbitrary Geant4 solid, an algorithm based on counting the intersection points of random lines with the surface is implemented, as described in [1]. Note that, unlike the description in that publication, remage implements the surface sampling directly, without a first simulation pass that generates the vertices using geantinos and Geant4’s tracking mechanism.

All sampling modes described above are available, with few notes/limitations:

  • The algorithm samples across volumes weighted by surface area, to ensure uniform vertex surface density. The mass-based weighting modes apply to bulk sampling only and cannot be combined with surface sampling.

  • Sampling on the surface of volumes that contain daughters will result in vertices being distributed on the outer surface of the mother volume only.

  • volumes that have daughters coincinding with the mothers’s surface will be weighted by the surface area including the daughter volume.

  • Sampling on intersections/subtractions of surfaces is not possible. remage will instead sample vertices in intersections/subtractions between surfaces and volumes. Because of this, the group of volumes (geometrical or physical) to sample the candidate surface vertices from must be set with /RMG/Generator/Confinement/FirstSamplingVolume. This is not optional.

  • The value of /RMG/Generator/Confinement/SurfaceSampleMaxIntersections should be set to the maximum number of times a line can intersect with the surface of the volume. For example this is 2 for a sphere or cube. The supplied value can be an overestimate. For slight overestimates this is comes with a small but usually acceptable performance cost, however very large values can significantly slow down the simulation.

Depth profiles

Surface-sampled vertices can optionally be displaced inward into the material, to model sub-surface contamination (e.g. implanted or diffused activity). When a depth profile is configured, a depth is drawn from the chosen distribution and the vertex is moved from the surface along the inward normal by that amount. This only applies when surface sampling is active (/RMG/Generator/Confinement/SampleOnSurface).

The distribution is selected with /RMG/Generator/Confinement/DepthProfile/Type, which accepts:

  • None (default): no displacement, vertices stay on the surface.

  • Exponential: exponential with mean depth Mean (physically motivated for surface contamination).

  • Uniform: flat over [RangeLow, RangeHigh].

  • TruncatedGaussian: Gaussian of centre Mean and width Sigma, restricted to [RangeLow, RangeHigh].

The parameters are set with the Mean, Sigma, RangeLow and RangeHigh commands under /RMG/Generator/Confinement/DepthProfile/ (all lengths, default unit mm). Parameters are validated at the start of the run: Exponential requires Mean > 0, the range-based profiles require RangeHigh > RangeLow >= 0, and TruncatedGaussian additionally requires Sigma > 0.

The sampled depth is clamped to the distance from the surface point to the far boundary of the solid, so a displaced vertex can never cross to the other side or leave the solid. For thin volumes this means an over-large sampled depth is silently reduced; choose parameters consistent with the local wall thickness to keep the resulting depth distribution meaningful.

/RMG/Generator/Confinement/SampleOnSurface true
/RMG/Generator/Confinement/DepthProfile/Type Exponential
/RMG/Generator/Confinement/DepthProfile/Mean 0.1 um

Weighting modes

For the sampling in the bulk of volumes, remage by default weights the probability to find a sampled vertex in one of the volumes by the ratio of their volume to the total sampling volume, so that the resulting vertex density is uniform across the sampling region regardless of how many volumes contribute to it. Two alternative weighting modes are available for cases where the contaminant is not expected to scale with the volume. They can be selected by the user with a macro command:

  • by the mass of the volumes can with the command /RMG/Generator/Confinement/SampleWeightByMass.

  • by the mass of a given isotope in the materials with the command /RMG/Generator/Confinement/SampleWeightByMassIsotope. The isotope is specified by its atomic number \(Z\) (number of protons) followed by its mass number \(A\) (number of nucleons), e.g. 32 76 for \(^{76}\)Ge. This is the natural choice when the simulated process is bound to the abundance of a specific isotope, for instance double-beta decays generated in a set of volumes with different, known enrichment fractions.

These mass-based weighting modes apply only to bulk sampling. Surface sampling is always weighted by surface area instead, and cannot be combined with them.

Vertices from external files

For more complicated vertex confinement remage supports the possibility to read in directly event primary positions from input files, as described in Vertex input.

Visualization

You can use legend-pygeom-vis from the legend-pygeom-tools package to visualize the simulated vertices your generated output files:

$ remage -o {RMG_OUTPUT_FILE} -g {GDML_FILE} -- ...
$ legend-pygeom-vis --add_points {RMG_OUTPUT_FILE} {GDML_FILE}

If you want to only show the vertices without the run-time overhead of actually simulating any physics, you could consider switching to generating only geantinos instead of your usual physics.

Examples

In the bulk of all Germanium detectors:

Sampling uniformly distributed in all Germanium detectors of the LEGEND experiment is simple. Only one volume selection command is needed with the regex capabilities described above:

/RMG/Generator/Confine Volume
/RMG/Generator/Confinement/Physical/AddVolume [BCPV]\w+

This can now be used as an example to weigh the volumes not by their volume: It could be useful to weigh the different volumes by the mass fraction of the isotope \(^{76}\)Ge, i.e. for simulating double beta decays with bxdecay0:

/RMG/Generator/Confinement/SampleWeightByMassIsotope 32 76

Active LAr region of LEGEND-200

This is a typical example of the sampling from a volume intersection. This will sample from the liquid_argon volume, but

/RMG/Generator/Confine Volume
/RMG/Generator/Confinement/SamplingMode IntersectPhysicalWithGeometrical

/RMG/Generator/Confinement/Physical/AddVolume liquid_argon

/RMG/Generator/Confinement/Geometrical/AddSolid Cylinder
/RMG/Generator/Confinement/Geometrical/CenterPositionX 0 m
/RMG/Generator/Confinement/Geometrical/CenterPositionY 0 m
/RMG/Generator/Confinement/Geometrical/CenterPositionZ 0.69 m
/RMG/Generator/Confinement/Geometrical/Cylinder/InnerRadius 0 m
/RMG/Generator/Confinement/Geometrical/Cylinder/OuterRadius 0.7 m
/RMG/Generator/Confinement/Geometrical/Cylinder/Height 2 m

On the surface of the PEN pieces

Assuming the geometry contains PEN parts in volumes named with _pen_ somewhere in their name. Sampling on the surface can then be achieved by:

/RMG/Generator/Confine Volume
/RMG/Generator/Confinement/Physical/AddVolume .*_pen_.*

# sample on the surfaces of all volumes:
/RMG/Generator/Confinement/SampleOnSurface true
# replace "6" with another value suitable for the selected volumes
/RMG/Generator/Confinement/SurfaceSampleMaxIntersections 6