From 771a8fe45618893b3f7dfde612c8f2eeeec6ed36 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Fri, 11 Apr 2014 11:41:59 +0000 Subject: [PATCH] - modified to use SurfaceManager class (up to now now real test - just prints all surfaces ...) --- examples/ILDExDet/src/test_surfaces.cc | 79 +++++--------------------- 1 file changed, 15 insertions(+), 64 deletions(-) diff --git a/examples/ILDExDet/src/test_surfaces.cc b/examples/ILDExDet/src/test_surfaces.cc index f72deb0d8..4a288891b 100644 --- a/examples/ILDExDet/src/test_surfaces.cc +++ b/examples/ILDExDet/src/test_surfaces.cc @@ -1,21 +1,13 @@ #include "DD4hep/LCDD.h" -#include "DD4hep/TGeoUnits.h" -#include "DD4hep/Detector.h" -#include "DD4hep/Volumes.h" #include "DDRec/Surface.h" +#include "DDRec/DetectorSurfaces.h" +#include "DDRec/SurfaceManager.h" -// // #include "TGeoManager.h" -// //---- GEAR ---- -// #include "gear/GEAR.h" -// #include "gearxml/GearXML.h" -// #include "gearimpl/Util.h" -// #include "gearimpl/ConstantBField.h" -// #include "gearimpl/GearMgrImpl.h" -// #include "geartgeo/TGeoGearPointProperties.h" -// #include "geartgeo/TGeoGearDistanceProperties.h" +// #include "DD4hep/TGeoUnits.h" +// #include "DD4hep/Detector.h" +// #include "DD4hep/Volumes.h" -#include <list> using namespace std ; using namespace DD4hep ; @@ -23,7 +15,7 @@ using namespace DD4hep::Geometry; using namespace DD4hep::DDRec ; using namespace DDSurfaces ; -using namespace tgeo ; +//using namespace tgeo ; //============================================================================= @@ -40,66 +32,25 @@ int main(int argc, char** argv ){ lcdd.fromCompact( inFile ); - // gear::GearMgr* gearMgr = createGearMgr( lcdd ) ; - DetElement world = lcdd.world() ; - std::cout << " **** detector " << lcdd.header().name() << " to Gear \n" - << " Iterating over all DetElements: " << std::endl ; + // create a list of all surfaces in the detector: + SurfaceManager surfMan( world ) ; + + const SurfaceList& sL = surfMan.surfaceList() ; - //------------------ breadth first tree traversal --------- - std::list< DetElement > dets ; - std::list< DetElement > daugs ; - std::list< DetElement > gdaugs ; - - daugs.push_back( world ) ; - - while( ! daugs.empty() ) { - - for( std::list< DetElement >::iterator li=daugs.begin() ; li != daugs.end() ; ++li ){ - DetElement dau = *li ; - DetElement::Children chMap = dau.children() ; - for ( DetElement::Children::const_iterator it=chMap.begin() ; it != chMap.end() ; ++it ){ - DetElement de = (*it).second ; - gdaugs.push_back( de ) ; - } - } - dets.splice( dets.end() , daugs ) ; - daugs.splice( daugs.end() , gdaugs ) ; - } - //------------------ end tree traversal --------- - - std::cout << " **** # DetElements found " << dets.size() << std::endl ; - for( std::list< DetElement >::iterator li=dets.begin() ; li != dets.end() ; ++li ) { + for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){ - DetElement det = (*li) ; + Surface& surf = **it ; - if( ! volSurfaceList(det)->empty() ) { - - std::cout << " detector " << det.name() << " id: " << det.id() << " has " << volSurfaceList(det)->size() << " surfaces " << std::endl ; - - - // take first surface for now : - VolSurface volSurf = volSurfaceList(det)->front() ; - - Surface* surf = new Surface( det, volSurf ) ; - - std::cout << " ------------------------- " - << " surface: " << *surf << std::endl - << " ------------------------- " << std::endl ; - - - - - } - + std::cout << " ------------------------- " + << " surface: " << surf << std::endl + << " ------------------------- " << std::endl ; } - - return 0; } -- GitLab