From efb9228924a573f527882a3a59fb0a0d8143d73a Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 11 Nov 2016 20:30:53 +0100
Subject: [PATCH] Improve generic conditions data binding

---
 cmake/MakeRootMap.cmake                       |  8 ++---
 examples/AlignDet/CMakeLists.txt              |  8 +++++
 examples/CMakeLists.txt                       |  1 +
 examples/Conditions/CMakeLists.txt            | 29 +++++++++++++------
 .....2000.xml => Modules_run-1000...2000.xml} | 28 ++++++++++++++++++
 examples/Conditions/data/repository.xml       |  5 +---
 6 files changed, 62 insertions(+), 17 deletions(-)
 rename examples/Conditions/data/{Module1_run-1000...2000.xml => Modules_run-1000...2000.xml} (55%)

diff --git a/cmake/MakeRootMap.cmake b/cmake/MakeRootMap.cmake
index 731273eb5..452689a08 100644
--- a/cmake/MakeRootMap.cmake
+++ b/cmake/MakeRootMap.cmake
@@ -2,12 +2,13 @@ message(STATUS " *** ROOT_genmap[Root version: ${ROOT_VERSION_MAJOR}]: Generate
 if( ${ROOT_VERSION_MAJOR} GREATER 5 )
   #
   #  Running listcomponents from Gaudi
-  #
+  #   
   FIND_PROGRAM( ROOT_genmap_CMD listcomponents PATHS ${genmap_install_dir}/../bin ${DD4hep_DIR}/bin )
   ###MESSAGE( STATUS " *** MakeRootMap ${genmap_install_dir}/../bin $ENV{DD4hep_DIR}/bin ${DD4hep_DIR}" )
   MESSAGE( STATUS " *** MakeRootMap[${ROOT_VERSION_MAJOR}].cmake run command : ${ROOT_genmap_CMD} -o ${rootmapfile} ${libname} 
                  WORKING_DIRECTORY ${genmap_install_dir} "
-    )  
+    ) 
+
   if(APPLE)
     SET ( ENV{DYLD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{DYLD_LIBRARY_PATH}:$ENV{DD4HEP_LIBRARY_PATH} )
   else()
@@ -29,8 +30,7 @@ else()
     )
 
   if(APPLE)
-    #MESSAGE( STATUS " set DYLD_LIBRARY_PATH to  ./:$ENV{DYLD_LIBRARY_PATH} " )
-    SET ( ENV{DYLD_LIBRARY_PATH} ./:$ENV{DYLD_LIBRARY_PATH}:$ENV{ROOTSYS}/lib:${genmap_install_dir} )
+    SET ( ENV{DYLD_LIBRARY_PATH} ./:$ENV{DYLD_LIBRARY_PATH}:$ENV{DD4HEP_LIBRARY_PATH}:$ENV{ROOTSYS}/lib:${genmap_install_dir} )
   else()
     SET ( ENV{LD_LIBRARY_PATH} ./:$ENV{LD_LIBRARY_PATH}:$ENV{ROOTSYS}/lib:${genmap_install_dir} )
   endif()
diff --git a/examples/AlignDet/CMakeLists.txt b/examples/AlignDet/CMakeLists.txt
index d07c95a26..023deeec9 100644
--- a/examples/AlignDet/CMakeLists.txt
+++ b/examples/AlignDet/CMakeLists.txt
@@ -25,6 +25,14 @@ dd4hep_add_plugin( AlignDet SOURCES src/*.cpp  )
 dd4hep_install_dir( compact DESTINATION examples/AlignDet )
 dd4hep_configure_scripts( AlignDet DEFAULT_SETUP WITH_TESTS)
 
+#
+#---Testing: Load Telescope geometry and read conditions ------------------
+dd4hep_add_test_reg( test_DetAlign_Telescope_dump_geometry
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_AlignDet.sh"
+  EXEC_ARGS  geoPluginRun -volmgr -destroy
+  -compact file:${CMAKE_CURRENT_SOURCE_DIR}/../AlignDet/compact/Telescope.xml
+  -plugin DD4hepDetectorDump
+  REGEX_PASS "DetectorDump     INFO  003       /world/Telescope/module_9 #Dau\\:0 VolID\\:00000903")
 #
 #---Testing: Load ALEPH TPC geometry --------------------------------------
 dd4hep_add_test_reg( test_DetAlign_AlephTPC_load
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 1e9303b6d..c70d8454a 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -40,6 +40,7 @@ dd4hep_package ( DD4hepExample MAJOR 0 MINOR 15 PATCH 0
 dd4hep_enable_tests (AlignDet
   CLICSiD
   ClientTests
+  Conditions
   DDDB
   DDG4
   SimpleDetector)
diff --git a/examples/Conditions/CMakeLists.txt b/examples/Conditions/CMakeLists.txt
index 05bad5ed3..738308143 100644
--- a/examples/Conditions/CMakeLists.txt
+++ b/examples/Conditions/CMakeLists.txt
@@ -12,20 +12,31 @@
 cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
 include ( ${DD4hep_DIR}/cmake/DD4hep.cmake )
 
-#-----------------------------------------------------------------------------------
+#--------------------------------------------------------------------------
 dd4hep_configure_output ()
 dd4hep_package ( CLICSiD MAJOR 0 MINOR 0 PATCH 1
   USES  [ROOT   REQUIRED COMPONENTS Geom] 
         [DD4hep REQUIRED COMPONENTS DDCore]
 )
 dd4hep_install_dir( xml DESTINATION ${DD4hep_DIR}/examples/Conditions )
+dd4hep_configure_scripts ( Conditions DEFAULT_SETUP WITH_TESTS )
 #--------------------------------------------------------------------------
-#if (DD4HEP_USE_GEANT4)
-#  dd4hep_add_executable(CLICSiDXML SOURCES scripts/CLICSiDXML.C
-#    USES  [DD4hep REQUIRED COMPONENTS DDG4] GEANT4 )
-#  #--------------------------------------------------------------------------
-#  dd4hep_add_executable(CLICSiDAClick SOURCES scripts/CLICSiDAClick.C
-#    USES  [DD4hep REQUIRED COMPONENTS DDG4] GEANT4 )
-#endif()
 #
-dd4hep_configure_scripts ( Conditions DEFAULT_SETUP WITH_TESTS )
+#---Testing: Load Telescope geometry and read conditions ------------------
+dd4hep_add_test_reg( test_Conditions_Telescope_cond_dump_by_pool
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh"
+  EXEC_ARGS  geoPluginRun -volmgr -destroy
+  -compact file:${CMAKE_CURRENT_SOURCE_DIR}/../AlignDet/compact/Telescope.xml
+  -plugin DD4hep_ConditionsXMLRepositoryParser file:${CMAKE_CURRENT_SOURCE_DIR}/data/repository.xml
+  -plugin DD4hep_ConditionsDump
+  REGEX_PASS "Data:\\[\\(0,0,29\\), \\{phi\\(Z angle\\)\\: 0   theta\\(Y angle\\)\\: 1.5708   psi\\(X angle\\)\\: 0\\} , 0  0  0 \\]")
+#
+#
+#---Testing: Load Telescope geometry and read conditions ------------------
+dd4hep_add_test_reg( test_Conditions_Telescope_cond_dump_by_detelement
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_Conditions.sh"
+  EXEC_ARGS  geoPluginRun -volmgr -destroy
+  -compact file:${CMAKE_CURRENT_SOURCE_DIR}/../AlignDet/compact/Telescope.xml
+  -plugin DD4hep_ConditionsXMLRepositoryParser file:${CMAKE_CURRENT_SOURCE_DIR}/data/repository.xml
+  -plugin DD4hep_DetElementConditionsDump
+  REGEX_PASS "Path\\:/world/Telescope/module_9#alignment")
diff --git a/examples/Conditions/data/Module1_run-1000...2000.xml b/examples/Conditions/data/Modules_run-1000...2000.xml
similarity index 55%
rename from examples/Conditions/data/Module1_run-1000...2000.xml
rename to examples/Conditions/data/Modules_run-1000...2000.xml
index e6628b25d..cac8e81df 100644
--- a/examples/Conditions/data/Module1_run-1000...2000.xml
+++ b/examples/Conditions/data/Modules_run-1000...2000.xml
@@ -30,4 +30,32 @@
   <detelement path="/world/Telescope/module_5" ref="default_module.xml">
   </detelement>
 
+  <detelement path="/world/Telescope/module_6">
+    <alignment>
+      <position x="0" y="0"    z="290.0*mm"/>
+      <rotation x="0" y="pi/2" z="0"/>     
+    </alignment>
+  </detelement>
+
+  <detelement path="/world/Telescope/module_7">
+    <alignment>
+      <position x="0" y="0"    z="290.0*mm"/>
+      <rotation x="0" y="pi/2" z="0"/>     
+    </alignment>
+  </detelement>
+
+  <detelement path="/world/Telescope/module_8">
+    <alignment>
+      <position x="0" y="0"    z="290.0*mm"/>
+      <rotation x="0" y="pi/2" z="0"/>     
+    </alignment>
+  </detelement>
+
+  <detelement path="/world/Telescope/module_9">
+    <alignment>
+      <position x="0" y="0"    z="290.0*mm"/>
+      <rotation x="0" y="pi/2" z="0"/>     
+    </alignment>
+  </detelement>
+
 </conditions>
diff --git a/examples/Conditions/data/repository.xml b/examples/Conditions/data/repository.xml
index f914194b2..e476e80c0 100644
--- a/examples/Conditions/data/repository.xml
+++ b/examples/Conditions/data/repository.xml
@@ -17,9 +17,6 @@
   </repository>
 
   <repository>
-    <iov validity="1000,2000#run" ref="Module1_run-1000...2000.xml"/>
-<!--
-    <iov type="run" start="1000" end="2000" ref="module2_run-1000...2000.xml"/>
--->
+    <iov validity="1000,2000#run" ref="Modules_run-1000...2000.xml"/>
   </repository>
 </conditions>
-- 
GitLab