@@ -16,69 +16,52 @@ namespace dd4hep {
1616 namespace rec {
1717
1818
19+ DetectorSurfaces::DetectorSurfaces (dd4hep::DetElement const & e) {
1920
20- DetectorSurfaces::DetectorSurfaces (dd4hep::DetElement const & e) : DetElement(e) , _sL( 0 ) {
21-
22- initialize () ;
23- }
24-
25- DetectorSurfaces::~DetectorSurfaces (){
26- // nothing to do: SurfaceList is added as extension
27- // and is deleted automatically
21+ initialize (e) ;
2822 }
2923
30-
31- void DetectorSurfaces::initialize () {
32-
33- DetElement det = *this ;
24+ void DetectorSurfaces::initialize (dd4hep::DetElement const & det) {
3425
3526 const VolSurfaceList* vsL = volSurfaceList (det) ;
3627
37- try {
38- _sL = det.extension < SurfaceList >(false ) ;
39- if (not _sL) {
40- _sL = det.addExtension <SurfaceList >( new SurfaceList ( true ) ) ;
41- }
42- } catch (const std::exception& e) {
43- _sL = det.addExtension <SurfaceList >( new SurfaceList ( true ) ) ;
28+ _sL = det.extension < SurfaceList >(false ) ;
29+ if (! _sL) {
30+ _sL = det.addExtension <SurfaceList >( new SurfaceList ( true ) ) ;
4431 }
4532
46- if ( ! vsL->empty () && _sL->empty () ) { // only fill surfaces for this DetElement once
47-
48- // std::cout << " detector " << det.name() << " id: " << det.id() << " has " << vsL->size() << " surfaces " << std::endl ;
49-
50- // std::cout << " ------------------------- "
51- // << " DetectorSurfaces::initialize() adding surfaces : "
52- // << std::endl ;
53-
54- for ( VolSurfaceList::const_iterator it = vsL->begin () ; it != vsL->end () ; ++it ){
55-
56- VolSurface volSurf = *it ;
57-
58- Surface* surf = 0 ;
59-
60- if ( volSurf.type ().isCylinder () )
61- surf = new CylinderSurface ( det, volSurf ) ;
62-
63- else if ( volSurf.type ().isCone () )
64- surf = new ConeSurface ( det, volSurf ) ;
65-
66- else
67- surf = new Surface ( det, volSurf ) ;
33+ if ( ! _sL->empty () ) { // only fill surfaces for this DetElement once
34+ return ;
35+ }
6836
69- // std::cout << " ------------------------- "
70- // << " surface: " << *surf << std::endl
71- // << " ------------------------- " << std::endl ;
72-
73- _sL->push_back ( surf ) ;
74-
75- }
37+ // std::cout << " detector " << det.name() << " id: " << det.id() << " has " << vsL->size() << " surfaces " << std::endl ;
7638
39+ // std::cout << " ------------------------- "
40+ // << " DetectorSurfaces::initialize() adding surfaces : "
41+ // << std::endl ;
42+
43+ for ( const auto & volSurf : *vsL ) {
44+
45+ Surface* surf = nullptr ;
46+
47+ if ( volSurf.type ().isCylinder () )
48+ surf = new CylinderSurface ( det, volSurf ) ;
49+
50+ else if ( volSurf.type ().isCone () )
51+ surf = new ConeSurface ( det, volSurf ) ;
52+
53+ else
54+ surf = new Surface ( det, volSurf ) ;
55+
56+ // std::cout << " ------------------------- "
57+ // << " surface: " << *surf << std::endl
58+ // << " ------------------------- " << std::endl ;
59+
60+ _sL->push_back ( surf ) ;
7761
7862 }
7963
8064 }
81-
8265
8366
8467 } // namespace
0 commit comments