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;
43 rot.GetComponents(matrix.begin());
44 for (
double val : matrix) {
45 std::ostringstream numStream;
46 numStream << std::fixed << std::setprecision(7);
48 hashVal += numStream.str();
55 m_name = path.filename().substr(0, path.filename().rfind(
'.'));
62 "+++ Current namespace is now: %s",
68 m_name = path.filename().substr(0, path.filename().rfind(
'.'));
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) {
112 idq = val.find(
']', idx);
114 if (idp == string::npos || idp > idq)
116 else if (idp != string::npos && idp < idq)
125 return name.substr(0, idx);
132 return name.substr(idx + 1);
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;
188 else if (name ==
"NULL")
190 else if (name.find(
":NULL") == name.length() - 5)
199 throw runtime_error(
"Unknown rotation identifier:" + name);
204 dd4hep::Solid
s = vol.solid();
205 dd4hep::Material
m = vol.material();
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();
224 dd4hep::Material
m = vol.material();
226 const char* solidName =
"Invalid solid";
228 solidName = s.name();
231 "+++ Add volume:%-38s as [%s] Solid:%-26s[%-16s] Material:%s",
241 string n = assembly.name();
252 string n =
prepend(assembly.name());
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>();
355 auto n = result.find(
':');
356 if (
n == std::string::npos) {
359 return result.substr(
n + 1);
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
std::unordered_map< std::string, std::vector< double >> DDVectorsMap
std::string rotHash(const Double_t *rot)
const std::string & ns() const
dd4hep::Volume volume(const std::string &name, bool exc=true) const
std::unordered_map< std::string, dd4hep::Volume > volumes
const edm::EventSetup & c
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
dd4hep::Assembly addAssembly(dd4hep::Assembly asmb, bool addSolid=true) const
std::unordered_map< std::string, std::string > rotRevMap
dd4hep::Volume addVolume(dd4hep::Volume vol) const
dd4hep::Solid solid(const std::string &name) const
std::string_view name() const
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
static std::string nsName(const std::string &)
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
std::string realName(const std::string &) const
if(conf_.getParameter< bool >("UseStripCablingDB"))
static std::string objName(const std::string &)
dd4hep::Material material(const std::string &name) const
std::vector< double > vecDbl(const std::string &name) const
std::unordered_map< std::string, dd4hep::Solid > shapes
DDParsingContext * m_context
std::string prepend(const std::string &) const
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
std::vector< std::string > namespaces
double roundBinary(double value)
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
std::unordered_map< std::string, dd4hep::Assembly > assemblies
std::vector< float > vecFloat(const std::string &name) const
dd4hep::Assembly addAssemblySolid(dd4hep::Assembly assembly) const
const dd4hep::Rotation3D & rotation(const std::string &name) const
dd4hep::Detector & description
std::unordered_set< std::string > assemblySolids
dd4hep::Assembly assembly(const std::string &name, bool exception=true) const
void addConstant(const std::string &name, const std::string &value, const std::string &type) const
dd4hep::tools::Evaluator & evaluator()