Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:35

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : F.Gaede
0011 //
0012 //==========================================================================
0013 #include "DDRec/DetectorSurfaces.h"
0014 
0015 namespace dd4hep {
0016   namespace rec {
0017     
0018 
0019 
0020     DetectorSurfaces::DetectorSurfaces(dd4hep::DetElement const& e) : DetElement(e) , _sL( 0 ) {
0021 
0022       initialize() ;
0023     }
0024     
0025     DetectorSurfaces::~DetectorSurfaces(){
0026       // nothing to do: SurfaceList is added as extension
0027       // and is deleted automatically
0028     }
0029     
0030     
0031     void DetectorSurfaces::initialize() {
0032       
0033       DetElement det = *this ;
0034       
0035       const VolSurfaceList* vsL = volSurfaceList(det) ;
0036 
0037       try {
0038         _sL = det.extension< SurfaceList >(false) ;
0039         if (not _sL) {
0040           _sL = det.addExtension<SurfaceList >(  new SurfaceList( true )  ) ;
0041         }
0042       } catch(const std::exception& e) { 
0043         _sL = det.addExtension<SurfaceList >(  new SurfaceList( true )  ) ; 
0044       }
0045 
0046       if( ! vsL->empty() && _sL->empty() ) {  // only fill surfaces for this DetElement once
0047     
0048     // std::cout <<  "     detector  " << det.name() << " id: " << det.id() << " has " <<  vsL->size() << " surfaces "  << std::endl ;
0049     
0050     // std::cout << " ------------------------- " 
0051     //    << "  DetectorSurfaces::initialize()  adding surfaces : " 
0052     //    << std::endl ;
0053     
0054     for( VolSurfaceList::const_iterator it = vsL->begin() ; it != vsL->end() ; ++it ){
0055       
0056       VolSurface volSurf =  *it ;
0057       
0058       Surface* surf = 0 ;
0059       
0060       if( volSurf.type().isCylinder() )
0061         surf = new CylinderSurface(  det,  volSurf ) ;
0062       
0063       else if( volSurf.type().isCone() ) 
0064         surf = new ConeSurface( det, volSurf ) ;
0065       
0066       else
0067         surf = new Surface(  det,  volSurf ) ;
0068     
0069       // std::cout << " ------------------------- " 
0070       //        << " surface: "   << *surf        << std::endl
0071       //        << " ------------------------- "  << std::endl ;
0072       
0073       _sL->push_back( surf ) ;
0074       
0075     }
0076 
0077 
0078       }
0079 
0080     }
0081     
0082 
0083 
0084   } // namespace
0085 }// namespace