From 9ca858d920283d5e45500448027ec65328cda918 Mon Sep 17 00:00:00 2001
From: Whitney Armstrong <warmstrong@anl.gov>
Date: Thu, 20 May 2021 22:30:02 -0500
Subject: [PATCH] modified: gem_tracker.xml modified: gps.mac
modified: scripts/tutorial3_id_spec.cxx
---
gem_tracker.xml | 4 +-
gps.mac | 4 +-
scripts/tutorial3_id_spec.cxx | 77 ++++++++++++++++++++++-------------
3 files changed, 52 insertions(+), 33 deletions(-)
diff --git a/gem_tracker.xml b/gem_tracker.xml
index 6c72f93..578252a 100644
--- a/gem_tracker.xml
+++ b/gem_tracker.xml
@@ -82,8 +82,8 @@
<layer id="1" z="-100 *cm" inner_r="40*cm" outer_r="120*cm" phi0_offset="0.0*deg" />
<layer id="2" z="-80 *cm" inner_r="30*cm" outer_r="90*cm" phi0_offset="0.0*deg" />
<layer id="3" z="-60 *cm" inner_r="20*cm" outer_r="70*cm" phi0_offset="0.0*deg" />
- <layer id="4" z="-40 *cm" inner_r="20*cm" outer_r="50.0*cm" phi0_offset="0.0*deg" />
- <layer id="5" z=" 40 *cm" inner_r="20*cm" outer_r="50.0*cm" phi0_offset="0.0*deg" />
+ <layer id="4" z="-40 *cm" inner_r="10*cm" outer_r="20.0*cm" phi0_offset="0.0*deg" />
+ <layer id="5" z=" 40 *cm" inner_r="10*cm" outer_r="20.0*cm" phi0_offset="0.0*deg" />
<layer id="6" z=" 60 *cm" inner_r="25*cm" outer_r="70.0*cm" phi0_offset="0.0*deg" />
<layer id="7" z=" 80 *cm" inner_r="30*cm" outer_r="90.0*cm" phi0_offset="0.0*deg" />
<layer id="8" z="100 *cm" inner_r="40*cm" outer_r="100.0*cm" phi0_offset="0.0*deg" />
diff --git a/gps.mac b/gps.mac
index 90e9bbf..e8d141d 100644
--- a/gps.mac
+++ b/gps.mac
@@ -18,7 +18,7 @@
#/gps/direction 0 0.1 1.0
/gps/ang/type iso
-/gps/ang/mintheta 30 degree
-/gps/ang/maxtheta 160 degree
+/gps/ang/mintheta 10 degree
+/gps/ang/maxtheta 170 degree
/run/beamOn 1000
diff --git a/scripts/tutorial3_id_spec.cxx b/scripts/tutorial3_id_spec.cxx
index 3e95d71..6c5a4f9 100644
--- a/scripts/tutorial3_id_spec.cxx
+++ b/scripts/tutorial3_id_spec.cxx
@@ -49,8 +49,8 @@ void tutorial3_id_spec(const char* fname = "gem_tracker_sim.root") {
detector.fromCompact("gem_tracker.xml");
dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
- fmt::print("--------------------------");
- fmt::print("ID specification:");
+ fmt::print("--------------------------\n");
+ fmt::print("ID specification:\n");
auto decoder = detector.readout("GEMTrackerHits").idSpec().decoder();
fmt::print("{}\n", decoder->fieldDescription());
auto layer_index = decoder->index("layer");
@@ -59,8 +59,15 @@ void tutorial3_id_spec(const char* fname = "gem_tracker_sim.root") {
// Simple lambda to define nhits branch
auto nhits = [](const std::vector<dd4pod::TrackerHitData>& evt) { return (int)evt.size(); };
+ auto all_z_pos = [&](const std::vector<dd4pod::TrackerHitData>& hits) {
+ std::vector<double> result;
+ for (const auto& h : hits) {
+ result.push_back(h.position.z / 10.0);
+ }
+ return result;
+ };
auto local_position = [&](const std::vector<dd4pod::TrackerHitData>& hits) {
- std::vector<std::array<double, 2>> result;
+ std::vector<std::array<double, 3>> result;
for (const auto& h : hits) {
// The actual hit position:
auto pos0 = (h.position);
@@ -69,32 +76,37 @@ void tutorial3_id_spec(const char* fname = "gem_tracker_sim.root") {
// 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());
-
- auto context = cellid_converter.findContext( h.cellID ) ;
- dd4hep::Readout r = cellid_converter.findReadout( context->element ) ;
- dd4hep::Segmentation seg = r.segmentation() ;
- auto cell_dim = seg.cellDimensions(h.cellID);
- std::cout << " dim ";
- for(const auto& dim : cell_dim) {
- std::cout << dim << ", ";
+ //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());
+
+ auto detector_layer = decoder->get(h.cellID, layer_index);
+ if ((detector_layer !=4 ) && (detector_layer !=5 )) {
+ continue;
}
- std::cout << "\n";
- result.push_back({pos0.x / 10.0 - pos1.x(), pos0.y / 10.0 - pos1.y()});
+ //auto context = cellid_converter.findContext( h.cellID ) ;
+ //dd4hep::Readout r = cellid_converter.findReadout( context->element ) ;
+ //dd4hep::Segmentation seg = r.segmentation() ;
+ //auto cell_dim = seg.cellDimensions(h.cellID);
+ //std::cout << " dim ";
+ //for(const auto& dim : cell_dim) {
+ // std::cout << dim << ", ";
+ //}
+ //std::cout << "\n";
+
+ result.push_back({pos0.x / 10.0 - pos1.x(), pos0.y / 10.0 - pos1.y(),pos0.z / 10.0});
}
return result;
};
- auto x_pos = [&](const std::vector<std::array<double, 2>>& xypos) {
+ auto x_pos = [&](const std::vector<std::array<double, 3>>& xypos) {
std::vector<double> result;
for (const auto& h : xypos) {
result.push_back(h.at(0));
}
return result;
};
- auto y_pos = [&](const std::vector<std::array<double, 2>>& xypos) {
+ auto y_pos = [&](const std::vector<std::array<double, 3>>& xypos) {
std::vector<double> result;
for (auto h : xypos) {
result.push_back(h.at(1));
@@ -102,24 +114,31 @@ void tutorial3_id_spec(const char* fname = "gem_tracker_sim.root") {
return result;
};
+ auto z_pos = [&](const std::vector<std::array<double, 3>>& xypos) {
+ std::vector<double> result;
+ for (auto h : xypos) {
+ result.push_back(h.at(2));
+ }
+ return result;
+ };
auto d1 = d0.Define("nhits", nhits, {"GEMTrackerHits"})
- //.Filter([=](const std::vector<dd4pod::TrackerHitData>& hits) {
- // for (auto h : hits) {
- // 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)) {
- // return true;
- // }
- // }
- // return false;
- // },
- // {"GEMTrackerHits"})
+ .Define("all_z_pos", all_z_pos, {"GEMTrackerHits"})
.Define("xy_hit_pos", local_position, {"GEMTrackerHits"})
.Define("x_pos", x_pos, {"xy_hit_pos"})
- .Define("y_pos", y_pos, {"xy_hit_pos"});
+ .Define("y_pos", y_pos, {"xy_hit_pos"})
+ .Define("z_pos", z_pos, {"xy_hit_pos"});
- auto h_local_pos = d1.Histo2D(TH2D("h_local_pos", ";x [cm]; y [cm] ", 100, -5.0, 5.0, 100, -5.0, 5.0), "x_pos", "y_pos");
+ auto h_local_pos = d1.Histo2D(TH2D("h_local_pos", ";x [cm]; y [cm] ", 100, -5.0, 5.0, 100, -5.0, 5.0), "x_pos", "y_pos");
+ auto h_z_position0 = d1.Histo1D(TH1D("h_z_position0", ";z [cm]", 55, -110.0, 110.0), "all_z_pos");
+ auto h_z_position = d1.Histo1D(TH1D("h_z_position", ";z [cm]", 55, -110.0, 110.0), "z_pos");
TCanvas* c = new TCanvas();
h_local_pos->DrawClone("colz");
c->SaveAs("results/hit_position.png");
+
+ h_z_position0->SetLineColor(1);
+ h_z_position0->DrawClone();
+ h_z_position->SetLineColor(2);
+ h_z_position->DrawClone("same");
+ c->SaveAs("results/z_position.png");
}
--
GitLab