Extend SciFi binary search range to 1024 hits and fix the non-deterministic behaviour
Introduction
The current SciFi GEC is set to 20000, which corresponds to approximately 833 hits per SciFi part (zone). However, the existing binary search is only valid for nhits < 512.
This MR extends the binary search range up to 1024 hits. This should be a reasonable upper limit since the Triplet struct also uses 10 bits to store the SciFi hit index: if there are more than 2^10 (1024) hits, the triplet cannot be stored correctly. Therefore, performing a binary search for more than 1024 hits at this stage doesn't make any sense.
Checked with data (run 307533, only first 100k events):
- Before the fix, the number of SciFi seeds = 6953716
- After the fix, the number of SciFi seeds = 6956060 (↑ 2344 tracks)
Note: I performed another cross-check by extending the binary search range to 2^11 (2048) hits, and the number of SciFi seeds remained the same.
Fix for Non-Deterministic Results in Seeding
During local testing, a bug was found in the binary search function. The fix is included in this MR. Local tests show the following:
- Running 50k events of the Bs2PhiPhiMD sample (MC Production ID = 233404) with the
hlt1_pp_matching_no_utsequence on themasterbranch, the counters show differences every time:
--- ./deterministic_check/0.log
+++ ./deterministic_check/1.log
@@ -2,9 +2,9 @@
-----------------------------
Counters: 50000 events, 5 counters
- n_ft_hits: 255999716
- - n_matching: 3141595
- - n_seeding: 5600356
- - n_xz_seeds: 8154836
+ - n_matching: 3141592
+ - n_seeding: 5600353
+ - n_xz_seeds: 8154832
- n_xz_triplets: 81435347
-----------------------------
--- ./deterministic_check/0.log
+++ ./deterministic_check/2.log
@@ -2,9 +2,9 @@
-----------------------------
Counters: 50000 events, 5 counters
- n_ft_hits: 255999716
- - n_matching: 3141595
- - n_seeding: 5600356
- - n_xz_seeds: 8154836
+ - n_matching: 3141593
+ - n_seeding: 5600353
+ - n_xz_seeds: 8154833
- n_xz_triplets: 81435347
-----------------------------
- With the fix applied, this non-deterministic behavior is completely solved. No fluctuations were observed over 100 iterations.
-----------------------------
Counters: 50000 events, 5 counters
- n_ft_hits: 255999716
- n_matching: 3142062
- n_seeding: 5597856
- n_xz_seeds: 8153095
- n_xz_triplets: 81287782
-----------------------------
Protection of 1024 hits per SciFi zone
This MR also introduces a protection in the seeding to limit the number of hits per SciFi zone to 1024. When a SciFi zone contains more than 1024 hits, the hit container is shrunk toward the center by removing hits from the borders. This ensures that the hit index always remains below 1024 and avoids the phi asymmetry in tracking.
Note: if we simply kept the first 1024 hits (i.e., shrinking from the left), this could introduce significant phi asymmetry by reducing tracking efficiency for x > 0.
In principle, with the current GEC cut, this scenario is unlikely to occur (I haven’t observed it in the dumped MEPs so far). However, even if we loosen the GEC cut in the future, this protection will ensure reasonable tracking performance in seeding. If the scenario occurs too frequently, we should consider redesigning the triplet structure or applying a tighter GEC cut.
Change Log
20/03/2025
- Extended the binary search range to support up to 1024 hits.
08/04/2025
- Added protection in seeding: when the number of hits in a single SciFi zone exceeds 1024, the hit container is shrunk to fit the 1024-hit limit.
- Fixed a bug in the binary search function that caused non-deterministic results. See https://godbolt.org/z/6esfx7sxd
Note:
This MR should close #568 (closed)