diff --git a/src/docs/part1/simple_detector.md b/src/docs/part1/simple_detector.md index 79a82fad68bd46bc98ad20404d1c1973b214be87..3a57eaf429b6bfd8392dab023a79dfebbc6884d2 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:  @@ -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 11692dcfd2fc0d761c117e6b8b3c2a90adbe6307..969f68813815872aa35db14be9214aea22d8e3c0 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. + + 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.