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 const std::string& notes)
72 log->
info(1,
"Instantiating GSystem <", name,
"> using factory <", factoryName,
">");
75 log->
info(1,
"Instantiating GSystem <", name,
"> using path <", path,
"> ",
76 "and factory <", factoryName,
">");
82 return std::make_shared<GSystem>(gopts, dbhost,
getFilePath(), factoryName, experiment, runno, variation,
92 pars.emplace_back(variation);
93 pars.emplace_back(std::to_string(runno));
95 std::string volume_name = pars[0];
98 if (gvolumesMap.find(volume_name) == gvolumesMap.end()) {
100 gvolumesMap[volume_name] = std::make_shared<GVolume>(
log, name, pars);
101 log->
info(1,
"Adding gVolume <" + volume_name +
"> to gvolumesMap.");
102 log->
info(2, *gvolumesMap[volume_name]);
106 "gVolume <" + volume_name +
"> already exists in gvolumesMap.");
113 log->
warning(
"Adding ROOT volume using <" + rootVolumeDefinition +
"> to gvolumesMap.");
123namespace fs = std::filesystem;
127 std::vector<std::string> pars;
131 fs::path(filename).filename().
string(),
135 const std::string& gvolumeName = gvpaths.front();
139 pars.emplace_back(gvolumeName);
140 pars.emplace_back(importType);
142 pars.emplace_back(
"G4_AIR");
144 pars.emplace_back(
"0*cm, 0*cm, 0*cm");
145 pars.emplace_back(
"0*deg, 0*deg, 0*deg");
148 pars.emplace_back(
"1");
149 pars.emplace_back(
"1");
150 pars.emplace_back(
"999999");
151 pars.emplace_back(
"1");
157 pars.emplace_back(
"1");
158 pars.emplace_back(filename);
166 auto it = gvolumesMap.find(volumeName);
167 if (it != gvolumesMap.end())
168 return it->second.get();
177 std::string materialName = pars[0];
179 if (gmaterialsMap.find(materialName) == gmaterialsMap.end()) {
180 gmaterialsMap[materialName] = std::make_shared<GMaterial>(name, pars,
log);
181 log->
info(1,
"Adding gMaterial <" + materialName +
"> to gmaterialsMap.");
182 log->
info(2, *gmaterialsMap[materialName]);
186 "gMaterial <" + materialName +
"> already exists in gmaterialsMap.");
195 std::string mirrorName = pars[0];
197 if (gmirrorsMap.find(mirrorName) == gmirrorsMap.end()) {
198 gmirrorsMap[mirrorName] = std::make_shared<GMirror>(name, pars,
log);
199 log->
info(1,
"Adding gMirror <" + mirrorName +
"> to gmirrorsMap.");
200 log->
info(2, *gmirrorsMap[mirrorName]);
204 "gMirror <" + mirrorName +
"> already exists in gmirrorsMap.");
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();
228 "gMaterial <" + materialName +
"> not found for volume <" + volumeName +
">");
239 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.
Optical boundary (surface) definition belonging to a detector system.
Represents a single detector system (e.g., calorimeter, tracker).
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.
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.
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.).
Geometry volume record loaded into a GSystem.
Conventions and shared constants for the detector-system module.
#define GSYSTEMSQLITETFACTORYLABEL
#define ERR_GMIRRORALREADYPRESENT
#define DEFAULTG4PLACEMENTTYPE
#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)