Warning, /tutorial-geometry-development-using-dd4hep/episodes/02-viewing-geometry.md is written in an unsupported language. File is not indexed.
0001 ---
0002 title: "Viewing the geometry"
0003 teaching: 10
0004 exercises: 10
0005 ---
0006
0007 ::::::::::::::::::::::::::::::::::::::::::::: questions
0008
0009 - How can we view the geometry?
0010
0011 :::::::::::::::::::::::::::::::::::::::::::::
0012
0013 ::::::::::::::::::::::::::::::::::::::::::::: objectives
0014
0015 - Understand how to export the geometry with `dd_web_display`.
0016 - Know of multiple ways in which to open ROOT TGeo geometries.
0017
0018 :::::::::::::::::::::::::::::::::::::::::::::
0019
0020 ## Introduction
0021
0022 Before we move to discussion of the detector plugins in the next part, let's discuss visualization on your local system.
0023
0024 ## ROOT visualization
0025
0026 The geometry included in `eic-shell` can be viewed with the ROOT geometry browser. However, we first need to export it from the built-in DD4hep format to the ROOT TGeo format, with a small utility program `dd_web_display`. To do this, we will need to ensure we are in a directory where we have write access, such as the directory `~/eic/`.
0027
0028 ```bash
0029 $ cd ~/eic/
0030 $ dd_web_display --export $DETECTOR_PATH/$DETECTOR_CONFIG.xml
0031 ```
0032
0033 ::::::::::::::::::::::::::::::::::::::::::::: callout
0034
0035 Note: If you are not inside `eic-shell`, you may need to be connected to the internet as you run this command since a magnetic fieldmap will need to be downloaded.
0036
0037 :::::::::::::::::::::::::::::::::::::::::::::
0038
0039 The `dd_web_display` utility will create a ROOT file in the current directory that can be opened with the geometry viewer online at the [ANL geometry viewer](https://eic.phy.anl.gov/geoviewer/) or the [ROOT JSROOT viewer](https://root.cern/js/latest), or a local ROOT installation. VSCode also has a JSROOT extension which provides the same functionality as the browser.
0040
0041 ::::::::::::::::::::::::::::::::::::::::::::: callout
0042
0043 Note: The version of JSROOT on the [ANL geometry viewer](https://eic.phy.anl.gov/geoviewer/) is older than the [ROOT JSROOT viewer](https://root.cern/js/latest) version so some differences in the visualisation may be present.
0044
0045 :::::::::::::::::::::::::::::::::::::::::::::
0046
0047 The output file is by default named `detector_geometry.root` this can be changed if you want to look at several configurations using e.g.
0048
0049 ```bash
0050 $ dd_web_display -o vertex_geometry.root --export $DETECTOR_PATH/epic_vertex_only.xml
0051 ```
0052
0053 For local ROOT installations, the following commands may be helpful:
0054
0055 ```c++
0056 TGeoManager::Import("detector_geometry.root");
0057 gGeoManager->GetTopVolume()->Draw("ogl")
0058 ```
0059
0060 The geometry viewer has to make decisions on what to draw in order to keep the number of facets small enough. This means that detectors with a large number of repeated components may not be drawn, or other detectors may not be drawn when those detectors are drawn. For this reason, we also have the subsystem-specific entry points xml files. For visualization of specific subsystems, these files are recommended.
0061
0062 Parameters describing how each component of the geometry should be vizualised are contained within the detector plugins and can be controlled through the xml description.
0063
0064 ::::::::::::::::::::::::::::::::::::::::::::: challenge
0065
0066 ## Exercise: view a subsystem
0067
0068 - Export a different detector configuration from the default `epic.xml`, and export this to ROOT TGeo format.
0069 - Open the exported ROOT file in the geometry viewer at the [ANL geometry viewer](https://eic.phy.anl.gov/geoviewer/) or the [ROOT JSROOT viewer](https://root.cern/js/latest).
0070
0071 ::::::::::::::: solution
0072
0073 For example `dd_web_display -o vertex_geometry.root --export $DETECTOR_PATH/epic_vertex_only.xml`
0074 produces `vertex_geometry.root`; loading that file in either viewer shows only the vertex barrel,
0075 which renders faster and is easier to inspect than the full `epic.xml`.
0076
0077 :::::::::::::::
0078
0079 :::::::::::::::::::::::::::::::::::::::::::::
0080
0081 ## Geant4 visualization
0082
0083 **Warning: might not work for various reasons.** If you are used to the Geant4 geometry visualisation or want to visually inspect where a subset of your event sample this is still possible using npsim.
0084
0085 ```bash
0086 npsim --runType qt --compactFile $DETECTOR_PATH/epic_vertex_only.xml --inputFiles root://dtn-eic.jlab.org//volatile/eic/EPIC/EVGEN/SIDIS/pythia6-eic/1.0.0/18x275/q2_0to1/pythia_ep_noradcor_18x275_q2_0.000000001_1.0_run9.ab.hepmc3.tree.root --macro macro/b0_vis.mac
0087 ```
0088
0089 This particular example uses pythia6 min-bias events stored on the xrootd server at jlab. The visualization of particle tracks and the detector is controlled by the `macro/b0_vis.mac` file.
0090
0091 ::::::::::::::::::::::::::::::::::::::::::::: callout
0092
0093 Note: Geant4 does not try and limit its visualization of components so depending on your machine the full detector might struggle, please be patient. This performs much better outside of `eic-shell` but takes a long time to set up the environment.
0094
0095 :::::::::::::::::::::::::::::::::::::::::::::
0096
0097 ## Other visualisation you might want
0098
0099 - ACTS Surfaces
0100 - Material Map
0101 - Event display
0102
0103 These are avaliable in various forms but not covered in this tutorial.
0104
0105 ::::::::::::::::::::::::::::::::::::::::::::: keypoints
0106
0107 - The geometry, exported to the ROOT TGeo file, can be viewed with ROOT.
0108
0109 :::::::::::::::::::::::::::::::::::::::::::::