Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/DDRec/src/SurfaceHelper.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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/SurfaceHelper.h"
0014 
0015 #include "DDRec/DetectorSurfaces.h"
0016 #include "DD4hep/DetElement.h"
0017 #include "DD4hep/Detector.h"
0018 #include "DD4hep/VolumeManager.h"
0019 
0020 namespace dd4hep {
0021   
0022   using namespace detail ;
0023 
0024   namespace rec {
0025     
0026 
0027     SurfaceHelper::SurfaceHelper(dd4hep::DetElement const& e) : _det(e) {
0028 
0029       initialize() ;
0030     }
0031     
0032     SurfaceHelper::~SurfaceHelper(){
0033       // nothing to do
0034     }
0035     
0036     
0037     void SurfaceHelper::initialize() {
0038       
0039       // have to populate the volume manager once in order to have 
0040       // the volumeIDs attached to the DetElements
0041       Detector& description = Detector::getInstance();
0042       /* VolumeManager volMgr = */ VolumeManager::getVolumeManager(description);
0043 
0044       //------------------ breadth first tree traversal ---------
0045       std::list< DetElement > dets ;
0046       std::list< DetElement > daugs ; 
0047       std::list< DetElement > gdaugs ; 
0048       
0049       daugs.push_back( _det ) ;
0050       
0051       while( ! daugs.empty() ) {
0052     
0053         for( std::list< DetElement >::iterator li=daugs.begin() ; li != daugs.end() ; ++li ){
0054           DetElement dau = *li ;
0055           DetElement::Children chMap = dau.children() ;
0056           for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){
0057             DetElement de = (*it).second ;
0058             gdaugs.push_back( de ) ;
0059           }  
0060         }
0061         dets.splice( dets.end() , daugs ) ;
0062         daugs.splice( daugs.end() , gdaugs ) ;
0063       }
0064       //------------------ end tree traversal ---------
0065       
0066       //      std::cout << " **** SurfaceHelper::initialize() : # DetElements found  " << dets.size() << std::endl ;
0067       
0068       for( std::list< DetElement >::iterator li=dets.begin() ; li != dets.end() ; ++li ) {
0069     
0070         DetElement det = (*li) ;
0071     
0072 
0073 
0074         // create surfaces
0075         DetectorSurfaces ds( det ) ;
0076     
0077         const SurfaceList& detSL = ds.surfaceList() ;
0078 
0079 
0080         // // ---------------------- debug printout
0081         // std::cout << " ---- DetElement id: " << det.volumeID() << " name : " << det.name() << "  #surfaces : " << detSL.size() << std::endl ; 
0082         // PlacedVolume pv = det.placement() ;
0083         // if( pv.isValid() ) {
0084         //   try{ // needed as above is also true for world whcih has invalid placment ...
0085         //     PlacedVolume::VolIDs volIDs = pv.volIDs() ;
0086         //     for(unsigned i=0,n=volIDs.size(); i<n ; ++i){
0087         //       std::cout << "        " << volIDs[i].first << " : " << volIDs[i].second << std::endl ;
0088         //     }
0089         //   }catch(...){}
0090         // }else{
0091         //   std::cout << "        invalid placement for DetElement ??? !! " << std::endl ;
0092         // }
0093         // // ------------------------- end debug printout
0094 
0095 
0096         // and add copy them to this list
0097         _sL.insert( _sL.end(), detSL.begin(), detSL.end() );
0098       }
0099       
0100     }
0101     
0102 
0103 
0104   } // namespace
0105 }// namespace