Skip to content
Snippets Groups Projects

Updated after changes to data structure

Open Leszek Kosarzewski requested to merge update_ATHENAtoEPIC into master
1 file
+ 9
7
Compare changes
  • Side-by-side
  • Inline
@@ -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;
};
Loading