diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index 6df69feb047878edf21c1d446f4785f540e394db..59ce2f29b09230327153b61f8a53b09febcb67c0 100644 --- a/UtilityApps/CMakeLists.txt +++ b/UtilityApps/CMakeLists.txt @@ -21,6 +21,18 @@ target_link_libraries(geoPluginRun DD4hepCore) add_executable( print_materials src/print_materials.cpp) target_link_libraries(print_materials DD4hepCore DD4hepRec) #----------------------------------------------------------------------------------- + +if(DD4HEP_USE_GEANT4) + include_directories( ${CMAKE_SOURCE_DIR}/DDG4/include ) + + add_executable( dd_sim src/ddsim.cpp) + target_link_libraries(dd_sim DD4hepCore DD4hepG4) + install(TARGETS dd_sim RUNTIME DESTINATION bin ) +endif() +#----------------------------------------------------------------------------------- + + + root_generate_dictionary( G__teve src/EvNavHandler.h LINKDEF src/LinkDef.h) if(DD4HEP_USE_LCIO) find_package(LCIO REQUIRED) diff --git a/UtilityApps/src/ddsim.cpp b/UtilityApps/src/ddsim.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a1ef98b6e7ec09dc52d4be660b75ee2f615d605e --- /dev/null +++ b/UtilityApps/src/ddsim.cpp @@ -0,0 +1,58 @@ +//==================================================================== +// DDSim - LC simulation based on DD4hep +//-------------------------------------------------------------------- +// F.Gaede, DESY +// $Id:$ +//==================================================================== + +#include "DDG4/Geant4Config.h" +#include <iostream> + + +using namespace DD4hep::Simulation::Setup; + +/** Simple main program to run a simulation with DDG4 + * Loops over all xml files given on command line: + * - first file defines geometry + * - subsequent files configure the application + */ + +int main(int argc, char** argv) { + + + if( argc < 2 ){ + std::cout << " --- Usage example: \n " + << " dd_sim ../ILD/compact/ILD_o1_v05.xml [sensitive_detectors.xml] sequences.xml physics.xml " + << std::endl ; + exit( 0 ) ; + } + + + DD4hep::Geometry::LCDD& lcdd = DD4hep::Geometry::LCDD::getInstance(); + + Kernel& kernel = Kernel::instance(lcdd); + + // first argument: geometry file + + std::string geoFile = "file:" ; + geoFile += argv[1] ; + + kernel.loadGeometry( geoFile ) ; + + for( int i=2 ; i < argc ; ++i ) { + + std::cout << " will open xml file " << argv[i] << " and load to kernel ..." << std::endl ; + + kernel.loadXML( argv[i] ) ; + } + + kernel.configure(); + kernel.initialize(); + + kernel.run(); + + + std::cout << "Successfully executed application .... " << std::endl; + + kernel.terminate(); +}