From 63a816ac334f10b60c2c03e2468de90df87462f4 Mon Sep 17 00:00:00 2001 From: Whitney Armstrong <warmstrong@anl.gov> Date: Thu, 8 Jul 2021 14:36:48 -0500 Subject: [PATCH] Added simple dd4hep example To run root script: ``` root -b -q scripts/example_dd4hep.cxx+ ``` --- scripts/example_dd4hep.cxx | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/example_dd4hep.cxx diff --git a/scripts/example_dd4hep.cxx b/scripts/example_dd4hep.cxx new file mode 100644 index 00000000..bf6b24e8 --- /dev/null +++ b/scripts/example_dd4hep.cxx @@ -0,0 +1,36 @@ +#include "DD4hep/Detector.h" +#include "DDG4/Geant4Data.h" +#include "DDRec/CellIDPositionConverter.h" +#include "DDRec/SurfaceManager.h" +#include "DDRec/Surface.h" + + +#include "fmt/core.h" + + +/** Example using dd4hep + */ +void example_dd4hep(const char* fname = "test_tracker_disc.root"){ + + using namespace ROOT::Math; + + // ------------------------- + // Get the DD4hep instance + // Load the compact XML file + // Initialize the position converter tool + dd4hep::Detector& detector = dd4hep::Detector::getInstance(); + detector.fromCompact("athena.xml"); + dd4hep::rec::CellIDPositionConverter cellid_converter(detector); + + fmt::print("Detector Types:\n"); + for(const auto& dtype : detector.detectorTypes() ) { + fmt::print(" {}\n", dtype); + } + + fmt::print("\n"); + fmt::print("All detector subsystem names:\n"); + for(const auto& d : detector.detectors() ) { + fmt::print(" {}\n", d.first); + } + +} -- GitLab