Skip to content
Snippets Groups Projects
Commit 254d7ed2 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

modified: scripts/tutorial3_id_spec.cxx

parent 633e178d
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ R__LOAD_LIBRARY(libfmt.so) ...@@ -32,7 +32,7 @@ R__LOAD_LIBRARY(libfmt.so)
/** Hit position example. /** Hit position example.
* *
*/ */
void tutorial2_cell_size(const char* fname = "gem_tracker_sim.root") { void tutorial3_id_spec(const char* fname = "gem_tracker_sim.root") {
using namespace ROOT::Math; using namespace ROOT::Math;
TChain* t = new TChain("events"); TChain* t = new TChain("events");
...@@ -49,10 +49,12 @@ void tutorial2_cell_size(const char* fname = "gem_tracker_sim.root") { ...@@ -49,10 +49,12 @@ void tutorial2_cell_size(const char* fname = "gem_tracker_sim.root") {
detector.fromCompact("gem_tracker.xml"); detector.fromCompact("gem_tracker.xml");
dd4hep::rec::CellIDPositionConverter cellid_converter(detector); dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
fmt::print("--------------------------");
fmt::print("ID specification:");
auto decoder = detector.readout("GEMTrackerHits").idSpec().decoder(); auto decoder = detector.readout("GEMTrackerHits").idSpec().decoder();
fmt::print("{}\n", decoder->fieldDescription()); fmt::print("{}\n", decoder->fieldDescription());
auto layer_index = decoder->index("layer"); auto layer_index = decoder->index("layer");
fmt::print(" layer index is {}.\n", layer_index); fmt::print(" \"layer\" index is {}.\n", layer_index);
// Simple lambda to define nhits branch // Simple lambda to define nhits branch
auto nhits = [](const std::vector<dd4pod::TrackerHitData>& evt) { return (int)evt.size(); }; auto nhits = [](const std::vector<dd4pod::TrackerHitData>& evt) { return (int)evt.size(); };
...@@ -101,16 +103,16 @@ void tutorial2_cell_size(const char* fname = "gem_tracker_sim.root") { ...@@ -101,16 +103,16 @@ void tutorial2_cell_size(const char* fname = "gem_tracker_sim.root") {
}; };
auto d1 = d0.Define("nhits", nhits, {"GEMTrackerHits"}) auto d1 = d0.Define("nhits", nhits, {"GEMTrackerHits"})
.Filter([=](const std::vector<dd4pod::TrackerHitData>& hits) { //.Filter([=](const std::vector<dd4pod::TrackerHitData>& hits) {
for (auto h : hits) { // for (auto h : hits) {
auto pos = ROOT::Math::XYZVector(h.position.x,h.position.y,h.position.z); // auto pos = ROOT::Math::XYZVector(h.position.x,h.position.y,h.position.z);
if ((pos.r() > 100.0) && (std::abs(pos.phi()-M_PI/2.0)< M_PI/6)) { // if ((pos.r() > 100.0) && (std::abs(pos.phi()-M_PI/2.0)< M_PI/6)) {
return true; // return true;
} // }
} // }
return false; // return false;
}, // },
{"GEMTrackerHits"}) // {"GEMTrackerHits"})
.Define("xy_hit_pos", local_position, {"GEMTrackerHits"}) .Define("xy_hit_pos", local_position, {"GEMTrackerHits"})
.Define("x_pos", x_pos, {"xy_hit_pos"}) .Define("x_pos", x_pos, {"xy_hit_pos"})
.Define("y_pos", y_pos, {"xy_hit_pos"}); .Define("y_pos", y_pos, {"xy_hit_pos"});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment