From 2f71d4eceeca3acea63d602517f622e09d3755ac Mon Sep 17 00:00:00 2001 From: Markus Frank <markus.frank@cern.ch> Date: Fri, 4 Dec 2015 19:53:30 +0000 Subject: [PATCH] Fix examples with ROOT 6 --- DDG4/examples/initAClick.C | 30 ++++++++++++++++---------- DDG4/python/DDG4Dict.C | 30 +++++++++++++++----------- examples/CLICSiD/CMakeLists.txt | 33 +++++++++++++++-------------- examples/ClientTests/CMakeLists.txt | 12 +++++------ 4 files changed, 60 insertions(+), 45 deletions(-) diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C index 050e104ab..80e4f30d8 100644 --- a/DDG4/examples/initAClick.C +++ b/DDG4/examples/initAClick.C @@ -14,15 +14,25 @@ string make_str(const char* data) { return string(data); } -void processMacro(const char* macro, bool end_process) { - string cmd = ".X "; - cmd += macro; - cmd += ".C+()"; - int status = gInterpreter->ProcessLine(cmd.c_str()); - ::printf("Status(%s) = %d\n",cmd.c_str(),status); +int processCommand(const char* command, bool end_process) { + int status; + // Disabling auto-parse is a hack required by a bug in ROOT + gInterpreter->SetClassAutoparsing(false); + status = gInterpreter->ProcessLine(command); + gInterpreter->SetClassAutoparsing(true); + ::printf("+++ Status(%s) = %d\n",command,status); if ( end_process ) { gInterpreter->ProcessLine("gSystem->Exit(0)"); } + return status; +} + +int processMacro(const char* macro, bool end_process) { + int status; + string cmd = ".X "; + cmd += macro; + cmd += ".C+()"; + return processCommand(cmd.c_str(), end_process); } int initAClick(const char* command=0) { @@ -44,15 +54,13 @@ int initAClick(const char* command=0) { libs += (" -L"+g4_base+"/lib -L"+g4_base+"/lib64 -lG4event -lG4tracking -lG4particles"); gSystem->AddIncludePath(inc.c_str()); gSystem->AddLinkedLibs(libs.c_str()); - cout << "Includes: " << gSystem->GetIncludePath() << endl; - cout << "Linked libs:" << gSystem->GetLinkedLibs() << endl; + cout << "+++ Includes: " << gSystem->GetIncludePath() << endl; + cout << "+++ Linked libs:" << gSystem->GetLinkedLibs() << endl; int ret = gSystem->Load("libDDG4Plugins"); if ( 0 == ret ) { if ( command ) { - gInterpreter->ProcessLine(command); - gInterpreter->ProcessLine("gSystem->Exit(0)"); + processCommand(command, true); } } return ret; } - diff --git a/DDG4/python/DDG4Dict.C b/DDG4/python/DDG4Dict.C index 42116de65..2378a28ed 100644 --- a/DDG4/python/DDG4Dict.C +++ b/DDG4/python/DDG4Dict.C @@ -17,10 +17,10 @@ // //==================================================================== // FRamework include files +#include "DDG4/Geant4Config.h" #include "DDG4/Geant4Primary.h" #include "DDG4/Geant4Random.h" #include "DDG4/DDG4Dict.h" -#include "DDG4/Geant4Config.h" #include "DDG4/Geant4DataDump.h" #include "DDG4/Geant4InputAction.h" @@ -197,6 +197,7 @@ typedef DD4hep::Simulation::Geant4ActionCreation Geant4ActionCreation; #include "DD4hep/objects/DetectorInterna.h" using namespace std; +using namespace DD4hep; using namespace DD4hep::Simulation; // CINT configuration @@ -223,16 +224,21 @@ using namespace DD4hep::Simulation; #if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0) namespace { struct bla { - DD4hep::dd4hep_ptr<Geant4InputAction::Particles> __m1; - DD4hep::dd4hep_ptr<ParticleExtension> __m2; - DD4hep::dd4hep_ptr<DataExtension> __m3; + dd4hep_ptr<Geant4InputAction::Particles> __m1; + dd4hep_ptr<ParticleExtension> __m2; + dd4hep_ptr<DataExtension> __m3; }; } +#else +#pragma link C++ class Geant4ParticleHandle; +#pragma link C++ class Geant4ParticleMap; +#pragma link C++ class map<int,Geant4Particle*>; #endif -#pragma link C++ class DD4hep::dd4hep_ptr<VertexExtension>+; -#pragma link C++ class DD4hep::dd4hep_ptr<PrimaryExtension>+; -#pragma link C++ class DD4hep::dd4hep_ptr<Geant4InputAction::Particles>; -#pragma link C++ class DD4hep::dd4hep_ptr<Geant4InputAction::Particles>::base_t; + +#pragma link C++ class dd4hep_ptr<VertexExtension>+; +#pragma link C++ class dd4hep_ptr<PrimaryExtension>+; +#pragma link C++ class dd4hep_ptr<Geant4InputAction::Particles>; +#pragma link C++ class dd4hep_ptr<Geant4InputAction::Particles>::base_t; // Basic stuff #pragma link C++ class Geant4ActionCreation; @@ -309,8 +315,8 @@ namespace { #pragma link C++ class Geant4ActionPhase; #pragma link C++ class Geant4PhaseAction; -#pragma link C++ class DD4hep::Callback; -#pragma link C++ class DD4hep::Callback::mfunc_t; +#pragma link C++ class Callback; +#pragma link C++ class Callback::mfunc_t; // Other (specialized) components #pragma link C++ class Geant4DataDump; @@ -320,8 +326,8 @@ namespace { // somehow the symbol Geometry moved into global namespace. Redeclare it here -namespace Geometry {} -#pragma link C++ namespace Geometry; +//namespace Geometry {} +//#pragma link C++ namespace Geometry; #endif diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt index 35962a6ba..0fe04b7bd 100644 --- a/examples/CLICSiD/CMakeLists.txt +++ b/examples/CLICSiD/CMakeLists.txt @@ -27,16 +27,17 @@ if (DD4HEP_USE_GEANT4) dd4hep_add_executable(CLICSiDAClick SOURCES scripts/CLICSiDAClick.C USES [DD4hep REQUIRED COMPONENTS DDG4] GEANT4 ) endif() - -#---Testing------------------------------------------------------------------------- +# dd4hep_configure_scripts ( CLICSiD DEFAULT_SETUP WITH_TESTS ) - +# +#---Testing------------------------------------------------------------------------- +# #----- Tests for CLICSid: here we simply require that at least 100 volumes have been converted foreach ( typ lcdd gdml vis ) dd4hep_add_test_reg ( "test_CLICSiD_converter_${typ}" COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" EXEC_ARGS geoConverter -compact2${typ} - -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + -input file:${CMAKE_INSTALL_PREFIX}/examples/CLICSiD/compact/compact.xml -output file:CLICSiD.${typ} REGEX_PASS " Handled [1-9][0-9][0-9]+ volumes" ) endforeach() @@ -45,7 +46,7 @@ endforeach() dd4hep_add_test_reg( test_CLICSiD_check_geometry COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" EXEC_ARGS python ${DD4hep_DIR}/python/checkGeometry.py - --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + --compact=file:${CMAKE_INSTALL_PREFIX}/examples/CLICSiD/compact/compact.xml # This takes too long --full=true --ntracks=10 --option=o --vx=0 --vy=0 --vz=0 REGEX_PASS " Execution finished..." ) # @@ -53,17 +54,19 @@ dd4hep_add_test_reg( test_CLICSiD_check_geometry dd4hep_add_test_reg( test_CLICSiD_check_overlaps COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" EXEC_ARGS python ${DD4hep_DIR}/python/checkOverlaps.py - --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + --compact=file:${CMAKE_INSTALL_PREFIX}/examples/CLICSiD/compact/compact.xml --tolerance=0.1 REGEX_PASS " Execution finished..." ) # +#---Geant4 Testsing----------------------------------------------------------------- +# if (DD4HEP_USE_GEANT4) # # Basic DDG4 component/unit tests foreach(script testDDPython CLICMagField CLICPhysics CLICRandom CLICSiDScan) dd4hep_add_test_reg( test_CLICSiD_DDG4_${script} COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" - EXEC_ARGS python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script}.py + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/examples/CLICSiD/scripts/${script}.py REQUIRES DDG4 Geant4 REGEX_PASS "TEST_PASSED" REGEX_FAIL "Exception;EXCEPTION;ERROR" ) @@ -73,7 +76,7 @@ if (DD4HEP_USE_GEANT4) dd4hep_add_test_reg( test_CLICSiD_DDG4_g4material_scan COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" EXEC_ARGS python ${DD4hep_DIR}/python/g4MaterialScan.py - --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml + --compact=file:${CMAKE_INSTALL_PREFIX}/examples/CLICSiD/compact/compact.xml "--position=0,0,0" "--direction=0,1,0" REGEX_PASS " Terminate Geant4 and delete associated actions." ) # @@ -81,14 +84,12 @@ if (DD4HEP_USE_GEANT4) foreach(script CLICSiDXML CLICSiDAClick) # # Build AClick from the source file - if ( ${ROOT_VERSION_MAJOR} LESS 6 ) - dd4hep_add_test_reg( test_CLICSiD_DDG4_${script}_as_AClick - COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" - EXEC_ARGS root.exe -b -x -n -q -l "${DD4hep_DIR}/examples/DDG4/examples/run.C(\"${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script}\")" - REQUIRES DDG4 Geant4 - REGEX_PASS "UserEvent_1 INFO Geant4TestEventAction> calling end.event_id=9" - REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" ) - endif() + dd4hep_add_test_reg( test_CLICSiD_DDG4_${script}_as_AClick + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS root.exe -b -x -n -q -l "${DD4hep_DIR}/examples/DDG4/examples/run.C(\"${CMAKE_INSTALL_PREFIX}/examples/CLICSiD/scripts/${script}\")" + REQUIRES DDG4 Geant4 + REGEX_PASS "UserEvent_1 INFO Geant4TestEventAction> calling end.event_id=9" + REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" ) # # Execute identical source linked executable dd4hep_add_test_reg( test_CLICSiD_DDG4_${script}_as_exe diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index 3527c2263..09c1cff18 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -37,7 +37,7 @@ foreach (test Assemblies BoxTrafos IronCylinder LheD_tracker MagnetFields Materi dd4hep_add_test_reg( ClientTests_${test}_converter_${type} COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS geoConverter -compact2${type} - -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml + -input file:${CMAKE_INSTALL_PREFIX}/examples/ClientTests/compact/${test}.xml -output file:${test}.${type} REGEX_PASS " Handled [1-9][0-9]* volumes" ) endforeach(type) @@ -53,7 +53,7 @@ foreach (test Assemblies BoxTrafos LheD_tracker MagnetFields MiniTel SiliconBloc # Test material scans in [origine to 10 meters in y] dd4hep_add_test_reg( ClientTests_${test}_material_scan COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" - EXEC_ARGS materialScan file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml 0 0 0 0 10000 0 + EXEC_ARGS materialScan file:${CMAKE_INSTALL_PREFIX}/examples/ClientTests/compact/${test}.xml 0 0 0 0 10000 0 REGEX_PASS " Average Material " ) # # Geant4 material scan. From position=0,0,0 to end-of-world @@ -61,7 +61,7 @@ foreach (test Assemblies BoxTrafos LheD_tracker MagnetFields MiniTel SiliconBloc dd4hep_add_test_reg( ClientTests_${test}_g4material_scan COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS python ${DD4hep_DIR}/python/g4MaterialScan.py - --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml + --compact=file:${CMAKE_INSTALL_PREFIX}/examples/ClientTests/compact/${test}.xml "--position=0,0,0" "--direction=0,1,0" REGEX_PASS " Terminate Geant4 and delete associated actions." ) endif(DD4HEP_USE_GEANT4) @@ -75,7 +75,7 @@ foreach (test BoxTrafos IronCylinder MiniTel SiliconBlock NestedSimple ) dd4hep_add_test_reg( ClientTests_${test}_check_geometry COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS python ${DD4hep_DIR}/python/checkGeometry.py - --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml + --compact=file:${CMAKE_INSTALL_PREFIX}/examples/ClientTests/compact/${test}.xml --full=true --ntracks=10 REGEX_PASS " Execution finished..." ) # @@ -83,7 +83,7 @@ foreach (test BoxTrafos IronCylinder MiniTel SiliconBlock NestedSimple ) dd4hep_add_test_reg( ClientTests_${test}_check_overlaps COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" EXEC_ARGS python ${DD4hep_DIR}/python/checkOverlaps.py - --compact=file:${CMAKE_CURRENT_SOURCE_DIR}/compact/${test}.xml + --compact=file:${CMAKE_INSTALL_PREFIX}/examples/ClientTests/compact/${test}.xml --tolerance=0.1 REGEX_PASS " Execution finished..." ) endforeach() @@ -96,7 +96,7 @@ if (DD4HEP_USE_GEANT4) foreach(script Assemblies LheD_tracker MiniTel NestedDetectors ) dd4hep_add_test_reg( ClientTests_sim_${script} COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" - EXEC_ARGS python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/${script}.py batch + EXEC_ARGS python ${CMAKE_INSTALL_PREFIX}/examples/ClientTests/scripts/${script}.py batch REQUIRES DDG4 Geant4 REGEX_PASS NONE REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" ) -- GitLab