DD4hep  1.38.0
Detector Description Toolkit for High Energy Physics
DetectorImp.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 
14 #define DD4HEP_MUST_USE_DETECTORIMP_H 1
15 
16 // Framework include files
17 #include <DD4hep/Plugins.h>
18 #include <DD4hep/Printout.h>
19 #include <DD4hep/GeoHandler.h>
20 #include <DD4hep/DetectorHelper.h>
21 #include <DD4hep/DetectorTools.h>
22 
23 #include <DD4hep/InstanceCount.h>
28 #include <DD4hep/DetectorImp.h>
29 #include <DD4hep/DD4hepUnits.h>
30 
31 // C/C++ include files
32 #include <iostream>
33 #include <stdexcept>
34 #include <cerrno>
35 #include <cstdlib>
36 #include <mutex>
37 
38 // ROOT inlcude files
39 #include <TGeoSystemOfUnits.h>
40 #include <TGeoCompositeShape.h>
41 #include <TGeoBoolNode.h>
42 #include <TGeoManager.h>
43 #include <TGeoMatrix.h>
44 #include <TGeoVolume.h>
45 #include <TGeoShape.h>
46 #include <TClass.h>
47 
48 #include <XML/DocumentHandler.h>
49 
50 #ifndef __TIXML__
51 #include <xercesc/dom/DOMException.hpp>
52 namespace dd4hep {
53  namespace xml {
54  typedef xercesc::DOMException XmlException;
55  }
56 }
57 #endif
58 
59 using namespace dd4hep;
60 
62 
63 namespace {
64 
65  std::recursive_mutex s_detector_apply_lock;
66 
67  struct Instances {
68  std::recursive_mutex lock;
69  std::map<std::string, Detector*> detectors;
70  Detector* get(const std::string& name) {
71  const auto i = detectors.find(name);
72  return i == detectors.end() ? nullptr : (*i).second;
73  }
74  void insert(const std::string& name, Detector* detector) {
75  const auto [_, emplaced] = detectors.emplace(name,detector);
76  if ( !emplaced ) {
77  except("DD4hep","Cannot insert detector instance %s [Already present]",name.c_str());
78  }
79  }
80  Detector* remove(const std::string& name) {
81  const auto it = detectors.find(name);
82  if ( it == detectors.end() )
83  return nullptr;
84  Detector* det = it->second;
85  detectors.erase(it);
86  return det;
87  }
88  };
89 
90  class DetectorGuard final {
91  protected:
92  static std::pair<std::recursive_mutex, std::map<DetectorImp*, TGeoManager*> >& detector_lock() {
93  static std::pair<std::recursive_mutex, std::map<DetectorImp*, TGeoManager*> > s_inst;
94  return s_inst;
95  }
96  DetectorImp* detector {nullptr};
97  public:
98  DetectorGuard(DetectorImp* imp) : detector(imp) {}
99  void lock(TGeoManager* mgr) const {
100  auto& lock = detector_lock();
101  lock.first.lock();
102  lock.second[detector] = mgr;
103  }
104  TGeoManager* unlock() const {
105  TGeoManager* mgr = nullptr;
106  auto& lock = detector_lock();
107  auto i = lock.second.find(detector);
108  if ( i != lock.second.end() ) {
109  mgr = (*i).second;
110  lock.second.erase(i);
111  }
112  lock.first.unlock();
113  return mgr;
114  }
115  };
116 
117  Instances& detector_instances() {
118  static Instances s_inst;
119  return s_inst;
120  }
121 }
122 
123 std::string dd4hep::versionString(){
124  char vsn[32];
125  std::snprintf(vsn, sizeof(vsn), "v%2.2d-%2.2d", DD4HEP_MAJOR_VERSION, DD4HEP_MINOR_VERSION);
126  return { vsn };
127 }
128 
129 std::unique_ptr<Detector> Detector::make_unique(const std::string& name) {
130  return std::unique_ptr<Detector>(new DetectorImp(name));
131 }
132 
133 Detector& Detector::getInstance(const std::string& name) {
134  std::lock_guard<std::recursive_mutex> lock(detector_instances().lock);
135  Detector* description = detector_instances().get(name);
136  if ( !description ) {
137  gGeoManager = nullptr;
138  description = new DetectorImp(name);
139  detector_instances().insert(name,description);
140  }
141  return *description;
142 }
143 
145 void Detector::destroyInstance(const std::string& name) {
146  std::lock_guard<std::recursive_mutex> lock(detector_instances().lock);
147  Detector* description = detector_instances().remove(name);
148  delete description;
149 }
150 
153  : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE)
154 {
157  m_std_conditions.pressure = Pressure_NTP;
158  m_std_conditions.temperature = Temperature_NTP;
159 }
160 
162 DetectorImp::DetectorImp(const std::string& name)
163  : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE)
164 {
165 #if defined(DD4HEP_USE_GEANT4_UNITS)
166  printout(INFO,"DD4hep","++ Using globally Geant4 unit system (mm,ns,MeV)");
167  if ( TGeoManager::GetDefaultUnits() != TGeoManager::kG4Units ) {
168  TGeoManager::LockDefaultUnits(kFALSE);
169  TGeoManager::SetDefaultUnits(TGeoManager::kG4Units);
170  TGeoManager::LockDefaultUnits(kTRUE);
171  }
172 #else
173  if ( TGeoManager::GetDefaultUnits() != TGeoManager::kRootUnits ) {
174  TGeoManager::LockDefaultUnits(kFALSE);
175  TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits);
176  TGeoManager::LockDefaultUnits(kTRUE);
177  }
178 #endif
179 
180  SetName(name.c_str());
181  SetTitle("DD4hep detector description object");
182  //DetectorGuard(this).lock(gGeoManager);
183  gGeoManager = nullptr;
185  m_manager = new TGeoManager(name.c_str(), "Detector Geometry");
186  {
187  m_manager->AddNavigator();
188  m_manager->SetCurrentNavigator(0);
189  gGeoManager = m_manager;
190 #if 1 //FIXME: eventually this should be set to 1 - needs fixes in examples ...
191  TGeoElementTable* table = m_manager->GetElementTable();
192  table->TGeoElementTable::~TGeoElementTable();
193  new(table) TGeoElementTable();
194  // This will initialize the table without filling:
195  table->AddElement("VACUUM","VACUUM", 1, 1, 1e-15);
196 #endif
197  }
198  if ( !gGeoIdentity )
199  {
200  gGeoIdentity = new TGeoIdentity();
201  }
204  m_std_conditions.pressure = Pressure_NTP;
205  m_std_conditions.temperature = Temperature_NTP;
206 
207  VisAttr attr("invisible");
208  attr.setColor(1.0, 0.5, 0.5, 0.5);
211  attr.setVisible(false);
212  attr.setShowDaughters(true);
213  addVisAttribute(attr);
214  m_invisibleVis = attr;
215 }
216 
219  DetectorGuard(this).lock(gGeoManager);
220  if ( m_manager ) {
221  std::lock_guard<std::recursive_mutex> lock(detector_instances().lock);
222  if ( m_manager == gGeoManager ) gGeoManager = nullptr;
223  Detector* description = detector_instances().get(GetName());
224  if ( description ) {
225  detector_instances().remove(m_manager->GetName());
226  }
227  }
228  delete m_surfaceManager;
229  m_surfaceManager = nullptr;
230  destroyData(false);
232  m_detectorTypes.clear();
234  DetectorGuard(this).unlock();
235 }
236 
238 Int_t DetectorImp::saveObject(const char *name, Int_t option, Int_t bufsize) const {
239  Int_t nbytes = 0;
240  try {
241  DetectorData::patchRootStreamer(TGeoVolume::Class());
242  DetectorData::patchRootStreamer(TGeoNode::Class());
243  nbytes = TNamed::Write(name, option, bufsize);
244  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
245  DetectorData::unpatchRootStreamer(TGeoNode::Class());
246  return nbytes;
247  }
248  catch (const std::exception& e) {
249  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
250  DetectorData::unpatchRootStreamer(TGeoNode::Class());
251  except("Detector","Exception %s while saving dd4hep::Detector object", e.what());
252  }
253  catch (...) {
254  DetectorData::unpatchRootStreamer(TGeoVolume::Class());
255  DetectorData::unpatchRootStreamer(TGeoNode::Class());
256  except("Detector","UNKNOWN exception while saving dd4hep::Detector object.");
257  }
258  return nbytes;
259 }
260 
261 // Load volume manager
265 }
266 
268 void* DetectorImp::addUserExtension(unsigned long long int key, ExtensionEntry* entry) {
269  return m_extensions.addExtension(key,entry);
270 }
271 
273 void* DetectorImp::removeUserExtension(unsigned long long int key, bool destroy) {
274  return m_extensions.removeExtension(key,destroy);
275 }
276 
278 void* DetectorImp::userExtension(unsigned long long int key, bool alert) const {
279  return m_extensions.extension(key,alert);
280 }
281 
284  std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock);
286  return temp;
287 }
288 
290 void DetectorImp::declareParent(const std::string& detector_name, const DetElement& parent) {
291  if ( !detector_name.empty() ) {
292  if ( parent.isValid() ) {
293  auto i = m_detectorParents.find(detector_name);
294  if (i == m_detectorParents.end()) {
295  Volume parent_volume = parent.placement().volume();
296  if ( parent_volume.isValid() ) {
297  m_detectorParents.emplace(detector_name,parent);
298  return;
299  }
300  except("DD4hep","+++ Failed to access valid parent volume of %s from %s",
301  detector_name.c_str(), parent.name());
302  }
303  except("DD4hep",
304  "+++ A parent to the detector %s was already registered.",
305  detector_name.c_str());
306  }
307  except("DD4hep",
308  "+++ Attempt to register invalid parent for detector: %s [Invalid-Handle].",
309  detector_name.c_str());
310  }
311  except("DD4hep",
312  "+++ Attempt to register parent to invalid detector [Invalid-detector-name].");
313 }
314 
317  if ( !de.isValid() ) {
318  except("DD4hep","Detector: Attempt to access mother volume of invalid detector [Invalid-handle]");
319  return nullptr;
320  }
321  std::string de_name = de.name();
322  auto i = m_detectorParents.find(de_name);
323  if (i == m_detectorParents.end()) {
324  if ( m_worldVol.isValid() ) {
325  return m_worldVol;
326  }
327  except("DD4hep",
328  "+++ The world volume is not (yet) valid. "
329  "Are you correctly building the detector %s?",
330  de.name());
331  }
332  if ( (*i).second.isValid() ) {
333  Volume vol = (*i).second.volume();
334  if ( vol.isValid() ) {
335  return vol;
336  }
337  }
338  except("DD4hep",
339  "+++ The mother volume of %s is not valid. "
340  "Are you correctly building detectors?",
341  de.name());
342  return nullptr;
343 }
344 
349  {
350  printout(WARNING,"DD4hep","++ STD conditions NOT defined by client. NTP defaults taken.");
352  }
353  return m_std_conditions;
354 }
356 void DetectorImp::setStdConditions(double temp, double pressure) {
358  m_std_conditions.pressure = pressure;
360  if ( std::abs(temp-Temperature_NTP) < 1e-10 && std::abs(pressure-Pressure_NTP) < 1e-10 )
362  else if ( std::abs(temp-Temperature_STP) < 1e-10 && std::abs(pressure-Pressure_STP) < 1e-10 )
364  else
366 }
367 
369 void DetectorImp::setStdConditions(const std::string& type) {
370  if ( type == "STP" ) {
371  m_std_conditions.temperature = Temperature_STP;
372  m_std_conditions.pressure = Pressure_STP;
374  }
375  else if ( type == "NTP" ) {
376  m_std_conditions.temperature = Temperature_NTP;
377  m_std_conditions.pressure = Pressure_NTP;
379  }
380  else {
381  except("DD4hep",
382  "++ Attempt to set standard conditions to "
383  "unknown conventions (Only STP and NTP allowed).");
384  }
385 }
386 
388 DetElement DetectorImp::detector(const std::string& name) const {
389  HandleMap::const_iterator i = m_detectors.find(name);
390  if (i != m_detectors.end()) {
391  return (*i).second;
392  }
393  DetElement de = detail::tools::findElement(*this,name);
394  return de;
395 }
396 
398  DetElement det_element(ref_det);
399  DetectorHelper helper(this);
400  DetElement existing_det = helper.detectorByID(det_element.id());
401 
402  if ( existing_det.isValid() ) {
403  SensitiveDetector sd = helper.sensitiveDetector(existing_det);
404  if ( sd.isValid() ) {
405  std::stringstream str;
406  str << "Detector: The sensitive sub-detectors " << det_element.name() << " and "
407  << existing_det.name() << " have the identical ID:" << det_element.id() << ".";
408  except("DD4hep",str.str());
409  }
410  }
411  m_detectors.append(ref_det);
412  det_element->flag |= DetElement::Object::IS_TOP_LEVEL_DETECTOR;
413  PlacedVolume pv = det_element.placement();
414  if ( !pv.isValid() ) {
415  std::stringstream str;
416  str << "Detector: Adding subdetectors with no valid placement is not allowed: "
417  << det_element.name() << " ID:" << det_element.id() << ".";
418  except("DD4hep",str.str());
419  }
420  Volume volume = pv->GetMotherVolume();
421  if ( volume == m_worldVol ) {
422  printout(DEBUG,"DD4hep","+++ Detector: Added detector %s to the world instance.",
423  det_element.name());
424  m_world.add(det_element);
425  return *this;
426  }
428  auto ipar = m_detectorParents.find(det_element.name());
429  if (ipar != m_detectorParents.end()) {
430  DetElement parent = (*ipar).second;
431  parent.add(det_element);
432  printout(DEBUG,"DD4hep","+++ Detector: Added detector %s to parent %s.",
433  det_element.name(), parent.name());
434  return *this;
435  }
436 
437  // The detector's placement must be one of the existing detectors
438  for(HandleMap::iterator idet = m_detectors.begin(); idet != m_detectors.end(); ++idet) {
439  DetElement parent((*idet).second);
440  Volume vol = parent.placement().volume();
441  if ( vol == volume ) {
442  printout(INFO,"DD4hep","+++ Detector: Added detector %s to the parent:%s.",
443  det_element.name(),parent.name());
444  parent.add(det_element);
445  return *this;
446  }
447  }
448  except("DD4hep","+++ Detector: The detector %s has no known parent.", det_element.name());
449  throw std::runtime_error("Detector-Error"); // Never called....
450 }
451 
454  if ( strcmp(x.name(),"Detector_InhibitConstants") == 0 ) {
455  const char* title = x->GetTitle();
456  char c = ::toupper(title[0]);
457  m_inhibitConstants = (c=='Y' || c=='T' || c=='1');
458  }
459  m_define.append(x, false);
460  return *this;
461 }
462 
464 Constant DetectorImp::constant(const std::string& name) const {
465  if ( !m_inhibitConstants ) {
466  return getRefChild(m_define, name);
467  }
468  throw std::runtime_error("Detector:constant("+name+"): Access to global constants is inhibited.");
469 }
470 
472 std::string DetectorImp::constantAsString(const std::string& name) const {
473  if ( !m_inhibitConstants ) {
474  Handle<NamedObject> c = constant(name);
475  if (c.isValid())
476  return c->GetTitle();
477  throw std::runtime_error("Detector:constantAsString: The constant " + name + " is not known to the system.");
478  }
479  throw std::runtime_error("Detector:constantAsString("+name+"):: Access to global constants is inhibited.");
480 }
481 
483 long DetectorImp::constantAsLong(const std::string& name) const {
484  if ( !m_inhibitConstants ) {
485  return _toLong(constantAsString(name));
486  }
487  throw std::runtime_error("Detector:constantAsLong("+name+"): Access to global constants is inhibited.");
488 }
489 
491 double DetectorImp::constantAsDouble(const std::string& name) const {
492  if ( !m_inhibitConstants ) {
493  return _toDouble(constantAsString(name));
494  }
495  throw std::runtime_error("Detector:constantAsDouble("+name+"): Access to global constants is inhibited.");
496 }
497 
500  m_field.add(x);
501  m_fields.append(x);
502  return *this;
503 }
504 
506 Material DetectorImp::material(const std::string& name) const {
507  TGeoMedium* mat = m_manager->GetMedium(name.c_str());
508  if (mat) {
509  return Material(mat);
510  }
511  throw std::runtime_error("Cannot find a material referenced by name:" + name);
512 }
513 
516  m_detectorTypes[""] = {};
517  for( const auto& i : m_detectors ) {
518  DetElement det(i.second);
519  if ( det.parent().isValid() ) { // Exclude 'world'
520  HandleMap::const_iterator j=m_sensitive.find(det.name());
521  if ( j != m_sensitive.end() ) {
522  SensitiveDetector sd((*j).second);
523  m_detectorTypes[sd.type()].emplace_back(det);
524  }
525  else if ( det.type() == "compound" ) {
526  m_detectorTypes[det.type()].emplace_back(det);
527  }
528  else {
529  m_detectorTypes["passive"].emplace_back(det);
530  }
531  }
532  }
533 }
534 
536 std::vector<std::string> DetectorImp::detectorTypes() const {
537  if ( m_manager->IsClosed() ) {
538  std::vector<std::string> v;
539  v.reserve(m_detectorTypes.size());
540  for(const auto& t : m_detectorTypes )
541  v.emplace_back(t.first);
542  return v;
543  }
544  throw std::runtime_error("detectorTypes: Call only available once the geometry is closed!");
545 }
546 
548 const std::vector<DetElement>& DetectorImp::detectors(const std::string& type, bool throw_exc) const {
549  if ( m_manager->IsClosed() ) {
550  DetectorTypeMap::const_iterator i=m_detectorTypes.find(type);
551  if ( i != m_detectorTypes.end() ) return (*i).second;
552  if ( throw_exc ) {
553  throw std::runtime_error("detectors("+type+"): Detectors of this type do not exist in the current setup!");
554  }
555  // return empty vector instead of exception
556  return m_detectorTypes.at("") ;
557  }
558  throw std::runtime_error("detectors("+type+"): Detectors can only selected by type once the geometry is closed!");
559 }
560 
561 std::vector<DetElement> DetectorImp::detectors(unsigned int includeFlag, unsigned int excludeFlag ) const {
562  if( ! m_manager->IsClosed() ) {
563  throw std::runtime_error("detectors(typeFlag): Detectors can only selected by typeFlag once the geometry is closed!");
564  }
565  std::vector<DetElement> dets ;
566  dets.reserve( m_detectors.size() ) ;
567 
568  for(HandleMap::const_iterator i=m_detectors.begin(); i!=m_detectors.end(); ++i) {
569  DetElement det((*i).second);
570  if ( det.parent().isValid() ) { // Exclude 'world'
571 
572  //fixme: what to do with compounds - add their daughters ?
573  // ...
574 
575  if( ( det.typeFlag() & includeFlag ) == includeFlag &&
576  ( det.typeFlag() & excludeFlag ) == 0 )
577  dets.emplace_back( det ) ;
578  }
579  }
580  return dets ;
581 }
582 
584 std::vector<DetElement> DetectorImp::detectors(const std::string& type1,
585  const std::string& type2,
586  const std::string& type3,
587  const std::string& type4,
588  const std::string& type5 ) {
589  if ( m_manager->IsClosed() ) {
590  std::vector<DetElement> v;
591  DetectorTypeMap::const_iterator i, end=m_detectorTypes.end();
592  if ( !type1.empty() && (i=m_detectorTypes.find(type1)) != end )
593  v.insert(v.end(),(*i).second.begin(),(*i).second.end());
594  if ( !type2.empty() && (i=m_detectorTypes.find(type2)) != end )
595  v.insert(v.end(),(*i).second.begin(),(*i).second.end());
596  if ( !type3.empty() && (i=m_detectorTypes.find(type3)) != end )
597  v.insert(v.end(),(*i).second.begin(),(*i).second.end());
598  if ( !type4.empty() && (i=m_detectorTypes.find(type4)) != end )
599  v.insert(v.end(),(*i).second.begin(),(*i).second.end());
600  if ( !type5.empty() && (i=m_detectorTypes.find(type5)) != end )
601  v.insert(v.end(),(*i).second.begin(),(*i).second.end());
602  return v;
603  }
604  throw std::runtime_error("detectors("+type1+","+type2+",...): Detectors can only selected by type once the geometry is closed!");
605 }
606 
607 Handle<NamedObject> DetectorImp::getRefChild(const HandleMap& e, const std::string& name, bool do_throw) const {
608  HandleMap::const_iterator it = e.find(name);
609  if (it != e.end()) {
610  return it->second;
611  }
612  if (do_throw) {
613  union ptr {
614  const ObjectHandleMap* omap;
615  const char* c;
616  const void* other;
617  ptr(const void* p) { other = p; }
618  };
619  std::string nam = "";
620  ptr mptr(&e), ref(this);
621  if ( ref.c > mptr.c && mptr.c < ref.c+sizeof(*this) ) {
622  nam = mptr.omap->name;
623  }
624  std::stringstream err;
625  err << "getRefChild: Failed to find child with name: " << name
626  << " Map " << nam << " contains " << e.size() << " elements";
627  if ( std::getenv("DD4HEP_LIST_CHILDREN") ) {
628  err << ": {";
629  for (it = e.begin(); it != e.end(); ++it) {
630  if (it != e.begin()) {
631  err << ", ";
632  }
633  err << it->first;
634  }
635  err << "}";
636  }
637  else {
638  err << ". Set the environment variable DD4HEP_LIST_CHILDREN to list them.";
639  }
640  throw std::runtime_error(err.str());
641  }
642  return nullptr;
643 }
644 
645 namespace {
646  struct ShapePatcher: public detail::GeoScan {
647  VolumeManager m_volManager;
648  DetElement m_world;
649  ShapePatcher(VolumeManager m, DetElement e)
650  : detail::GeoScan(e), m_volManager(m), m_world(e) {
651  }
652  void patchShapes() {
653  auto& data = *m_data;
654  char text[32];
655  std::string nam;
656  printout(INFO,"Detector","+++ Patching names of anonymous shapes....");
657  for (auto i = data.rbegin(); i != data.rend(); ++i) {
658  for( const TGeoNode* n : (*i).second ) {
659  TGeoVolume* vol = n->GetVolume();
660  TGeoShape* s = vol->GetShape();
661  const char* sn = s->GetName();
662  ::snprintf(text,sizeof(text),"_shape_%p",(void*)s);
663  if ( !sn || 0 == ::strlen(sn)) {
664  nam = vol->GetName();
665  nam += text;
666  s->SetName(nam.c_str());
667  }
668  else if (0 == ::strcmp(sn, s->IsA()->GetName())) {
669  nam = vol->GetName();
670  nam += text;
671  s->SetName(nam.c_str());
672  }
673  else {
674  nam = sn;
675  if (nam.find("_shape") == std::string::npos)
676  nam += text;
677  s->SetName(nam.c_str());
678  }
679  if (s->IsA() == TGeoCompositeShape::Class()) {
680  TGeoCompositeShape* c = (TGeoCompositeShape*) s;
681  const TGeoBoolNode* boolean = c->GetBoolNode();
682  s = boolean->GetLeftShape();
683  sn = s->GetName();
684  if ( !sn || 0 == ::strlen(sn)) {
685  s->SetName((nam + "_left").c_str());
686  }
687  else if (0 == ::strcmp(sn, s->IsA()->GetName())) {
688  s->SetName((nam + "_left").c_str());
689  }
690  s = boolean->GetRightShape();
691  sn = s->GetName();
692  if ( !sn || 0 == ::strlen(sn)) {
693  s->SetName((nam + "_right").c_str());
694  }
695  else if (0 == ::strcmp(s->GetName(), s->IsA()->GetName())) {
696  s->SetName((nam + "_right").c_str());
697  }
698  }
699  }
700  }
701  }
702  };
703 }
704 
706 void DetectorImp::endDocument(bool close_geometry) {
707  const char* option = (close_geometry) ? "close" : nullptr;
708  this->endDocument(option);
709 }
710 
712 void DetectorImp::endDocument(const char* option) {
713  TGeoManager* mgr = m_manager;
714  TString clopt, opt(option == nullptr ? "" : option);
715  std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock);
716  opt.ToLower();
717  if ( opt.Contains("close") && !mgr->IsClosed() ) {
718 #if 0
719  Region trackingRegion("TrackingRegion");
720  trackingRegion.setThreshold(1);
721  trackingRegion.setStoreSecondaries(true);
722  add(trackingRegion);
723  m_trackingVol.setRegion(trackingRegion);
724  // Set the tracking volume to invisible.
725  VisAttr trackingVis("TrackingVis");
726  trackingVis.setVisible(false);
727  m_trackingVol.setVisAttributes(trackingVis);
728  add(trackingVis);
729 #endif
730  m_worldVol.solid()->ComputeBBox();
731  // Propagating reflections: This is useless now and unused!!!!
732  // Since we allow now for anonymous shapes,
733  // we will rename them to use the name of the volume they are assigned to
734  if( opt.Contains("i") ) clopt += "i";
735  if( opt.Contains("nv") ) clopt += "nv";
736  (clopt.Length()>0) ? mgr->CloseGeometry(clopt) : mgr->CloseGeometry();
737  if( clopt.Contains("nv") ) {
738  printout(INFO,"Detector","++ Geometry voxelization is disabled.");
739  }
740  PlacedVolume pv = mgr->GetTopNode();
741  auto* extension = pv->GetUserExtension();
742  if ( nullptr == extension ) {
744  pv->SetUserExtension(extension);
745  }
746  m_world.setPlacement(pv);
747  // Paths cached while the geometry was built may be outdated
749  }
750  // Patching shape names of anonymous shapes
751  ShapePatcher patcher(m_volManager, m_world);
752  patcher.patchShapes();
754  m_state = READY;
755  //DetectorGuard(this).unlock();
756 }
757 
760  if (!m_world.isValid()) {
761  TGeoManager* mgr = m_manager;
762  std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock);
763  Constant air_const = getRefChild(m_define, "Air", false);
764  Constant vac_const = getRefChild(m_define, "Vacuum", false);
765  Box worldSolid;
766 
767  m_materialVacuum = material(vac_const.isValid() ? vac_const->GetTitle() : "Vacuum");
768 
769  m_worldVol = m_manager->GetTopVolume();
770  if ( m_worldVol.isValid() ) {
771  worldSolid = m_worldVol.solid();
773  printout(INFO,"Detector", "*********** Use Top Node from manager as "
774  "world volume [%s]. Material: %s BBox: %4.0f %4.0f %4.0f",
775  worldSolid->IsA()->GetName(), m_materialAir.name(),
776  worldSolid->GetDX(), worldSolid->GetDY(), worldSolid->GetDZ());
777  }
778  else {
780  Solid parallelWorldSolid = Box("world_x", "world_y", "world_z");
781  worldSolid = Box("world_x", "world_y", "world_z");
782  m_materialAir = material(air_const.isValid() ? air_const->GetTitle() : "Air");
783  m_worldVol = Volume("world_volume", worldSolid, m_materialAir);
784  parallelWorldSolid->SetName("parallel_world_solid");
785  printout(INFO,"Detector","*********** Created World volume with size: %4.0f %4.0f %4.0f",
786  worldSolid->GetDX(), worldSolid->GetDY(), worldSolid->GetDZ());
787  }
788  m_world = DetElement(new WorldObject(*this,"world"));
790  VisAttr worldVis = visAttributes("WorldVis");
791  if ( !worldVis.isValid() ) {
792  worldVis = VisAttr("WorldVis");
793  worldVis.setVisible(false);
794  worldVis.setShowDaughters(true);
795  worldVis.setColor(1., 1., 1., 1.);
796  worldVis.setLineStyle(VisAttr::SOLID);
798  //m_worldVol.setVisAttributes(worldVis);
799  m_worldVol->SetVisibility(kFALSE);
800  m_worldVol->SetVisDaughters(kTRUE);
801  m_worldVol->SetVisContainers(kTRUE);
802  add(worldVis);
803  }
804  m_worldVol.setVisAttributes(worldVis);
805  m_manager->SetTopVolume(m_worldVol.ptr());
806 
809  m_world.setPlacement(mgr->GetTopNode());
810 
812  m_parallelWorldVol = Volume("parallel_world_volume", worldSolid, m_materialAir);
813 
815  m_field = OverlayedField("global");
816  m_state = LOADING;
817  }
818 }
819 
821 void DetectorImp::fromXML(const std::string& xmlfile, DetectorBuildType build_type) {
822  std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock);
823  m_buildType = build_type;
824  processXML(xmlfile, nullptr);
825 }
826 
828 void DetectorImp::fromXML(const std::string& fname, xml::UriReader* entity_resolver, DetectorBuildType build_type) {
829  std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock);
830  m_buildType = build_type;
831  processXML(fname, entity_resolver);
832 }
833 
834 void DetectorImp::dump() const {
835  TGeoManager* mgr = m_manager;
836  mgr->SetVisLevel(4);
837  mgr->SetVisOption(1);
838  m_worldVol->Draw("ogl");
839 }
840 
842 long DetectorImp::apply(const char* factory_type, int argc, char** argv) const {
843  std::lock_guard<std::recursive_mutex> lock(s_detector_apply_lock);
844  std::string fac = factory_type;
845  try {
846  Detector* thisPtr = const_cast<DetectorImp*>(this);
847  long result = PluginService::Create<long>(fac, thisPtr, argc, argv);
848  if (0 == result) {
849  PluginDebug dbg;
850  result = PluginService::Create<long>(fac, thisPtr, argc, argv);
851  if ( 0 == result ) {
852  throw std::runtime_error("dd4hep: apply-plugin: Failed to locate plugin " +
853  fac + ". " + dbg.missingFactory(fac));
854  }
855  }
856  result = *(long*) result;
857  if (result != 1) {
858  throw std::runtime_error("dd4hep: apply-plugin: Failed to execute plugin " + fac);
859  }
860  return result;
861  }
862  catch (const xml::XmlException& e) {
863  throw std::runtime_error(xml::_toString(e.msg) + "\ndd4hep: XML-DOM Exception with plugin:" + fac);
864  }
865  catch (const std::exception& e) {
866  throw std::runtime_error(std::string(e.what()) + "\ndd4hep: with plugin:" + fac);
867  }
868  catch (...) {
869  throw std::runtime_error("UNKNOWN exception from plugin:" + fac);
870  }
871  return EINVAL;
872 }
dd4hep::DetectorImp::detectors
virtual const HandleMap & detectors() const override
Accessor to the map of sub-detectors.
Definition: DetectorImp.h:298
dd4hep::DetectorImp::DetectorImp
DetectorImp()
Default constructor used by ROOT I/O.
Definition: DetectorImp.cpp:152
dd4hep::Detector::LOADING
@ LOADING
The geometry is being created and loaded. (parsing ongoing)
Definition: Detector.h:101
dd4hep::DetectorImp::add
virtual Detector & add(Constant x) override
Add a new constant to the detector description.
Definition: DetectorImp.h:344
dd4hep::detail::OpticalSurfaceManagerObject
This structure describes the internal data of the volume manager object.
Definition: OpticalSurfaceManagerInterna.h:43
dd4hep::DetectorData::m_sensitive
ObjectHandleMap m_sensitive
The map of top level sub-detector sensitive detector objects indexed by the detector name.
Definition: DetectorData.h:111
dd4hep::ExtensionEntry
Definition of the extension entry interface class.
Definition: ExtensionEntry.h:37
dd4hep::DetectorImp::init
virtual void init() override
Open the geometry at startup.
Definition: DetectorImp.cpp:759
dd4hep::DetectorData::m_detectorParents
std::map< std::string, DetElement > m_detectorParents
Definition: DetectorData.h:121
dd4hep::DetectorImp::buildType
virtual DetectorBuildType buildType() const override
Access flag to steer the detail of building of the geometry/detector description.
Definition: DetectorImp.cpp:283
dd4hep::DetectorImp::m_buildType
DetectorBuildType m_buildType
VolumeManager m_volManager;.
Definition: DetectorImp.h:71
dd4hep::xml::XmlException
xercesc::DOMException XmlException
Definition: DetectorImp.cpp:54
dd4hep::detail::destroyHandle
void destroyHandle(T &handle)
Helper to delete objects from heap and reset the handle.
Definition: Handle.h:183
v
View * v
Definition: MultiView.cpp:28
dd4hep::WorldObject
Data class with properties of a detector element.
Definition: DetectorInterna.h:187
dd4hep::SensitiveDetector
Handle class to hold the information of a sensitive detector.
Definition: DetElement.h:43
DetectorImp.h
dd4hep::DetectorData::ObjectHandleMap::append
void append(const Handle< NamedObject > &e, bool throw_on_doubles=true)
Append entry to map.
Definition: DetectorData.h:69
dd4hep::DetectorData::m_trackingVol
Volume m_trackingVol
Definition: DetectorData.h:127
dd4hep::exception
void exception(const std::string &src, const std::string &msg)
Definition: RootDictionary.h:69
dd4hep::Region::setStoreSecondaries
Region & setStoreSecondaries(bool value)
Set flag to store secondaries.
Definition: Objects.cpp:524
dd4hep::PlacedVolume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:164
dd4hep::VisAttr
Handle class describing visualization attributes.
Definition: Objects.h:331
dd4hep::DetectorImp::addConstant
virtual Detector & addConstant(const Handle< NamedObject > &x) override
Add a new constant by named reference to the detector description.
Definition: DetectorImp.cpp:453
dd4hep::STD_Conditions::USER
@ USER
Definition: Detector.h:62
dd4hep::DetElement::placement
PlacedVolume placement() const
Access to the physical volume of this detector element.
Definition: DetElement.cpp:362
VolumeManagerInterna.h
dd4hep::DetectorImp::addField
virtual Detector & addField(const Handle< NamedObject > &x) override
Add a field component by named reference to the detector description.
Definition: DetectorImp.cpp:499
dd4hep::DetectorData::m_world
DetElement m_world
Definition: DetectorData.h:123
dd4hep::ObjectExtensions::removeExtension
void * removeExtension(unsigned long long int key, bool destroy)
Remove an existing extension object from the instance.
Definition: ObjectExtensions.cpp:90
dd4hep::VisAttr::setShowDaughters
void setShowDaughters(bool value)
Set Flag to show/hide daughter elements.
Definition: Objects.cpp:359
dd4hep::versionString
std::string versionString()
return a string with the current dd4hep version in the form vXX-YY.
Definition: DetectorImp.cpp:123
dd4hep::Volume::solid
Solid solid() const
Access to Solid (Shape)
Definition: Volumes.cpp:1268
dd4hep::DetectorImp::m_std_conditions
STD_Conditions m_std_conditions
Standard conditions.
Definition: DetectorImp.h:65
dd4hep::Handle::isValid
bool isValid() const
Check the validity of the object held by the handle.
Definition: Handle.h:126
dd4hep::Handle< NamedObject >
DetectorInterna.h
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:1287
dd4hep::PlacedVolume::Object
PlacedVolumeExtension Object
Definition: Volumes.h:166
dd4hep::STD_Conditions::USER_SET
@ USER_SET
Definition: Detector.h:63
dd4hep::OverlayedField::add
void add(CartesianField field)
Add a new field component.
Definition: Fields.cpp:113
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
dd4hep::DetectorImp::addDetector
virtual Detector & addDetector(const Handle< NamedObject > &x) override
Add a new subdetector by named reference to the detector description.
Definition: DetectorImp.cpp:397
dd4hep::VisAttr::setLineStyle
void setLineStyle(int style)
Set line style.
Definition: Objects.cpp:379
dd4hep::Solid_type< TGeoShape >
dd4hep::DetElement::add
DetElement & add(DetElement sub_element)
Add new child to the detector structure.
Definition: DetElement.cpp:299
dd4hep::DetectorImp::detector
virtual DetElement detector(const std::string &name) const override
Retrieve a subdetector element by its name from the detector description.
Definition: DetectorImp.cpp:388
DetectorHelper.h
dd4hep::DetectorData::m_field
OverlayedField m_field
Definition: DetectorData.h:132
dd4hep::Handle::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::DetectorData::patchRootStreamer
static void patchRootStreamer(TClass *cl)
Assignment operator.
Definition: DetectorData.cpp:187
dd4hep::DetectorImp::world
virtual DetElement world() const override
Return reference to the top-most (world) detector element.
Definition: DetectorImp.h:177
dd4hep::DetectorData::m_inhibitConstants
bool m_inhibitConstants
Flag to inhibit the access to global constants. Value set by constants section 'Detector_InhibitConst...
Definition: DetectorData.h:146
dd4hep::_toLong
long _toLong(const std::string &value)
String conversions: string to long integer value.
Definition: Handle.cpp:98
dd4hep::DetectorData::m_worldVol
Volume m_worldVol
Definition: DetectorData.h:125
dd4hep::detail::GeoScan
Geometry scanner (handle object)
Definition: GeoHandler.h:137
dd4hep::OverlayedField
Class describing a field overlay with several sources.
Definition: Fields.h:138
dd4hep::DetectorData::m_define
ObjectHandleMap m_define
Definition: DetectorData.h:119
dd4hep::Volume::material
Material material() const
Access to the Volume material.
Definition: Volumes.cpp:1167
dd4hep::DetectorImp::constantAsLong
virtual long constantAsLong(const std::string &name) const override
Typed access to constants: long values.
Definition: DetectorImp.cpp:483
dd4hep::detail::tools::findElement
DetElement findElement(const Detector &description, const std::string &path)
Find DetElement as child of the top level volume by its absolute path.
Definition: DetectorTools.cpp:304
DocumentHandler.h
dd4hep::Material
Handle class describing a material.
Definition: Objects.h:271
dd4hep::DetectorImp::declareParent
virtual void declareParent(const std::string &detector_name, const DetElement &parent) override
Register new mother volume using the detector name.
Definition: DetectorImp.cpp:290
dd4hep::DetectorImp::m_detectorTypes
DetectorTypeMap m_detectorTypes
Inventory of detector types.
Definition: DetectorImp.h:68
dd4hep::DetectorHelper::detectorByID
DetElement detectorByID(int id) const
Find a detector element by its system ID.
Definition: DetectorHelper.cpp:48
dd4hep::VisAttr::setDrawingStyle
void setDrawingStyle(int style)
Set drawing style.
Definition: Objects.cpp:389
dd4hep::STD_Conditions::temperature
double temperature
Definition: Detector.h:68
dd4hep::BUILD_NONE
@ BUILD_NONE
Definition: BuildType.h:35
dd4hep::Detector::getInstance
static Detector & getInstance(const std::string &name="default")
—Factory method----—
Definition: DetectorImp.cpp:133
dd4hep::STD_Conditions
Helper class to access default temperature and pressure.
Definition: Detector.h:57
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
dd4hep::Utilities::GetName
const char * GetName(T *p)
Definition: Utilities.h:45
dd4hep::Constant
Handle class describing a constant (define) object in description.
Definition: Objects.h:208
dd4hep::Volume
Handle class holding a placed volume (also called physical volume)
Definition: Volumes.h:371
dd4hep::VolumeManager
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:135
dd4hep::DetectorImp::~DetectorImp
virtual ~DetectorImp()
Standard destructor.
Definition: DetectorImp.cpp:218
dd4hep::DetectorData::m_state
Detector::State m_state
Detector description state.
Definition: DetectorData.h:143
dd4hep::DetectorData::m_volManager
VolumeManager m_volManager
Volume manager reference.
Definition: DetectorData.h:140
dd4hep::VisAttr::setVisible
void setVisible(bool value)
Set visibility flag.
Definition: Objects.cpp:369
dd4hep::DetectorImp::dump
virtual void dump() const override
Stupid legacy method.
Definition: DetectorImp.cpp:834
dd4hep::DetectorImp::visAttributes
virtual const HandleMap & visAttributes() const override
Accessor to the map of visualisation attributes.
Definition: DetectorImp.h:282
DetectorTools.h
dd4hep::DetectorData::m_detectors
ObjectHandleMap m_detectors
The map of top level sub-detector objects indexed by name.
Definition: DetectorData.h:113
dd4hep::DetectorImp::constant
virtual Constant constant(const std::string &name) const override
Retrieve a constant by its name from the detector description.
Definition: DetectorImp.cpp:464
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::xml
Namespace for the AIDA detector description toolkit supporting XML utilities.
Definition: ConditionsTags.h:27
dd4hep::DetectorImp::apply
virtual long apply(const char *factory, int argc, char **argv) const override
Manipulate geometry using facroy converter.
Definition: DetectorImp.cpp:842
dd4hep::Detector::destroyInstance
static void destroyInstance(const std::string &name="default")
Destroy the singleton instance.
Definition: DetectorImp.cpp:145
dd4hep::DetectorImp::removeUserExtension
virtual void * removeUserExtension(unsigned long long int key, bool destroy=true) override
Remove an existing extension object from the Detector instance. If not destroyed, the instance is ret...
Definition: DetectorImp.cpp:273
TNamed
Class of the ROOT toolkit. See http://root.cern.ch/root/htmldoc/ClassIndex.html.
Definition: ROOTClasses.h:37
dd4hep::DetectorImp::saveObject
Int_t saveObject(const char *name=0, Int_t option=0, Int_t bufsize=0) const
ROOT I/O call.
Definition: DetectorImp.cpp:238
Plugins.h
dd4hep::Region
Handle class describing a region as used in simulation.
Definition: Objects.h:469
dd4hep::PluginDebug
Helper to debug plugin manager calls.
Definition: Plugins.h:71
dd4hep::DetectorHelper
DetectorHelper: class to shortcut certain questions to the dd4hep detector description interface.
Definition: DetectorHelper.h:32
dd4hep::DetectorData::m_materialAir
Material m_materialAir
Definition: DetectorData.h:129
dd4hep::DetectorData::destroyData
void destroyData(bool destroy_mgr=true)
Clear data content: releases all allocated resources.
Definition: DetectorData.cpp:209
dd4hep::xml::_toString
std::string _toString(const Attribute attr)
Convert xml attribute to STL string.
Definition: XMLElements.cpp:237
dd4hep::DetectorImp::endDocument
virtual void endDocument(bool close_geometry) override
Close the geometry.
Definition: DetectorImp.cpp:706
dd4hep::DetectorImp::material
virtual Material material(const std::string &name) const override
Retrieve a matrial by its name from the detector description.
Definition: DetectorImp.cpp:506
dd4hep::Detector::make_unique
static std::unique_ptr< Detector > make_unique(const std::string &name)
Unique creation without internal registration.
Definition: DetectorImp.cpp:129
dd4hep::DetectorLoad
Data implementation class of the Detector interface.
Definition: DetectorLoad.h:43
dd4hep::PluginDebug::missingFactory
std::string missingFactory(const std::string &name) const
Helper to check factory existence.
Definition: Plugins.cpp:147
dd4hep::DetectorData::m_fields
ObjectHandleMap m_fields
The map of electro magnet field components for the global overlay field.
Definition: DetectorData.h:117
dd4hep::DetectorImp::stdConditions
virtual const STD_Conditions & stdConditions() const override
Access default conditions (temperature and pressure.
Definition: DetectorImp.cpp:346
dd4hep::DetectorImp::pickMotherVolume
virtual Volume pickMotherVolume(const DetElement &sd) const override
Access mother volume by detector element.
Definition: DetectorImp.cpp:316
dd4hep::DetElement::setPlacement
DetElement & setPlacement(const PlacedVolume &volume)
Set the physical volumes of the detector element.
Definition: DetElement.cpp:371
dd4hep::NamedObject::GetTitle
const char * GetTitle() const
Get name (used by Handle)
Definition: NamedObject.h:70
detectors
DetectorMap detectors
Definition: AlignmentsCalculator.cpp:79
dd4hep::xml::UriReader
Class supporting to read data given a URI.
Definition: UriReader.h:35
dd4hep::SensitiveDetector::type
std::string type() const
Access the type of the sensitive detector.
Definition: DetElement.cpp:450
dd4hep::Detector::HandleMap
std::map< std::string, Handle< NamedObject > > HandleMap
Type definition of a map of named handles.
Definition: Detector.h:92
dd4hep::DetectorData::ObjectHandleMap
Implementation of a map of named dd4hep Handles.
Definition: DetectorData.h:59
dd4hep::DetectorImp::m_surfaceManager
detail::OpticalSurfaceManagerObject * m_surfaceManager
Optical surface manager.
Definition: DetectorImp.h:74
dd4hep::DetectorHelper::sensitiveDetector
SensitiveDetector sensitiveDetector(const std::string &detector) const
Access the sensitive detector of a given subdetector (if the sub-detector is sensitive!...
Definition: DetectorHelper.cpp:23
dd4hep::VolumeManager::TREE
@ TREE
Definition: VolumeManager.h:140
dd4hep::DetectorImp::userExtension
virtual void * userExtension(unsigned long long int key, bool alert=true) const override
Access an existing extension object from the Detector instance.
Definition: DetectorImp.cpp:278
dd4hep::STD_Conditions::USER_NOTIFIED
@ USER_NOTIFIED
Definition: Detector.h:64
dd4hep::_toDouble
double _toDouble(const std::string &value)
String conversions: string to double value.
Definition: Handle.cpp:116
key
unsigned char key
Definition: AlignmentsCalculator.cpp:69
dd4hep::DetectorImp::addUserExtension
virtual void * addUserExtension(unsigned long long int key, ExtensionEntry *entry) override
Add an extension object to the Detector instance.
Definition: DetectorImp.cpp:268
dd4hep::DetectorImp::constantAsString
virtual std::string constantAsString(const std::string &name) const override
Typed access to constants: access string values.
Definition: DetectorImp.cpp:472
dd4hep::Box
Class describing a box shape.
Definition: Shapes.h:295
dd4hep::DetectorImp::addVisAttribute
virtual Detector & addVisAttribute(const Handle< NamedObject > &x) override
Add a new visualisation attribute by named reference to the detector description.
Definition: DetectorImp.h:404
dd4hep::DetectorImp::fromXML
virtual void fromXML(const std::string &fname, DetectorBuildType type=BUILD_DEFAULT) override
Read any XML file.
Definition: DetectorImp.cpp:821
dd4hep::DetectorData::m_parallelWorldVol
Volume m_parallelWorldVol
Definition: DetectorData.h:126
dd4hep::VisAttr::SOLID
@ SOLID
Definition: Objects.h:334
dd4hep::Handle::ptr
T * ptr() const
Access to the held object.
Definition: Handle.h:151
dd4hep::DetectorData::m_materialVacuum
Material m_materialVacuum
Definition: DetectorData.h:130
ObjectsInterna.h
dd4hep::DetectorData::m_extensions
ObjectExtensions m_extensions
Definition of the extension type.
Definition: DetectorData.h:138
dd4hep::ObjectExtensions::clear
void clear(bool destroy=true)
Clear all extensions.
Definition: ObjectExtensions.cpp:49
dd4hep::DetectorImp::setStdConditions
virtual void setStdConditions(double temp, double pressure) override
Set the STD temperature and pressure.
Definition: DetectorImp.cpp:356
dd4hep::STD_Conditions::convention
long convention
Definition: Detector.h:69
OpticalSurfaceManagerInterna.h
dd4hep::Volume::setVisAttributes
const Volume & setVisAttributes(const VisAttr &obj) const
Set Visualization attributes to the volume.
Definition: Volumes.cpp:1172
dd4hep::Detector::extension
IFACE * extension(bool alert=true) const
Access extension element by the type.
Definition: Detector.h:343
dd4hep::DetectorBuildType
DetectorBuildType
Detector description build types.
Definition: BuildType.h:34
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::VisAttr::WIREFRAME
@ WIREFRAME
Definition: Objects.h:334
det
DetElement::Object * det
Definition: AlignmentsCalculator.cpp:66
dd4hep::DetectorData
Data implementation class of the Detector interface.
Definition: DetectorData.h:38
dd4hep::PlacedVolume::volume
Volume volume() const
Logical volume of this placement.
Definition: Volumes.cpp:472
dd4hep::STD_Conditions::pressure
double pressure
Definition: Detector.h:67
dd4hep::DetectorImp::mapDetectorTypes
void mapDetectorTypes()
Internal helper to map detector types once the geometry is closed.
Definition: DetectorImp.cpp:515
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:89
dd4hep::Readout
Handle to the implementation of the readout structure of a subdetector.
Definition: Readout.h:38
dd4hep::DetectorData::m_manager
TGeoManager * m_manager
Reference to the geometry manager object from ROOT.
Definition: DetectorData.h:101
dd4hep::DetectorImp::detectorTypes
virtual std::vector< std::string > detectorTypes() const override
Access the available detector types.
Definition: DetectorImp.cpp:536
dd4hep::DetElement::id
int id() const
Get the detector identifier.
Definition: DetElement.cpp:189
dd4hep::DetectorImp::getRefChild
virtual Handle< NamedObject > getRefChild(const HandleMap &e, const std::string &name, bool throw_if_not=true) const
Definition: DetectorImp.cpp:607
dd4hep::STD_Conditions::STP
@ STP
Definition: Detector.h:60
dd4hep::DetectorData::m_invisibleVis
VisAttr m_invisibleVis
Definition: DetectorData.h:131
InstanceCount.h
dd4hep::detail::tools::clearPathCaches
void clearPathCaches(DetElement element)
Clear the placement path cache of this thread and the paths cached by the detector element and its ch...
Definition: DetectorTools.cpp:127
dd4hep::VisAttr::setColor
void setColor(float alpha, float red, float green, float blue)
Set object color.
Definition: Objects.cpp:404
ClassImp
ClassImp(DetectorImp) namespace
Definition: DetectorImp.cpp:61
dd4hep::DetElementObject::IS_TOP_LEVEL_DETECTOR
@ IS_TOP_LEVEL_DETECTOR
Definition: DetectorInterna.h:93
DD4hepUnits.h
Printout.h
dd4hep::DetectorImp::imp_loadVolumeManager
void imp_loadVolumeManager()
Local method (no interface): Load volume manager.
Definition: DetectorImp.cpp:262
dd4hep::DetectorImp::constantAsDouble
virtual double constantAsDouble(const std::string &name) const override
Typed access to constants: double values.
Definition: DetectorImp.cpp:491
dd4hep::DetectorData::unpatchRootStreamer
static void unpatchRootStreamer(TClass *cl)
UNPatch the ROOT streamers to adapt for DD4hep (set fUserExtension transient)
Definition: DetectorData.cpp:198
dd4hep::DetectorImp
Concrete implementation class of the Detector interface.
Definition: DetectorImp.h:59
dd4hep::ObjectExtensions::addExtension
void * addExtension(unsigned long long int key, ExtensionEntry *entry)
Add an extension object to the detector element.
Definition: ObjectExtensions.cpp:67
dd4hep::DetectorLoad::processXML
virtual void processXML(const std::string &fname, xml::UriReader *entity_resolver=0)
Process XML unit and adopt all data from source structure.
Definition: DetectorLoad.cpp:49
dd4hep::ObjectExtensions::extension
void * extension(unsigned long long int key, bool alert) const
Access an existing extension object from the detector element.
Definition: ObjectExtensions.cpp:119
dd4hep::Detector::READY
@ READY
The geometry is loaded.
Definition: Detector.h:103
dd4hep::STD_Conditions::NTP
@ NTP
Definition: Detector.h:61
GeoHandler.h
dd4hep::Region::setThreshold
Region & setThreshold(double value)
Set threshold in MeV.
Definition: Objects.cpp:529