Skip to content

Add DBSCAN clustering step to Sophronia city#951

Open
camacortespar wants to merge 9 commits intonext-exp:masterfrom
camacortespar:develop
Open

Add DBSCAN clustering step to Sophronia city#951
camacortespar wants to merge 9 commits intonext-exp:masterfrom
camacortespar:develop

Conversation

@camacortespar
Copy link

Summary

This PR integrates a hit clustering step (using DBSCAN) into the Sophronia city workflow.

Key Changes

1. New Logic (reco/hits_functions.py)

  • Implemented cluster_tagger: A function that applies DBSCAN on an event-by-event basis.
  • It handles spatial anisotropy via scale_xy and scale_z parameters.
  • It preserves data structure and alignment perfectly.

2. Integration (cities/sophronia.py)

  • Added clustering_params to the city configuration.
  • Inserted the clustering step in the dataflow.
  • Backward Compatibility: If clustering_params is None (default), the city skips clustering and produces the exact same output structure as before (no cluster column).

3. Testing (cities/sophronia_test.py & reco/hits_functions_test.py)

  • Added unit tests for structure preservation, row alignment, and noise rejection in DBSCAN.
  • Added integration tests ensuring cluster column appears only when enabled.
  • Verified that enabling clustering does not corrupt other physical variables.

4. Reference Update

  • Updated database/test_data/228Th_10evt_hits.h5.
  • Re-generated this reference file using the current master logic to ensure test_sophronia_exact_result passes with the new code structure.

Configuration Example

To use this feature, add the following to the configuration file (these values are optimized for NEXT-100 detector geometry):

clustering_params = dict(
    eps = 3,
    min_samples = 5,
    scale_xy = 14.55,
    scale_z = 3.7
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant