diff --git a/benchmarks/far_forward/scripts/hits_far_forward_protons.cxx b/benchmarks/far_forward/scripts/hits_far_forward_protons.cxx index 6b5dd524a5b13e9b1219692fb195458936276515..be3515b15cc88601957eac91eb137ec28db03bcc 100644 --- a/benchmarks/far_forward/scripts/hits_far_forward_protons.cxx +++ b/benchmarks/far_forward/scripts/hits_far_forward_protons.cxx @@ -80,6 +80,24 @@ auto delta_p_over_p = [](const std::vector<double>& tracks, const std::vector<do return res; }; +auto local_position = [&](const std::vector<dd4pod::TrackerHitData>& hits) { + std::vector<std::array<double, 2>> result; + for (const auto& h : hits) { + // The actual hit 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); + //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()}); + } + return result; + }; + + int hits_far_forward_protons(const char* fname = "sim_far_forward_protons.root") { @@ -107,9 +125,16 @@ int hits_far_forward_protons(const char* fname = "sim_far_forward_protons.root") .Define("N_EndcapHits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"TrackerEndcapHits"}) //.Define("N_OMD_hits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"ForwardOffMTrackerHits"}) //.Define("N_RP_hits", [](std::vector<dd4pod::TrackerHitData> hits) { return hits.size();}, {"ForwardRomanPotsHits"}) + .Define("xy_hit_pos", local_position, {"ForwardRomanPotsHits"}) + .Define("x_pos", x_pos, {"xy_hit_pos"}) + .Define("y_pos", y_pos, {"xy_hit_pos"}) ; - auto hBarrel_x_vs_y = df0.Histo2D({"hBarrel_x_vs_y", "; x ; y ", 100, -900, 900,100, -900, 900 }, "ForwardRomanPotRawHits.position.x", "ForwardRomanPotRawHits.position.y"); + auto h_local_pos = d1.Histo2D({"h_local_pos", ";x [cm]; y [cm] ", 100, -5.0, 5.0, 100, -5.0, 5.0}, "x_pos", "y_pos"); + + + + auto hBarrel_x_vs_y = df0.Histo2D({"hBarrel_x_vs_y", "; x ; y ", 100, -900, 900,100, -900, 900 }, "TrackerBarrelHits.position.x", "TrackerBarrelHits.position.y"); auto hBarrel_N_vs_theta = df0.Histo1D({"hBarrel_N_vs_theta", "; #theta [deg.]", 20, 0, 180 }, "theta0", "N_BarrelHits"); auto hEndcap_N_vs_theta = df0.Histo1D({"hEndcap_N_vs_theta", "; #theta [deg.]", 20, 0, 180 }, "theta0", "N_EndcapHits"); @@ -185,7 +210,8 @@ int hits_far_forward_protons(const char* fname = "sim_far_forward_protons.root") c->SaveAs("results/far_forward/B0/hits_far_forward_protons_nhits.pdf"); c = new TCanvas(); - hBarrel_x_vs_y->DrawCopy("colz"); + //hBarrel_x_vs_y->DrawCopy("colz"); + h_local_pos->DrawCopy("colz"); c->SaveAs("results/far_forward/B0/hits_far_forward_protons_xy.png"); c->SaveAs("results/far_forward/B0/hits_far_forward_protons_xy.pdf"); return 0;