Skip to content
Snippets Groups Projects
Commit 54929bf2 authored by Frank Gaede's avatar Frank Gaede
Browse files

- added dumpdetector utility

   shows all DetElements in model incl. #surfaces
parent 8781a4bc
No related branches found
No related tags found
No related merge requests found
......@@ -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
)
......
// $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;
}
//=============================================================================
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment