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