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 questions:
0006 - "How can we view the geometry?"
0007 objectives:
0008 - "Understand how to export the geometry with `dd_web_display`."
0009 - "Know of multiple way in which to open ROOT TGeo geometries."
0010 keypoints:
0011 - "The geometry, exported to the ROOT TGeo file, can be viewed with ROOT."
0012 ---
0013
0014 ## Introduction
0015
0016 Before we move to discussion of the detector plugins in the next part, let's discuss visualization on your local system.
0017
0018 ## ROOT visualization
0019
0020 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/`.
0021 ```console
0022 $ cd ~/eic/
0023 $ dd_web_display --export $DETECTOR_PATH/$DETECTOR_CONFIG.xml
0024 ```
0025
0026 > Note: If you are not inside `eic-shell`, you may need to be connected to the internet as your run this command since a magnetic fieldmap will need to be downloaded.
0027 {: .callout}
0028
0029 The `dd_web_display` utility will create a ROOT file in the current directory that can be opened with the geometry viewer online at [https://eic.phy.anl.gov/geoviewer/](https://eic.phy.anl.gov/geoviewer/) or [https://root.cern/js/latest](https://root.cern/js/latest), or a local ROOT installation. VSCode also has a JSROOT extension which provides the same functionality as the browser.
0030
0031 > Note: The version of JSROOT on https://eic.phy.anl.govgeoviewer/ is older than the https://root.cern/js/latest version so some differences in the visualisation may be present.
0032 {: .callout}
0033
0034 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.
0035
0036 ```console
0037 $ dd_web_display -o vertex_geometry.root --export $DETECTOR_PATH/epic_vertex_only.xml
0038 ```
0039
0040 For local ROOT installations, the following commands may be helpful:
0041 ```
0042 TGeoManager::Import("detector_geometry.root");
0043 gGeoManager->GetTopVolume()->Draw("ogl")
0044 ```
0045
0046 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.
0047
0048 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.
0049
0050 > Exercise:
0051 > - Export a different detector configuration from the default `epic.xml`, and export this to ROOT TGeo format.
0052 > - Open the exported ROOT file in the geometry viewer at [https://eic.phy.anl.gov/geoviewer/](https://eic.phy.anl.gov/geoviewer/) or [https://root.cern/js/latest](https://root.cern/js/latest).
0053 {: .challenge}
0054
0055 ## Geant4 visualization
0056 **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.
0057
0058 ```console
0059 npsim --runType qt --compactFile $DETECTOR_PATH/epic_vertex_only.xml --inputFiles root://dtn-eic.jlab.org//work/eic2/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
0060 ```
0061
0062 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
0063
0064 > 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 for me outside of `eic_shell` but takes a long time to set up the environment.
0065 {: .callout}
0066
0067
0068 ## Other visualisation you might want
0069 ACTS Surfaces
0070
0071 Material Map
0072
0073 Event display
0074
0075 These are avaliable in various forms but not covered in this tutorial.