From 4d55fe9665cfc98c3a1ff4614e8a5305148a1449 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Thu, 5 Feb 2015 18:50:50 +0000 Subject: [PATCH] - made test_surfaces a generic tool ( checks all SimTrackerHit collections ) --- CMakeLists.txt | 1 - UtilityApps/CMakeLists.txt | 22 ++++++++--- .../{test_surfaces.cc => test_surfaces.cpp} | 37 ++++++++----------- examples/CMakeLists.txt | 10 +---- 4 files changed, 34 insertions(+), 36 deletions(-) rename UtilityApps/src/{test_surfaces.cc => test_surfaces.cpp} (85%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4ace1cd3..8d20cfce2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,6 @@ add_subdirectory(DDSegmentation) add_subdirectory(DDCore) add_subdirectory(DDSurfaces) add_subdirectory(DDRec) -add_subdirectory(DDSense) add_subdirectory(DDEve) add_subdirectory(DDDetectors) diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index 9a50c9bcc..20fb66516 100644 --- a/UtilityApps/CMakeLists.txt +++ b/UtilityApps/CMakeLists.txt @@ -4,7 +4,8 @@ include_directories( ${CMAKE_SOURCE_DIR}/DDCore/include ${ROOT_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/DDSegmentation/include ${CMAKE_SOURCE_DIR}/DDSurfaces/include - ${CMAKE_SOURCE_DIR}/DDRec/include ) + ${CMAKE_SOURCE_DIR}/DDRec/include + ${CMAKE_SOURCE_DIR}/DDTest/include ) @@ -31,6 +32,9 @@ if(DD4HEP_USE_LCIO) find_package(LCIO REQUIRED) include_directories( ${LCIO_INCLUDE_DIRS} ) add_executable(teveDisplay src/teve_display.cpp G__teve.cxx src/next_event_lcio.cpp) + + add_executable(test_surfaces src/test_surfaces.cpp ) + target_link_libraries(test_surfaces DD4hepCore DD4hepRec ${LCIO_LIBRARIES} ) else() add_executable(teveDisplay src/teve_display.cpp G__teve.cxx src/next_event_dummy.cpp) endif() @@ -38,9 +42,17 @@ target_link_libraries( teveDisplay DD4hepCore ${ROOT_EVE_LIBRARIES} DD4hepRec ${ #--- install target------------------------------------- -install(TARGETS geoDisplay geoConverter geoPluginRun teveDisplay print_materials materialScan - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ) +if(DD4HEP_USE_LCIO) + install(TARGETS geoDisplay geoConverter geoPluginRun teveDisplay print_materials materialScan test_surfaces + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ) +else() + install(TARGETS geoDisplay geoConverter geoPluginRun teveDisplay print_materials materialScan + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ) +endif() + # to do: add corresponding uninstall... #------------------------------------------------------- diff --git a/UtilityApps/src/test_surfaces.cc b/UtilityApps/src/test_surfaces.cpp similarity index 85% rename from UtilityApps/src/test_surfaces.cc rename to UtilityApps/src/test_surfaces.cpp index 599b4d858..b727ce338 100644 --- a/UtilityApps/src/test_surfaces.cc +++ b/UtilityApps/src/test_surfaces.cpp @@ -68,7 +68,7 @@ int main(int argc, char** argv ){ } //--------------------------------------------------------------------- - // open lcio file (created with ILDExSimu) + // open lcio file with SimTrackerHits //--------------------------------------------------------------------- std::string lcioFileName = argv[2] ; @@ -78,35 +78,28 @@ int main(int argc, char** argv ){ LCEvent* evt = 0 ; - UTIL::BitField64 idDecoder( ILDCellID0::encoder_string ) ; - - - std::vector< std::string > colNames ; - colNames.push_back( "VXDCollection" ) ; - colNames.push_back( "SITCollection" ) ; - colNames.push_back( "SETCollection" ) ; - colNames.push_back( "FTDCollection" ) ; - colNames.push_back( "TPCCollection" ) ; while( ( evt = rdr->readNextEvent() ) != 0 ){ + const std::vector< std::string >& colNames = *evt->getCollectionNames() ; for(unsigned icol=0, ncol = colNames.size() ; icol < ncol ; ++icol ){ - - LCCollection* col = 0 ; - try{ + LCCollection* col = evt->getCollection( colNames[ icol ] ) ; - col = evt->getCollection( colNames[ icol ] ) ; + std::string typeName = col->getTypeName() ; - }catch(lcio::DataNotAvailableException&e){ - - std::cout << " --- collection : " << colNames[ icol ] << " not in event ... " << std::endl ; + if( typeName != lcio::LCIO::SIMTRACKERHIT ) continue ; - } - int nHit = col->getNumberOfElements() ; + + std::cout << " -- testing collection : " << colNames[ icol ] << std::endl ; + + std::string cellIDEcoding = col->getParameters().getStringVal("CellIDEncoding") ; + UTIL::BitField64 idDecoder( cellIDEcoding ) ; + int nHit = col->getNumberOfElements() ; + for(int i=0 ; i< nHit ; ++i){ SimTrackerHit* sHit = (SimTrackerHit*) col->getElementAt(i) ; @@ -119,7 +112,7 @@ int main(int argc, char** argv ){ Surface* surf = surfMap[ id ] ; std::stringstream sst ; - sst << " surface found for id : " << std::hex << id << std::dec ; + sst << " surface found for id : " << std::hex << id << std::dec << " " << idDecoder.valueString() << std ::endl ; // ===== test that we have a surface with the correct ID for every hit ====================== @@ -148,7 +141,7 @@ int main(int argc, char** argv ){ if( ! isInside ) { std::cout << " found surface " << *surf << std::endl - << " id : " << idDecoder + << " id : " << idDecoder.valueString() << " point : " << point << " is inside : " << isInside << " distance from surface : " << dist/dd4hep::mm << std::endl @@ -166,7 +159,7 @@ int main(int argc, char** argv ){ if( ! isInside ) { std::cout << " found surface " << *surf << std::endl - << " id : " << idDecoder + << " id : " << idDecoder.valueString() << " point : " << point << " is inside : " << isInside << " distance from surface : " << dist/dd4hep::mm << std::endl diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a11628bac..2ed7e7b55 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,15 +24,9 @@ endif(BUILD_TESTING) # # (un)comment as needed # -add_subdirectory(ILDExDet) - -add_subdirectory(ILDExSimu) add_subdirectory(CLICSiD) -add_subdirectory(noviceN04) - -add_subdirectory(firstExample) +add_subdirectory(ClientTests) + -#---- does not build on mac or ubuntu ... -#add_subdirectory(Segmentation) -- GitLab