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);
42 for (
const auto& [key, mirrorPtr] : other.gmirrorsMap) {
44 gmirrorsMap[key] = std::make_shared<GMirror>(*mirrorPtr);
52 const std::string& dbh,
53 const std::string& sname,
54 const std::string& factory,
55 const std::string& exp,
57 const std::string& variation,
58 std::optional<std::string> notes)
67 annotations(std::move(notes))
72 log->info(1,
"Instantiating GSystem <%1> using factory <%2>", name, factoryName);
75 log->info(1,
"Instantiating GSystem <%1> using path <%2> and factory <%3>", name, path, factoryName);
81 return std::make_shared<GSystem>(gopts, dbhost,
getFilePath(), factoryName, experiment, runno, variation,
91 pars.emplace_back(variation);
92 pars.emplace_back(std::to_string(runno));
94 std::string volume_name = pars[0];
97 if (!gvolumesMap.contains(volume_name)) {
99 gvolumesMap[volume_name] = std::make_shared<GVolume>(
log, name, pars);
100 log->info(1,
"Adding gVolume <%1> to gvolumesMap.", volume_name);
101 log->info(2,
"%1", *gvolumesMap[volume_name]);
112 log->warning(
"Adding ROOT volume using <%1> to gvolumesMap.", rootVolumeDefinition);
122namespace fs = std::filesystem;
126 std::vector<std::string> pars;
130 fs::path(filename).filename().
string(),
134 const std::string& gvolumeName = gvpaths.front();
138 pars.emplace_back(gvolumeName);
139 pars.emplace_back(importType);
141 pars.emplace_back(
"G4_AIR");
143 pars.emplace_back(
"0*cm, 0*cm, 0*cm");
144 pars.emplace_back(
"0*deg, 0*deg, 0*deg");
147 pars.emplace_back(
"1");
148 pars.emplace_back(
"1");
149 pars.emplace_back(
"999999");
150 pars.emplace_back(
"1");
156 pars.emplace_back(
"1");
157 pars.emplace_back(filename);
165 auto it = gvolumesMap.find(volumeName);
166 if (it != gvolumesMap.end())
167 return it->second.get();
176 std::string materialName = pars[0];
178 if (!gmaterialsMap.contains(materialName)) {
179 gmaterialsMap[materialName] = std::make_shared<GMaterial>(name, pars,
log);
180 log->info(1,
"Adding gMaterial <%1> to gmaterialsMap.", materialName);
181 log->info(2,
"%1", *gmaterialsMap[materialName]);
195 std::string mirrorName = pars[0];
197 if (!gmirrorsMap.contains(mirrorName)) {
198 gmirrorsMap[mirrorName] = std::make_shared<GMirror>(name, pars,
log);
199 log->info(1,
"Adding gMirror <%1> to gmirrorsMap.", mirrorName);
200 log->info(2,
"%1", *gmirrorsMap[mirrorName]);
211 auto it = gmirrorsMap.find(mirrorName);
212 if (it != gmirrorsMap.end())
213 return it->second.get();
220 auto it = gvolumesMap.find(volumeName);
221 if (it != gvolumesMap.end()) {
222 std::string materialName = it->second->getMaterial();
223 auto matIt = gmaterialsMap.find(materialName);
224 if (matIt != gmaterialsMap.end())
225 return matIt->second.get();
240 return path +
"/" + name;
GBase(const std::shared_ptr< GOptions > &gopt, std::string logger_name="")
std::shared_ptr< GLogger > log
Material definition belonging to a detector system.
Optical boundary (surface) definition belonging to a detector system.
std::string getFilePath() const
Gets the full file path of the system.
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.
std::shared_ptr< GSystem > descriptorClone(const std::shared_ptr< GOptions > &gopts) const
Clone only the system selection metadata.
const GMirror * getGMirror(const std::string &mirrorName) const
Retrieve a mirror by name.
void addGVolume(std::vector< std::string > pars)
Build and add a volume from a serialized parameter list.
void addGMirror(std::vector< std::string > pars)
Build and add a mirror (optical surface) 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.).
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, std::optional< std::string > annotations=std::nullopt)
Construct a detector system descriptor.
Geometry volume record loaded into a GSystem.
Conventions and shared constants for the detector-system module.
Option definitions and extraction helpers for the gsystem module.
constexpr const char * GSYSTEM_LOGGER
constexpr int ERR_GVOLUMEALREADYPRESENT
constexpr char DEFAULTG4PLACEMENTTYPE[]
constexpr char GSYSTEMSQLITETFACTORYLABEL[]
constexpr int ERR_GMIRRORALREADYPRESENT
constexpr int ERR_GMATERIALALREADYPRESENT
constexpr int ERR_GMATERIALNOTFOUND
constexpr char ROOTWORLDGVOLUMENAME[]
Canonical name for the ROOT/world gvolume entry.
vector< string > getStringVectorFromStringWithDelimiter(const string &input, const string &x)
string getDirFromPath(const std::string &path)
string getFileFromPath(const std::string &path)
constexpr char SERIALIZED_NULL_TOKEN[]