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

modified: part1/simple_detector.md

parent fee8f0c5
No related branches found
No related tags found
No related merge requests found
Pipeline #10129 passed
...@@ -162,9 +162,9 @@ This is the local position in the segmentation cell (i.e. pixel, strip, readout ...@@ -162,9 +162,9 @@ This is the local position in the segmentation cell (i.e. pixel, strip, readout
At the top of the script you can see these lines: At the top of the script you can see these lines:
```cpp ```cpp
dd4hep::Detector& detector = dd4hep::Detector::getInstance(); dd4hep::Detector& detector = dd4hep::Detector::getInstance();
detector.fromCompact("gem_tracker.xml"); detector.fromCompact("gem_tracker.xml");
dd4hep::rec::CellIDPositionConverter cellid_converter(detector); dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
``` ```
This This
...@@ -215,14 +215,14 @@ Here `cell_dim` is a `std::vector<double>` passed by the specific segmentation i ...@@ -215,14 +215,14 @@ Here `cell_dim` is a `std::vector<double>` passed by the specific segmentation i
Look at the `readouts` tag of `gem_tracker.xml` and you will see this: Look at the `readouts` tag of `gem_tracker.xml` and you will see this:
```xml ```xml
<readout name="GEMTrackerHits"> <readout name="GEMTrackerHits">
<segmentation type="CartesianGridXY" grid_size_x="1*cm" grid_size_y="3*cm" /> <segmentation type="CartesianGridXY" grid_size_x="1*cm" grid_size_y="3*cm" />
<id>system:8,barrel:2,layer:4,module:12,sensor:2,x:32:-16,y:-16</id> <id>system:8,barrel:2,layer:4,module:12,sensor:2,x:32:-16,y:-16</id>
<!-- <!--
<segmentation type="PolarGridRPhi" grid_size_phi="3.0*degree" grid_size_r="5.0*cm"/> <segmentation type="PolarGridRPhi" grid_size_phi="3.0*degree" grid_size_r="5.0*cm"/>
<id>system:5,barrel:3,layer:4,module:5,r:32:-16,phi:-16</id> <id>system:5,barrel:3,layer:4,module:5,r:32:-16,phi:-16</id>
--> -->
</readout> </readout>
``` ```
Note the `grid_size_x` and `grid_size_y` attributes with values corresponding to the sizes above. Note the `grid_size_x` and `grid_size_y` attributes with values corresponding to the sizes above.
...@@ -232,10 +232,10 @@ In the `CartesianGridXY` case, the cell sizes are always the same. ...@@ -232,10 +232,10 @@ In the `CartesianGridXY` case, the cell sizes are always the same.
1. Swap in the comment on segmentation and id to create the `PolarGridRPhi` segmentation. Should look like this: 1. Swap in the comment on segmentation and id to create the `PolarGridRPhi` segmentation. Should look like this:
```xml ```xml
<readout name="GEMTrackerHits"> <readout name="GEMTrackerHits">
<segmentation type="PolarGridRPhi" grid_size_phi="3.0*degree" grid_size_r="5.0*cm"/> <segmentation type="PolarGridRPhi" grid_size_phi="3.0*degree" grid_size_r="5.0*cm"/>
<id>system:5,barrel:3,layer:4,module:5,r:32:-16,phi:-16</id> <id>system:5,barrel:3,layer:4,module:5,r:32:-16,phi:-16</id>
</readout> </readout>
``` ```
2. Re-run npsim command above. 2. Re-run npsim command above.
3. Re-run the root script: 3. Re-run the root script:
...@@ -268,8 +268,8 @@ For example, a tracking covariance matrix could be computed using this method, a ...@@ -268,8 +268,8 @@ For example, a tracking covariance matrix could be computed using this method, a
The cell ID is a 64bit integer with field names assigned to a few bits. The cell ID is a 64bit integer with field names assigned to a few bits.
Looking at the id specification we see the following: Looking at the id specification we see the following:
```xml ```xml
<segmentation type="PolarGridRPhi" grid_size_phi="3.0*degree" grid_size_r="5.0*cm"/> <segmentation type="PolarGridRPhi" grid_size_phi="3.0*degree" grid_size_r="5.0*cm"/>
<id>system:5,barrel:3,layer:4,module:5,r:32:-16,phi:-16</id> <id>system:5,barrel:3,layer:4,module:5,r:32:-16,phi:-16</id>
``` ```
This means there are 5 bits associated with system (this is the `<detector>`'s `id`) this field is mandatory but can differ from 5 bits. This means there are 5 bits associated with system (this is the `<detector>`'s `id`) this field is mandatory but can differ from 5 bits.
The subsequent fields are arbitrary but should result in a unique 64 bit integer. The subsequent fields are arbitrary but should result in a unique 64 bit integer.
...@@ -303,11 +303,11 @@ system:0:8,barrel:8:2,layer:10:4,module:14:12,sensor:26:2,x:32:-16,y:48:-16 ...@@ -303,11 +303,11 @@ system:0:8,barrel:8:2,layer:10:4,module:14:12,sensor:26:2,x:32:-16,y:48:-16
This comes from the snippet at the initialization stage: This comes from the snippet at the initialization stage:
```cpp ```cpp
fmt::print("ID specification:\n"); fmt::print("ID specification:\n");
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);
``` ```
This gets an index for the named field "layer" and initializes a decoder. This gets an index for the named field "layer" and initializes a decoder.
...@@ -315,10 +315,10 @@ See [BitFieldCoder documentation](https://dd4hep.web.cern.ch/dd4hep/reference/cl ...@@ -315,10 +315,10 @@ See [BitFieldCoder documentation](https://dd4hep.web.cern.ch/dd4hep/reference/cl
Later in the loop over event hits. Later in the loop over event hits.
```cpp ```cpp
auto detector_layer = decoder->get(h.cellID, layer_index); auto detector_layer = decoder->get(h.cellID, layer_index);
if ((detector_layer !=4 ) && (detector_layer !=5 )) { if ((detector_layer !=4 ) && (detector_layer !=5 )) {
continue; continue;
} }
``` ```
Note the `layer_index` is computed once in the beginning when the decoder is also initialized. 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. This means it will be fast because it only parses the ID specification string once.
...@@ -328,6 +328,10 @@ Look at the generated plot in `results`: ...@@ -328,6 +328,10 @@ Look at the generated plot in `results`:
![z_position](../z_position_part1.png) ![z_position](../z_position_part1.png)
### Homework
Can you adjust the compact description so that layers 4 and 5 have similar number of hits as the other layers?
## References ## References
- [NPdet](https://eic.phy.anl.gov/npdet/) - [NPdet](https://eic.phy.anl.gov/npdet/)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment