Vertex confinement¶
remage 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)IntersectPhysicalWithGeometricalSubtractGeometrical
In the following, we will refer to physical volumes as \(P_i\) and geometrical volumes as \(G_i\).
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:
IntersectPhysicalWithGeometrical¶
In this mode, vertices are sampled in the intersection between physical and geometrical volumes. Formally:
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:
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:
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, the algorithm described in [1] is implemented.
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.
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.
Weighting modes¶
For the sampling in 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. Other weighting modes 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 (specified by the pair of proton and neutron number) in the materials with the command /RMG/Generator/Confinement/SampleWeightByMassIsotope.
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