allpix::GeometryManager
Module: Managers
Manager responsible for the global geometry. More…
#include <GeometryManager.hpp>
Public Functions
Name | |
---|---|
GeometryManager(const GeometryManager & ) =delete Copying the manager is not allowed. |
|
GeometryManager & | operator=(const GeometryManager & ) =delete Copying the manager is not allowed. |
GeometryManager(GeometryManager && ) =delete Disallow move because of atomic boolean. |
|
GeometryManager & | operator=(GeometryManager && ) =delete Disallow move because of atomic boolean. |
GeometryManager() Construct the geometry manager. |
|
~GeometryManager() =default Use default destructor. |
|
void | load(ConfigManager * conf_manager, RandomNumberGenerator & seeder) Loads the geometry from the global configuration. |
const std::vector< std::string > & | getModelsPath() const Returns the list of standard paths where models should be searched in. |
std::pair< ROOT::Math::XYZPoint, ROOT::Math::Rotation3D > | getPassiveElementOrientation(const std::string & passive_element) const Returns the position and orientation for a passive element. |
ROOT::Math::XYZPoint | getMinimumCoordinate() Return the minimum coordinate of all detectors in the geometry. |
ROOT::Math::XYZPoint | getMaximumCoordinate() Return the maximum coordinate of all detectors in the geometry. |
void | addPoint(ROOT::Math::XYZPoint point) Add a point to the geometry (used for the minimum and maximum coordinate) |
bool | needsModel(const std::string & name) const Return if the model is currently in the list of required models. |
void | addModel(std::shared_ptr< DetectorModel > model) Add a detector model and apply it to the registered detectors. |
bool | hasModel(const std::string & name) const Check if a detector model exists. |
const std::vector< std::shared_ptr< DetectorModel > > & | getModels() const Get all added detector models. |
std::shared_ptr< DetectorModel > | getModel(const std::string & name) const Get a detector model by its name. |
void | addDetector(std::shared_ptr< Detector > detector) Add a detector to the global geometry. |
bool | hasDetector(const std::string & name) const Check if a detector exists. |
std::vector< std::shared_ptr< Detector > > | getDetectors() Get all detectors in the geometry. |
std::shared_ptr< Detector > | getDetector(const std::string & name) Get a detector by its name. |
std::vector< std::shared_ptr< Detector > > | getDetectorsByType(const std::string & type) Get all detectors in the geometry of a particular model type. |
void | setMagneticFieldFunction(MagneticFieldFunction function, MagneticFieldType type =MagneticFieldType::CUSTOM) Set the magnetic field in the volume. |
bool | hasMagneticField() const Returns if a magnetic field is present. |
ROOT::Math::XYZVector | getMagneticField(const ROOT::Math::XYZPoint & position) const Get the magnetic field at a global position. |
MagneticFieldType | getMagneticFieldType() const |
template <typename T > std::shared_ptr< T > |
getExternalObject(const std::string & associated_name, const std::string & id) const Fetch an external object associated to a detector or passive volume. |
template <typename T > std::vector< std::shared_ptr< T > > |
getExternalObjects(const std::string & associated_name, const std::regex & regex) const Fetch an array of external objects associated to a detector or passive volume. |
template <typename T > void |
setExternalObject(const std::string & associated_name, const std::string & id, std::shared_ptr< T > external_object) Sets an external object associated to a detector or passive volume. |
const std::set< std::string > & | getExternalObjectNames() const Get all names of external objects registered via setExternalObject. |
const std::list< Configuration > & | getPassiveElements() const Get the list of Configuration objects for all passive elements in the current geometry. |
Detailed Description
class allpix::GeometryManager;
Manager responsible for the global geometry.
The framework defines the geometry as a set of independent instances of a detector. Each independent detector has a detector model. Detector and models can be added before the manager closes. The manager closes as soon as GeometryManager::getDetectors() or a similar method is called. Afterwards the geometry is constant and cannot be changed anymore.
Public Functions Documentation
function GeometryManager
GeometryManager(
const GeometryManager &
) =delete
Copying the manager is not allowed.
function operator=
GeometryManager & operator=(
const GeometryManager &
) =delete
Copying the manager is not allowed.
function GeometryManager
GeometryManager(
GeometryManager &&
) =delete
Disallow move because of atomic boolean.
function operator=
GeometryManager & operator=(
GeometryManager &&
) =delete
Disallow move because of atomic boolean.
function GeometryManager
GeometryManager()
Construct the geometry manager.
function ~GeometryManager
~GeometryManager() =default
Use default destructor.
function load
void load(
ConfigManager * conf_manager,
RandomNumberGenerator & seeder
)
Loads the geometry from the global configuration.
Parameters:
- conf_manager Configuration manager of the framework
- seeder PRNG to use for generating random misalignments
Warning: Has to be the first function called after the constructor
Loads the geometry by looping over all defined detectors
function getModelsPath
inline const std::vector< std::string > & getModelsPath() const
Returns the list of standard paths where models should be searched in.
Return: List of absolute paths to file or directories that contain models
The default list of models to search for are in the following order
- The list of paths provided in the main configuration as model_paths
- The build variable ALLPIX_MODEL_DIR pointing to the installation directory of the framework models
- The directories in XDG_DATA_DIRS attached by ALLPIX_PROJECT_NAME or /usr/share/:/usr/local/share if not defined
function getPassiveElementOrientation
std::pair< ROOT::Math::XYZPoint, ROOT::Math::Rotation3D > getPassiveElementOrientation(
const std::string & passive_element
) const
Returns the position and orientation for a passive element.
Return: Pair of position and orientation
Returns the pre-calculated position and orientation of a passive element in global coordinates
function getMinimumCoordinate
ROOT::Math::XYZPoint getMinimumCoordinate()
Return the minimum coordinate of all detectors in the geometry.
Return: Minimum coordinate in global frame
Note: Closes the geometry if it has not been closed yet
The minimum coordinate is the location of the point where no part of any detector exist with a lower x, y or z-coordinate in the geometry. The minimum point is never above the origin (the origin is always included in the geometry).
function getMaximumCoordinate
ROOT::Math::XYZPoint getMaximumCoordinate()
Return the maximum coordinate of all detectors in the geometry.
Return: Maximum coordinate in global frame
Note: Closes the geometry if it has not been closed yet
The maximum coordinate is the location of the point where no part of any detector exist with a higher x, y or z-coordinate in the geometry. The maximum point is never below the origin (the origin is always included in the geometry).
function addPoint
void addPoint(
ROOT::Math::XYZPoint point
)
Add a point to the geometry (used for the minimum and maximum coordinate)
Parameters:
- point Point that should be included in the geometry
Exceptions:
- ModuleError If the geometry is already closed before calling this function
Warning: Can only be used as long as the geometry is still open
Can be used to add an arbitrary and unspecified point which is part of the geometry
function needsModel
bool needsModel(
const std::string & name
) const
Return if the model is currently in the list of required models.
Parameters:
- name Type of the model to search for
Return: True if at least one model still needs this type, false otherwise
function addModel
void addModel(
std::shared_ptr< DetectorModel > model
)
Add a detector model and apply it to the registered detectors.
Parameters:
- model Pointer to the detector model
Exceptions:
- InvalidModuleActionException If the passed detector is a null pointer
- ModuleError If the geometry is already closed before calling this function
- DetectorModelExistsError If the detector name is already registered before
Warning: Can only be used as long as the geometry is still open
function hasModel
bool hasModel(
const std::string & name
) const
Check if a detector model exists.
Parameters:
- name Model type to search for
Return: True if the model is part of the geometry, false otherwise
function getModels
inline const std::vector< std::shared_ptr< DetectorModel > > & getModels() const
Get all added detector models.
Return: List of all models
Warning: The models returned might not be used in the geometry
function getModel
std::shared_ptr< DetectorModel > getModel(
const std::string & name
) const
Get a detector model by its name.
Parameters:
- name Name of the model to search for
Exceptions:
- InvalidDetectorError If a model with this name does not exist
Return: Return the model if it exists (an error is raised if it does not)
Warning: The method GeometryManager::hasModel should be used to check for existence
function addDetector
void addDetector(
std::shared_ptr< Detector > detector
)
Add a detector to the global geometry.
Parameters:
- detector Pointer to the detector to add to the geometry
Exceptions:
- InvalidModuleActionException If the passed detector is a null pointer
- ModuleError If the geometry is already closed before calling this function
- DetectorInvalidNameError If the detector name is invalid
- DetectorExistsError If the detector name is already registered before
Warning: Can only be used as long as the geometry is still open
function hasDetector
bool hasDetector(
const std::string & name
) const
Check if a detector exists.
Parameters:
- name Model type to search for
Return: True if the detector is part of the geometry, false otherwise
function getDetectors
std::vector< std::shared_ptr< Detector > > getDetectors()
Get all detectors in the geometry.
Return: List of all detectors
Note: Closes the geometry if it not has been closed yet
function getDetector
std::shared_ptr< Detector > getDetector(
const std::string & name
)
Get a detector by its name.
Parameters:
- name Name of the detector to search for
Exceptions:
- InvalidDetectorError If a detector with this name does not exist
Return: Return the detector if it exists (an error is raised if it does not)
Note: Closes the geometry if it has not been closed yet
Warning: The method GeometryManager::hasDetector should be used to check for existence
function getDetectorsByType
std::vector< std::shared_ptr< Detector > > getDetectorsByType(
const std::string & type
)
Get all detectors in the geometry of a particular model type.
Parameters:
- type Type of the detector model to search for
Exceptions:
- InvalidDetectorError If not a single detector with this type exists
Return: List of all detectors of a particular type (an error is raised if none exist)
Note: Closes the geometry if it has not been closed yet
Warning: This method should not be used to check if an instantiation of a model exists
function setMagneticFieldFunction
void setMagneticFieldFunction(
MagneticFieldFunction function,
MagneticFieldType type =MagneticFieldType::CUSTOM
)
Set the magnetic field in the volume.
Parameters:
- function Function used to retrieve the magnetic field
- type Type of the magnetic field function used
function hasMagneticField
bool hasMagneticField() const
Returns if a magnetic field is present.
Return: True if the a magnetic field is present in the volume, false otherwise
function getMagneticField
ROOT::Math::XYZVector getMagneticField(
const ROOT::Math::XYZPoint & position
) const
Get the magnetic field at a global position.
Parameters:
- position Position in the global frame
Return: Vector of the field at the queried point
function getMagneticFieldType
MagneticFieldType getMagneticFieldType() const
function getExternalObject
template <typename T >
std::shared_ptr< T > getExternalObject(
const std::string & associated_name,
const std::string & id
) const
Fetch an external object associated to a detector or passive volume.
Parameters:
- associated_name Name of the detector or passive volume the external object is associated to
- id ID of the external object
Return: External object or null pointer if it does not exist
function getExternalObjects
template <typename T >
std::vector< std::shared_ptr< T > > getExternalObjects(
const std::string & associated_name,
const std::regex & regex
) const
Fetch an array of external objects associated to a detector or passive volume.
Parameters:
- associated_name Name of the detector or passive volume the external object is associated to
- regex Regular expression which the ID is required to satisfy
Return: Vector of external objects, empty vector if no match could be found
function setExternalObject
template <typename T >
void setExternalObject(
const std::string & associated_name,
const std::string & id,
std::shared_ptr< T > external_object
)
Sets an external object associated to a detector or passive volume.
Parameters:
- associated_name Name of the detector or passive volume the external object is associated to
- id ID of the external object
- external_object External object of arbitrary type
function getExternalObjectNames
inline const std::set< std::string > & getExternalObjectNames() const
Get all names of external objects registered via setExternalObject.
Return: Set of names of external objects
function getPassiveElements
inline const std::list< Configuration > & getPassiveElements() const
Get the list of Configuration objects for all passive elements in the current geometry.
Return: List of Configuration objects for passive elements
Updated on 2024-12-13 at 08:31:37 +0000