-
Whitney Armstrong authored
modified: part1/simple_detector.md
Whitney Armstrong authoredmodified: part1/simple_detector.md
title: "Simple Detector"
Setup
Note all these commands assume you are in an eic-shell
singularity session.
git clone https://eicweb.phy.anl.gov/EIC/tutorials/ip6_tutorial_1.git part1
cd part1
Inspect files
Look around see what's what.
The files
compact/materials.xml
,
compact/elements.xml
,
and
gem_tracker.xml
are the compact detector description files. The first two files are included in
the main gem_tracker.xml
file. Note these files are often found in
directories named compact (but not always).
Compile the detector library
mkdir build
cmake ../. -DCMAKE_INSTALL_PREFIX=../../local
make -j4 install
Visualize and Check Geometry
Look at disk tracker
dd_web_display --export gem_tracker.xml
Copy the generated file detector_geometry.root
to your local machine.
Then open the web viewer, click on the ...
and open the local root file.
Examine the compact description, specifically this part:
<detector id="2" name="GEMTracker" vis="RedVis" type="my_GEMTracker" readout="GEMTrackerHits" >
<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="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" />
</detector>
Check for overlaps
checkOverlaps -t 0.0001 -c gem_tracker.xml
...
Info in <TGeoNodeMatrix::CheckOverlaps>: Checking overlaps for world_volume and daughters within 0.0001
Check overlaps: [==========] 11 [100.00 %] 00:00
Info in <TGeoNodeMatrix::CheckOverlaps>: Number of illegal overlaps/extrusions : 0
Look at all the constants
Look at the constants as defined in the compact description (xml files).
npdet_info dump gem_tracker.xml
This should output something like this:
CrossingAngle = 0.020 = 0.020*rad
ForwardTrackerPlane_z0 = 400.000 = 400*cm
Place_Center = 0.000 = 0*cm
compact_checksum = 1924675351.000 = 1924675351
tracker_region_rmax = 200.000 = 2.0*m
tracker_region_zmax = 400.000 = 4.0*m
world_side = 1000.000 = 10*m
world_x = 1000.000 = world_side
world_y = 1000.000 = world_side
world_z = 10000.000 = 10*world_side
Or if there are too many constants to dump, try searching:
npdet_info search world --all gem_tracker.xml
world_side = 1000.000 = 10*m
world_x = 1000.000 = world_side
world_y = 1000.000 = world_side
world_z = 10000.000 = 10*world_side
This is very useful with a good subsystem naming convention.
Running Geant4 simulation
npsim
is a clone of DD4hep's ddsim
but has a different output plugin.
npsim --runType run --enableG4GPS \
--macroFile gps.mac \
--compactFile ./gem_tracker.xml \
--outputFile gem_tracker_sim.root
This will run geant4 using the General Particle Source (GPS) tool. The output will be a root file containing the generated events and GEM tracker hits. Look at gps.mac.
Refer to the GPS Documentation for more setup possibilities.
Using detector description in analysis
Preface: data model
First, the geant4 output data model used by npsim
is described in a single yaml file.
Note that this is purposefully factorized from the larger EIC data model, eicd
, which is used
at every step post geant4.
Look at the generated file in results:
This is the local position in the segmentation (i.e. pixel, strip, readout pad, etc.).
Cell ID (channel) to Position
At the top of the script you can see these lines:
dd4hep::Detector& detector = dd4hep::Detector::getInstance();
detector.fromCompact("gem_tracker.xml");
dd4hep::rec::CellIDPositionConverter cellid_converter(detector);
This
- gets the main DD4hep Detector instance
- loads the compact detector file
- initializes the position converter tool (which provides thread safe access)
Later on you can see its use:
auto pos1 = cellid_converter.position(h.cellID);
Cell size
root -b -q scripts/tutorial2_cell_size.cxx+
You will see this:
...
Segmentation-Cell Position : 39,102,-100
dim 1, 3,
Id Specification
root -b -q scripts/tutorial3_id_spec.cxx+
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);
See BitFieldCoder documentation documentation for more details.
Later in the loop over event hits.
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.
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
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.