From 20435ea06654d7c32ca31cc1c55476e50a9646f4 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Mon, 17 Nov 2014 10:40:34 +0000 Subject: [PATCH] - reverted delete by Markus: we need this application as it is the main simulation application for LC --- UtilityApps/CMakeLists.txt | 12 ++++++++ UtilityApps/src/ddsim.cpp | 58 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 UtilityApps/src/ddsim.cpp diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt index 6df69feb0..59ce2f29b 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 000000000..a1ef98b6e --- /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(); +} -- GitLab