|
|
Go to the documentation of this file.
3 #include "DD4hep/Path.h"
4 #include "DD4hep/Printout.h"
8 #include <unordered_map>
14 DDNamespace::DDNamespace(
DDParsingContext* context, xml_h element) : m_context(context) {
23 "+++ Current namespace is now: %s",
36 "+++ Current namespace is now: %s",
55 "+++ Current namespace is now: %s",
70 while ((
idx =
val.find(
'[')) != string::npos) {
75 if (idp == string::npos || idp > idq)
77 else if (idp != string::npos && idp < idq)
102 const string&
v =
val;
103 const string&
n =
name;
106 "+++ Add constant object: %-40s = %s [type:%s]",
110 dd4hep::_toDictionary(
n,
v,
type);
126 static const dd4hep::Rotation3D s_null;
133 else if (
name.find(
":NULL") ==
name.length() - 5)
142 throw runtime_error(
"Unknown rotation identifier:" +
name);
147 dd4hep::Solid
s = vol.solid();
149 vol->SetName(
n.c_str());
151 const char* solidName =
"Invalid solid";
153 solidName =
s.name();
156 "+++ Add volumeNS:%-38s Solid:%-26s[%-16s] Material:%s",
167 dd4hep::Solid
s = vol.solid();
170 const char* solidName =
"Invalid solid";
172 solidName =
s.name();
175 "+++ Add volume:%-38s as [%s] Solid:%-26s[%-16s] Material:%s",
202 throw runtime_error(
"Unknown assembly identifier:" +
name);
216 throw runtime_error(
"Unknown volume identifier:" +
name);
224 "+++ Add shape of type %s : %s",
225 solid->IsA()->GetName(),
257 auto tmpShape =
m_context->
shapes.emplace(nam, dd4hep::Solid(
nullptr));
258 return (*tmpShape.first).second;
263 auto it = registry->find(
name);
264 if (it != registry->end()) {
265 return {begin(it->second),
end(it->second)};
267 return std::vector<double>();
272 auto it = registry->find(
name);
273 if (it != registry->end()) {
274 std::vector<float>
result;
276 begin(it->second),
end(it->second), std::back_inserter(
result), [](
double i) ->
float { return (float)i; });
279 return std::vector<float>();
285 if (
n == std::string::npos) {
std::string realName(const std::string &) const
DDParsingContext * m_context
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
void addConstant(const std::string &name, const std::string &value, const std::string &type) const
dd4hep::Solid solid(const std::string &name) const
dd4hep::Material material(const std::string &name) const
std::string noNamespace(const std::string &) const
std::vector< float > vecFloat(const std::string &name) const
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
const std::string & ns() const
static std::string objName(const std::string &)
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
dd4hep::Assembly assembly(const std::string &name) const
std::string prepend(const std::string &) const
dd4hep::Assembly addAssembly(dd4hep::Assembly asmb) const
const dd4hep::Rotation3D & rotation(const std::string &name) const
std::unordered_map< std::string, dd4hep::Solid > shapes
std::unordered_map< std::string, dd4hep::Assembly > assemblies
dd4hep::Volume addVolume(dd4hep::Volume vol) const
Add rotation matrix to current namespace.
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
std::vector< std::string > namespaces
static std::string nsName(const std::string &)
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
std::vector< double > vecDbl(const std::string &name) const
std::unordered_map< std::string, dd4hep::Volume > volumes
std::string_view name() const
dd4hep::Volume volume(const std::string &name, bool exc=true) const
dd4hep::Detector & description
Namespace of DDCMS conversion namespace.