gsystem
Loading...
Searching...
No Matches
GSystem Class Reference

Represents a single detector system (e.g., calorimeter, tracker). More...

#include <gsystem.h>

Public Member Functions

 GSystem (const std::shared_ptr< GOptions > &gopts, const std::string &dbhost, const std::string &sname, const std::string &factory, const std::string &experiment, int runno, const std::string &variation, const std::string &annotations="none")
 Construct a detector system descriptor.
 
 GSystem (const GSystem &other)
 Deep copy constructor (used only by clone()).
 
 GSystem (GSystem &&) noexcept=default
 
GSystemoperator= (GSystem &&) noexcept=default
 
GSystemoperator= (const GSystem &)=delete
 
std::unique_ptr< GSystemclone () const
 Clone helper.
 
std::string getFilePath ()
 Gets the full file path of the system.
 
void set_dbhost (const std::string &dbh)
 Sets the database host.
 
void addROOTVolume (const std::string &rootVolumeDefinition)
 Adds the special ROOT/world volume to the system.
 
void addGVolume (std::vector< std::string > pars)
 Build and add a volume from a serialized parameter list.
 
void addVolumeFromFile (const std::string &importType, const std::string &filename)
 Add a volume imported from a file (CAD, GDML, etc.).
 
GVolumegetGVolume (const std::string &volumeName) const
 Retrieve a volume by name.
 
const std::map< std::string, std::shared_ptr< GVolume > > & getGVolumesMap () const
 Access all volumes in this system.
 
const std::map< std::string, std::shared_ptr< GMaterial > > & getGMaterialMap () const
 Access all materials in this system.
 
void addGMaterial (std::vector< std::string > pars)
 Build and add a material from a serialized parameter list.
 
const GMaterialgetMaterialForGVolume (const std::string &volumeName) const
 Retrieve the material associated with a given volume.
 
System metadata
std::string getName () const
 
std::string getFactoryName () const
 
std::string getVariation () const
 
std::string getExperiment () const
 
std::string getAnnotations () const
 
int getRunno () const
 
std::string get_dbhost () const
 
- Public Member Functions inherited from GBase< GSystem >
 GBase (const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
 
 GBase (const std::shared_ptr< GLogger > &logger)
 
 GBase (const GBase &)=default
 
 GBase (GBase &&) noexcept=default
 
virtual ~GBase ()
 
GBaseoperator= (const GBase &)=default
 
GBaseoperator= (GBase &&) noexcept=default
 

Additional Inherited Members

- Protected Attributes inherited from GBase< GSystem >
std::shared_ptr< GLoggerlog
 

Detailed Description

A GSystem is a container for:

  • a set of geometry volumes (GVolume) that define shapes/placements;
  • a set of materials (GMaterial) that volumes refer to by name.

Systems are typically created from configuration (GOptions) and then populated by a factory (derived from GSystemFactory) that loads geometry/material rows from a source (sqlite DB, ASCII, CAD import, GDML import, etc.).

Key configuration dimensions:

  • experiment : filters DB queries and system selection
  • variation : selects a geometry/material variant
  • runno : selects a run-dependent configuration

Definition at line 31 of file gsystem.h.

Constructor & Destructor Documentation

◆ GSystem() [1/3]

GSystem::GSystem ( const std::shared_ptr< GOptions > & gopts,
const std::string & dbhost,
const std::string & sname,
const std::string & factory,
const std::string & experiment,
int runno,
const std::string & variation,
const std::string & annotations = "none" )
Parameters
goptsShared options/configuration instance.
dbhostDatabase host (sqlite filename or remote host, depending on factory).
snameAbsolute or relative path including the system name (e.g. "detectors/ecal"). The name and path are parsed from this string.
factoryFactory label used to load this system (e.g. "ascii", "sqlite", "CAD", "GDML").
experimentExperiment name used in DB filtering.
runnoRun number used in DB filtering.
variationVariation string used in DB filtering and file naming.
annotationsOptional system annotations (e.g. "mats_only").

Definition at line 44 of file gsystem.cc.

◆ GSystem() [2/3]

GSystem::GSystem ( const GSystem & other)
Parameters
otherSource system.

This constructor performs a deep copy of volumes and materials so that the copied system owns independent objects (while preserving value semantics).

Definition at line 15 of file gsystem.cc.

◆ GSystem() [3/3]

GSystem::GSystem ( GSystem && )
defaultnoexcept

Member Function Documentation

◆ addGMaterial()

void GSystem::addGMaterial ( std::vector< std::string > pars)
Parameters
parsSerialized material parameter list.
  • If the material name key is new, a material object is constructed and inserted.
  • If the key already exists, the method logs ERR_GMATERIALALREADYPRESENT.

Definition at line 161 of file gsystem.cc.

◆ addGVolume()

void GSystem::addGVolume ( std::vector< std::string > pars)
Parameters
parsSerialized volume parameter list.

This method appends system-wide selectors (variation and run number) and then constructs a new volume, inserting it into the internal volume map.

Error handling:

  • If the volume name key already exists, the method logs ERR_GVOLUMEALREADYPRESENT.
  • If the parameter vector size is wrong, the volume constructor logs ERR_GWRONGNUMBEROFPARS.

Definition at line 77 of file gsystem.cc.

◆ addROOTVolume()

void GSystem::addROOTVolume ( const std::string & rootVolumeDefinition)
Parameters
rootVolumeDefinitionThe ROOT/world definition string (solid + parameters + material).

This method is typically called only when the world volume is injected automatically. It creates a top-level volume whose mother marker is MOTHEROFUSALL.

Definition at line 99 of file gsystem.cc.

◆ addVolumeFromFile()

void GSystem::addVolumeFromFile ( const std::string & importType,
const std::string & filename )
Parameters
importTypeImport label (factory-specific).
filenameFull filename (including path) of the imported geometry asset.

This builds a synthetic parameter vector with reasonable defaults and forwards it to addGVolume().

The defaults are chosen so the imported asset is placeable:

  • mother is ROOTWORLDGVOLUMENAME
  • position and rotation are zero
  • material defaults to G4_AIR
  • visibility/style/color are set to visible + simple defaults

Definition at line 113 of file gsystem.cc.

◆ clone()

std::unique_ptr< GSystem > GSystem::clone ( ) const
inline
Returns
A deep-copied system instance.

Definition at line 79 of file gsystem.h.

◆ get_dbhost()

std::string GSystem::get_dbhost ( ) const
inline

Definition at line 114 of file gsystem.h.

◆ getAnnotations()

std::string GSystem::getAnnotations ( ) const
inline

Definition at line 112 of file gsystem.h.

◆ getExperiment()

std::string GSystem::getExperiment ( ) const
inline

Definition at line 111 of file gsystem.h.

◆ getFactoryName()

std::string GSystem::getFactoryName ( ) const
inline

Definition at line 109 of file gsystem.h.

◆ getFilePath()

std::string GSystem::getFilePath ( )
Returns
If path is empty, returns name; otherwise returns path + "/" + name.

This is used primarily by file-based factories to resolve where to search for system resources (e.g. ASCII geometry/material files, CAD directories).

Definition at line 194 of file gsystem.cc.

◆ getGMaterialMap()

const std::map< std::string, std::shared_ptr< GMaterial > > & GSystem::getGMaterialMap ( ) const
inline
Returns
Const reference to the internal material map.

Definition at line 202 of file gsystem.h.

◆ getGVolume()

GVolume * GSystem::getGVolume ( const std::string & volumeName) const
Parameters
volumeNameVolume name key.
Returns
Pointer to the volume if found, otherwise nullptr.

The returned pointer is non-owning and remains valid as long as the system retains the corresponding shared pointer in its volume map.

Definition at line 150 of file gsystem.cc.

◆ getGVolumesMap()

const std::map< std::string, std::shared_ptr< GVolume > > & GSystem::getGVolumesMap ( ) const
inline
Returns
Const reference to the internal volume map.

Definition at line 193 of file gsystem.h.

◆ getMaterialForGVolume()

const GMaterial * GSystem::getMaterialForGVolume ( const std::string & volumeName) const
Parameters
volumeNameName of the volume whose material is requested.
Returns
Pointer to the material if found, otherwise nullptr.

The lookup is performed by:

  • locating the volume in the volume map;
  • extracting its material name;
  • locating the material in the material map.

If the volume exists but the material does not, the method logs ERR_GMATERIALNOTFOUND.

Definition at line 177 of file gsystem.cc.

◆ getName()

std::string GSystem::getName ( ) const
inline

Definition at line 108 of file gsystem.h.

◆ getRunno()

int GSystem::getRunno ( ) const
inline

Definition at line 113 of file gsystem.h.

◆ getVariation()

std::string GSystem::getVariation ( ) const
inline

Definition at line 110 of file gsystem.h.

◆ operator=() [1/2]

GSystem & GSystem::operator= ( const GSystem & )
delete

◆ operator=() [2/2]

GSystem & GSystem::operator= ( GSystem && )
defaultnoexcept

◆ set_dbhost()

void GSystem::set_dbhost ( const std::string & dbh)
inline

This is used by front-ends (e.g. GUI) to override the DB location after construction.

Parameters
dbhNew database host/filename.

Definition at line 134 of file gsystem.h.


The documentation for this class was generated from the following files: