Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:42

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/SurfaceManager.h"
0014 
0015 #include "DDRec/SurfaceHelper.h"
0016 #include "DD4hep/VolumeManager.h"
0017 #include "DD4hep/Detector.h"
0018 
0019 #include <sstream>
0020 
0021 namespace dd4hep {
0022   
0023   using namespace detail ;
0024 
0025   namespace rec {
0026     
0027 
0028     SurfaceManager::SurfaceManager(const Detector& theDetector){
0029 
0030       // have to make sure the volume manager is populated once in order to have
0031       // the volumeIDs attached to the DetElements
0032 
0033       VolumeManager::getVolumeManager(theDetector);
0034 
0035       initialize(theDetector) ;
0036     }
0037     
0038     SurfaceManager::~SurfaceManager(){
0039       // nothing to do
0040     }
0041     
0042     
0043     const SurfaceMap* SurfaceManager::map( const std::string name ) const {
0044 
0045       SurfaceMapsMap::const_iterator it = _map.find( name ) ;
0046 
0047       if( it != _map.end() ){
0048 
0049         return & it->second ;
0050       }
0051 
0052       return 0 ;
0053     }
0054 
0055     void SurfaceManager::initialize(const Detector& description) {
0056       
0057       const std::vector<std::string>& types = description.detectorTypes() ;
0058 
0059       for(unsigned i=0,N=types.size();i<N;++i){
0060 
0061         const std::vector<DetElement>& dets = description.detectors( types[i] ) ;  
0062 
0063         for(unsigned j=0,M=dets.size();j<M;++j){
0064 
0065           std::string name = dets[j].name() ;
0066 
0067           SurfaceHelper surfH( dets[j] ) ;
0068       
0069           const SurfaceList& detSL = surfH.surfaceList() ;
0070   
0071           // add an empty map for this detector in case there are no surfaces attached 
0072           _map.emplace(name , SurfaceMap());
0073 
0074           for( SurfaceList::const_iterator it = detSL.begin() ; it != detSL.end() ; ++it ){
0075             ISurface* surf =  *it ;
0076         
0077             // enter surface into map for this detector
0078             _map[ name ].emplace(surf->id(), surf );
0079 
0080             // enter surface into map for detector type
0081             _map[ types[i] ].emplace(surf->id(), surf );
0082 
0083             // enter surface into world map 
0084             _map[ "world" ].emplace(surf->id(), surf );
0085 
0086           }
0087         }
0088       }
0089 
0090     }
0091 
0092     std::string SurfaceManager::toString() const {
0093       
0094       std::stringstream sstr ;
0095        
0096       sstr << "--------  SurfaceManager contains the following maps : --------- " << std::endl ;
0097  
0098       for( SurfaceMapsMap::const_iterator mi = _map.begin() ; mi != _map.end() ; ++mi ) {
0099     
0100         sstr << "  key: " <<  mi->first << " \t number of surfaces : " << mi->second.size() << std::endl ; 
0101       }
0102       sstr << "---------------------------------------------------------------- " << std::endl ;
0103 
0104       return sstr.str() ;
0105     }
0106 
0107 
0108   } // namespace
0109 }// namespace