Warning, /eic-opticks/docs/physics-and-inputs.md is written in an unsupported language. File is not indexed.
0001 # Physics and simulation inputs
0002
0003 This guide collects the Geant4 optical-surface notes, Simphony source
0004 configuration, and the input requirements that were previously documented in
0005 the top-level README.
0006
0007 ## Optical surface models in Geant4
0008
0009 In Geant4, optical surface properties such as `finish`, `model`, and `type`
0010 are defined using enums in the `G4OpticalSurface` and `G4SurfaceProperty`
0011 header files:
0012
0013 - [`G4OpticalSurface.hh`](https://github.com/Geant4/geant4/blob/geant4-11.3-release/source/materials/include/G4OpticalSurface.hh#L52-L113)
0014 - [`G4SurfaceProperty.hh`](https://github.com/Geant4/geant4/blob/geant4-11.3-release/source/materials/include/G4SurfaceProperty.hh#L58-L68)
0015
0016 These enums allow users to configure how optical photons interact with
0017 surfaces, controlling behaviors like reflection, transmission, and absorption
0018 based on physical models and surface qualities. The string values
0019 corresponding to these enums, such as `ground`, `glisur`, and
0020 `dielectric_dielectric`, can also be used directly in GDML files when defining
0021 `<opticalsurface>` elements for geometry. Geant4 parses these attributes and
0022 applies the corresponding surface behavior.
0023
0024 For a physics-motivated explanation of how Geant4 handles optical photon
0025 boundary interactions, refer to the [Geant4 Application Developer Guide -
0026 Boundary
0027 Process](https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/TrackingAndPhysics/physicsProcess.html#boundary-process).
0028
0029 ```gdml
0030 <gdml>
0031 ...
0032 <solids>
0033 <opticalsurface finish="ground" model="glisur" name="medium_surface" type="dielectric_dielectric" value="1">
0034 <property name="EFFICIENCY" ref="EFFICIENCY_DEF"/>
0035 <property name="REFLECTIVITY" ref="REFLECTIVITY_DEF"/>
0036 </opticalsurface>
0037 </solids>
0038 ...
0039 </gdml>
0040 ```
0041
0042 ## Torch configuration
0043
0044 `GPUPhotonSource` and `GPUPhotonSourceMinimal` read photon source parameters
0045 from a JSON config file, by default `config/dev.json`.
0046
0047 | Field | Description |
0048 |-------|-------------|
0049 | `type` | Source shape: `disc`, `sphere`, `point` |
0050 | `radius` | Size of the source area (mm) |
0051 | `pos` | Center position `[x, y, z]` (mm) |
0052 | `mom` | Emission direction `[x, y, z]` (normalized automatically) |
0053 | `numphoton` | Number of photons to generate |
0054 | `wavelength` | Photon wavelength (nm) |
0055
0056 ## Code differences
0057
0058 | Feature | GPUCerenkov | GPURaytrace | GPUPhotonSource | GPUPhotonSourceMinimal | GPUPhotonFileSource |
0059 |---------|-------------|-------------|-----------------|------------------------|---------------------|
0060 | Cerenkov genstep collection | Yes | Yes | No | No | No |
0061 | Scintillation genstep collection | No | Yes | No | No | No |
0062 | Wavelength shifting (WLS) | Yes | Yes | Yes | Yes | Yes |
0063 | Torch photon generation | No | No | Yes | Yes | No |
0064 | Photon input from text file | No | No | No | No | Yes |
0065 | G4 optical photon tracking | Yes | Yes | Yes | No | No |
0066 | GPU simulation (Simphony) | Yes | Yes | Yes | Yes | Yes |
0067 | Multi-threaded | Yes | Yes | No | No | No |
0068
0069 `GPUCerenkov` and `GPURaytrace` collect gensteps from charged particle
0070 interactions and pass them to Simphony for GPU photon generation and tracing.
0071 `GPUPhotonSource` and `GPUPhotonSourceMinimal` instead generate photons
0072 directly from a torch configuration. `GPUPhotonSource` runs both G4 and GPU
0073 tracking for validation, while `GPUPhotonSourceMinimal` skips G4 tracking
0074 entirely to show the minimal GPU-only path. `GPUPhotonFileSource` reads
0075 photons from a user-provided text file, enabling custom photon distributions
0076 without code changes.
0077
0078 ## GDML scintillation properties for Geant4 11.x and Simphony
0079
0080 For scintillation to work with both Geant4 11.x and Simphony GPU simulation,
0081 the GDML must define properties using the correct syntax.
0082
0083 1. Const properties, such as yield and time constants, must use
0084 `coldim="1"` matrices:
0085
0086 ```xml
0087 <define>
0088 <matrix coldim="1" name="SCINT_YIELD" values="5000.0"/>
0089 <matrix coldim="1" name="FAST_TIME_CONST" values="21.5"/>
0090 </define>
0091 ```
0092
0093 2. Both old and new style property names are required for Simphony
0094 compatibility:
0095
0096 ```xml
0097 <material name="Crystal">
0098 <!-- New Geant4 11.x names -->
0099 <property name="SCINTILLATIONYIELD" ref="SCINT_YIELD"/>
0100 <property name="SCINTILLATIONCOMPONENT1" ref="SCINT_SPECTRUM"/>
0101 <property name="SCINTILLATIONTIMECONSTANT1" ref="FAST_TIME_CONST"/>
0102 <!-- Old-style names for Opticks U4Scint -->
0103 <property name="FASTCOMPONENT" ref="SCINT_SPECTRUM"/>
0104 <property name="SLOWCOMPONENT" ref="SCINT_SPECTRUM"/>
0105 <property name="REEMISSIONPROB" ref="REEMISSION_PROB"/>
0106 </material>
0107 ```
0108
0109 See `tests/geom/8x8SiPM_w_CSI_optial_grease.gdml` for a complete working
0110 example.
0111
0112 ## User and developer defined inputs
0113
0114 ### Defining primary particles
0115
0116 There are several inputs that the user or developer has to define. In
0117 `src/GPUCerenkov`, which imports `src/GPUCerenkov.h`, the code provides a
0118 working example with a simple geometry. The user or developer has to change
0119 the following details: the number of primary particles to simulate in a macro
0120 file and the number of G4 threads. For example:
0121
0122 ```text
0123 /run/numberOfThreads {threads}
0124 /run/verbose 1
0125 /process/optical/cerenkov/setStackPhotons {flag}
0126 /run/initialize
0127 /run/beamOn 500
0128 ```
0129
0130 Here `setStackPhotons` defines whether G4 will propagate optical photons or
0131 not. In production, Simphony on the GPU takes care of optical photon
0132 propagation. Additionally, the user has to define the starting position,
0133 momentum, and related settings of the primary particles in the
0134 `GeneratePrimaries` function in `src/GPUCerenkov.h`. The hits of the optical
0135 photons are returned in the `EndOfRunAction` function. If more photons are
0136 simulated than can fit in GPU RAM, the execution of a GPU call should be moved
0137 to `EndOfEventAction` together with retrieving the hits.
0138
0139 ### Loading geometry into Simphony
0140
0141 Simphony can import geometries in GDML format automatically. About ten
0142 primitives are supported now, for example `G4Box`. `G4Trd` and `G4Trap` are
0143 not supported yet. `GPUCerenkov` takes GDML files through command line
0144 arguments, for example `GPUCerenkov -g mygdml.gdml`.
0145
0146 The GDML must define all optical properties of surfaces and materials,
0147 including:
0148
0149 - Efficiency, used by Simphony to specify detection efficiency and assign
0150 sensitive surfaces
0151 - Refractive index
0152 - Group velocity
0153 - Reflectivity
0154 - Additional material and surface optical properties as required by the model