DD4hep  1.34.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 
34  // have to populate the volume manager once in order to have
35  // the volumeIDs attached to the DetElements
36  Detector& description = Detector::getInstance();
37  /* VolumeManager volMgr = */ VolumeManager::getVolumeManager(description);
38 
39  //------------------ breadth first tree traversal ---------
40  std::list< DetElement > dets ;
41  std::list< DetElement > daugs ;
42  std::list< DetElement > gdaugs ;
43 
44  daugs.push_back( _det ) ;
45 
46  while( ! daugs.empty() ) {
47 
48  for( const auto& dag : daugs ){
49  const DetElement::Children& chMap = dag.children() ;
50  for ( const auto& [_, de] : chMap ){
51  gdaugs.push_back( de ) ;
52  }
53  }
54  dets.splice( dets.end() , daugs ) ;
55  daugs.splice( daugs.end() , gdaugs ) ;
56  }
57  //------------------ end tree traversal ---------
58 
59  // std::cout << " **** SurfaceHelper::initialize() : # DetElements found " << dets.size() << std::endl ;
60 
61  for( const auto& det : dets) {
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
Detector.h
dd4hep::rec::SurfaceHelper::initialize
void initialize()
initializes surfaces from VolSurfaces assigned to this DetElement in detector construction
Definition: SurfaceHelper.cpp:32
SurfaceHelper.h
dd4hep::rec::SurfaceHelper::_det
const DetElement & _det
Definition: SurfaceHelper.h:48
VolumeManager.h
dd4hep::Detector::getInstance
static Detector & getInstance(const std::string &name="default")
—Factory method----—
Definition: DetectorImp.cpp:132
dd4hep::DetElement
Handle class describing a detector element.
Definition: DetElement.h:187
dd4hep::rec::SurfaceList
Definition: Surface.h:679
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:34
dd4hep::DetElement::Children
std::map< std::string, DetElement > Children
Definition: DetElement.h:205
DetElement.h
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
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:47
dd4hep::rec::DetectorSurfaces
Definition: DetectorSurfaces.h:28