OMSim
Geant4 for IceCube optical module studies
OMSimInputData Class Reference

Manages the input data, including parsing and storing material properties. More...

Inheritance diagram for OMSimInputData:
[legend]
Collaboration diagram for OMSimInputData:
[legend]

Detailed Description

Extends the functionalities provided by the ParameterTable class. It's dedicated to the specific needs of managing input data related to materials and optical properties.

This class follows a global instance pattern and its lifecycle is managed by OMSimDetectorConstruction. It can be accessed by other classes using OMSimInputData::getInstance(). For example:

G4Material* lWater = OMSimInputData::getInstance().getMaterial("CustomWater"); // Retrieve a Geant4 material by name
G4OpticalSurface* lSurface = OMSimInputData::getInstance().getOpticalSurface("SomeSurfaceName"); // Retrieve an optical surface by name
G4Material * getMaterial(G4String pName)
Retrieves a G4Material based on the given name.
Definition: OMSimInputData.cc:190
static OMSimInputData & getInstance()
Definition: OMSimInputData.cc:169
G4OpticalSurface * getOpticalSurface(G4String pName)
Definition: OMSimInputData.cc:236

(see also Minimal example) This class assumes certain conventions in naming and structuring the input files, which aids in automatically identifying and processing them.

Public Member Functions

G4Material * getMaterial (G4String pName)
 Retrieves a G4Material based on the given name. More...
 
G4OpticalSurface * getOpticalSurface (G4String pName)
 
void searchFolders ()
 Searches through predefined folders for input data files.
 
- Public Member Functions inherited from ParameterTable
template<typename T >
getValue (G4String pKey, G4String pParameter)
 Fetches a value from the table based on a key and parameter. More...
 
G4bool checkIfTreeNameInTable (G4String pKey)
 Checks if a key exists within the table. More...
 
G4bool checkIfKeyInTree (G4String p_treeName, G4String p_key)
 Checks if a specific key exists in a given JSON tree. More...
 
G4double getValueWithUnit (G4String pKey, G4String pParameter)
 Fetches the value associated with a given key and parameter. More...
 
pt::ptree appendAndReturnTree (G4String pFileName)
 
pt::ptree getJSONTree (G4String pKey)
 
template<typename T >
void parseKeyContentToVector (std::vector< T > &pVector, pt::ptree pTree, std::basic_string< char > pKey, G4double pScaling, bool pInverse)
 Parses the content of a JSON subtree into a vector, scaling values if necessary. More...
 
template<typename T >
void parseKeyContentToVector (std::vector< T > &pVector, std::basic_string< char > p_MapKey, std::basic_string< char > pKey, G4double pScaling, bool pInverse)
 Parses the content of a JSON subtree into a vector, scaling values if necessary. More...
 

Static Public Member Functions

static void init ()
 Initializes the global instance of OMSimInputData and calls OMSimInputData::searchFolders to load data. More...
 
static void shutdown ()
 Deletes the global instance of OMSimInputData. More...
 
static OMSimInputDatagetInstance ()
 

Public Attributes

std::map< G4String, G4OpticalSurface * > m_opticalSurfaceMap
 Map that links names with optical surfaces.
 

Private Types

enum class  FileType {
  IceCubeICE , Scintillator , Extra , Table ,
  Surface , Material
}
 

Private Member Functions

FileType getFileType (const std::string &fileName) const
 
 OMSimInputData (const OMSimInputData &)=delete
 
OMSimInputDataoperator= (const OMSimInputData &)=delete
 
void scannDataDirectory ()
 
void processFile (const std::string &filePath, const std::string &fileName)
 Processes a data file based on its name prefix. More...
 

Private Attributes

G4String m_dataDirectory
 The current directory being scanned for data.
 

Static Private Attributes

static const std::unordered_map< std::string, FileType > fileTypePrefixes
 

Member Function Documentation

◆ getInstance()

OMSimInputData & OMSimInputData::getInstance ( )
static
Returns
A reference to the OMSimInputData instance.
Exceptions
std::runtime_errorif accessed before initialization or after shutdown.

◆ getMaterial()

G4Material * OMSimInputData::getMaterial ( G4String  p_name)

Handles both predefined and argument-based materials. For argument materials (prefixed with "arg"), it selects materials based on user-defined indices for glass, gel, and environment. For standard materials, it retrieves from Geant4's material database or NIST manager.

Parameters
pNameMaterial name or argument material key ("argVesselGlass", "argGel", "argWorld").
Returns
Pointer to the requested G4Material, or nullptr if not found.
Note
Uses OMSimCommandArgsTable for argument-based material selection.
Warning
May cause undefined behavior if argument indices are out of bounds.

◆ getOpticalSurface()

G4OpticalSurface * OMSimInputData::getOpticalSurface ( G4String  p_name)

Get a G4OpticalSurface. In order to get custom built materials, method searchFolders() should have already been called.

Parameters
p_namename of the optical surface or argument reflectors "argReflector"
Returns
G4OpticalSurface

◆ init()

void OMSimInputData::init ( )
static

This method is normally called during construction of the base class OMSimDetectorConstruction.

◆ processFile()

void OMSimInputData::processFile ( const std::string &  p_filePath,
const std::string &  p_fileName 
)
private

The function identifies the type of data file based on the prefix of the filename. It then calls the correct extraction method. For 'Surf' prefixed files, it also updates the m_opticalSurfaceMap. For 'pmt_', 'om_', and 'usr_' prefixed files, it invokes directly appendAndReturnTree without any extra parsing into Geant4 objects.

Parameters
p_filePathFull path to the file.
p_fileNameName of the file (without the path).

◆ shutdown()

void OMSimInputData::shutdown ( )
static

This method is normally called in the destructor ~OMSimDetectorConstruction.

Member Data Documentation

◆ fileTypePrefixes

const std::unordered_map< std::string, OMSimInputData::FileType > OMSimInputData::fileTypePrefixes
staticprivate
Initial value:
= {
{"IceCubeICE", FileType::IceCubeICE},
{"Scint", FileType::Scintillator},
{"Extra", FileType::Extra},
{"pmt_", FileType::Table},
{"usr_", FileType::Table},
{"Surf", FileType::Surface}}

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