Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New context #72

Merged
merged 21 commits into from
Dec 22, 2023
Merged

New context #72

merged 21 commits into from
Dec 22, 2023

Conversation

HenningSE
Copy link
Collaborator

This PR will add a proper simulation context to fuse.

@HenningSE HenningSE mentioned this pull request Oct 16, 2023
@HenningSE
Copy link
Collaborator Author

The last commit updates the S1 LCE map handling. The map is now calculated from the S1 pattern map like it is done in WFSim: https://github.com/XENONnT/WFSim/blob/0c7dee5157ce23461c6b0536c932ebd54cd5fecc/wfsim/load_resource.py#L246-L250

@HenningSE
Copy link
Collaborator Author

The tests ran without problem. I think the PR is ready for review.

Copy link
Collaborator

@ramirezdiego ramirezdiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @HenningSE, finally here :) I tested the context and saw how the different configs are tracked and everything works perfectly as far as I can tell. This is clean work, as the rest of fuse!

I am now simply going through the code in detail (also checking back into WFSim to try to remember how some corrections were added) and have minor comments, see below. In addition, could you please remind me what we decided with the s1_lce_correction_map option from WFSim? See description here. Sorry if I missed something we have already discussed, it's been a while. I'll finish reading tomorrow morning.

fuse/plugins/detector_physics/s1_photon_hits.py Outdated Show resolved Hide resolved
Comment on lines 161 to 167
self.gains = self.gains = pmt_gains(self.gain_model_mc,
digitizer_voltage_range=self.digitizer_voltage_range,
digitizer_bits=self.digitizer_bits,
pmt_circuit_load_resistor=self.pmt_circuit_load_resistor
)

self.pmt_mask = np.array(self.gains) > 0 # Converted from to pe (from cmt by default)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do not miss something obvious, I think that this part of the code and the commented function below could be just erased, together with the gains URL config for this plugin. I think the gains were meant to mask the data-driven maps to keep backwards compatibility with ancient data-driven configs in WFSim.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ramirezdiego, the pmt_mask is used when building the s2_pattern_map. It is not very obvious and hidden in the URLConfig:

s2_pattern_map = straxen.URLConfig(
default = 'pattern_map://resource://simulation_config://'
'SIMULATION_CONFIG_FILE.json?'
'&key=s2_pattern_map'
'&fmt=pkl'
'&pmt_mask=plugin.pmt_mask',
cache=True,
help='S2 pattern map',
)

To clean up the code I removed the lines below that were not used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is used to build the map, like in the analogue S1 plugin. My point here is that, if we remove the ancient code in which s2_pattern_map is propagated for the extraction efficiency correction, this config is no longer needed, is it? We could then remove the gains and pattern map dependences here, but maybe I missed something obvious reading through this class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right, s2_pattern_map is not used in the plugin so I removed it. Thanks for spotting this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, done in ff14f2b. Also removed the arguments involved in the gain calculation, as pointed out by you.

@ramirezdiego
Copy link
Collaborator

Hey @HenningSE, finally here :) I tested the context and saw how the different configs are tracked and everything works perfectly as far as I can tell. This is clean work, as the rest of fuse!

I am now simply going through the code in detail (also checking back into WFSim to try to remember how some corrections were added) and have minor comments, see below. In addition, could you please remind me what we decided with the s1_lce_correction_map option from WFSim? See description here. Sorry if I missed something we have already discussed, it's been a while. I'll finish reading tomorrow morning.

Clarifying the s1_lce_correction_map comment here for future reference: in WFSim we used this map (data-driven) or s1_pattern_map (sims-driven) to build the LCE correction. As we shifted towards the second, we slightly modify WFSim to take s1_lce_correction_map as a boolean and, if set to false, default to the simulations-driven one. I think that we now decided to drop this option and only use s1_pattern_map, right? Trying to spot WFSim "features" which aimed at keeping backwards compatibility (and we should of course no longer propagate).

@HenningSE
Copy link
Collaborator Author

Ahh thanks for clarifying! I dropped most of the backwards compatibility stuff to clean up the code and have a good implementation of the latest WFSim version. If someone needs these old functions we can add them later in dedicated plugins or so.

Copy link
Collaborator

@ramirezdiego ramirezdiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally through. Thanks for the patience and for the clean work :)

🚀

@ramirezdiego ramirezdiego merged commit b150426 into main Dec 22, 2023
@ramirezdiego ramirezdiego deleted the new_context branch December 22, 2023 10:06
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.

2 participants