DUNE / larnd-sim

Simulation framework for a pixelated Liquid Argon TPC
Apache License 2.0
10 stars 26 forks source link

zero suppress light backtracking matrix #195

Closed russellphysics closed 5 months ago

russellphysics commented 5 months ago

Light truth backtracking reshaped to suppress null-valued ticks. N-dimensional arrays saved per spill. Apply masks to quickly filter to light truth of interest. Truth fields: 'event_id', 'det_id', 'track_id', 'pe_current', and 'tick'. This implementation was validated on 2x2 production MiniRun 5 edepsim files, verifying on spill, optical detector, and waveform level that information from original backtracking implementation was accurately preserved with new implementation. Example validation attached. example2

YifanC commented 5 months ago

Hi Brooke @russellphysics, thanks for the PR! I renamed some attributes to be consistent with the rest of the output. Hope you are okay with it. In addition, when I tested this, I encountered some issues.

waveforms_true_track_id.size will always be greater than 0 as long as max_light_truth_ids is set to a non-zero value. However, truth_data can still be empty due to the filter function you added. When truth_data is empty, the data appending here or here may raise error.

If I modify waveforms_true_track_id.size to truth_data.size here and here correspondingly, it would be fine for non module variation case, but again having error in merge_module_light_wvfm_same_trigger(), because the backtracking size for each module is different (ref).

Another issue is that if module variation is enabled, the det_id / op_channel_id will always be up to the number of single module light channels. Namely, (0, 95) for 2x2, but this det_id / op_channel_id is expected to be global channel id (0, 385) in the current setup.

Consider this two, I wonder if it would be easier if the light backtracking filter is run after the waveform merging for module variation cases. I suppose something after this, which can be used for both module variation and non module variation.

Thanks!

russellphysics commented 5 months ago

Thank you, Yifan. We recently encountered the same issue of an empty truth_data container in the process of code profiling. We added an if statement for an empty container to evade this issue.

russellphysics commented 5 months ago

Regarding the issues on compatibility with running larndsim with module variations enabled, unfortunately we did not validate this code with module variations enabled, rather we only validated with the default configuration in 2x2_sim develop branch. We do not yet have remedy for the first issue and need to take a closer look at the module variation specific function referenced. The final issue noted appears straightforward to remedy by indexing the opdet id based on module under consideration.

mjkramer commented 5 months ago

Superseded by #201