Skip to content

Commit c711df5

Browse files
committed
feat: determine detector checksum on geometry read (if supported)
1 parent e13d78b commit c711df5

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ if(EDM4EIC_INTERFACE_COMPILE_DEFINITIONS)
194194
endif()
195195

196196
# DD4Hep is required for the most of the part
197-
find_package(DD4hep REQUIRED)
197+
find_package(DD4hep 1.26 REQUIRED)
198198

199199
# ACTS cmake-lint: disable=C0103
200200
find_package(Acts REQUIRED COMPONENTS Core PluginDD4hep PluginJson)

cmake/jana_plugin.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ endmacro()
248248
macro(plugin_add_dd4hep _name)
249249

250250
if(NOT DD4hep_FOUND)
251-
find_package(DD4hep REQUIRED)
251+
find_package(DD4hep 1.26 REQUIRED)
252252
endif()
253253

254-
plugin_link_libraries(${_name} DD4hep::DDCore DD4hep::DDRec)
254+
plugin_link_libraries(${_name} DD4hep::DDCore DD4hep::DDRec ${ARGN})
255255

256256
endmacro()
257257

src/services/geometry/dd4hep/DD4hep_service.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include <utility>
1818
#include <vector>
1919

20+
#if __has_include(<DD4hep/plugins/DetectorChecksum.h>)
21+
#include <DD4hep/plugins/DetectorChecksum.h>
22+
#endif
23+
2024
#include "DD4hep_service.h"
2125
#include "services/log/Log_service.h"
2226

@@ -139,6 +143,21 @@ void DD4hep_service::Initialize() {
139143
detector->volumeManager();
140144
detector->apply("DD4hepVolumeManager", 0, nullptr);
141145
m_cellid_converter = std::make_unique<const dd4hep::rec::CellIDPositionConverter>(*detector);
146+
147+
// Determine detector checksum
148+
#if __has_include(<DD4hep/plugins/DetectorChecksum.h>)
149+
using dd4hep::detail::DetectorChecksum;
150+
DetectorChecksum checksum(*detector);
151+
checksum.precision = 3;
152+
checksum.hash_meshes = true;
153+
checksum.hash_readout = true;
154+
checksum.analyzeDetector(detector->world());
155+
DetectorChecksum::hashes_t hash_vec{checksum.handleHeader().hash};
156+
checksum.checksumDetElement(0, detector->world(), hash_vec, true);
157+
DetectorChecksum::hash_t hash = dd4hep::detail::hash64(&hash_vec[0], hash_vec.size() * sizeof(DetectorChecksum::hash_t));
158+
m_log->info("Geometry checksum 0x%016lx", hash);
159+
#endif
160+
142161
m_dd4hepGeo = std::move(detector); // const
143162

144163
m_log->info("Geometry successfully loaded.");

0 commit comments

Comments
 (0)