Geometry

Configuration related to the geometry used in the simulation phase.

Main Geometry Configuration

class Gaussino.Geometry.GaussinoGeometry(*args, **kwargs)[source]

Bases: GaussinoConfigurable

Configurable for the geometry in Gaussino.

Main

Variables
  • GeometryService (str, optional) – default: "", name of the geometry service, if not provided then some custom geometry must be provided or using the external detector package

  • SensDetMap (dict, optional) – default: {}, additional map of sensitive volumes to volumes added on top of any geometry service

  • ExtraGeoTools (list, optional) – default: [], additional list of tools related to the geometry

Handling GDML files

Variables
  • ExportGDML (dict, optional) – default: {}

  • ImportGDML (list, optional) – default: []

External Detector

Variables

ExternalDetectorEmbedder (str, optional) – default: "", name of the embedder used when creating external geometry

__apply_configuration__()[source]

Main configuration method for the geometry to be used in Gaussino. It applies the properties of the geoemtry right after the simulation configurable GaussinoSimulation, generation GaussinoGeneration and the main configurable: Gaussino.

_set_custom_simulation_regions(dettool: ConfigurableMeta)[source]

Sets up the fast simulation interface that will assign models to the regions.

Parameters

dettool (ConfigurableMeta) – detector constructor GiGaMTDetectorConstructionFAC("DetConst")

_set_external_detector(dettool: ConfigurableMeta) list[source]

Sets up the external detector package if requested. See more info in a dedicated section below.

Parameters

dettool (ConfigurableMeta) – detector constructor GiGaMTDetectorConstructionFAC("DetConst")

Returns

list of algorithms

Return type

list

_set_gdml_export(dettool: ConfigurableMeta)[source]

Sets up the properties needed to export the geometry to a GDML file. See more info in a dedicated section below.

Parameters

dettool (ConfigurableMeta) – detector constructor GiGaMTDetectorConstructionFAC("DetConst")

Raises
  • RuntimeError – if ExportGDML not a dictionary

  • RuntimeError – if options of ExportGDML do not start with GDML*

_set_gdml_import(dettool)[source]

Sets up the properties needed to import geometry from a GDML file. The geometry can be added to the geometry created with a geometry service. See more info in a dedicated section below.

Parameters

dettool (ConfigurableMeta) – detector constructor GiGaMTDetectorConstructionFAC("DetConst")

Raises
  • RuntimeError – if ImportGDML not a dictionary

  • RuntimeError – if values of ImportGDML are not dictionaries either

_set_parallel_geometry(dettool: ConfigurableMeta) list[source]

Sets up the parallel geoemtry package if requested. It works only with the external detector package. See more info in a dedicated section below.

Parameters

dettool (ConfigurableMeta) – detector constructor GiGaMTDetectorConstructionFAC("DetConst")

Returns

list of algorithms

Return type

list

only_generation_phase = False

options set internally by Gaussino()

External Detector

Gaussino as a standalone application does not have a ‘main’ geometry service. ExternalDetector package provides an abstract geometry service that can work on its own, but it also works with any of the ‘main’ geometry services (e.g. LHCb’s GaussGeo, DD4hepCnvSvc). ExternalDetector provides all the necessary tools that are needed to embed volumes and make them sensitive. Moreover, it is possible to attach hit extraction and monitoring algorithms.

Important

ExternalDetector can work as a standalone geometry service or it can work wit other geometry services.

ExternalDetector configuration

class ExternalDetector.Configuration.ExternalDetectorEmbedder(*args, **kwargs)[source]

Bases: ConfigurableUser

This class sets up the provides all the necessary tools that are needed to embed volumes (Shapes) and make them sensitive (Sensitive). Moreover, it is possible to attach hit extraction (Hit) and monitoring algorithms (Moni). It can also serve as a geometry service that can work on its own by providing the World property. Finally, it gives a possibility to create custom materials through Materials property.

Variables
  • Shapes (dict, optional) – Properties of the volumes used.

  • Sensitive (dict, optional) – Properties of the sensitive detectors associated with the previosuly defined volumes.

  • Hit (dict, optional) – Properties of the hit exteraction algorithms associated with the previosuly defined sensitive detectors.

  • Moni (dict, optional) – Properties of the monitoring algorithms associated with the previosuly defined sensitive detectors.

  • World (dict, optional) – Properties of the world volume. Set this on if you want ExternalDetector pacage to work in a standalone mode

  • Materials (dict, optional) – Properties of the materials used by the world or other volumes created by the ExternalDetector.

  • MagneticField (dict, optional) – Properties of the magnetic field factory.

Example
from Configurables import (
    GaussinoSimulation,
    ExternalDetectorEmbedder,
)
GaussinoSimulation().ExternalDetectorEmbedder = "MyEmbedder"
external = ExternalDetectorEmbedder("MyEmbedder")

external.Shapes = {
    "MyPlane": {
        # -> type of the embedder
        "Type": "Cuboid",
        # -> x position of its center
        "xPos": 0 * m,
        # -> y position of its center
        "yPos": 0 * m,
        # -> z position of its center
        "zPos": 0 * m,
        # -> length of the x side
        "xSize": 1. * m,
        # -> length of the y side
        "ySize": 1. * m,
        # -> length of the z side
        "zSize": 1. * m,
        # + other properties used by the CuboidEmbedder
          e.g. OutputLevel etc.
    },
}

external.Sensitive = {
    # -> important! you have to specify what volume
    "MyPlane": {
        # -> required, type of the sensitive detector factory
        "Type": "MCCollectorSensDet",
        # + other properties used by the GiGaMTG4SensDetFactory
          e.g. OutputLevel etc.
    },
}

external.Hit = {
    # -> important! you have to specify what sensitive volume
    "MyPlane": {
        # -> required, type of the hit extraction algorithm
        "Type": "GetMCCollectorHitsAlg",
        # + other properties used by the Gaudi::Functional
        #   algorithm e.g. OutputLevel etc.
    },
}

external.Moni = {
    # -> important! you have to specify what sensitive volume
    "MyPlane": {
        # -> required, type of the monitoring algorithm
        "Type": "SomeMonitoringAlgorithm",
        # + other properties used by the Gaudi::Functional
        #   algorithm e.g. OutputLevel etc.
    },
}
_added_dets = []
_added_hits_algs = []
_check_props(name, props, required=['Type'])[source]
_embedding_tool(name, geo, tool_name, props)[source]
_refine_props(props, keys_to_refine=['Type'])[source]
_register_prop(props, key, prop)[source]
activate_hits_alg(slot='')[source]

Takes care of setting up the right hit extraction algorithms. It is based on the properties provided in Hit, but the volume must be created before as mentioned by Shapes. Properties correspond to the properites used by each hit extraction factory.

Parameters

slot – additional naming for spill-over, not working for now

activate_moni_alg(slot='')[source]

Takes care of setting up the right monitoring algorithms. It is based on the properties provided in Moni, but the volume must be created before as mentioned by Shapes. Properties correspond to the properites used by each hit extraction factory.

Parameters

slot – additional naming for spill-over, not working for now

embed(geo)[source]

Takes care of setting up the right tools and factories responsible for the geometry. It is based on the properties provided in Shapes, Sensitive, Materials, and World. Properties correspond to the properites used by each factory.

Parameters

geo – Tool responsible for detector construction in Geant4. In Gaussino, it is GiGaMTDetectorConstructionFAC.

External World (standalone mode)

This is a default mode for Gaussino as it does not provide any main geometry services. Main geometry services should be provided by the projects built on top of Gaussino. In the standalone mode, the ExternalDetector package provides all the necessary tools to create an abstract world volume. This is done by setting the ExternalDetectorEmbedder.World property.

external.World = {
    "Type": "ExternalWorldCreator",
    # -> type of the factory used to build the world
    # -> see: Sim/ExternalDetector/WorldFactory.h if you need to create a custom one
    "WorldMaterial": "SomeG4Material",
    # -> material used by the world, it is the name of the G4Material
    #    that must be defined before
    # -> see section for materials and Sim/ExternalDetector/MaterialFactory.h
    # + other properties used by the WorldFactory e.g. OutputLevel etc.
}

External Materials

Since there is no geometry service, Gaussino does not have any materials it can use for the creation of the worlds and volumes. Materials property will do this jon provided you give all the required properties needed to create a G4Material. As of now, there are 2 generic types of factories, but the template class MaterialFactory allows for adding any custom factory that constructs a G4Material object.

MaterialFromChemicalPropertiesFactory

MaterialFromChemicalPropertiesFactory creates a G4Material given the chemical properties. Below you’ll find an example of the interstellar vacuum OuterSpace material.

from GaudiKernel.SystemOfUnits import g, cm3, pascal, mole, kelvin

external.Materials = {
    # -> dictionaries of properties, one dict per material
    "OuterSpace": {
        "Type": "MaterialFromChemicalPropertiesFactory"
        # -> type of material factory
        "AtomicNumber": 1.,
        # -> required, atomic number
        "MassNumber": 1.01 * g / mole,
        # -> required, mass number [g / mole]
        "Density": 1.e-25 * g / cm3,
        # -> required, density of the material [g / cm3]
        "Pressure": 3.e-18 * pascal,
        # -> optional, pressure [Pa], default: 1 atm
        "Temperature": 2.73 * kelvin,
        # -> optional, temperature [K], default: room temperature
        "State": 'Gas',
        # -> optional, state: ['Gas', 'Liquid', 'Solid'], default: 'Undefined'
        # + other properties used by the MaterialFactory e.g. OutputLevel etc.
    },
}

and the Geant4 output:

GiGaMT.DetConst...  DEBUG
 Material: OuterSpace    density:  0.001 mg/cm3  RadL: 1010.068 km   Nucl.Int.Length: 560.762 km
                       Imean:  19.200 eV   temperature:   2.73 K  pressure:   0.00 atm

   --->  Element: H (H)   Z =  1.0   N =     1   A =  1.008 g/mole
         --->  Isotope:    H1   Z =  1   N =   1   A =   1.01 g/mole   abundance: 99.989 %
         --->  Isotope:    H2   Z =  1   N =   2   A =   2.01 g/mole   abundance:  0.011 %
          ElmMassFraction: 100.00 %  ElmAbundance 100.00 %

MaterialFromElements

MaterialFromElements creates a G4Material given the properties of the used elements. Below you’ll find an example of the material made out of lead.

from GaudiKernel.SystemOfUnits import g, cm3, pascal, mole, kelvin

external.Materials = {
    # -> dictionaries of properties, one dict per material
    'Pb': {
        'Type': 'MaterialFromElements',
        # -> type of material factory
        'Symbols': ['Pb'],
        # -> required, list of the elements' symbols
        'AtomicNumbers': [82.],
        # -> required, list of atomic numbers per element
        'MassNumbers': [207.2 * g / mole],
        # -> required, list of mass numbers per element
        'MassFractions': [1.],
        # -> required, list of mass fractions in 0. - 1., total <= 1.
        'Density': 11.29 * g / cm3,
        # -> required, density of the material [g / cm3]
        'State': 'Solid',
        # -> optional, state: ['Gas', 'Liquid', 'Solid'], default: 'Undefined'
        # + other properties used by the MaterialFactory e.g. OutputLevel etc.
    },
}

and the Geant4 output:

GiGaMT.DetConst.Pb  DEBUG
 Material:       Pb    density: 11.290 g/cm3   RadL:   5.642 mm   Nucl.Int.Length:  18.344 cm
                       Imean: 823.000 eV   temperature: 273.15 K  pressure: 6241.51 atm

   --->  Element: Pb (Pb)   Z = 82.0   N =   207   A = 207.200 g/mole
         --->  Isotope: Pb204   Z = 82   N = 204   A = 203.97 g/mole   abundance:  1.400 %
         --->  Isotope: Pb206   Z = 82   N = 206   A = 205.97 g/mole   abundance: 24.100 %
         --->  Isotope: Pb207   Z = 82   N = 207   A = 206.98 g/mole   abundance: 22.100 %
         --->  Isotope: Pb208   Z = 82   N = 208   A = 207.98 g/mole   abundance: 52.400 %
          ElmMassFraction: 100.00 %  ElmAbundance 100.00 %

External Shapes / Volumes

External Detector provides a template class Embedder that is responsible for creating and embedding the volume of a particular shape in the geometry. The library comes only with just factory CuboidEmbedder creating cuboid-like shapes, but it is fairly easy to create your own (see: section).

from GaudiKernel.SystemOfUnits import m

external.Shapes = {
    "MyPlane": {
        # -> type of the embedder
        "Type": "Cuboid",
        # -> x position of its center
        "xPos": 0 * m,
        # -> y position of its center
        "yPos": 0 * m,
        # -> z position of its center
        "zPos": 0 * m,
        # -> length of the x side
        "xSize": 1. * m,
        # -> length of the y side
        "ySize": 1. * m,
        # -> length of the z side
        "zSize": 1. * m,
        # + other properties used by the CuboidEmbedder e.g. OutputLevel etc.
    },
}

If you want your volume to be sensitive, you have to specify exactly what factory creating object of type G4VSensitiveDetector will be activated. Sensitive property was created for this purpose. MCCollector package provides a very generic sensitive detector class.

external.Sensitive = {
    # -> important! you have to specify what volume
    "MyPlane": {
        # -> required, type of the sensitive detector factory
        "Type": "MCCollectorSensDet",
        # + other properties used by the GiGaMTG4SensDetFactory e.g. OutputLevel etc.
    },
}

External Hit extraction

If you want to attach a special algorithm resposible for extracting hits generated by your sensitive volume, then you can use the Hit property for this purpose. MCCollector package provides a very generic hit extraction algorithm that creats MCExtendedHits.

external.Hit = {
    # -> important! you have to specify what sensitive volume
    "MyPlane": {
        # -> required, type of the hit extraction algorithm
        "Type": "GetMCCollectorHitsAlg",
        # + other properties used by the Gaudi::Functional algorithm e.g. OutputLevel etc.
    },
}

External Monitoring

Finally, there is a possinility add a monitoring algorithm on top of other aglorithms associated with your sensitive volume. It should be also a Gaudi::Functional algorithm, most likely a Consumer. As of now, there’s no monitoring algorithm in Gaussino that can be used here as an example.

external.Moni = {
    # -> important! you have to specify what sensitive volume
    "MyPlane": {
        # -> required, type of the monitoring algorithm
        "Type": "SomeMonitoringAlgorithm",
        # + other properties used by the Gaudi::Functional algorithm e.g. OutputLevel etc.
    },
}

Embedding your own, custom shape

ExternalDetector::Embedder is responsible for building and placing your detector in the mother volume. You have to inherit from it and override ExternalDetector::Embedder::build() method that creates an object inheriting from G4VSolid.

Below, you’ll find an example of how a custom SphereEmebedder can be implemented.

namespace ExternalDetector {
  class SphereEmbedder : public Embedder<G4Sphere> { // here is G4Sphere, but can be anything < G4VSolid
    // some properties
    Gaudi::Property<double> m_rMin{this, "RMin", 0.};
    Gaudi::Property<double> m_rMax{this, "RMax", 0.};
    Gaudi::Property<double> m_sPhi{this, "SPhi", 0.};
    Gaudi::Property<double> m_dPhi{this, "DPhi", 0.};
    Gaudi::Property<double> m_sTheta{this, "STheta", 0.};
    Gaudi::Property<double> m_dTheta{this, "DTheta", 0.};
    // name of the sphere
    Gaudi::Property<std::string> m_sphereName{this, "SphereName", "Sphere"};

  public:
    using Embedder::Embedder;

    inline virtual G4Sphere* build() const override {
      return new G4Sphere( m_sphereName.value(),
                           m_rMin.value(),
                           m_rMax.value(),
                           m_sPhi.value(),
                           m_dPhi.value(),
                           m_sTheta.value(),
                           m_dTheta.value());
    }
  };
} // namespace ExternalDetector

DECLARE_COMPONENT_WITH_ID( ExternalDetector::SphereEmbedder, "SphereEmbedder" )

Parallel Geometry

This adds a new package ParallelGeometry that allows for adding external detectors (from ExternalDetector package) in parallel worlds on top of mass geometry. This can be used in studies where we would like to have volumes / sensitive detectors overlapping each other.

Embedding a volume / sensitive detector in a parallel world is almost the same as for the mass geometry with the exception that materials are not required to be defined i.e. can be nullptr. If that is the case, then all the particles just “see” the boundaries coming from the parallel world.

If you actually want to set any material in your parallel world, then make sure you have LayeredMass=True in the configuration of parallel world physics. Otherwise, it won’t work. If LayeredMass=True, then all the worlds below in your stack will see the material of that world.

ParallelGeometry configuration

class ParallelGeometry.Configuration.ParallelGeometry(*args, **kwargs)[source]

Bases: ConfigurableUser

This class sets up external detectors (from ExternalDetector package) in parallel worlds on top of mass geometry. This can be used in studies where we would like to have volumes / sensitive detectors overlapping each other.

Variables
  • ParallelWorlds (dict, required) – Properties of the parallel worlds (there can be more than one parallel world).

  • ParallelPhysics (dict, required) – Properties of the physics factories that add a special behaviour of the particles tracked in the parallel worlds.

Note

Note! Make sure that all your detectors have materials if you want to export a GDML ( in parallel geometry volumes do not have have materials defined) i.e. material != nullptr, as G4GDMLParser will most likely crash

Example
from Configurables import ParallelGeometry
ParallelGeometry().ParallelWorlds = {
    'ParallelWorld1': {
        'ExternalDetectorEmbedder': 'ParallelEmbedder',
        'ExportGDML': {
            'GDMLFileName': 'ParallelWorld1.gdml',
            'GDMLFileNameOverwrite': True,
            'GDMLExportSD': True,
            'GDMLExportEnergyCuts': True,
        },
    },
}

ParallelGeometry().ParallelPhysics = {
    'ParallelWorld1': {
        'LayeredMass': False,
        # -> False = see material of the world below in stack
        'ParticlePIDs': [22],
        # -> empty means track all particles
    },
}

# then define ParallelEmbedder as in the ``ExternalDetector``
# section
_check_props(name, props)[source]
_external_embedders = []
_refine_props(props, keys_to_refine=['Type'])[source]
attach(dettool)[source]

Takes care of setting up the right tools and factories responsible for the parallel geometries as defined in ParallelWorlds property.

Parameters

dettool – Detector construction tool, should be GiGaMTDetectorConstructionFAC

attach_physics(modular_list)[source]

Takes care of setting up the right tools and factories responsible for the parallel physics factories that correspond to the parallel worlds. All these properties should be provided in ParallelPhysics property.

Parameters

modular_list – Modular physics list tool, should be GiGaMTModularPhysListFAC