DD4hep  1.34.0
Detector Description Toolkit for High Energy Physics
VolumeBuilder.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_NONE
14 
15 // Framework include files
16 #include <XML/VolumeBuilder.h>
17 #include <XML/Utilities.h>
18 #include <DD4hep/Printout.h>
19 #include <DD4hep/Plugins.h>
20 #include <DD4hep/Detector.h>
22 #include <Math/Polar2D.h>
23 
24 #include <TClass.h>
25 
27 
29 VolumeBuilder::VolumeBuilder(Detector& dsc, xml_h x_parent, SensitiveDetector sd)
30  : description(dsc), x_det(x_parent), sensitive(sd)
31 {
32  if ( x_det ) {
33  name = x_det.nameStr();
34  id = x_det.id();
35  detector = DetElement(name, id);
36  }
38 }
39 
41 std::size_t VolumeBuilder::collectMaterials(xml_h element) {
42  std::size_t len = materials.size();
43  for( xml_coll_t c(element,_U(material)); c; ++c ) {
44  xml_comp_t x_c = c;
45  std::string nam = x_c.nameStr();
46  std::string val = x_c.valueStr();
47  Material mat = description.material(val);
48  materials[nam] = mat;
49  }
50  return materials.size()-len;
51 }
52 
54 void VolumeBuilder::registerShape(const std::string& nam, Solid shape) {
55  auto is = shapes.find(nam);
56  if( is == shapes.end() ) {
57  shapes[nam] = std::make_pair(xml_h(0), shape);
58  return;
59  }
60  except("VolumeBuilder","+++ Shape %s is already known to this builder unit. ",nam.c_str());
61 }
62 
64 void VolumeBuilder::registerVolume(const std::string& nam, Volume volume) {
65  auto is = volumes.find(nam);
66  if( is == volumes.end() ) {
67  printout(debug ? ALWAYS : DEBUG,"VolumeBuilder",
68  "+++ Register volume: %-20s shape:%-24s vis:%s sensitive:%s",
69  nam.c_str(),
70  volume.solid()->IsA()->GetName(),
72  yes_no(volume.isSensitive()));
73  volumes[nam] = std::make_pair(xml_h(0), volume);
74  return;
75  }
76  except("VolumeBuilder","+++ Volume %s is already known to this builder unit. ",nam.c_str());
77 }
78 
80 dd4hep::Volume VolumeBuilder::volume(const std::string& nam) const {
81  auto iv = volumes.find(nam);
82  if( iv == volumes.end() ) {
83  auto ib = vol_veto.find(nam);
84  if( ib != vol_veto.end() ) {
85  // Veto'ed shape. Ignore it.
86  return Volume();
87  }
88  except("VolumeBuilder","+++ Volume %s is not known to this builder unit. ",nam.c_str());
89  }
90  Volume vol = (*iv).second.second;
91  if( !vol.isValid() ) {
92  except("VolumeBuilder","+++ Failed to access volume %s from the local cache.",nam.c_str());
93  }
94  return vol;
95 }
96 
98 dd4hep::Transform3D VolumeBuilder::getTransform(const std::string& nam) const {
99  auto it = transformations.find(nam);
100  if( it == transformations.end() ) {
101  except("VolumeBuilder","+++ Tranformation %s is not known to this builder unit. ",nam.c_str());
102  }
103  return (*it).second.second;
104 }
105 
107 dd4hep::Solid VolumeBuilder::getShape(const std::string& nam) const {
108  auto is = shapes.find(nam);
109  if( is == shapes.end() ) {
110  auto ib = shape_veto.find(nam);
111  if( ib != shape_veto.end() ) {
112  // Veto'ed shape. Ignore it.
113  return Solid();
114  }
115  except("VolumeBuilder","+++ Shape %s is not known to this builder unit. ",nam.c_str());
116  }
117  Solid solid = (*is).second.second;
118  if( !solid.isValid() ) {
119  except("VolumeBuilder","+++ Failed to access shape %s from the local cache.",nam.c_str());
120  }
121  return solid;
122 }
123 
126  xml_comp_t x = handle;
127  xml_attr_t a = handle.attr_nothrow(_U(name));
128  std::string nam;
129  if( a ) {
130  nam = handle.attr<std::string>(a);
131  auto is = shapes.find(nam);
132  if( is != shapes.end() ) {
133  except("VolumeBuilder","+++ The named shape %s is already known to this builder unit. "
134  "Cannot be overridden.",nam.c_str());
135  }
136  }
138  if( !nam.empty() ) {
139  auto iv = shape_veto.find(nam);
140  if( iv != shape_veto.end() ) {
141  return Solid();
142  }
143  }
145  a = handle.attr_nothrow(_U(build));
146  if( a ) {
147  std::string build = handle.attr<std::string>(a);
148  if( !buildMatch(build, buildType) ) {
149  printout(INFO,"VolumeBuilder",
150  "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str());
151  if( !nam.empty() ) shape_veto.emplace(nam);
152  return Solid();
153  }
154  }
156  std::string type = x.attr<std::string>(_U(type));
157  Solid solid = xml::createShape(description, type, x);
158  if( !solid.isValid() ) {
159  except("VolumeBuilder","+++ Failed to create shape %s of type: %s",
160  nam.c_str(), type.c_str());
161  }
163  if( !nam.empty() ) {
164  solid.setName(nam);
165  shapes.emplace(nam,std::make_pair(handle,solid));
166  }
167  printout(debug ? ALWAYS : DEBUG, "VolumeBuilder",
168  "+++ Created shape of type: %s name: %s",type.c_str(), nam.c_str());
169  return solid;
170 }
171 
174  std::size_t len = shapes.size();
175  for( xml_coll_t c(handle,_U(shape)); c; ++c ) {
176  xml_elt_t x = c;
177  std::string nam = x.attr<std::string>(_U(name));
178  auto is = shapes.find(nam);
179  if( is == shapes.end() ) {
181  xml_attr_t x_build = c.attr_nothrow(_U(build));
182  if( x_build ) {
183  std::string build = c.attr<std::string>(x_build);
184  if( !buildMatch(build, buildType) ) {
185  printout(INFO,"VolumeBuilder",
186  "+++ Shape %s does NOT match build requirements. [Ignored]",nam.c_str());
187  shape_veto.emplace(nam);
188  continue;
189  }
190  }
191  std::string type = x.attr<std::string>(_U(type));
192  if( type == "Assembly" ) {
193  continue;
194  }
195  Solid solid = xml::createShape(description, type, c);
196  if( !solid.isValid() ) {
197  except("VolumeBuilder","+++ Failed to create shape %s of type: %s",
198  nam.c_str(), type.c_str());
199  }
200  printout(debug ? ALWAYS : DEBUG,"VolumeBuilder",
201  "+++ Building shape from XML: %s of type: %s",
202  nam.c_str(), solid->IsA()->GetName());
203  shapes.emplace(nam, std::make_pair(c,solid));
204  continue;
205  }
206  except("VolumeBuilder","+++ Shape %s is already known to this builder unit. "
207  "Cannot be overridden.", nam.c_str());
208  }
209  return shapes.size()-len;
210 }
211 
214  std::size_t len = volumes.size();
215  xml_elt_t x_comp(0);
216  for( xml_coll_t c(handle, _U(volume)); c; ++c ) {
217  Solid solid;
218  xml_comp_t x = c;
219  std::string nam = x.attr<std::string>(_U(name));
220  xml_attr_t attr = c.attr_nothrow(_U(build));
222  if( attr ) {
223  std::string build = c.attr<std::string>(attr);
224  if( !buildMatch(build,buildType) ) {
225  printout(INFO,"VolumeBuilder",
226  "+++ Volume %s does NOT match build requirements. [Ignored]",nam.c_str());
227  continue;
228  }
229  }
232  bool is_volume_with_shape = x.child(_U(shape),false) != 0 || c.attr_nothrow(_U(shape)) != 0;
233  if( !is_volume_with_shape ) {
234  is_volume_with_shape = x.child(_U(solid),false) != 0 || c.attr_nothrow(_U(solid)) != 0;
235  }
236  bool is_volume_with_type = c.attr_nothrow(_U(type)) != 0;
237  bool is_assembly = (x.child(_U(assembly),false) != 0 || c.attr_nothrow(_U(assembly)) != 0);
238  if ( is_assembly && ( is_volume_with_shape || is_volume_with_type) ) {
239  printout(ERROR, "VolumeBuilder",
240  "+++ Shape defined, but ignored for ASSEMBLY volume: %s %s",
241  nam.c_str(), "[Inconsistent description]" );
242  }
244  if ( is_assembly || (!is_volume_with_shape && !is_volume_with_type) ) {
245  Assembly vol(nam);
246  Solid sol = vol.solid();
247  xml_elt_t solid_handle(0);
248  if( (solid_handle=x.child(_U(shape), false)) ) {
249  shapes.emplace(nam, std::make_pair(solid_handle,sol));
250  }
251  placeDaughters(detector, vol, x);
252  vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr());
253  volumes.emplace(nam,std::make_pair(c,vol));
254  printout(debug ? ALWAYS : DEBUG,"VolumeBuilder",
255  "+++ Building assembly from XML: %-20s shape:%-24s vis:%s",
256  nam.c_str(), vol->GetShape()->IsA()->GetName(), x.visStr().c_str());
257  buildVolumes(c);
258  continue;
259  }
260  //
261  bool is_sensitive = c.attr_nothrow(_U(sensitive));
263  if( (attr=c.attr_nothrow(_U(type))) ) {
264  std::string typ = c.attr<std::string>(attr);
265  Volume vol = xml::createVolume(description, typ, c);
266  vol.setAttributes(description, x.regionStr(), x.limitsStr(), x.visStr());
267  volumes.emplace(nam,std ::make_pair(c,vol));
269  if( is_sensitive ) {
270  vol.setSensitiveDetector(sensitive);
271  }
272  solid = vol.solid();
273  printout(debug ? ALWAYS : DEBUG, "VolumeBuilder",
274  "+++ Building volume from XML: %-20s shape:%-24s vis:%s sensitive:%s",
275  nam.c_str(), solid->IsA()->GetName(), x.visStr().c_str(),
276  yes_no(is_sensitive));
277  buildVolumes(c);
278  continue;
279  }
280 
282  if( (attr=c.attr_nothrow(_U(shape))) ) {
283  std::string ref = c.attr<std::string>(attr);
284  if( !(solid=getShape(ref)).isValid() ) continue;
285  }
287  else if( (attr=c.attr_nothrow(_U(solid))) ) {
288  std::string ref = c.attr<std::string>(attr);
289  if( !(solid=getShape(ref)).isValid() ) continue;
290  }
292  else if( (x_comp=x.child(_U(shape),false)) ) {
293  if( !(solid=makeShape(x_comp)).isValid() ) continue;
294  }
296  else if( (x_comp=x.child(_U(solid),false)) ) {
297  if( !(solid=makeShape(x_comp)).isValid() ) continue;
298  }
299 
301  if( solid.isValid() ) {
302  Material mat = description.material(x.attr<std::string>(_U(material)));
303  Volume vol(nam, solid, mat);
304  placeDaughters(detector, vol, x);
305  vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr());
306  volumes.emplace(nam,std::make_pair(c,vol));
308  if( is_sensitive ) {
310  }
311  printout(debug ? ALWAYS : DEBUG, "VolumeBuilder",
312  "+++ Building volume from XML: %-20s shape:%-24s vis:%s sensitive:%s",
313  nam.c_str(), solid->IsA()->GetName(), x.visStr().c_str(),
314  yes_no(is_sensitive));
315  buildVolumes(c);
316  continue;
317  }
318  except("VolumeBuilder","+++ Failed to create volume %s - "
319  "It is neither Volume nor assembly....", nam.c_str());
320  }
321  return volumes.size()-len;
322 }
323 
326  xml_attr_t attr = c.attr_nothrow(_U(logvol));
327  if( !attr ) {
328  attr = c.attr_nothrow(_U(volume));
329  }
330  if( !attr ) {
331  except("VolumeBuilder","+++ The xml volume element has no 'logvol' or 'volume' attribute!");
332  }
333  std::string nam = c.attr<std::string>(attr);
334  if( vol_veto.find(nam) != vol_veto.end() ) {
335  return;
336  }
337  auto iv = volumes.find(nam);
338  if( iv == volumes.end() ) {
339  except("VolumeBuilder",
340  "+++ Failed to locate volume %s [typo somewhere in the XML?]",
341  nam.c_str());
342  }
343  PlacedVolume pv;
344  Volume daughter = (*iv).second.second;
345  attr = c.attr_nothrow(_U(transformation));
346  if( attr ) {
347  std::string tr_nam = c.attr<std::string>(attr);
348  auto it = transformations.find(tr_nam);
349  if( it == transformations.end() ) {
350  except("VolumeBuilder",
351  "+++ Failed to locate name transformation %s [typo in the XML?]",
352  nam.c_str());
353  }
354  const Transform3D& tr = (*it).second.second;
355  pv = vol.placeVolume(daughter, tr);
356  }
357  else {
359  pv = vol.placeVolume(daughter, tr);
360  }
361  xml_attr_t attr_nam = c.attr_nothrow(_U(name));
362  if( attr_nam ) {
363  std::string phys_nam = c.attr<std::string>(attr_nam);
364  pv->SetName(phys_nam.c_str());
365  }
366  attr = c.attr_nothrow(_U(element));
367  if( attr && !parent.isValid() ) {
368  except("VolumeBuilder",
369  "+++ Failed to set DetElement placement for volume %s [Invalid parent]",
370  nam.c_str());
371  }
372  else if( attr ) {
373  int elt_id = parent.id();
374  std::string elt = c.attr<std::string>(attr);
375  attr = c.attr_nothrow(_U(id));
376  if( attr ) {
377  elt_id = c.attr<int>(attr);
378  elt += c.attr<std::string>(attr);
379  }
380  DetElement de(parent, elt, elt_id);
381  de.setPlacement(pv);
382  placeDaughters(de, daughter, c);
383  }
384  else {
385  placeDaughters(parent, daughter, c);
386  }
387 }
388 
391  xml_attr_t attr_tr, attr_elt, attr_nam;
392  xml_h x_phys = c.child(_U(physvol));
393  xml_attr_t attr = x_phys.attr_nothrow(_U(logvol));
394  if( !attr ) {
395  attr = x_phys.attr_nothrow(_U(volume));
396  }
397  if( !attr ) {
398  except("VolumeBuilder","+++ The xml volume element has no 'logvol' or 'volume' attribute!");
399  }
400  std::string nam = x_phys.attr<std::string>(attr);
401  if( vol_veto.find(nam) != vol_veto.end() ) {
402  return;
403  }
404  auto iv = volumes.find(nam);
405  if( iv == volumes.end() ) {
406  except("VolumeBuilder",
407  "+++ Failed to locate volume %s [typo somewhere in the XML?]",
408  nam.c_str());
409  }
410  attr_elt = c.attr_nothrow(_U(element));
411  if( attr_elt && !parent.isValid() ) {
412  except("VolumeBuilder",
413  "+++ Failed to set DetElement placement for volume %s [Invalid parent]",
414  nam.c_str());
415  }
416  Volume daughter = (*iv).second.second;
417  attr_tr = c.attr_nothrow(_U(transformation));
418  Transform3D tr;
419  if( attr_tr ) {
420  std::string tr_nam = c.attr<std::string>(attr_tr);
421  auto it = transformations.find(tr_nam);
422  if( it == transformations.end() ) {
423  except("VolumeBuilder",
424  "+++ Failed to locate name transformation %s "
425  "[typo somewhere in the XML?]",
426  nam.c_str());
427  }
428  tr = (*it).second.second;
429  }
430  else {
432  }
433  Transform3D transformation(Position(0,0,0));
434  int elt_id = -1;
435  std::string elt, phys_nam;
436  attr_nam = x_phys.attr_nothrow(_U(name));
437  if( attr_nam ) {
438  phys_nam = x_phys.attr<std::string>(_U(name))+"_%d";
439  }
440  if( attr_elt ) {
441  elt_id = parent.id();
442  elt = c.attr<std::string>(attr_elt);
443  }
444  int number = c.attr<int>(_U(number));
445  printout(debug ? ALWAYS : DEBUG,"VolumeBuilder","+++ Mother:%s place volume %s %d times.",
446  vol.name(), daughter.name(), number);
447  for(int i=0; i<number; ++i) {
448  PlacedVolume pv = vol.placeVolume(daughter, transformation);
449  if( attr_nam ) {
450  //pv->SetName(_toStd::String(i,phys_nam.c_str()).c_str());
451  }
452  if( attr_elt ) {
453  DetElement de(parent,elt,elt_id);
454  de.setPlacement(pv);
455  //placeDaughters(de, daughter, c);
456  }
457  else {
458  //placeDaughters(parent, daughter, c);
459  }
460  transformation *= tr;
461  }
462 }
463 
465 std::size_t VolumeBuilder::load(xml_h element, const std::string& tag) {
466  std::size_t count = 0;
467  for( xml_coll_t c(element,Unicode(tag)); c; ++c ) {
468  std::string ref = c.attr<std::string>(_U(ref));
469  std::unique_ptr<xml::DocumentHolder> doc(new xml::DocumentHolder(xml::DocumentHandler().load(element, c.attr_value(_U(ref)))));
470  xml_h vols = doc->root();
471  printout(debug ? ALWAYS : DEBUG, "VolumeBuilder",
472  "++ Processing xml document %s.", doc->uri().c_str());
473  included_docs[ref] = std::unique_ptr<xml::DocumentHolder>(doc.release());
474  buildShapes(vols);
475  buildTransformations(vols);
476  buildVolumes(vols);
477  ++count;
478  }
479  return count;
480 }
481 
484  DetElement null_de;
485  return placeDaughters(null_de, vol, handle);
486 }
487 
490  for( xml_coll_t c(handle,_U(physvol)); c; ++c )
491  _placeSingleVolume(parent, vol, c);
492  for( xml_coll_t c(handle,_U(paramphysvol)); c; ++c )
493  _placeParamVolumes(parent, vol, c);
494  return *this;
495 }
496 
499  std::size_t len = transformations.size();
500  for( xml_coll_t c(handle,_U(transformation)); c; ++c ) {
501  std::string nam = xml_comp_t(c).nameStr();
502  transformations.emplace(nam,std::make_pair(c,xml::createTransformation(c)));
503  }
504  return transformations.size() - len;
505 }
506 
509  return placeDetector(vol, x_det);
510 }
511 
514  xml_comp_t x = handle;
515  xml_dim_t x_pos = x_det.child(_U(position),false);
516  xml_dim_t x_rot = x_det.child(_U(rotation),false);
517  xml_dim_t x_tr = x_det.child(_U(transformation),false);
519  PlacedVolume pv;
520 
521  if( x_tr ) {
523  pv = mother.placeVolume(vol, tr);
524  }
525  else if( x_pos && x_rot ) {
527  pv = mother.placeVolume(vol, tr);
528  }
529  else if( x_pos ) {
530  pv = mother.placeVolume(vol, Position(x_pos.x(0),x_pos.y(0),x_pos.z(0)));
531  }
532  else {
533  pv = mother.placeVolume(vol);
534  }
535  vol.setVisAttributes(description, x.visStr());
536  vol.setLimitSet(description, x.limitsStr());
537  vol.setRegion(description, x.regionStr());
538  if( detector.isValid() ) {
540  }
541  return pv;
542 }
543 
544 #endif
dd4hep::xml::tools::VolumeBuilder::description
Detector & description
Definition: VolumeBuilder.h:149
dd4hep::xml::Collection_t
Class to support the access to collections of XmlNodes (or XmlElements)
Definition: XMLElements.h:636
dd4hep::xml::tools::VolumeBuilder::vol_veto
std::set< std::string > vol_veto
Definition: VolumeBuilder.h:160
dd4hep::Volume::setLimitSet
const Volume & setLimitSet(const Detector &description, const std::string &name) const
Set the limits to the volume. Note: If the name string is empty, the action is ignored.
Definition: Volumes.cpp:1290
dd4hep::xml::tools::VolumeBuilder
Helper class to build volume and shapes according to ertain patterns in the XML tree.
Definition: VolumeBuilder.h:140
dd4hep::xml::tools::VolumeBuilder::volume
Volume volume(const std::string &nam) const
Access a registered volume by name.
Definition: VolumeBuilder.cpp:80
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:43
Detector.h
dd4hep::xml::tools::VolumeBuilder::shape_veto
std::set< std::string > shape_veto
Definition: VolumeBuilder.h:160
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:164
dd4hep::xml::tools::VolumeBuilder::volumes
Volumes volumes
Definition: VolumeBuilder.h:157
dd4hep::xml::tools::VolumeBuilder::x_det
xml_det_h x_det
Definition: VolumeBuilder.h:150
dd4hep::xml::tools::VolumeBuilder::buildVolumes
size_t buildVolumes(Handle_t handle)
Build all <volume> identifiers in the passed parent xml element.
Definition: VolumeBuilder.cpp:213
dd4hep::Volume::solid
Solid solid() const
Access to Solid (Shape)
Definition: Volumes.cpp:1252
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:126
dd4hep::Volume::setRegion
const Volume & setRegion(const Detector &description, const std::string &name) const
Set the regional attributes to the volume. Note: If the name string is empty, the action is ignored.
Definition: Volumes.cpp:1271
dd4hep::xml::tools::VolumeBuilder::name
std::string name
Definition: VolumeBuilder.h:152
dd4hep::Detector::pickMotherVolume
virtual Volume pickMotherVolume(const DetElement &sd) const =0
Access mother volume by detector element.
dd4hep::Solid_type< TGeoShape >
dd4hep::xml::tools::VolumeBuilder::buildType
DetectorBuildType buildType
Definition: VolumeBuilder.h:155
dd4hep::xml::Handle_t
Class to easily access the properties of single XmlElements.
Definition: XMLElements.h:380
dd4hep::xml::tools::VolumeBuilder::makeShape
Solid makeShape(Handle_t handle)
Create a new shape from the information given in the xml handle.
Definition: VolumeBuilder.cpp:125
dd4hep::Volume::isSensitive
bool isSensitive() const
Accessor if volume is sensitive (ie. is attached to a sensitive detector)
Definition: Volumes.cpp:1322
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::Assembly
Implementation class extending the ROOT assembly volumes (TGeoVolumeAssembly)
Definition: Volumes.h:762
dd4hep::Volume::placeVolume
PlacedVolume placeVolume(const Volume &volume) const
Place daughter volume. The position and rotation are the identity.
Definition: Volumes.cpp:859
dd4hep::xml::tools::VolumeBuilder::shapes
Shapes shapes
Definition: VolumeBuilder.h:156
xml_attr_t
dd4hep::xml::Attribute xml_attr_t
Definition: XML.h:27
xml_comp_t
dd4hep::xml::Component xml_comp_t
Definition: XML.h:33
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:271
dd4hep::xml::tools::VolumeBuilder::detector
DetElement detector
Definition: VolumeBuilder.h:153
dd4hep::xml::tools::VolumeBuilder::placeDetector
PlacedVolume placeDetector(Volume vol)
Place the detector object into the mother volume returned by the Detector instance.
Definition: VolumeBuilder.cpp:508
dd4hep::Detector::material
virtual Material material(const std::string &name) const =0
Retrieve a matrial by its name from the detector description.
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:371
dd4hep::Volume::setSensitiveDetector
const Volume & setSensitiveDetector(const SensitiveDetector &obj) const
Assign the sensitive detector structure.
Definition: Volumes.cpp:1309
dd4hep::xml::tools::VolumeBuilder::collectMaterials
size_t collectMaterials(Handle_t element)
Collect a set of materials from the leafs of an xml tag.
Definition: VolumeBuilder.cpp:41
dd4hep::xml::tools::VolumeBuilder::_placeParamVolumes
void _placeParamVolumes(DetElement de, Volume vol, Handle_t c)
Place parametrized volumes.
Definition: VolumeBuilder.cpp:390
dd4hep::xml::Handle_t::attr_value
const XmlChar * attr_value(const Attribute attr) const
Access attribute value by the attribute (throws exception if not present)
Definition: XMLElements.cpp:867
dd4hep::xml::Element::child
Handle_t child(const Strng_t &tag_value, bool except=true) const
Access child by tag name. Thow an exception if required in case the child is not present.
Definition: XMLElements.h:914
dd4hep::xml::tools::VolumeBuilder::registerVolume
void registerVolume(const std::string &nam, Volume volume)
Register volume to map.
Definition: VolumeBuilder.cpp:64
dd4hep::xml::createShape
Solid createShape(Detector &description, const std::string &shape_type, xml::Element element)
Create a solid shape using the plugin mechanism from the attributes of the XML element.
Definition: Utilities.cpp:84
Unicode
dd4hep::xml::Strng_t Unicode
Definition: XML.h:24
dd4hep::xml::tools::VolumeBuilder::placeDaughters
VolumeBuilder & placeDaughters(Volume vol, Handle_t handle)
Build all <physvol> identifiers as PlaceVolume daughters. Ignores structure.
Definition: VolumeBuilder.cpp:483
_U
#define _U(a)
Definition: Tags.h:23
dd4hep::xml::tools::VolumeBuilder::included_docs
std::map< std::string, std::unique_ptr< xml::DocumentHolder > > included_docs
Definition: VolumeBuilder.h:148
Plugins.h
dd4hep::buildMatch
bool buildMatch(const std::string &value, DetectorBuildType match)
Check if a build type matches the current.
Definition: BuildType.cpp:79
dd4hep::xml::tools::VolumeBuilder::sensitive
SensitiveDetector sensitive
Definition: VolumeBuilder.h:154
dd4hep::xml::tools::VolumeBuilder::_placeSingleVolume
void _placeSingleVolume(DetElement de, Volume vol, Handle_t c)
Place single volumes.
Definition: VolumeBuilder.cpp:325
VolumeBuilder.h
dd4hep::xml::DocumentHolder
Class supporting the basic functionality of an XML document including ownership.
Definition: XMLElements.h:741
dd4hep::xml::Handle_t::child
Handle_t child(const XmlChar *tag, bool throw_exception=true) const
Access a single child by its tag name (unicode)
Definition: XMLElements.cpp:713
dd4hep::xml::tools::VolumeBuilder::debug
bool debug
Definition: VolumeBuilder.h:161
dd4hep::DetElement::setPlacement
DetElement & setPlacement(const PlacedVolume &volume)
Set the physical volumes of the detector element.
Definition: DetElement.cpp:330
dd4hep::Transform3D
ROOT::Math::Transform3D Transform3D
Definition: Objects.h:116
dd4hep::xml::tools::VolumeBuilder::load
size_t load(Handle_t element, const std::string &tag)
Load include tags contained in the passed XML handle.
Definition: VolumeBuilder.cpp:465
xml_h
dd4hep::xml::Handle_t xml_h
Definition: ConditionsRepository.cpp:32
dd4hep::xml::tools::VolumeBuilder::getShape
Solid getShape(const std::string &nam) const
Access element from shape cache by name. Invalid returns means 'veto'. Otherwise exception.
Definition: VolumeBuilder.cpp:107
dd4hep::Position
ROOT::Math::XYZVector Position
Definition: Objects.h:80
DetFactoryHelper.h
dd4hep::xml::createVolume
Volume createVolume(Detector &description, const std::string &type, xml::Element element)
Create a volume using the plugin mechanism from the attributes of the XML element.
Definition: Utilities.cpp:197
dd4hep::Detector::buildType
virtual DetectorBuildType buildType() const =0
Access flag to steer the detail of building of the geometry/detector description.
dd4hep::xml::DocumentHandler
Class supporting to read and parse XML documents.
Definition: DocumentHandler.h:39
dd4hep::xml::tools::VolumeBuilder::transformations
Transformations transformations
Definition: VolumeBuilder.h:159
dd4hep::xml::tools::VolumeBuilder::getTransform
Transform3D getTransform(const std::string &nam) const
Access element from transformation cache by name.
Definition: VolumeBuilder.cpp:98
dd4hep::xml::Element
User abstraction class to manipulate XML elements within a document.
Definition: XMLElements.h:769
dd4hep::Volume::setVisAttributes
const Volume & setVisAttributes(const VisAttr &obj) const
Set Visualization attributes to the volume.
Definition: Volumes.cpp:1156
dd4hep::Solid
Solid_type< TGeoShape > Solid
Definition: Shapes.h:198
dd4hep::xml::tools::VolumeBuilder::materials
Materials materials
Definition: VolumeBuilder.h:158
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::xml::tools::VolumeBuilder::buildShapes
size_t buildShapes(Handle_t handle)
Build all <shape> identifiers in the passed parent xml element.
Definition: VolumeBuilder.cpp:173
dd4hep::DetElement::id
int id() const
Get the detector identifier.
Definition: DetElement.cpp:169
dd4hep::xml::createTransformation
Transform3D createTransformation(xml::Element element)
Create layered transformation from xml information.
Definition: Utilities.cpp:42
dd4hep::Volume::setAttributes
const Volume & setAttributes(const Detector &description, const std::string &region, const std::string &limits, const std::string &vis) const
Attach attributes to the volume.
Definition: Volumes.cpp:1229
dd4hep::Volume::visAttributes
VisAttr visAttributes() const
Access the visualisation attributes.
Definition: Volumes.cpp:1239
dd4hep::xml::Handle_t::attr
T attr(const Attribute a) const
Access typed attribute value by the XmlAttr.
Definition: XMLElements.h:454
Printout.h
dd4hep::xml::tools::VolumeBuilder::DetElement
::dd4hep::DetElement DetElement
Definition: VolumeBuilder.h:142
xml_dim_t
dd4hep::xml::Dimension xml_dim_t
Definition: XML.h:31
dd4hep::xml::tools::VolumeBuilder::registerShape
void registerShape(const std::string &nam, Solid shape)
Register shape to map.
Definition: VolumeBuilder.cpp:54
dd4hep::xml::tools::VolumeBuilder::buildTransformations
size_t buildTransformations(Handle_t handle)
Build all <transformation> identifiers in the passed parent xml element.
Definition: VolumeBuilder.cpp:498
Utilities.h
dd4hep::xml::Element::attr
T attr(const XmlAttr *att) const
Access attribute with implicit return type conversion.
Definition: XMLElements.h:851
handle
void handle(const O *o, const C &c, F pmf)
Definition: LCDDConverter.cpp:1104
dd4hep::xml::Handle_t::attr_nothrow
Attribute attr_nothrow(const XmlChar *tag) const
Access attribute pointer by the attribute's unicode name (no exception thrown if not present)
Definition: XMLElements.cpp:671