DD4hep  01.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
DetectorSurfaces.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/DetectorSurfaces.h"
14 
15 namespace dd4hep {
16  namespace rec {
17 
18 
19 
20  DetectorSurfaces::DetectorSurfaces(dd4hep::DetElement const& e) : DetElement(e) , _sL( 0 ) {
21 
22  initialize() ;
23  }
24 
26  // nothing to do: SurfaceList is added as extension
27  // and is deleted automatically
28  }
29 
30 
32 
33  DetElement det = *this ;
34 
35  const VolSurfaceList* vsL = volSurfaceList(det) ;
36 
37  try {
38  _sL = det.extension< SurfaceList >() ;
39 
40  } catch(const std::exception& e) {
41  _sL = det.addExtension<SurfaceList >( new SurfaceList( true ) ) ;
42  }
43 
44  if( ! vsL->empty() && _sL->empty() ) { // only fill surfaces for this DetElement once
45 
46  // std::cout << " detector " << det.name() << " id: " << det.id() << " has " << vsL->size() << " surfaces " << std::endl ;
47 
48  // std::cout << " ------------------------- "
49  // << " DetectorSurfaces::initialize() adding surfaces : "
50  // << std::endl ;
51 
52  for( VolSurfaceList::const_iterator it = vsL->begin() ; it != vsL->end() ; ++it ){
53 
54  VolSurface volSurf = *it ;
55 
56  Surface* surf = 0 ;
57 
58  if( volSurf.type().isCylinder() )
59  surf = new CylinderSurface( det, volSurf ) ;
60 
61  else if( volSurf.type().isCone() )
62  surf = new ConeSurface( det, volSurf ) ;
63 
64  else
65  surf = new Surface( det, volSurf ) ;
66 
67  // std::cout << " ------------------------- "
68  // << " surface: " << *surf << std::endl
69  // << " ------------------------- " << std::endl ;
70 
71  _sL->push_back( surf ) ;
72 
73  }
74 
75 
76  }
77 
78  }
79 
80 
81 
82  } // namespace
83 }// namespace
bool isCylinder() const
true if this a cylindrical surface
Definition: ISurface.h:208
T empty(T...args)
std::list of VolSurfaces that takes ownership.
Definition: Surface.h:300
virtual const SurfaceType & type() const
properties of the surface encoded in Type.
Definition: Surface.cpp:248
T end(T...args)
std::list of Surfaces that optionally takes ownership.
Definition: Surface.h:681
VolSurfaceList * volSurfaceList(DetElement &det)
Helper function for accessing the list assigned to a DetElement - attaches empty list if needed...
Definition: Surface.cpp:528
void initialize()
initializes surfaces from VolSurfaces assigned to this DetElement in detector construction ...
T push_back(T...args)
bool isCone() const
true if this a conical surface
Definition: ISurface.h:211
Reference counted handle class for a local surface attached to a volume (VolSurfaceBase).
Definition: Surface.h:181
STL class.
Specialization of Surface for cones - specializes CyliderSurface (for lazyness ...)
Definition: Surface.h:655
T begin(T...args)
Implementation of Surface class holding a local surface attached to a volume and the DetElement holdi...
Definition: Surface.h:498
DetectorSurfaces(const DetElement &e)
Specialization of Surface for cylinders.
Definition: Surface.h:614