DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceHelper.cpp
Go to the documentation of this file.
1 #include "DDRec/SurfaceHelper.h"
2 
4 #include "DD4hep/Detector.h"
5 #include "DD4hep/LCDD.h"
6 #include "DD4hep/VolumeManager.h"
7 
8 namespace DD4hep {
9 
10  using namespace Geometry ;
11 
12  namespace DDRec {
13 
14 
15  SurfaceHelper::SurfaceHelper(DD4hep::Geometry::DetElement const& e) : _det(e) {
16 
17  initialize() ;
18  }
19 
21  // nothing to do
22  }
23 
24 
26 
27  // have to populate the volume manager once in order to have
28  // the volumeIDs attached to the DetElements
29  LCDD& lcdd = LCDD::getInstance();
30  static VolumeManager volMgr( lcdd , "volMan" , lcdd.world() ) ;
31 
32 
33  //------------------ breadth first tree traversal ---------
34  std::list< DetElement > dets ;
35  std::list< DetElement > daugs ;
36  std::list< DetElement > gdaugs ;
37 
38  daugs.push_back( _det ) ;
39 
40  while( ! daugs.empty() ) {
41 
42  for( std::list< DetElement >::iterator li=daugs.begin() ; li != daugs.end() ; ++li ){
43  DetElement dau = *li ;
44  DetElement::Children chMap = dau.children() ;
45  for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){
46  DetElement de = (*it).second ;
47  gdaugs.push_back( de ) ;
48  }
49  }
50  dets.splice( dets.end() , daugs ) ;
51  daugs.splice( daugs.end() , gdaugs ) ;
52  }
53  //------------------ end tree traversal ---------
54 
55  // std::cout << " **** SurfaceHelper::initialize() : # DetElements found " << dets.size() << std::endl ;
56 
57  for( std::list< DetElement >::iterator li=dets.begin() ; li != dets.end() ; ++li ) {
58 
59  DetElement det = (*li) ;
60 
61 
62 
63  // create surfaces
64  DetectorSurfaces ds( det ) ;
65 
66  const SurfaceList& detSL = ds.surfaceList() ;
67 
68 
69  // // ---------------------- debug printout
70  // std::cout << " ---- DetElement id: " << det.volumeID() << " name : " << det.name() << " #surfaces : " << detSL.size() << std::endl ;
71  // PlacedVolume pv = det.placement() ;
72  // if( pv.isValid() ) {
73  // try{ // needed as above is also true for world whcih has invalid placment ...
74  // PlacedVolume::VolIDs volIDs = pv.volIDs() ;
75  // for(unsigned i=0,n=volIDs.size(); i<n ; ++i){
76  // std::cout << " " << volIDs[i].first << " : " << volIDs[i].second << std::endl ;
77  // }
78  // }catch(...){}
79  // }else{
80  // std::cout << " invalid placement for DetElement ??? !! " << std::endl ;
81  // }
82  // // ------------------------- end debug printout
83 
84 
85  // and add copy them to this list
86  _sL.insert( _sL.end(), detSL.begin(), detSL.end() );
87  }
88 
89  }
90 
91 
92 
93  } // namespace
94 }// namespace
void initialize()
initializes surfaces from VolSurfaces assigned to this DetElement in detector construction ...
virtual DetElement world() const =0
Return reference to the top-most (world) detector element.
const Children & children() const
Access to the list of children.
Definition: Detector.cpp:207
static LCDD & getInstance(void)
—Factory method----—
Definition: LCDDImp.cpp:87
return e
Definition: Volumes.cpp:297
const Geometry::DetElement & _det
Definition: SurfaceHelper.h:32
Handle class describing a detector element.
Definition: Detector.h:172
Class to support the retrieval of detector elements and volumes given a valid identifier.
Definition: VolumeManager.h:70
The main interface to the DD4hep detector description package.
Definition: LCDD.h:82
std::map< std::string, DetElement > Children
Definition: Detector.h:202
const SurfaceList & surfaceList()
get the list of surfaces added to this DetElement