---
# System prepended metadata

title: Flash matching for SBN

---

# Flash matching for SBN

## OpT0Finder

* You can use [this docker image](https://hub.docker.com/layers/154629651/deeplearnphysics/dune-nd-sim/ub20.04-generator/images/sha256-8a264351a29cc7ee0cb72dbedc6484eb7e73a65188cfaf5bebf27de33a8ccc21?context=explore) to exactly replicate the environment. Otherwise we use root 6.22 and visualization tools need `plotly` with `dash`
* [This](https://github.com/drinkingkazu/OpT0Finder) is the flashmatching repository.
* Sample data files used: `muons_opflashana.root` and `muons_particleana.root` under ~~``/icarus/data/users/kterao/opflash_muon_p02/``~~ `/icarus/data/users/kterao/opflash_muon_p02` (updated 09/15/2021)
* How to run a script: ~~`python3 bin/demo.py muons_particleana.root muons_opflashana.root out.csv`~~ `python3 bin/demo.py muons_particleana.root muons_opflashana.root out=out.csv` (updated 09/15/2021)
* How to run an interactive playground `python3 bin/view_data.py -od muons_opflashana.root -pd muons_particleana.root`
* [A quick look at plots](https://web.stanford.edu/~kterao/QuickLookFMatch.html) I show during demo (axis labels + comments will be added over the wkend)

Here's a [movie](https://stanford.zoom.us/rec/share/pbVGkZd2xT8tn3uZ4HG1sbQtQhUMa0PTD6Gf--T-BtJDa8jAdhfmAoaEl8OiRFkj.2py9wFuz3sMamD2l) where I go step-by-step of how to run the code in both batch and interactive mode with a visualization tool. **WARNING**: note two changes including the data location and a slight modification on specifying the output files for running `demo.py` (see above).

## Milestones

1. Update the [sbncode implementation](https://github.com/SBNSoftware/sbncode/tree/develop/sbncode/OpT0Finder) with the latest version of [OpT0Finder](https://github.com/drinkingkazu/OpT0Finder) `develop` branch(!)  following the experiment-agnostic implementation started by [Marco](mailto:mdeltutt@fnal.gov).~~
    * **Done.** Compiles in LArSoft, reproduces the performance in the original version. The `sbncode` is currently in [this fork](https://github.com/drinkingkazu/sbncode), and assumes an update in `larana` in [this fork](https://github.com/drinkingkazu/larana). These will be kept updated.
2. Benchmark the resource usage of the code, mainly time. Adjust hyperparameters to make it usable for high statistics run. Feedback any change to the original OpT0Finder repository.
    * ~~**On-going, mostly done.** It is usable for ICARUS, to be demonstrated using/writing a driver module in icaruscode.~~ **Done.** Speed performance is same (in a single-thread mode).
3. Reproduce the [performance last presented](https://sbn-docdb.fnal.gov/cgi-bin/sso/RetrieveFile?docid=15995&filename=ICARUS%20OpReco%20meeting%2012_19_2019.pdf&version=1) using 4-6 (uniform sampling) muons simulated uniform position (including a little bit outside of the active volume).
    * [Kazu] ~~benchmark OpHit and OpFlash reconstruction performance on simulation samples (ntuples already exist, ask Kazu)~~ ... **pretty much done**, OpHit fix introduced. Need to be merged into larana ([this fork](https://github.com/drinkingkazu/larana)).
    * [Kazu] ~~Reproduce the matching performance in the stand-alone mode.~~ **Done**`larsoft_merge` branch merged back into `develop`. Photon library needs to be updated for those who use `develop` branch.
    * [Kazu] Implement the driver code in icaruscode and reproduce the performance using the exact same input samples between larsoft v.s. stand-alone OpT0Finder
4. Prepare a collection of T0-tagged tracks (need reconstructed space points and associated optical flash) and run flash matching. Main purpose: debugging to make it work with real data (not sim/data discrepancy study, but basic level debugging like interpretation of timing information, etc.).
    * [Jacob help get started] **Starting**... a module for identifying t0-tagged (using geometry) tracks exist. We can write our own module to write n-tuples for those t0-tagged tracks referrencing how it's done in the existing module used by the calibration group. Why we don't use the existing one as is? Because our goal is very specific and info to write out is also different. Be familiar with OpT0Finder input information needs first! then combine that knowledge with the existing module. 
    * First samples only need less than 100 tracks. We want t0-tagged track space points, opflash info (these are the OpT0Finder input). But also full OpHit info (ch, time, area, PE) and optical waveform. First study is to understand the light yield / QE (how much PE we see for MIP) + time constants (i.e. how much fraction of PE do we see within 0.1, 2, 8 us of interaction)
5. Split T0-tagged tracks into half. Use one to calibrate global collection and quantum efficiencies. Use another half to benchmark the performance. [Here's slides](https://web.stanford.edu/~kterao/Random_Summary_OpRecoAndFlashMatch_2016_09_24.pdf) about this study in MicroBooNE.
    * **Not yet**
6. Study the flash-matching performance on simulated neutrino samples w/ cosmic rays
    * **Not yet**

## Timeline
- Step 1-3, 4 in July
- Step 5 in August
- Step 6 in August

Step 1-3 are pre-requisites. Step 4 must happen before 5. Step 5 is **most critical (and fun part)**, took about a month in MicroBooNE. Step 6 can start after step 1-3, but ultimately re-quantified after Step 5 is done. But Step 6 should not take long (compared to step 5).

