From 38446f42dd9291ab16df9db0a2d61407d40d03a3 Mon Sep 17 00:00:00 2001
From: Whitney Armstrong <warmstrong@anl.gov>
Date: Thu, 20 May 2021 22:31:11 -0500
Subject: [PATCH] 	modified:   part1/simple_detector.md 	modified:  
 part2/adding_detectors.md

---
 src/docs/part1/simple_detector.md  | 43 ++++++++++++++++++++++++++++--
 src/docs/part2/adding_detectors.md |  8 ++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/docs/part1/simple_detector.md b/src/docs/part1/simple_detector.md
index 79a82fa..3a57eaf 100644
--- a/src/docs/part1/simple_detector.md
+++ b/src/docs/part1/simple_detector.md
@@ -79,8 +79,7 @@ https://eic.phy.anl.gov/eicd/
 ## Hit position
 
 ```bash
-root -b -q scripts/tutorial1_hit_position.cxx
-# note if this fails because of ACLiC, run it again. This is a root bug.
+root -b -q scripts/tutorial2_cell_size.cxx+
 ```
 Look at the generated file in results:
 ![local hit position](../hit_position.png)
@@ -89,6 +88,7 @@ This is the local position in the segmentation (i.e. pixel, strip, readout pad,
 
 ### Cell ID (channel) to Position
 
+
 At the top of the script you can see these lines:
 ```cpp
   dd4hep::Detector& detector = dd4hep::Detector::getInstance();
@@ -115,4 +115,43 @@ Segmentation-Cell Position : 39,102,-100
 ```
 
 
+### Id Specification
+
+```bash
+root -b -q scripts/tutorial3_id_spec.cxx+
+```
+
+```cpp
+  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");
+  fmt::print(" \"layer\" index is {}.\n", layer_index);
+```
+
+Later in the loop over event hits.
+```cpp
+      auto detector_layer = decoder->get(h.cellID, layer_index);
+      if ((detector_layer !=4 ) && (detector_layer !=5 )) {
+        continue;
+      }
+```
+Note the `layer_index` is computed once in the beginning when the decoder is also initialized. 
+This means it will be fast because it only parses the ID specification string once.
+
+```bash
+ID specification:
+system:0:5,barrel:5:3,layer:8:4,module:12:5,r:32:-16,phi:48:-16
+ "layer" index is 2.
+```
+or
+```bash
+ID specification:
+system:0:8,barrel:8:2,layer:10:4,module:14:12,sensor:26:2,x:32:-16,y:48:-16
+ "layer" index is 2.
+```
+
+For more information, see the [BitFieldCoder documentation](https://dd4hep.web.cern.ch/dd4hep/reference/classdd4hep_1_1DDSegmentation_1_1BitFieldCoder.html).
+
 
diff --git a/src/docs/part2/adding_detectors.md b/src/docs/part2/adding_detectors.md
index 11692dc..969f688 100644
--- a/src/docs/part2/adding_detectors.md
+++ b/src/docs/part2/adding_detectors.md
@@ -160,6 +160,14 @@ static Ref_t build_detector(Detector& dtor, xml_h e, SensitiveDetector sens)
   string        det_name = x_det.nameStr(); // "MyRomanPot"
 ```
 
+
+### What materials exist
+
+To browse the list of materials and elements (other than looking in the compact files), go to 
+[geo viewer](https://eic.phy.anl.gov/geoviewer/index.htm?file=https://eicweb.phy.anl.gov/api/v4/projects/473/jobs/artifacts/master/raw/geo/detector_geo_full.root?job=report)
+and scroll through the materials.
+![browse_materials](../browse_materials.png)
+
 Here we are grabbing the materials that are assumed to be already defined. Also 
 we are getting the detector id and name defined in the `detector` tag.
 
-- 
GitLab