|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: 2022 CERN |
| 3 | +SPDX-License-Identifier: CC-BY-4.0 |
| 4 | +--> |
| 5 | + |
| 6 | +## Example 20 |
| 7 | + |
| 8 | +Example based on Example 19, but smaller kernels are fed with queues instead of the `SOAData` structure. |
| 9 | + |
| 10 | + * arbitrary geometry via gdml file (tested with cms2018.gdml from VecGeom persistency/gdml/gdmls folder) and optionally a magnetic field with constant Bz, |
| 11 | + * geometry read as Geant4 geometry, reading in regions and cuts, to initialize G4HepEm data |
| 12 | + * geometry read then into VecGeom, and synchronized to GPU |
| 13 | + * G4HepEm material-cuts couple indices mapped to VecGeom logical volume id's |
| 14 | + * physics processes for e-/e+ (including MSC) and gammas using G4HepEm. |
| 15 | + * scoring per placed volume, no sensitive detector feature |
| 16 | + * configurable particle gun via command line arguments |
| 17 | + * E.g., use `-gunpos -220,0,0 -gundir 1,0,0` for `testEm3.gdml`. For `cms2018.gdml`, the default gun is correct. |
| 18 | + |
| 19 | +Electrons, positrons, and gammas are stored in separate containers in device memory. |
| 20 | +Free positions in the storage are handed out with monotonic slot numbers, slots are not reused. |
| 21 | +Active tracks are passed via three queues per particle type (see `struct ParticleQueues`). |
| 22 | +Results are reproducible using one RANLUX++ state per track. |
| 23 | + |
| 24 | +Additionally, the kernels score energy deposit and the charged track length per volume. |
| 25 | + |
| 26 | +### Kernels |
| 27 | + |
| 28 | +This example uses one stream per particle type to launch kernels asynchronously. |
| 29 | +They are synchronized via a fourth stream using CUDA events. |
| 30 | + |
| 31 | +#### `TransportElectrons<bool IsElectron>` |
| 32 | + |
| 33 | +1. Obtain safety unless the track is currently on a boundary. |
| 34 | +2. Determine physics step limit, including conversion to geometric step length according to MSC. |
| 35 | +3. Query geometry (or optionally magnetic field) to get geometry step length. |
| 36 | +4. Convert geometry to true step length according to MSC, apply net direction change and displacement. |
| 37 | +5. Apply continuous effects; kill track if stopped. |
| 38 | +6. If the particle reaches a boundary, perform relocation. |
| 39 | +7. If not, and if there is a discrete process, hand over to interaction kernel. |
| 40 | + |
| 41 | +#### `TransportGammas` |
| 42 | + |
| 43 | +1. Determine the physics step limit. |
| 44 | +2. Query VecGeom to get geometry step length (no magnetic field for neutral particles!). |
| 45 | +3. If the particle reaches a boundary, perform relocation. |
| 46 | +4. If not, and if there is a discrete process, hand over to interaction kernel. |
| 47 | + |
| 48 | +#### Interaction kernels |
| 49 | +In electrons.cu and gammas.cu, there is dedicated kernels for all discrete processes. These were |
| 50 | +extracted from the main transport kernels in example18. |
| 51 | +1. Sample the final state. |
| 52 | +2. Update the primary and produce secondaries. |
| 53 | + |
| 54 | +#### `FinishIteration` |
| 55 | + |
| 56 | +Clear the queues and return the tracks in flight. |
| 57 | +This kernel runs after all secondary particles were produced. |
| 58 | + |
| 59 | +#### `InitPrimaries` and `InitParticleQueues` |
| 60 | + |
| 61 | +Used to initialize multiple primary particles with separate seeds. |
0 commit comments