20 factoryName(other.factoryName),
21 experiment(other.experiment),
23 variation(other.variation),
24 annotations(other.annotations) {
28 for (
const auto& [key, volumePtr] : other.gvolumesMap) {
30 gvolumesMap[key] = std::make_shared<GVolume>(*volumePtr);
35 for (
const auto& [key, materialPtr] : other.gmaterialsMap) {
37 gmaterialsMap[key] = std::make_shared<GMaterial>(*materialPtr);
45 const std::string& dbh,
46 const std::string& sname,
47 const std::string& factory,
48 const std::string& exp,
50 const std::string& variation,
51 const std::string& notes)
65 log->
info(1,
"Instantiating GSystem <", name,
"> using factory <", factoryName,
">");
68 log->
info(1,
"Instantiating GSystem <", name,
"> using path <", path,
"> ",
69 "and factory <", factoryName,
">");
79 pars.emplace_back(variation);
80 pars.emplace_back(std::to_string(runno));
82 std::string volume_name = pars[0];
85 if (gvolumesMap.find(volume_name) == gvolumesMap.end()) {
87 gvolumesMap[volume_name] = std::make_shared<GVolume>(
log, name, pars);
88 log->
info(1,
"Adding gVolume <" + volume_name +
"> to gvolumesMap.");
89 log->
info(2, *gvolumesMap[volume_name]);
93 "gVolume <" + volume_name +
"> already exists in gvolumesMap.");
100 log->
warning(
"Adding ROOT volume using <" + rootVolumeDefinition +
"> to gvolumesMap.");
110namespace fs = std::filesystem;
114 std::vector<std::string> pars;
118 fs::path(filename).filename().
string(),
122 const std::string& gvolumeName = gvpaths.front();
126 pars.emplace_back(gvolumeName);
127 pars.emplace_back(importType);
129 pars.emplace_back(
"G4_AIR");
131 pars.emplace_back(
"0*cm, 0*cm, 0*cm");
132 pars.emplace_back(
"0*deg, 0*deg, 0*deg");
134 pars.emplace_back(
"1");
135 pars.emplace_back(
"1");
136 pars.emplace_back(
"999999");
142 pars.emplace_back(
"1");
143 pars.emplace_back(filename);
151 auto it = gvolumesMap.find(volumeName);
152 if (it != gvolumesMap.end())
153 return it->second.get();
162 std::string materialName = pars[0];
164 if (gmaterialsMap.find(materialName) == gmaterialsMap.end()) {
165 gmaterialsMap[materialName] = std::make_shared<GMaterial>(name, pars,
log);
166 log->
info(1,
"Adding gMaterial <" + materialName +
"> to gmaterialsMap.");
167 log->
info(2, *gmaterialsMap[materialName]);
171 "gMaterial <" + materialName +
"> already exists in gmaterialsMap.");
178 auto it = gvolumesMap.find(volumeName);
179 if (it != gvolumesMap.end()) {
180 std::string materialName = it->second->getMaterial();
181 auto matIt = gmaterialsMap.find(materialName);
182 if (matIt != gmaterialsMap.end())
183 return matIt->second.get();
186 "gMaterial <" + materialName +
"> not found for volume <" + volumeName +
">");
197 return path +
"/" + name;
std::shared_ptr< GLogger > log
void warning(Args &&... args) const
void debug(debug_type type, Args &&... args) const
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
Material definition belonging to a detector system.
Represents a single detector system (e.g., calorimeter, tracker).
const GMaterial * getMaterialForGVolume(const std::string &volumeName) const
Retrieve the material associated with a given volume.
void addROOTVolume(const std::string &rootVolumeDefinition)
Adds the special ROOT/world volume to the system.
void addGMaterial(std::vector< std::string > pars)
Build and add a material from a serialized parameter list.
GVolume * getGVolume(const std::string &volumeName) const
Retrieve a volume by name.
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.
void addGVolume(std::vector< std::string > pars)
Build and add a volume from a serialized parameter list.
std::string getFilePath()
Gets the full file path of the system.
void addVolumeFromFile(const std::string &importType, const std::string &filename)
Add a volume imported from a file (CAD, GDML, etc.).
Geometry volume record loaded into a GSystem.
Conventions and shared constants for the detector-system module.
#define GSYSTEMSQLITETFACTORYLABEL
#define ERR_GVOLUMEALREADYPRESENT
#define ROOTWORLDGVOLUMENAME
Canonical name for the ROOT/world gvolume entry.
#define ERR_GMATERIALALREADYPRESENT
#define ERR_GMATERIALNOTFOUND
Option definitions and extraction helpers for the gsystem module.
constexpr const char * GSYSTEM_LOGGER
#define UNINITIALIZEDSTRINGQUANTITY
vector< string > getStringVectorFromStringWithDelimiter(const string &input, const string &x)
string getDirFromPath(const std::string &path)
string getFileFromPath(const std::string &path)