From a84328b13067eb066dd6fe46d251a14bdd76137c Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 2 Dec 2022 14:39:30 +0100
Subject: [PATCH] Add tests for plugin DD4hepDetectorChecksum for MIniTel and
 CLICSiD

---
 DDDetectors/compact/SiD/SiD_Ecal.xml |  4 ++--
 DDDigi/src/DigiData.cpp              |  2 +-
 DDG4/src/Geant4Output2ROOT.cpp       |  2 +-
 examples/CLICSiD/CMakeLists.txt      | 16 ++++++++++++++++
 examples/ClientTests/CMakeLists.txt  | 17 +++++++++++++++++
 5 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/DDDetectors/compact/SiD/SiD_Ecal.xml b/DDDetectors/compact/SiD/SiD_Ecal.xml
index 0fca44873..2890ee314 100644
--- a/DDDetectors/compact/SiD/SiD_Ecal.xml
+++ b/DDDetectors/compact/SiD/SiD_Ecal.xml
@@ -37,11 +37,11 @@
   <!--  Definition of the readout segmentation/definition  -->
   <readouts>
     <readout name="EcalBarrelHits">
-      <segmentation type="CartesianGridXY" grid_size_x="3.5" grid_size_y="3.5" />
+      <segmentation type="CartesianGridXY" grid_size_x="3.5*mm" grid_size_y="3.5*mm" />
       <id>system:8,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
     </readout>        
     <readout name="EcalEndcapHits">
-      <segmentation type="CartesianGridXY" grid_size_x="3.5" grid_size_y="3.5" />
+      <segmentation type="CartesianGridXY" grid_size_x="3.5*mm" grid_size_y="3.5*mm" />
       <id>system:8,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
     </readout>
   </readouts>
diff --git a/DDDigi/src/DigiData.cpp b/DDDigi/src/DigiData.cpp
index fc9b20771..2e90d70e9 100644
--- a/DDDigi/src/DigiData.cpp
+++ b/DDDigi/src/DigiData.cpp
@@ -228,7 +228,7 @@ const EnergyDeposit& DepositVector::at(std::size_t cell)   const    {
 }
 
 /// Remove entry
-void DepositVector::remove(iterator position)   {
+void DepositVector::remove(iterator /* position */)   {
   //data.erase(position);
 }
 
diff --git a/DDG4/src/Geant4Output2ROOT.cpp b/DDG4/src/Geant4Output2ROOT.cpp
index 952020a72..7e8ca9438 100644
--- a/DDG4/src/Geant4Output2ROOT.cpp
+++ b/DDG4/src/Geant4Output2ROOT.cpp
@@ -56,7 +56,7 @@ void Geant4Output2ROOT::closeOutput()   {
   if (m_file) {
     TDirectory::TContext ctxt(m_file);
     Sections::iterator i = m_sections.find(m_section);
-    info("+++ Closing ROOT ourpur file %s", m_file->GetName());
+    info("+++ Closing ROOT ourput file %s", m_file->GetName());
     if ( i != m_sections.end() )
       m_sections.erase(i);
     m_branches.clear();
diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt
index f147b2bc6..7727547c6 100644
--- a/examples/CLICSiD/CMakeLists.txt
+++ b/examples/CLICSiD/CMakeLists.txt
@@ -129,6 +129,22 @@ dd4hep_add_test_reg( CLICSiD_GDML_import_LONGTEST
 #
 endif()
 #
+# Checksum test of the EcalBarrel sub-detector
+dd4hep_add_test_reg( CLICSiD_check_checksum_EcalBarrel
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh"
+  EXEC_ARGS  geoPluginRun -input ${DD4hep_ROOT}/DDDetectors/compact/SiD.xml -plugin DD4hepDetectorChecksum -newline -readout -detector EcalBarrel
+  REGEX_PASS "Combined hash code                      4105a5e5b8ee5046  \\(10375 sub-codes\\)"
+  REGEX_FAIL "Exception;EXCEPTION;ERROR"
+)
+#
+# Checksum test of the full detector
+dd4hep_add_test_reg( CLICSiD_check_checksum_full
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh"
+  EXEC_ARGS  geoPluginRun -input ${DD4hep_ROOT}/DDDetectors/compact/SiD.xml -plugin DD4hepDetectorChecksum -newline -readout
+  REGEX_PASS "Combined hash code                      85690f29788735eb  \\(3395674 sub-codes\\)"
+  REGEX_FAIL "Exception;EXCEPTION;ERROR"
+)
+#
 #---Geant4 Testing-----------------------------------------------------------------
 #
 if (DD4HEP_USE_GEANT4)
diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt
index d527513bf..92092acf6 100644
--- a/examples/ClientTests/CMakeLists.txt
+++ b/examples/ClientTests/CMakeLists.txt
@@ -369,6 +369,23 @@ foreach (test BoxTrafos CaloEndcapReflection IronCylinder MiniTel SiliconBlock N
     REGEX_PASS " Execution finished..." )
 endforeach()
 #
+#
+# Checksum test of the Minitel3 sub-detector
+dd4hep_add_test_reg( MiniTel_check_checksum_Minitel3
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh"
+  EXEC_ARGS  geoPluginRun -input ${ClientTestsEx_INSTALL}/compact/MiniTelGenerate.xml -plugin DD4hepDetectorChecksum -newline -readout -detector Minitel3
+  REGEX_PASS "Combined hash code                      e577a7c2d045d8c3  \\(52 sub-codes\\)"
+  REGEX_FAIL "Exception;EXCEPTION;ERROR"
+)
+#
+# Checksum test of the full detector
+dd4hep_add_test_reg( MiniTel_check_checksum_full
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh"
+  EXEC_ARGS  geoPluginRun -input ${ClientTestsEx_INSTALL}/compact/MiniTelGenerate.xml -plugin DD4hepDetectorChecksum -newline -readout
+  REGEX_PASS "Combined hash code                      458d9af534c44b90  \\(201 sub-codes\\)"
+  REGEX_FAIL "Exception;EXCEPTION;ERROR"
+)
+#
 #      EXEC_ARGS  test_with_root.sh ${script}
 #
 if (DD4HEP_USE_GEANT4)
-- 
GitLab