Skip to content

Commit 384f5e9

Browse files
start page on sim from scoring plane (#68)
* start page on sim from scoring plane * fixup, add a few more analysis comments * add version placeholder, fix Simulator case * version number that the feature is included in
1 parent 76b9194 commit 384f5e9

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

‎src/SUMMARY.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [Configuring the Simulation](using/sim/configuring.md)
1717
- [Re-Simulation](using/sim/resim.md)
1818
- [Alternative photo-nuclear models](using/sim/Alternative-Photo-Nuclear-Models.md)
19+
- [Simulation from Scoring Planes](using/sim/sim-from-scoring-planes.md)
1920
- [Dark Brem Signal Samples](using/dark-brem/intro.md)
2021
- [How to Run](using/dark-brem/how-to.md)
2122
- [Legacy Instructions](using/dark-brem/legacy.md)
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Simulation from Scoring Plane Hits
2+
3+
Available in ldmx-sw v4.8.2 and later.
4+
5+
~~~admonish note title="Not Re-Sim"
6+
The `FromScoringPlane` generator is mainly focused on doing "two stage" simulation
7+
where _replication_ is not required. If you want to **fully replicate**
8+
past events within an input file, you should use the [re-simulation
9+
infrastructure](resim.md).
10+
~~~
11+
12+
Two-stage simulation is helpful when two parts of the simulation are
13+
physically separate enough that the physical effects are approximately one direction.
14+
For example, the tracking, target, and trigger scintillator ("tracking") region compared
15+
to the ecal and hcal ("calorimeter") region. These two regions are separated into two distinct
16+
areas along the beam line and (excluding the lower rate and lower energy "backsplash"),
17+
particles pass through the upstream region and then pass through the downstream
18+
calorimeter region.
19+
Another example would be if we wanted to simulate some beamline components upstream
20+
of our detector apparatus.
21+
22+
Since these two stages are physically separate, we can simulate them separately and
23+
get physically-reasonable events (even if the events we simulate are not identical
24+
to if we simulated the two regions together at once).
25+
Below, I walk through an example of doing a two-stage simulation where we first
26+
simulate the tracking region alone and then simulate the calorimeter region.
27+
We separate out the tracking region because, since it has less mass in the detector,
28+
it doesn't cause the beam particle to shower and so the simluation has less particles
29+
to deal with and therefore completes much faster.
30+
In this way, we can simulate many more events in the tracking region and then
31+
filter out events from that sample that are particularly troublesome that we
32+
want to study in more detail with the calorimeter simulation as well.
33+
34+
## Stage One: "simtrk"
35+
`SimCore/exampleConfigs/stage-one-no-cal.py`
36+
37+
In this stage, we do a normal simulation but we omit the detector volumes
38+
and sensitive detectors (SDs) that are not within the region we care about.
39+
The tracking region already has a GDML detector model constructed that is
40+
equivalent to the full v15 detector but without the two calorimeters,
41+
so we can just use that model.
42+
43+
For example,
44+
```python
45+
from LDMX.SimCore import simulator, generators, sensitive_detectors
46+
sim = simulator.Simulator('sim')
47+
sim.set_detector('ldmx-det-v15-8gev-no-cals')
48+
sim.generators = [
49+
generators.single_8gev_e_upstream_tagger()
50+
]
51+
sim.description = 'single electron 8gev beam, no calorimeters, no biasing or filtering'
52+
# manually add the sensitive detectors that we want
53+
sim.sensitive_detectors = [
54+
sensitive_detectors.TrackerSD.tagger(),
55+
sensitive_detectors.TrackerSD.recoil(),
56+
sensitive_detectors.TrigScintSD.target(),
57+
sensitive_detectors.TrigScintSD.pad1(),
58+
sensitive_detectors.TrigScintSD.pad2(),
59+
sensitive_detectors.TrigScintSD.pad3(),
60+
sensitive_detectors.ScoringPlaneSD.tracker(),
61+
sensitive_detectors.ScoringPlaneSD.target(),
62+
sensitive_detectors.ScoringPlaneSD.ecal()
63+
]
64+
```
65+
We want to _remove_ all of the SDs that pertain to subsystems we are not
66+
including (e.g. `EcalSD` and `HcalSD` are omitted), but we do want to
67+
include the scoring planes for the area from which we want to start
68+
stage two (in this case, `ScoringPlaneSD.ecal()` contains one "plane"
69+
at the front of the calorimeter region, `ScoringPlaneSD.hcal()` has
70+
a similar one which is larger in the transverse dimensions if you
71+
need to capture wider scatters).
72+
73+
## Stage Two: "simcal"
74+
`SimCore/exampleConfigs/stage-two-cal.py`
75+
76+
The `FromScoringPlane` generator requires an input file to be given to the
77+
process so that (a) the prior pass's information is copied into the output
78+
file for analysis and (b) so this generator can access the prior
79+
pass's scoring plane hits to start the second stage of simulation.
80+
81+
You should also make sure the pass name is different for the stage two run so that both sets of simulation collections (e.g. `SimParticles`) are able to be stored in the output event file.
82+
```python
83+
p = ldmxcfg.Process("simcal")
84+
p.input_files = ["output-file-from-stage-one.root"]
85+
```
86+
87+
And then the simulation can use the special generator that uses hits from the input file to create primary particles.
88+
89+
```python
90+
# sim is a normal simulator.Simulator
91+
from LDMX.SimCore.generators import FromScoringPlane
92+
sim.generators = [ FromScoringPlane.ecal() ]
93+
```
94+
95+
You can do a similar thing as stage one where you tune the `sim.sensitive_detectors` to only the subsystems that are of-interest in this stage. Technically, that is not necessary but it would be helpful to avoid downstream confusion during analysis.
96+
97+
### Analysis Comments
98+
The file output by "Stage Two" of the simulation is complicated since it was constructed in an abnormal way.
99+
100+
- **Be Careful with Pass Names**: Remember that both stages could have contributed a collection with the same name, so make sure the two stages have different pass names and you choose the correct pass name when analyzing the resulting file. For example, I know that the `RecoilSimHits` collection from the `simcal` pass will only be back-splash hits while the `RecoilSimHits` collection from the `simtrk` pass will be near-normal.
101+
- **Neglecting Backspash**: While we expect backsplash from the calorimeters confusing the recoil tracker to be a small/neglible effect, this two-stage simulation completely omits this possibility. In some sense, the tracking in the recoil detector is therefore a bit "too easy" compared to real events.
102+
- **Re-Sampling**: Since the fate of particles is inherently probabilistic, you may want to simulate the same scoring-plane events many times to try to understand the distribution of possible signals in the calorimeters. This can be achieved by using the same input file and simply using a different run number in stage two so that the random number generator is seeded differently.

0 commit comments

Comments
 (0)