4 #include "DD4hep/Path.h" 5 #include "DD4hep/Printout.h" 6 #include "Evaluator/Evaluator.h" 12 #include <unordered_map> 20 static constexpr
double roundingVal = 1 << 24;
21 value = (round(
value * roundingVal) / roundingVal);
28 for (
int row = 0; row <= 2; ++row) {
30 std::ostringstream numStream;
31 numStream <<
std::fixed << std::setprecision(7);
33 hashVal += numStream.str();
41 std::vector<double>
matrix;
45 std::ostringstream numStream;
46 numStream <<
std::fixed << std::setprecision(7);
48 hashVal += numStream.str();
62 "+++ Current namespace is now: %s",
75 "+++ Current namespace is now: %s",
94 "+++ Current namespace is now: %s",
107 size_t idx, idq, idp;
109 while ((
idx =
val.find(
'[')) != string::npos) {
114 if (idp == string::npos || idp > idq)
116 else if (idp != string::npos && idp < idq)
145 const string&
v =
val;
146 const string&
n =
name;
149 "+++ Add constant object: %-40s = %s [type:%s]",
154 bool constExists = eval.findVariable(
n);
157 if (constExists ==
false) {
159 dd4hep::_toDictionary(
n,
v,
type);
183 static const dd4hep::Rotation3D s_null;
190 else if (
name.find(
":NULL") ==
name.length() - 5)
199 throw runtime_error(
"Unknown rotation identifier:" +
name);
204 dd4hep::Solid
s = vol.solid();
206 vol->SetName(
n.c_str());
208 const char* solidName =
"Invalid solid";
210 solidName =
s.name();
213 "+++ Add volumeNS:%-38s Solid:%-26s[%-16s] Material:%s",
223 dd4hep::Solid
s = vol.solid();
226 const char* solidName =
"Invalid solid";
228 solidName =
s.name();
231 "+++ Add volume:%-38s as [%s] Solid:%-26s[%-16s] Material:%s",
270 throw runtime_error(
"Unknown assembly identifier: " +
name);
287 throw runtime_error(
"Unknown volume identifier:" +
name);
295 "+++ Add shape of type %s : %s",
296 solid->IsA()->GetName(),
328 auto tmpShape =
m_context->
shapes.emplace(nam, dd4hep::Solid(
nullptr));
329 return (*tmpShape.first).second;
334 auto it = registry->find(
name);
335 if (it != registry->end()) {
336 return {begin(it->second),
end(it->second)};
338 return std::vector<double>();
343 auto it = registry->find(
name);
344 if (it != registry->end()) {
345 std::vector<float>
result;
347 begin(it->second),
end(it->second), std::back_inserter(
result), [](
double i) ->
float { return (float)i; });
350 return std::vector<float>();
356 if (
n == std::string::npos) {
std::string rotHash(const Double_t *rot)
std::unordered_map< std::string, dd4hep::Volume > volumes
const dd4hep::Rotation3D & rotation(const std::string &name) const
const std::string & ns() const
dd4hep::Assembly addAssembly(dd4hep::Assembly asmb, bool addSolid=true) const
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
std::string realName(const std::string &) const
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
std::unordered_map< std::string, std::string > rotRevMap
dd4hep::Material material(const std::string &name) const
std::string noNamespace(const std::string &) const
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
static std::string nsName(const std::string &)
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
std::vector< float > vecFloat(const std::string &name) const
std::string_view name() const
static std::string objName(const std::string &)
dd4hep::Volume addVolume(dd4hep::Volume vol) const
std::unordered_map< std::string, dd4hep::Solid > shapes
DDParsingContext * m_context
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
dd4hep::Solid solid(const std::string &name) const
Namespace of DDCMS conversion namespace.
std::vector< std::string > namespaces
double roundBinary(double value)
dd4hep::Assembly addAssemblySolid(dd4hep::Assembly assembly) const
std::unordered_map< std::string, dd4hep::Assembly > assemblies
dd4hep::Detector & description
void addConstant(const std::string &name, const std::string &value, const std::string &type) const
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
std::unordered_set< std::string > assemblySolids
dd4hep::Volume volume(const std::string &name, bool exc=true) const
std::vector< double > vecDbl(const std::string &name) const
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
std::string prepend(const std::string &) const
dd4hep::tools::Evaluator & evaluator()
dd4hep::Assembly assembly(const std::string &name, bool exception=true) const