Skip to content

Remove Cherenkov threshold for LS detectors - #71

Open
JostMigenda wants to merge 3 commits into
mainfrom
JostMigenda/threshold
Open

JostMigenda wants to merge 3 commits into
mainfrom
JostMigenda/threshold

Conversation

@JostMigenda

Copy link
Copy Markdown
Member

Fixes #52. As a side effect (because the allowed eNu range for certain channels is now slightly larger), the event rate in es and c12e/c12eb channels increases by a few per cent for LS detectors.

(Not 100% happy with how I implemented this, but I think that’s about as good as it gets without a larger restructuring of the code base. At least I got to clean up the main() implementation slightly.)

Since gen_evts() is executed in separate processes for parallelisation, this needed to be done in that function, which required changes to the surrounding code.
* update hash of sample output file
* remove old sample output file from tests directory
* remove diff from CI (was left over from initial debugging) and set explicit exit code instead
@JostMigenda
JostMigenda requested a review from mcolomerm March 19, 2026 21:35
@JostMigenda

Copy link
Copy Markdown
Member Author

Hmm … the integration test is failing under Ubuntu; the only difference I can see from the logs is in the c12e channel:

[c12e] Generated 64 particles (expected: 66.86 particles) (macOS/Windows)

[c12e] Generated 64 particles (expected: 66.82 particles) (Ubuntu)

Not sure what's going on there; I'll look into it (but am on annual leave this afternoon, so this will need to wait until next week).

Default method depends on OS and Python version and `fork` doesn’t work with the cherenkov_threshold hack in this PR.
@JostMigenda

Copy link
Copy Markdown
Member Author

Fixed the issue—turns out, ProcessPoolExecutor uses different ways to create new processes depending on OS and Python version. macOS and Windows use spawn by default, which creates a blank slate process; Linux uses fork which inherits existing module imports from the parent process (so updating sntools.interaction_channels.cherenkov_threshold inside gen_evts() was too late).

@mcolomerm Please go ahead and try this branch now; I’ll merge it sometime after the Easter holidays if you don’t discover any further issues.

@mcolomerm

Copy link
Copy Markdown

Fixed the issue—turns out, ProcessPoolExecutor uses different ways to create new processes depending on OS and Python version. macOS and Windows use spawn by default, which creates a blank slate process; Linux uses fork which inherits existing module imports from the parent process (so updating sntools.interaction_channels.cherenkov_threshold inside gen_evts() was too late).

@mcolomerm Please go ahead and try this branch now; I’ll merge it sometime after the Easter holidays if you don’t discover any further issues.

Thanks @JostMigenda for having a look at this. I will try to test it on the coming days.

@hecsanper

Copy link
Copy Markdown

Hi,
The way this pull request is implemented, changing the cherenkov_threshold variable in channel.py, I think it would correctly fix the issue when using sntools from the terminal to generate events. (Which is sntools' main purpose.)

However, it would not address the issue when using sntools as a Python library to calculate differential cross sections, which is another valid use case of the code that is mentioned in the documentation and used, for example, in this SNOwGLoBES pull request, since the cherenkov_threshold variable would not be changed in this case, as channel.py is not called. In the code that I am developing, I also intend to use sntools in this way.

Fixing the issue in a way that accounts for this use case and allows for including or excluding the Cherenkov threshold would definitely be possible, but non-trivial.

Instead, what I did in my sntools fork (building on what this PR already adds) was to remove the Cherenkov threshold entirely (except in oxygen channels, since those are exclusive to Cherenkov detectors), replacing it by a minimal threshold given by the electron mass plus a small numerical offset.

The reasoning is that sntools is not intended to be a full detector simulator, and real Cherenkov detectors have effective thresholds that are higher than the Cherenkov threshold, so any realistic simulation needs to account for the corresponding detector's effective threshold and cut events below that energy. In that sense, whether sntools cuts the events below the Cherenkov threshold does not matter, as those events would be cut anyway when applying the detector's effective threshold, and sntools cutting them does not eliminate the need to apply that additional detector-level cut.

What do you think? If you're interested, I'd be happy to send a pull request with my changes. Conversely, if you have any objections or concerns, I'd be happy to discuss them.

Best regards,
Héctor

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.

Remove Cherenkov threshold for LS detectors

3 participants