diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index 20fb66516eb253ff425b726a107597cdf09d6db7..19ed2f03fe69950a4c7eee7cce801dec4e048d10 100644 --- a/UtilityApps/CMakeLists.txt +++ b/UtilityApps/CMakeLists.txt @@ -25,6 +25,9 @@ target_link_libraries(print_materials DD4hepCore DD4hepRec) add_executable( materialScan src/materialScan.cpp) target_link_libraries(materialScan DD4hepCore DD4hepRec) #----------------------------------------------------------------------------------- +add_executable( dumpdetector src/dumpdetector.cpp) +target_link_libraries(dumpdetector DD4hepCore DD4hepRec) +#----------------------------------------------------------------------------------- root_generate_dictionary( G__teve src/EvNavHandler.h LINKDEF src/LinkDef.h) @@ -43,12 +46,12 @@ target_link_libraries( teveDisplay DD4hepCore ${ROOT_EVE_LIBRARIES} DD4hepRec ${ #--- install target------------------------------------- if(DD4HEP_USE_LCIO) - install(TARGETS geoDisplay geoConverter geoPluginRun teveDisplay print_materials materialScan test_surfaces + install(TARGETS geoDisplay geoConverter geoPluginRun teveDisplay print_materials materialScan dumpdetector test_surfaces RUNTIME DESTINATION bin LIBRARY DESTINATION lib ) else() - install(TARGETS geoDisplay geoConverter geoPluginRun teveDisplay print_materials materialScan + install(TARGETS geoDisplay geoConverter geoPluginRun teveDisplay print_materials materialScand umpdetector RUNTIME DESTINATION bin LIBRARY DESTINATION lib ) diff --git a/UtilityApps/src/dumpdetector.cpp b/UtilityApps/src/dumpdetector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d056b97de77d9c476474da25ad860cc49711fdf --- /dev/null +++ b/UtilityApps/src/dumpdetector.cpp @@ -0,0 +1,92 @@ +// $Id:$ +//==================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------- +// +// Simple program to dump the complete DetElement hierarchy +// +// Author : F.Gaede, CERN/DESY +// Date : 07 Nov 2014 +//==================================================================== +#include "DD4hep/LCDD.h" +#include "DD4hep/DD4hepUnits.h" + +#include "DDRec/Surface.h" +#include "DDRec/DetectorSurfaces.h" +#include "DDRec/SurfaceManager.h" + +#include <list> + + +using namespace std ; +using namespace DD4hep ; +using namespace DD4hep::Geometry; +using namespace DD4hep::DDRec; +using namespace DDSurfaces ; +using namespace dd4hep ; + +//============================================================================= + +int main(int argc, char** argv ){ + + if( argc != 2 ) { + std::cout << " usage: dumpdetector compact.xml " << std::endl ; + exit(1) ; + } + + std::string inFile = argv[1] ; + + LCDD& lcdd = LCDD::getInstance(); + + lcdd.fromCompact( inFile ); + + DetElement world = lcdd.world() ; + + std::cout << "############################################################################### " << std::endl << std::endl ; + + + //------------------ 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 --------- + + + for ( std::list< DetElement >::const_iterator it=dets.begin() ; it != dets.end() ; ++it ){ + + DetElement de = (*it) ; + + SurfaceManager surfMan( de ) ; + + const SurfaceList& sL = surfMan.surfaceList() ; + + std::cout << "DetElement: " << de.name() << "[ path: "<< de.placementPath () << "] \t surfaces : " << ( sL.empty() ? 0 : sL.size() ) << std::endl ; + + // for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){ + // Surface* surf = *it ; + // std::cout << " ------------------------- " + // << " surface: " << *surf << std::endl + // << " ------------------------- " << std::endl ; + // } + } + + std::cout << "############################################################################### " << std::endl << std::endl ; + + + return 0; +} + +//=============================================================================