From 663ac44e2d9f4f5489456a39743ee6f599bf165c Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 5 Jul 2023 13:29:01 -0500 Subject: [PATCH 01/11] feat: support detector checksum for TGeoTessellated volumes --- DDCore/src/plugins/DetectorChecksum.cpp | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index e1bddc7c9..09739f9e4 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -515,6 +515,41 @@ const DetectorChecksum::entry_t& DetectorChecksum::handleSolid(Solid solid) cons else if ( shape->IsA() == TGeoShapeAssembly::Class() ) { log << ""; } + else if ( shape->IsA() == TGeoTessellated::Class() ) { + const TGeoTessellated* sh = (TGeoTessellated*)shape; + log << "" << newline; + if ( sh->IsClosedBody() == false ) { + except("DetectorChecksum","+++ TGeoTessellated volume is not closed: %s", solid.name()); + } + for (int ivertex = 0; ivertex < sh->GetNvertices(); ivertex++) { + const auto& vtx = const_cast(sh)->GetVertex(ivertex); + log << "" << newline; + } + log << "" << newline; + log << "" << newline; + for (int ifacet = 0; ifacet < sh->GetNfacets(); ifacet++) { + const auto& facet = const_cast(sh)->GetFacet(ifacet); + if ( facet.GetNvert() == 3 ) { + log << "" << newline; + } + log << "" << newline; + } else { except("DetectorChecksum","+++ Unknown shape: %s", solid.name()); } From d9631631c8b71aab0cf28192f4baafa4d21e3be9 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 5 Jul 2023 17:41:28 -0500 Subject: [PATCH 02/11] fix: add comment indicating need for const_cast --- DDCore/src/plugins/DetectorChecksum.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index 09739f9e4..7c5c7c584 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -522,6 +522,7 @@ const DetectorChecksum::entry_t& DetectorChecksum::handleSolid(Solid solid) cons except("DetectorChecksum","+++ TGeoTessellated volume is not closed: %s", solid.name()); } for (int ivertex = 0; ivertex < sh->GetNvertices(); ivertex++) { + // Note: const_cast since TGeoTessellated::GetVertex not marked const in ROOT <= 6.28 const auto& vtx = const_cast(sh)->GetVertex(ivertex); log << "" << newline; log << "" << newline; for (int ifacet = 0; ifacet < sh->GetNfacets(); ifacet++) { + // Note: const_cast since TGeoTessellated::GetFacet not marked const in ROOT <= 6.28 const auto& facet = const_cast(sh)->GetFacet(ifacet); if ( facet.GetNvert() == 3 ) { log << " Date: Wed, 5 Jul 2023 17:42:07 -0500 Subject: [PATCH 03/11] test: DD4hepDetectorChecksum on Check_Shape_Tessellated --- examples/ClientTests/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index 917a55ccc..3d8bc48ed 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -392,6 +392,15 @@ dd4hep_add_test_reg( MiniTel_check_checksum_full REGEX_FAIL "Exception;EXCEPTION;ERROR" ) # +# Checksum test of the full detector +dd4hep_add_test_reg( Check_Shape_Tessellated_check_checksum + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS geoPluginRun -input ${ClientTestsEx_INSTALL}/compact/Check_Shape_Tessellated.xml + -plugin DD4hepDetectorChecksum -readout + REGEX_PASS "Combined hash code 7fc1ef04482fc040 \\(13 sub-codes\\)" + REGEX_FAIL "Exception;EXCEPTION;ERROR" +) +# # Test the sequential processing of two xml files dd4hep_add_test_reg( minitel_config_plugins_include_command_line COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" From d1a83e5e3a8cbbf5a2151be929295da053399748 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 5 Jul 2023 18:00:00 -0500 Subject: [PATCH 04/11] DetectorChecksum: fiix up quotes and spaces --- DDCore/src/plugins/DetectorChecksum.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index 7c5c7c584..5d284829a 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -546,9 +546,9 @@ const DetectorChecksum::entry_t& DetectorChecksum::handleSolid(Solid solid) cons except("DetectorChecksum","+++ TGeoTessellated volume with unsupported number of vertices: %s", solid.name()); } for (int ivertex = 0; ivertex < facet.GetNvert(); ivertex++) { - log << " vertex" << ivertex + 1 << "=\"" << nam << "_v" << facet.GetVertexIndex(ivertex); + log << " vertex" << ivertex + 1 << "=\"" << nam << "_v" << facet.GetVertexIndex(ivertex) << "\""; } - log << "type=\"ABSOLUTE\"/>" << newline; + log << " type=\"ABSOLUTE\"/>" << newline; } log << "" << newline; } From 60e909e58cc15a612b23a8c43acab6e480bb51f0 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 5 Jul 2023 19:41:29 -0500 Subject: [PATCH 05/11] DetectorChecksum: fix test hash after quotes and spaces --- examples/ClientTests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index 3d8bc48ed..c589c2b73 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -397,7 +397,7 @@ dd4hep_add_test_reg( Check_Shape_Tessellated_check_checksum COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" EXEC_ARGS geoPluginRun -input ${ClientTestsEx_INSTALL}/compact/Check_Shape_Tessellated.xml -plugin DD4hepDetectorChecksum -readout - REGEX_PASS "Combined hash code 7fc1ef04482fc040 \\(13 sub-codes\\)" + REGEX_PASS "Combined hash code 2e6b0d0c8839df5e \\(13 sub-codes\\)" REGEX_FAIL "Exception;EXCEPTION;ERROR" ) # From c3d3c5b97d54889f19f47a8c78f7a8a0086c0569 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 5 Jul 2023 19:59:38 -0500 Subject: [PATCH 06/11] DetectorChecksum: ensure correct units --- DDCore/src/plugins/DetectorChecksum.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index 5d284829a..3233e8439 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -526,9 +526,9 @@ const DetectorChecksum::entry_t& DetectorChecksum::handleSolid(Solid solid) cons const auto& vtx = const_cast(sh)->GetVertex(ivertex); log << "" << newline; } log << "" << newline; From cb3497118f6fbfc8e4471592406ccdb73edd1a4e Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 6 Jul 2023 13:47:44 -0500 Subject: [PATCH 07/11] add `-meshes` option to include meshed solids --- DDCore/src/plugins/DetectorChecksum.cpp | 8 +++++++- DDCore/src/plugins/DetectorChecksum.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index 3233e8439..1a9023ba5 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -1306,7 +1306,7 @@ void DetectorChecksum::dump_sensitives() const { static long create_checksum(Detector& description, int argc, char** argv) { std::vector detectors; - int precision = 6, newline = 1, level = 1, readout = 0, debug = 0; + int precision = 6, newline = 1, level = 1, meshes = 0, readout = 0, debug = 0; int dump_elements = 0, dump_materials = 0, dump_solids = 0, dump_volumes = 0; int dump_placements = 0, dump_detelements = 0, dump_sensitives = 0; int dump_iddesc = 0, dump_segmentations = 0; @@ -1333,6 +1333,8 @@ static long create_checksum(Detector& description, int argc, char** argv) { debug = ::atol(argv[++i]); else if ( 0 == ::strncmp("+newline",argv[i],5) ) newline = 0; + else if ( 0 == ::strncmp("-meshes",argv[i],5) ) + meshes = 1; else if ( 0 == ::strncmp("-readout",argv[i],5) ) readout = 1; else if ( 0 == ::strncmp("-dump_elements",argv[i],10) ) @@ -1357,6 +1359,9 @@ static long create_checksum(Detector& description, int argc, char** argv) { std::cout << "Usage: -plugin DD4hepDetectorChecksum -arg [-arg] \n\n" " -detector Top level DetElement path. Default: '/world' \n" + " -meshes also hash the detector's meshed solids \n" + " (may be sensitive to changes due to rounding) \n" + " default: false \n" " -readout also hash the detector's readout properties \n" " (sensitive det, id desc, segmentation) \n" " default: false \n" @@ -1396,6 +1401,7 @@ static long create_checksum(Detector& description, int argc, char** argv) { if ( !dens_unit.empty() ) wr.m_densunit_nam = dens_unit; if ( !atom_unit.empty() ) wr.m_atomunit_nam = atom_unit; if ( newline ) wr.newline = "\n"; + wr.hash_meshes = meshes; wr.hash_readout = readout; wr.max_level = level; wr.debug = debug; diff --git a/DDCore/src/plugins/DetectorChecksum.h b/DDCore/src/plugins/DetectorChecksum.h index bf69edaff..5474d3bbb 100644 --- a/DDCore/src/plugins/DetectorChecksum.h +++ b/DDCore/src/plugins/DetectorChecksum.h @@ -114,6 +114,8 @@ namespace dd4hep { /// Property: precision of hashed printouts mutable int precision { 6 }; + /// Property: Include meshed solids in detector hash + int hash_meshes { 0 }; /// Property: Include readout property in detector hash int hash_readout { 0 }; /// Property: maximum depth level for printouts From d78083c34939fd88ec74a4d4370cab2fd14e2cf6 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 6 Jul 2023 13:49:29 -0500 Subject: [PATCH 08/11] use new -meshes option to write details of meshed solids --- DDCore/src/plugins/DetectorChecksum.cpp | 67 +++++++++++++------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index 1a9023ba5..e194857c8 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -516,41 +516,46 @@ const DetectorChecksum::entry_t& DetectorChecksum::handleSolid(Solid solid) cons log << ""; } else if ( shape->IsA() == TGeoTessellated::Class() ) { - const TGeoTessellated* sh = (TGeoTessellated*)shape; - log << "" << newline; - if ( sh->IsClosedBody() == false ) { - except("DetectorChecksum","+++ TGeoTessellated volume is not closed: %s", solid.name()); - } - for (int ivertex = 0; ivertex < sh->GetNvertices(); ivertex++) { - // Note: const_cast since TGeoTessellated::GetVertex not marked const in ROOT <= 6.28 - const auto& vtx = const_cast(sh)->GetVertex(ivertex); - log << "" << newline; - } - log << "" << newline; - log << "" << newline; - for (int ifacet = 0; ifacet < sh->GetNfacets(); ifacet++) { - // Note: const_cast since TGeoTessellated::GetFacet not marked const in ROOT <= 6.28 - const auto& facet = const_cast(sh)->GetFacet(ifacet); - if ( facet.GetNvert() == 3 ) { - log << "" << newline; + if ( sh->IsClosedBody() == false ) { + except("DetectorChecksum","+++ TGeoTessellated volume is not closed: %s", solid.name()); } - else if ( facet.GetNvert() == 4 ) { - log << "GetNvertices(); ivertex++) { + // Note: const_cast since TGeoTessellated::GetVertex not marked const in ROOT <= 6.28 + const auto& vtx = const_cast(sh)->GetVertex(ivertex); + log << "" << newline; } - else { - except("DetectorChecksum","+++ TGeoTessellated volume with unsupported number of vertices: %s", solid.name()); + log << "" << newline; + log << "" << newline; + for (int ifacet = 0; ifacet < sh->GetNfacets(); ifacet++) { + // Note: const_cast since TGeoTessellated::GetFacet not marked const in ROOT <= 6.28 + const auto& facet = const_cast(sh)->GetFacet(ifacet); + if ( facet.GetNvert() == 3 ) { + log << "" << newline; } - for (int ivertex = 0; ivertex < facet.GetNvert(); ivertex++) { - log << " vertex" << ivertex + 1 << "=\"" << nam << "_v" << facet.GetVertexIndex(ivertex) << "\""; - } - log << " type=\"ABSOLUTE\"/>" << newline; + log << "" << newline; + } + else { + log << "" << newline } - log << "" << newline; } else { except("DetectorChecksum","+++ Unknown shape: %s", solid.name()); From 69e1b6da0f12ea8e014011b194e328d0c78459d6 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Thu, 6 Jul 2023 14:25:49 -0500 Subject: [PATCH 09/11] fix: typo semicolon --- DDCore/src/plugins/DetectorChecksum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index e194857c8..168f949f0 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -554,7 +554,7 @@ const DetectorChecksum::entry_t& DetectorChecksum::handleSolid(Solid solid) cons log << "" << newline; } else { - log << "" << newline + log << "" << newline; } } else { From e33f3f4961341fbcc2bc27c88fad130e50a84755 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 12 Jul 2023 17:35:27 -0500 Subject: [PATCH 10/11] fix: use hash_meshes in tesselated check --- DDCore/src/plugins/DetectorChecksum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDCore/src/plugins/DetectorChecksum.cpp b/DDCore/src/plugins/DetectorChecksum.cpp index 168f949f0..8f3e8b363 100644 --- a/DDCore/src/plugins/DetectorChecksum.cpp +++ b/DDCore/src/plugins/DetectorChecksum.cpp @@ -516,7 +516,7 @@ const DetectorChecksum::entry_t& DetectorChecksum::handleSolid(Solid solid) cons log << ""; } else if ( shape->IsA() == TGeoTessellated::Class() ) { - if ( hash_readout ) { + if ( hash_meshes ) { const TGeoTessellated* sh = (TGeoTessellated*)shape; log << "" << newline; if ( sh->IsClosedBody() == false ) { From c99e55958a12c1e38d7a22f02e2d60daf33f9c97 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Wed, 12 Jul 2023 17:36:09 -0500 Subject: [PATCH 11/11] update tests with precision 3 for meshes --- examples/ClientTests/CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index c589c2b73..6d6fa5dd4 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -392,12 +392,21 @@ dd4hep_add_test_reg( MiniTel_check_checksum_full REGEX_FAIL "Exception;EXCEPTION;ERROR" ) # -# Checksum test of the full detector +# Checksum test of a tessellated solid (default, without meshes) dd4hep_add_test_reg( Check_Shape_Tessellated_check_checksum COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" EXEC_ARGS geoPluginRun -input ${ClientTestsEx_INSTALL}/compact/Check_Shape_Tessellated.xml - -plugin DD4hepDetectorChecksum -readout - REGEX_PASS "Combined hash code 2e6b0d0c8839df5e \\(13 sub-codes\\)" + -plugin DD4hepDetectorChecksum + REGEX_PASS "Combined hash code c8eb13dd1d4d9ca1 \\(13 sub-codes\\)" + REGEX_FAIL "Exception;EXCEPTION;ERROR" +) +# +# Checksum test of a tessellated solid (with meshes) +dd4hep_add_test_reg( Check_Shape_Tessellated_check_checksum_with_meshes + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS geoPluginRun -input ${ClientTestsEx_INSTALL}/compact/Check_Shape_Tessellated.xml + -plugin DD4hepDetectorChecksum -meshes -precision 3 + REGEX_PASS "Combined hash code ada64a13764bb466 \\(13 sub-codes\\)" REGEX_FAIL "Exception;EXCEPTION;ERROR" ) #