DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
SurfaceHelper.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 : F.Gaede
11 //
12 //==========================================================================
13 #include "DDRec/SurfaceHelper.h"
14 
15 #include "DDRec/DetectorSurfaces.h"
16 #include "DD4hep/DetElement.h"
17 #include "DD4hep/Detector.h"
18 #include "DD4hep/VolumeManager.h"
19 
20 namespace dd4hep {
21 
22  using namespace detail ;
23 
24  namespace rec {
25 
26 
27  SurfaceHelper::SurfaceHelper(dd4hep::DetElement const& e) : _det(e) {
28 
29  initialize() ;
30  }
31 
33  // nothing to do
34  }
35 
36 
38 
39  // have to populate the volume manager once in order to have
40  // the volumeIDs attached to the DetElements
41  Detector& description = Detector::getInstance();
42  /* VolumeManager volMgr = */ VolumeManager::getVolumeManager(description);
43 
44  //------------------ breadth first tree traversal ---------
45  std::list< DetElement > dets ;
46  std::list< DetElement > daugs ;
47  std::list< DetElement > gdaugs ;
48 
49  daugs.push_back( _det ) ;
50 
51  while( ! daugs.empty() ) {
52 
53  for( std::list< DetElement >::iterator li=daugs.begin() ; li != daugs.end() ; ++li ){
54  DetElement dau = *li ;
55  DetElement::Children chMap = dau.children() ;
56  for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){
57  DetElement de = (*it).second ;
58  gdaugs.push_back( de ) ;
59  }
60  }
61  dets.splice( dets.end() , daugs ) ;
62  daugs.splice( daugs.end() , gdaugs ) ;
63  }
64  //------------------ end tree traversal ---------
65 
66  // std::cout << " **** SurfaceHelper::initialize() : # DetElements found " << dets.size() << std::endl ;
67 
68  for( std::list< DetElement >::iterator li=dets.begin() ; li != dets.end() ; ++li ) {
69 
70  DetElement det = (*li) ;
71 
72 
73 
74  // create surfaces
75  DetectorSurfaces ds( det ) ;
76 
77  const SurfaceList& detSL = ds.surfaceList() ;
78 
79 
80  // // ---------------------- debug printout
81  // std::cout << " ---- DetElement id: " << det.volumeID() << " name : " << det.name() << " #surfaces : " << detSL.size() << std::endl ;
82  // PlacedVolume pv = det.placement() ;
83  // if( pv.isValid() ) {
84  // try{ // needed as above is also true for world whcih has invalid placment ...
85  // PlacedVolume::VolIDs volIDs = pv.volIDs() ;
86  // for(unsigned i=0,n=volIDs.size(); i<n ; ++i){
87  // std::cout << " " << volIDs[i].first << " : " << volIDs[i].second << std::endl ;
88  // }
89  // }catch(...){}
90  // }else{
91  // std::cout << " invalid placement for DetElement ??? !! " << std::endl ;
92  // }
93  // // ------------------------- end debug printout
94 
95 
96  // and add copy them to this list
97  _sL.insert( _sL.end(), detSL.begin(), detSL.end() );
98  }
99 
100  }
101 
102 
103 
104  } // namespace
105 }// namespace
dd4hep::DetElement::children
const Children & children() const
Access to the list of children.
Definition: DetElement.cpp:207
Detector.h
dd4hep::rec::SurfaceHelper::initialize
void initialize()
initializes surfaces from VolSurfaces assigned to this DetElement in detector construction
Definition: SurfaceHelper.cpp:37
SurfaceHelper.h
dd4hep::rec::SurfaceHelper::_det
const DetElement & _det
Definition: SurfaceHelper.h:44
VolumeManager.h
dd4hep::Detector::getInstance
static Detector & getInstance(const std::string &name="default")
—Factory method----—
Definition: DetectorImp.cpp:150
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:188
dd4hep::rec::SurfaceList
Definition: Surface.h:681
dd4hep::VolumeManager::getVolumeManager
static VolumeManager getVolumeManager(const Detector &description)
static accessor calling DD4hepVolumeManagerPlugin if necessary
Definition: VolumeManager.cpp:420
DetectorSurfaces.h
dd4hep::rec::DetectorSurfaces::surfaceList
const SurfaceList & surfaceList()
get the list of surfaces added to this DetElement
Definition: DetectorSurfaces.h:38
dd4hep::DetElement::Children
std::map< std::string, DetElement > Children
Definition: DetElement.h:206
DetElement.h
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::rec::SurfaceHelper::~SurfaceHelper
~SurfaceHelper()
Definition: SurfaceHelper.cpp:32
det
DetElement::Object * det
Definition: AlignmentsCalculator.cpp:66
dd4hep::Detector
The main interface to the dd4hep detector description package.
Definition: Detector.h:90
dd4hep::rec::SurfaceHelper::_sL
SurfaceList _sL
Definition: SurfaceHelper.h:43
dd4hep::rec::DetectorSurfaces
Definition: DetectorSurfaces.h:28