From 068ca72b09efa5761b6f01992d75d1cbd800d1d8 Mon Sep 17 00:00:00 2001
From: lkosarz <leszek.kosarzewski@gmail.com>
Date: Wed, 21 Sep 2022 01:21:12 +0200
Subject: [PATCH] Updated after changes to data structure now using
 dd4hep::sim::Geant4Tracker::Hit*

Signed-off-by: lkosarz <leszek.kosarzewski@gmail.com>
---
 scripts/tutorial1_hit_position.cxx | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/scripts/tutorial1_hit_position.cxx b/scripts/tutorial1_hit_position.cxx
index fbe83c5..a5032e7 100644
--- a/scripts/tutorial1_hit_position.cxx
+++ b/scripts/tutorial1_hit_position.cxx
@@ -29,13 +29,15 @@ R__LOAD_LIBRARY(libfmt.so)
 #include "edm4hep/MCParticleCollection.h"
 #include "edm4hep/SimTrackerHitCollection.h"
 
+#include "DDG4/DDG4Dict.h"
+
 /** Hit position example.
  *
  */
 void tutorial1_hit_position(const char* fname = "gem_tracker_sim.root") {
   using namespace ROOT::Math;
 
-  TChain* t = new TChain("events");
+  TChain* t = new TChain("EVENT");
   t->Add(fname);
 
   ROOT::RDataFrame d0(*t, {"GEMTrackerHits", "MCParticles"});
@@ -50,21 +52,21 @@ void tutorial1_hit_position(const char* fname = "gem_tracker_sim.root") {
   dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
 
   // Simple lambda to define nhits branch
-  auto nhits = [](const std::vector<edm4hep::SimTrackerHitData>& evt) { return (int)evt.size(); };
+  auto nhits = [](const std::vector<dd4hep::sim::Geant4Tracker::Hit*>& evt) { return (int)evt.size(); };
 
-  auto local_position = [&](const std::vector<edm4hep::SimTrackerHitData>& hits) {
+  auto local_position = [&](const std::vector<dd4hep::sim::Geant4Tracker::Hit*>& hits) {	  
     std::vector<std::array<double, 2>> result;
     for (const auto& h : hits) {
       // The actual hit position:
-      auto pos0 = (h.position);
+      auto pos0 = (h->position);
 
       // **This is the most important part.** It provides a way of getting the
       // geometry information in a flexible way.
       // The segmentation hit postion:
-      auto pos1 = cellid_converter.position(h.cellID);
-      fmt::print("              Hit Position : {},{},{}\n", pos0.x / 10.0, pos0.y / 10.0, pos0.z / 10.0);
+      auto pos1 = cellid_converter.position(h->cellID);
+      fmt::print("              Hit Position : {},{},{}\n", pos0.x() / 10.0, pos0.y() / 10.0, pos0.z() / 10.0);
       fmt::print("Segmentation-Cell Position : {},{},{}\n", pos1.x(), pos1.y(), pos1.z());
-      result.push_back({pos0.x / 10.0 - pos1.x(), pos0.y / 10.0 - pos1.y()});
+      result.push_back({pos0.x() / 10.0 - pos1.x(), pos0.y() / 10.0 - pos1.y()});
     }
     return result;
   };
-- 
GitLab