Skip to content
Snippets Groups Projects
Commit 068ca72b authored by lkosarz's avatar lkosarz
Browse files

Updated after changes to data structure

now using dd4hep::sim::Geant4Tracker::Hit*

Signed-off-by: default avatarlkosarz <leszek.kosarzewski@gmail.com>
parent 41cc2209
No related tags found
1 merge request!2Updated after changes to data structure
Pipeline #37376 failed
...@@ -29,13 +29,15 @@ R__LOAD_LIBRARY(libfmt.so) ...@@ -29,13 +29,15 @@ R__LOAD_LIBRARY(libfmt.so)
#include "edm4hep/MCParticleCollection.h" #include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h" #include "edm4hep/SimTrackerHitCollection.h"
#include "DDG4/DDG4Dict.h"
/** Hit position example. /** Hit position example.
* *
*/ */
void tutorial1_hit_position(const char* fname = "gem_tracker_sim.root") { void tutorial1_hit_position(const char* fname = "gem_tracker_sim.root") {
using namespace ROOT::Math; using namespace ROOT::Math;
TChain* t = new TChain("events"); TChain* t = new TChain("EVENT");
t->Add(fname); t->Add(fname);
ROOT::RDataFrame d0(*t, {"GEMTrackerHits", "MCParticles"}); ROOT::RDataFrame d0(*t, {"GEMTrackerHits", "MCParticles"});
...@@ -50,21 +52,21 @@ void tutorial1_hit_position(const char* fname = "gem_tracker_sim.root") { ...@@ -50,21 +52,21 @@ void tutorial1_hit_position(const char* fname = "gem_tracker_sim.root") {
dd4hep::rec::CellIDPositionConverter cellid_converter(detector); dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
// Simple lambda to define nhits branch // 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; std::vector<std::array<double, 2>> result;
for (const auto& h : hits) { for (const auto& h : hits) {
// The actual hit position: // 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 // **This is the most important part.** It provides a way of getting the
// geometry information in a flexible way. // geometry information in a flexible way.
// The segmentation hit postion: // The segmentation hit postion:
auto pos1 = cellid_converter.position(h.cellID); 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(" 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()); 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; return result;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment