CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
cms::DDNamespace Class Reference

#include <DDNamespace.h>

Public Member Functions

dd4hep::Assembly addAssembly (dd4hep::Assembly asmb, bool addSolid=true) const
 
dd4hep::Assembly addAssemblySolid (dd4hep::Assembly assembly) const
 
void addConstant (const std::string &name, const std::string &value, const std::string &type) const
 
void addConstantNS (const std::string &name, const std::string &value, const std::string &type) const
 
void addRotation (const std::string &name, const dd4hep::Rotation3D &rot) const
 
dd4hep::Solid addSolid (const std::string &name, dd4hep::Solid solid) const
 
dd4hep::Solid addSolidNS (const std::string &name, dd4hep::Solid solid) const
 
dd4hep::Volume addVolume (dd4hep::Volume vol) const
 
dd4hep::Volume addVolumeNS (dd4hep::Volume vol) const
 
dd4hep::Assembly assembly (const std::string &name, bool exception=true) const
 
template<typename T >
T attr (xml_elt_t element, const xml_tag_t &name) const
 
template<typename T >
T attr (xml_elt_t element, const xml_tag_t &name, T defaultValue) const
 
DDParsingContext *const context () const
 
 DDNamespace (DDParsingContext *, xml_h)
 
 DDNamespace (DDParsingContext &, xml_h, bool)
 
 DDNamespace (DDParsingContext *)
 
 DDNamespace (DDParsingContext &)
 
 DDNamespace ()=delete
 
 DDNamespace (const DDNamespace &)=delete
 
dd4hep::Material material (const std::string &name) const
 
std::string_view name () const
 
std::string noNamespace (const std::string &) const
 
DDNamespaceoperator= (const DDNamespace &)=delete
 
std::string prepend (const std::string &) const
 
std::string realName (const std::string &) const
 
const dd4hep::Rotation3D & rotation (const std::string &name) const
 
DDParsingContextsetContext ()
 
dd4hep::Solid solid (const std::string &name) const
 
std::vector< double > vecDbl (const std::string &name) const
 
std::vector< float > vecFloat (const std::string &name) const
 
dd4hep::Volume volume (const std::string &name, bool exc=true) const
 
 ~DDNamespace ()
 

Static Public Member Functions

static std::string nsName (const std::string &)
 
static std::string objName (const std::string &)
 

Private Attributes

DDParsingContextm_context = nullptr
 
std::string m_name
 
bool m_pop = false
 

Detailed Description

Definition at line 22 of file DDNamespace.h.

Constructor & Destructor Documentation

◆ DDNamespace() [1/6]

DDNamespace::DDNamespace ( DDParsingContext context,
xml_h  element 
)

Definition at line 53 of file DDNamespace.cc.

References DEBUG, cms::DDParsingContext::debug_namespaces, m_context, m_name, m_pop, NAMESPACE_SEP, cms::DDParsingContext::namespaces, castor_dqm_sourceclient_file_cfg::path, and mps_fire::Path.

53  : m_context(context) {
54  dd4hep::Path path(xml_handler_t::system_path(element));
55  m_name = path.filename().substr(0, path.filename().rfind('.'));
56  if (!m_name.empty())
58  m_context->namespaces.emplace_back(m_name);
59  m_pop = true;
60  dd4hep::printout(m_context->debug_namespaces ? dd4hep::ALWAYS : dd4hep::DEBUG,
61  "DD4CMS",
62  "+++ Current namespace is now: %s",
63  m_name.c_str());
64 }
std::string m_name
Definition: DDNamespace.h:87
DDParsingContext *const context() const
Definition: DDNamespace.h:76
DDParsingContext * m_context
Definition: DDNamespace.h:86
std::vector< std::string > namespaces
#define DEBUG
Definition: DMRChecker.cc:120
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ DDNamespace() [2/6]

DDNamespace::DDNamespace ( DDParsingContext ctx,
xml_h  element,
bool   
)

Definition at line 66 of file DDNamespace.cc.

References DEBUG, cms::DDParsingContext::debug_namespaces, m_context, m_name, m_pop, NAMESPACE_SEP, cms::DDParsingContext::namespaces, castor_dqm_sourceclient_file_cfg::path, and mps_fire::Path.

66  : m_context(&ctx) {
67  dd4hep::Path path(xml_handler_t::system_path(element));
68  m_name = path.filename().substr(0, path.filename().rfind('.'));
69  if (!m_name.empty())
71  m_context->namespaces.emplace_back(m_name);
72  m_pop = true;
73  dd4hep::printout(m_context->debug_namespaces ? dd4hep::ALWAYS : dd4hep::DEBUG,
74  "DD4CMS",
75  "+++ Current namespace is now: %s",
76  m_name.c_str());
77 }
std::string m_name
Definition: DDNamespace.h:87
DDParsingContext * m_context
Definition: DDNamespace.h:86
std::vector< std::string > namespaces
#define DEBUG
Definition: DMRChecker.cc:120
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ DDNamespace() [3/6]

DDNamespace::DDNamespace ( DDParsingContext ctx)

Definition at line 79 of file DDNamespace.cc.

References m_context, m_name, and cms::DDParsingContext::namespaces.

79  : m_context(ctx) {
80  if (!m_context->namespaces.empty())
81  m_name = m_context->namespaces.back();
82 }
std::string m_name
Definition: DDNamespace.h:87
DDParsingContext * m_context
Definition: DDNamespace.h:86
std::vector< std::string > namespaces

◆ DDNamespace() [4/6]

DDNamespace::DDNamespace ( DDParsingContext ctx)

Definition at line 84 of file DDNamespace.cc.

References m_context, m_name, and cms::DDParsingContext::namespaces.

84  : m_context(&ctx) {
85  if (!m_context->namespaces.empty())
86  m_name = m_context->namespaces.back();
87 }
std::string m_name
Definition: DDNamespace.h:87
DDParsingContext * m_context
Definition: DDNamespace.h:86
std::vector< std::string > namespaces

◆ ~DDNamespace()

DDNamespace::~DDNamespace ( )

Definition at line 89 of file DDNamespace.cc.

References DEBUG, cms::DDParsingContext::debug_namespaces, m_context, m_pop, cms::DDParsingContext::namespaces, and cms::DDParsingContext::ns().

89  {
90  if (m_pop) {
91  m_context->namespaces.pop_back();
92  dd4hep::printout(m_context->debug_namespaces ? dd4hep::ALWAYS : dd4hep::DEBUG,
93  "DD4CMS",
94  "+++ Current namespace is now: %s",
95  m_context->ns().c_str());
96  }
97 }
const std::string & ns() const
DDParsingContext * m_context
Definition: DDNamespace.h:86
std::vector< std::string > namespaces
#define DEBUG
Definition: DMRChecker.cc:120

◆ DDNamespace() [5/6]

cms::DDNamespace::DDNamespace ( )
delete

◆ DDNamespace() [6/6]

cms::DDNamespace::DDNamespace ( const DDNamespace )
delete

Member Function Documentation

◆ addAssembly()

dd4hep::Assembly DDNamespace::addAssembly ( dd4hep::Assembly  asmb,
bool  addSolid = true 
) const

Definition at line 240 of file DDNamespace.cc.

References addSolid(), cms::DDParsingContext::assemblies, assembly(), cms::DDParsingContext::assemblySolids, DEBUG, cms::DDParsingContext::debug_volumes, m_context, and dqmiodumpmetadata::n.

Referenced by algorithm().

240  {
241  string n = assembly.name();
243  if (addSolid) { // In algorithms, Assembly solids are not added separately, so add it here
244  m_context->assemblySolids.emplace(n);
245  }
246  dd4hep::printout(
247  m_context->debug_volumes ? dd4hep::ALWAYS : dd4hep::DEBUG, "DD4CMS", "+++ Add assembly: %-38s", n.c_str());
248  return assembly;
249 }
DDParsingContext * m_context
Definition: DDNamespace.h:86
std::unordered_map< std::string, dd4hep::Assembly > assemblies
#define DEBUG
Definition: DMRChecker.cc:120
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:307
std::unordered_set< std::string > assemblySolids
dd4hep::Assembly assembly(const std::string &name, bool exception=true) const
Definition: DDNamespace.cc:259

◆ addAssemblySolid()

dd4hep::Assembly DDNamespace::addAssemblySolid ( dd4hep::Assembly  assembly) const

Definition at line 251 of file DDNamespace.cc.

References assembly(), cms::DDParsingContext::assemblySolids, DEBUG, cms::DDParsingContext::debug_volumes, m_context, dqmiodumpmetadata::n, and prepend().

251  {
252  string n = prepend(assembly.name());
253  m_context->assemblySolids.emplace(n);
254  dd4hep::printout(
255  m_context->debug_volumes ? dd4hep::ALWAYS : dd4hep::DEBUG, "DD4CMS", "+++ Add assembly solid: %-38s", n.c_str());
256  return assembly;
257 }
DDParsingContext * m_context
Definition: DDNamespace.h:86
#define DEBUG
Definition: DMRChecker.cc:120
std::unordered_set< std::string > assemblySolids
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99
dd4hep::Assembly assembly(const std::string &name, bool exception=true) const
Definition: DDNamespace.cc:259

◆ addConstant()

void DDNamespace::addConstant ( const std::string &  name,
const std::string &  value,
const std::string &  type 
) const

Definition at line 136 of file DDNamespace.cc.

References addConstantNS(), name(), prepend(), and heppy_batch::val.

136  {
138 }
void addConstantNS(const std::string &name, const std::string &value, const std::string &type) const
Definition: DDNamespace.cc:144
std::string_view name() const
Definition: DDNamespace.h:79
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99

◆ addConstantNS()

void DDNamespace::addConstantNS ( const std::string &  name,
const std::string &  value,
const std::string &  type 
) const

Definition at line 144 of file DDNamespace.cc.

References HltBtagPostValidation_cff::c, DEBUG, cms::DDParsingContext::debug_constants, cms::DDParsingContext::description, dd4hep::evaluator(), m_context, dqmiodumpmetadata::n, name(), findQualityFiles::v, and heppy_batch::val.

Referenced by addConstant().

144  {
145  const string& v = val;
146  const string& n = name;
147  dd4hep::printout(m_context->debug_constants ? dd4hep::ALWAYS : dd4hep::DEBUG,
148  "DD4CMS",
149  "+++ Add constant object: %-40s = %s [type:%s]",
150  n.c_str(),
151  v.c_str(),
152  type.c_str());
153  const dd4hep::tools::Evaluator& eval(dd4hep::evaluator());
154  bool constExists = eval.findVariable(n);
155  dd4hep::printout(
156  m_context->debug_constants ? dd4hep::ALWAYS : dd4hep::DEBUG, "DD4CMS", "findVariable result = %d", constExists);
157  if (constExists == false) {
158  // Only add it to the dictionary if it is not yet defined
159  dd4hep::_toDictionary(n, v, type);
160  }
162 
163  m_context->description.addConstant(c);
164 }
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
Polynomial< 0 > Constant
Definition: Constant.h:6
#define DEBUG
Definition: DMRChecker.cc:120
dd4hep::Detector & description
dd4hep::tools::Evaluator & evaluator()

◆ addRotation()

void DDNamespace::addRotation ( const std::string &  name,
const dd4hep::Rotation3D &  rot 
) const

Definition at line 170 of file DDNamespace.cc.

References m_context, cms::DDParsingContext::makePayload, dqmiodumpmetadata::n, name(), prepend(), makeMuonMisalignmentScenario::rot, cms::DDParsingContext::rotations, cms::rotation_utils::rotHash(), and cms::DDParsingContext::rotRevMap.

Referenced by cms::rotation_utils::addRotWithNewName(), and OutputDD4hepToDDL::beginRun().

170  {
171  string n = prepend(name);
172  m_context->rotations[n] = rot;
173  if (m_context->makePayload) {
174  string hashVal = cms::rotation_utils::rotHash(rot);
175  if (m_context->rotRevMap.find(hashVal) == m_context->rotRevMap.end()) {
176  // Only set a rotation that is not already in the map
177  m_context->rotRevMap[hashVal] = n;
178  }
179  }
180 }
std::string rotHash(const Double_t *rot)
Definition: DDNamespace.cc:26
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
std::unordered_map< std::string, std::string > rotRevMap
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99

◆ addSolid()

dd4hep::Solid DDNamespace::addSolid ( const std::string &  name,
dd4hep::Solid  solid 
) const

Definition at line 307 of file DDNamespace.cc.

References addSolidNS(), name(), prepend(), and mkfit::Const::sol.

Referenced by addAssembly(), algorithm(), and convert_boolean().

307  {
308  return addSolidNS(prepend(name), sol);
309 }
std::string_view name() const
Definition: DDNamespace.h:79
constexpr float sol
Definition: Config.h:56
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:292
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99

◆ addSolidNS()

dd4hep::Solid DDNamespace::addSolidNS ( const std::string &  name,
dd4hep::Solid  solid 
) const

Definition at line 292 of file DDNamespace.cc.

References DEBUG, cms::DDParsingContext::debug_shapes, m_context, name(), l1trig_cff::shape, cms::DDParsingContext::shapes, and solid().

Referenced by addSolid(), algorithm(), DDHGCalGeom::constructLayers(), HGCalEEAlgo::ConstructLayers(), HGCalEEFileAlgo::HGCalEEFileAlgo(), HGCalHEAlgo::HGCalHEAlgo(), HGCalHEFileAlgo::HGCalHEFileAlgo(), HGCalMixLayer::HGCalMixLayer(), HGCalMixRotatedLayer::HGCalMixRotatedLayer(), HGCalSiliconModule::HGCalSiliconModule(), HGCalSiliconRotatedModule::HGCalSiliconRotatedModule(), HGCalHEFileAlgo::positionMix(), HGCalHEAlgo::positionMix(), HGCalMixLayer::positionMix(), and HGCalMixRotatedLayer::positionMix().

292  {
293  dd4hep::printout(m_context->debug_shapes ? dd4hep::ALWAYS : dd4hep::DEBUG,
294  "DD4CMS",
295  "+++ Add shape of type %s : %s",
296  solid->IsA()->GetName(),
297  name.c_str());
298 
299  auto shape = m_context->shapes.emplace(name, solid.setName(name));
300  if (!shape.second) {
301  m_context->shapes[name] = solid.setName(name);
302  }
303 
304  return solid;
305 }
std::string_view name() const
Definition: DDNamespace.h:79
std::unordered_map< std::string, dd4hep::Solid > shapes
DDParsingContext * m_context
Definition: DDNamespace.h:86
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:311
#define DEBUG
Definition: DMRChecker.cc:120

◆ addVolume()

dd4hep::Volume DDNamespace::addVolume ( dd4hep::Volume  vol) const

Definition at line 221 of file DDNamespace.cc.

References DEBUG, cms::DDParsingContext::debug_volumes, visualization-live-secondInstance_cfg::m, m_context, g4SimHits_cfi::Material, dqmiodumpmetadata::n, prepend(), alignCSCRings::s, and cms::DDParsingContext::volumes.

Referenced by algorithm().

221  {
222  string n = prepend(vol.name());
223  dd4hep::Solid s = vol.solid();
224  dd4hep::Material m = vol.material();
225  m_context->volumes[n] = vol;
226  const char* solidName = "Invalid solid";
227  if (s.isValid()) // Protect against seg fault
228  solidName = s.name(); // If Solid is not valid, s.name() will seg fault.
229  dd4hep::printout(m_context->debug_volumes ? dd4hep::ALWAYS : dd4hep::DEBUG,
230  "DD4CMS",
231  "+++ Add volume:%-38s as [%s] Solid:%-26s[%-16s] Material:%s",
232  vol.name(),
233  n.c_str(),
234  solidName,
235  s.type(),
236  m.name());
237  return vol;
238 }
std::unordered_map< std::string, dd4hep::Volume > volumes
DDParsingContext * m_context
Definition: DDNamespace.h:86
#define DEBUG
Definition: DMRChecker.cc:120
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99

◆ addVolumeNS()

dd4hep::Volume DDNamespace::addVolumeNS ( dd4hep::Volume  vol) const

Definition at line 202 of file DDNamespace.cc.

References DEBUG, cms::DDParsingContext::debug_volumes, visualization-live-secondInstance_cfg::m, m_context, g4SimHits_cfi::Material, dqmiodumpmetadata::n, prepend(), alignCSCRings::s, and cms::DDParsingContext::volumes.

Referenced by algorithm(), HCalEndcapAlgo::constructGeneralVolume(), HGCalEEAlgo::ConstructLayers(), HGCalEEFileAlgo::HGCalEEFileAlgo(), HGCalHEAlgo::HGCalHEAlgo(), HGCalHEFileAlgo::HGCalHEFileAlgo(), HGCalMixLayer::HGCalMixLayer(), HGCalMixRotatedLayer::HGCalMixRotatedLayer(), HGCalSiliconModule::HGCalSiliconModule(), HGCalSiliconRotatedModule::HGCalSiliconRotatedModule(), HGCalHEFileAlgo::positionMix(), HGCalHEAlgo::positionMix(), HGCalMixLayer::positionMix(), and HGCalMixRotatedLayer::positionMix().

202  {
203  string n = prepend(vol.name());
204  dd4hep::Solid s = vol.solid();
205  dd4hep::Material m = vol.material();
206  vol->SetName(n.c_str());
207  m_context->volumes[n] = vol;
208  const char* solidName = "Invalid solid";
209  if (s.isValid()) // Protect against seg fault
210  solidName = s.name(); // If Solid is not valid, s.name() will seg fault.
211  dd4hep::printout(m_context->debug_volumes ? dd4hep::ALWAYS : dd4hep::DEBUG,
212  "DD4CMS",
213  "+++ Add volumeNS:%-38s Solid:%-26s[%-16s] Material:%s",
214  vol.name(),
215  solidName,
216  s.type(),
217  m.name());
218  return vol;
219 }
std::unordered_map< std::string, dd4hep::Volume > volumes
DDParsingContext * m_context
Definition: DDNamespace.h:86
#define DEBUG
Definition: DMRChecker.cc:120
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99

◆ assembly()

dd4hep::Assembly DDNamespace::assembly ( const std::string &  name,
bool  exception = true 
) const

Definition at line 259 of file DDNamespace.cc.

References cms::DDParsingContext::assemblies, cppFunctionSkipper::exception, mps_fire::i, m_context, name(), and NAMESPACE_SEP.

Referenced by addAssembly(), addAssemblySolid(), algorithm(), and placeAssembly().

259  {
260  auto i = m_context->assemblies.find(name);
261  if (i != m_context->assemblies.end()) {
262  return (*i).second;
263  }
264  if (name.front() == NAMESPACE_SEP) {
265  i = m_context->assemblies.find(name.substr(1, name.size()));
266  if (i != m_context->assemblies.end())
267  return (*i).second;
268  }
269  if (exception) {
270  throw runtime_error("Unknown assembly identifier: " + name);
271  }
272  dd4hep::Volume nullVol(nullptr);
273  return nullVol;
274 }
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
dd4hep::Volume Volume
std::unordered_map< std::string, dd4hep::Assembly > assemblies
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ attr() [1/2]

template<typename T >
T cms::DDNamespace::attr ( xml_elt_t  element,
const xml_tag_t &  name 
) const
inline

Definition at line 40 of file DDNamespace.h.

References name(), realName(), AlCaHLTBitMon_QueryRunRegistry::string, and heppy_batch::val.

40  {
41  std::string val = realName(element.attr<std::string>(name));
42  element.setAttr(name, val);
43  return element.attr<T>(name);
44  }
std::string realName(const std::string &) const
Definition: DDNamespace.cc:106
std::string_view name() const
Definition: DDNamespace.h:79
long double T

◆ attr() [2/2]

template<typename T >
T cms::DDNamespace::attr ( xml_elt_t  element,
const xml_tag_t &  name,
T  defaultValue 
) const
inline

Definition at line 47 of file DDNamespace.h.

References hltPixelClustersMultiplicity_cfi::defaultValue, name(), realName(), AlCaHLTBitMon_QueryRunRegistry::string, and heppy_batch::val.

47  {
48  if (element.hasAttr(name)) {
49  std::string val = realName(element.attr<std::string>(name));
50  element.setAttr(name, val);
51  return element.attr<T>(name);
52  }
53  return defaultValue;
54  }
std::string realName(const std::string &) const
Definition: DDNamespace.cc:106
std::string_view name() const
Definition: DDNamespace.h:79
long double T

◆ context()

DDParsingContext* const cms::DDNamespace::context ( ) const
inline

Definition at line 76 of file DDNamespace.h.

References m_context.

Referenced by convert_boolean(), placeAssembly(), and cms::DDAlgoArguments::resolveValue().

76 { return m_context; }
DDParsingContext * m_context
Definition: DDNamespace.h:86

◆ material()

dd4hep::Material DDNamespace::material ( const std::string &  name) const

Definition at line 166 of file DDNamespace.cc.

References cms::DDParsingContext::description, m_context, name(), and realName().

Referenced by algorithm(), HCalEndcapAlgo::constructGeneralVolume(), HcalBarrelAlgo::constructInsideDetectors(), HcalBarrelAlgo::constructInsideLayers(), HCalEndcapModuleAlgo::constructInsideModule(), HCalEndcapAlgo::constructInsideModule(), HCalEndcapModuleAlgo::constructInsideModule0(), HCalEndcapAlgo::constructInsideModule0(), HCalEndcapAlgo::constructInsideSector(), DDHGCalGeom::constructLayers(), HGCalEEAlgo::ConstructLayers(), HcalBarrelAlgo::constructMidLayer(), HCalEndcapModuleAlgo::constructScintLayer(), HCalEndcapAlgo::constructScintLayer(), HcalBarrelAlgo::constructSideLayer(), HcalBarrelAlgo::HcalBarrelAlgo(), HGCalEEFileAlgo::HGCalEEFileAlgo(), HGCalHEAlgo::HGCalHEAlgo(), HGCalHEFileAlgo::HGCalHEFileAlgo(), HGCalMixLayer::HGCalMixLayer(), HGCalMixRotatedLayer::HGCalMixRotatedLayer(), HGCalSiliconModule::HGCalSiliconModule(), HGCalSiliconRotatedModule::HGCalSiliconRotatedModule(), HGCalHEFileAlgo::positionMix(), HGCalHEAlgo::positionMix(), HGCalMixLayer::positionMix(), and HGCalMixRotatedLayer::positionMix().

166  {
167  return m_context->description.material(realName(name));
168 }
std::string realName(const std::string &) const
Definition: DDNamespace.cc:106
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
dd4hep::Detector & description

◆ name()

std::string_view cms::DDNamespace::name ( void  ) const
inline

◆ noNamespace()

std::string DDNamespace::noNamespace ( const std::string &  fullName) const

Definition at line 353 of file DDNamespace.cc.

References newFWLiteAna::fullName, dqmiodumpmetadata::n, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by algorithm().

353  {
355  auto n = result.find(':');
356  if (n == std::string::npos) {
357  return result;
358  } else {
359  return result.substr(n + 1);
360  }
361 }

◆ nsName()

string DDNamespace::nsName ( const std::string &  )
static

Definition at line 122 of file DDNamespace.cc.

References heavyIonCSV_trainingSettings::idx, name(), and NAMESPACE_SEP.

Referenced by algorithm().

122  {
123  size_t idx;
124  if ((idx = name.find(NAMESPACE_SEP)) != string::npos)
125  return name.substr(0, idx);
126  return "";
127 }
std::string_view name() const
Definition: DDNamespace.h:79
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ objName()

string DDNamespace::objName ( const std::string &  )
static

Definition at line 129 of file DDNamespace.cc.

References heavyIonCSV_trainingSettings::idx, name(), and NAMESPACE_SEP.

Referenced by algorithm().

129  {
130  size_t idx;
131  if ((idx = name.find(NAMESPACE_SEP)) != string::npos)
132  return name.substr(idx + 1);
133  return "";
134 }
std::string_view name() const
Definition: DDNamespace.h:79
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ operator=()

DDNamespace& cms::DDNamespace::operator= ( const DDNamespace )
delete

◆ prepend()

string DDNamespace::prepend ( const std::string &  ) const

Definition at line 99 of file DDNamespace.cc.

References m_name, dqmiodumpmetadata::n, and NAMESPACE_SEP.

Referenced by addAssemblySolid(), addConstant(), addRotation(), addSolid(), addVolume(), addVolumeNS(), algorithm(), HCalEndcapAlgo::constructGeneralVolume(), HcalBarrelAlgo::constructInsideDetectors(), HcalBarrelAlgo::constructInsideLayers(), HCalEndcapModuleAlgo::constructInsideModule(), HCalEndcapAlgo::constructInsideModule(), HCalEndcapModuleAlgo::constructInsideModule0(), HCalEndcapAlgo::constructInsideModule0(), HCalEndcapAlgo::constructInsideSector(), DDHGCalGeom::constructLayers(), HGCalEEAlgo::ConstructLayers(), HcalBarrelAlgo::constructMidLayer(), HCalEndcapModuleAlgo::constructScintLayer(), HCalEndcapAlgo::constructScintLayer(), HcalBarrelAlgo::constructSideLayer(), HcalBarrelAlgo::HcalBarrelAlgo(), HGCalEEFileAlgo::HGCalEEFileAlgo(), HGCalHEAlgo::HGCalHEAlgo(), HGCalHEFileAlgo::HGCalHEFileAlgo(), HGCalMixLayer::HGCalMixLayer(), HGCalMixRotatedLayer::HGCalMixRotatedLayer(), HGCalSiliconModule::HGCalSiliconModule(), HGCalSiliconRotatedModule::HGCalSiliconRotatedModule(), HGCalHEFileAlgo::positionMix(), HGCalHEAlgo::positionMix(), HGCalMixLayer::positionMix(), and HGCalMixRotatedLayer::positionMix().

99  {
100  if (strchr(n.c_str(), NAMESPACE_SEP) == nullptr)
101  return m_name + n;
102  else
103  return n;
104 }
std::string m_name
Definition: DDNamespace.h:87
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ realName()

string DDNamespace::realName ( const std::string &  ) const

Definition at line 106 of file DDNamespace.cc.

References heavyIonCSV_trainingSettings::idx, m_name, NAMESPACE_SEP, findQualityFiles::v, and heppy_batch::val.

Referenced by algorithm(), attr(), material(), cms::DDAlgoArguments::resolved_scalar_arg(), and solid().

106  {
107  size_t idx, idq, idp;
108  string val = v;
109  while ((idx = val.find('[')) != string::npos) {
110  val.erase(idx, 1);
111  idp = val.find(NAMESPACE_SEP, idx);
112  idq = val.find(']', idx);
113  val.erase(idq, 1);
114  if (idp == string::npos || idp > idq)
115  val.insert(idx, m_name);
116  else if (idp != string::npos && idp < idq)
117  val[idp] = NAMESPACE_SEP;
118  }
119  return val;
120 }
std::string m_name
Definition: DDNamespace.h:87
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ rotation()

const dd4hep::Rotation3D & DDNamespace::rotation ( const std::string &  name) const

Definition at line 182 of file DDNamespace.cc.

References mps_fire::i, heavyIonCSV_trainingSettings::idx, caHitNtupletGeneratorKernels::if(), m_context, dqmiodumpmetadata::n, name(), NAMESPACE_SEP, and cms::DDParsingContext::rotations.

Referenced by algorithm(), HCalEndcapModuleAlgo::getRotation(), HcalBarrelAlgo::getRotation(), HCalEndcapAlgo::getRotation(), HGCalSiliconModule::HGCalSiliconModule(), and HGCalSiliconRotatedModule::HGCalSiliconRotatedModule().

182  {
183  static const dd4hep::Rotation3D s_null;
184  size_t idx;
185  auto i = m_context->rotations.find(name);
186  if (i != m_context->rotations.end())
187  return (*i).second;
188  else if (name == "NULL")
189  return s_null;
190  else if (name.find(":NULL") == name.length() - 5)
191  return s_null;
192  string n = name;
193  if ((idx = name.find(NAMESPACE_SEP)) != string::npos) {
194  n[idx] = NAMESPACE_SEP;
195  i = m_context->rotations.find(n);
196  if (i != m_context->rotations.end())
197  return (*i).second;
198  }
199  throw runtime_error("Unknown rotation identifier:" + name);
200 }
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ setContext()

DDParsingContext* cms::DDNamespace::setContext ( )
inline

Definition at line 77 of file DDNamespace.h.

References m_context.

77 { return m_context; }
DDParsingContext * m_context
Definition: DDNamespace.h:86

◆ solid()

dd4hep::Solid DDNamespace::solid ( const std::string &  name) const

Definition at line 311 of file DDNamespace.cc.

References mps_fire::i, heavyIonCSV_trainingSettings::idx, caHitNtupletGeneratorKernels::if(), m_context, m_name, dqmiodumpmetadata::n, NAMESPACE_SEP, realName(), and cms::DDParsingContext::shapes.

Referenced by addSolidNS(), algorithm(), DDHGCalGeom::constructLayers(), and convert_boolean().

311  {
312  size_t idx;
313  string n = m_name + nam;
314  auto i = m_context->shapes.find(n);
315  if (i != m_context->shapes.end())
316  return (*i).second;
317  if ((idx = nam.find(NAMESPACE_SEP)) != string::npos) {
318  n = realName(nam);
319  n[idx] = NAMESPACE_SEP;
320  i = m_context->shapes.find(n);
321  if (i != m_context->shapes.end())
322  return (*i).second;
323  }
324  i = m_context->shapes.find(nam);
325  if (i != m_context->shapes.end())
326  return (*i).second;
327  // Register a temporary shape
328  auto tmpShape = m_context->shapes.emplace(nam, dd4hep::Solid(nullptr));
329  return (*tmpShape.first).second;
330 }
std::string realName(const std::string &) const
Definition: DDNamespace.cc:106
std::string m_name
Definition: DDNamespace.h:87
std::unordered_map< std::string, dd4hep::Solid > shapes
DDParsingContext * m_context
Definition: DDNamespace.h:86
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

◆ vecDbl()

std::vector< double > DDNamespace::vecDbl ( const std::string &  name) const

Definition at line 332 of file DDNamespace.cc.

References cms::DDParsingContext::description, m_context, and name().

332  {
333  cms::DDVectorsMap* registry = m_context->description.extension<cms::DDVectorsMap>();
334  auto it = registry->find(name);
335  if (it != registry->end()) {
336  return {begin(it->second), end(it->second)};
337  } else
338  return std::vector<double>();
339 }
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
Definition: DDNamespace.h:20
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
dd4hep::Detector & description

◆ vecFloat()

std::vector< float > DDNamespace::vecFloat ( const std::string &  name) const

Definition at line 341 of file DDNamespace.cc.

References cms::DDParsingContext::description, mps_fire::i, m_context, name(), mps_fire::result, and HcalDetIdTransform::transform().

Referenced by algorithm().

341  {
342  cms::DDVectorsMap* registry = m_context->description.extension<cms::DDVectorsMap>();
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; });
348  return result;
349  } else
350  return std::vector<float>();
351 }
std::unordered_map< std::string, std::vector< double > > DDVectorsMap
Definition: DDNamespace.h:20
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
dd4hep::Detector & description
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ volume()

dd4hep::Volume DDNamespace::volume ( const std::string &  name,
bool  exc = true 
) const

Definition at line 276 of file DDNamespace.cc.

References mps_fire::i, m_context, name(), NAMESPACE_SEP, and cms::DDParsingContext::volumes.

Referenced by algorithm(), DDHGCalGeom::constructLayers(), HcalBarrelAlgo::HcalBarrelAlgo(), HCalEndcapAlgo::HCalEndcapAlgo(), HCalEndcapModuleAlgo::HCalEndcapModuleAlgo(), HGCalEEAlgo::HGCalEEAlgo(), HGCalEEFileAlgo::HGCalEEFileAlgo(), HGCalHEAlgo::HGCalHEAlgo(), HGCalHEFileAlgo::HGCalHEFileAlgo(), HGCalMixLayer::HGCalMixLayer(), HGCalMixRotatedLayer::HGCalMixRotatedLayer(), HGCalSiliconModule::HGCalSiliconModule(), HGCalSiliconRotatedModule::HGCalSiliconRotatedModule(), HGCalMixLayer::positionMix(), HGCalMixRotatedLayer::positionMix(), HGCalEEFileAlgo::positionSensitive(), HGCalSiliconModule::positionSensitive(), HGCalSiliconRotatedModule::positionSensitive(), HGCalEEAlgo::PositionSensitive(), HGCalHEFileAlgo::positionSensitive(), and HGCalHEAlgo::positionSensitive().

276  {
277  auto i = m_context->volumes.find(name);
278  if (i != m_context->volumes.end()) {
279  return (*i).second;
280  }
281  if (name.front() == NAMESPACE_SEP) {
282  i = m_context->volumes.find(name.substr(1, name.size()));
283  if (i != m_context->volumes.end())
284  return (*i).second;
285  }
286  if (exc) {
287  throw runtime_error("Unknown volume identifier:" + name);
288  }
289  return nullptr;
290 }
std::unordered_map< std::string, dd4hep::Volume > volumes
std::string_view name() const
Definition: DDNamespace.h:79
DDParsingContext * m_context
Definition: DDNamespace.h:86
#define NAMESPACE_SEP
Definition: DDNamespace.h:92

Member Data Documentation

◆ m_context

DDParsingContext* cms::DDNamespace::m_context = nullptr
private

◆ m_name

std::string cms::DDNamespace::m_name
private

Definition at line 87 of file DDNamespace.h.

Referenced by DDNamespace(), name(), prepend(), realName(), and solid().

◆ m_pop

bool cms::DDNamespace::m_pop = false
private

Definition at line 88 of file DDNamespace.h.

Referenced by DDNamespace(), and ~DDNamespace().