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

Add corrections_run_id for mini analysis #1339

Closed
wants to merge 2 commits into from
Closed

Conversation

mhliu0001
Copy link

What does the code in this PR do / what does it improve?

In the mini analysis code, straxen will look for the gain_model for the run_id specified. However, for MC runs the run_id is meaningless and should not be used to find corrections. Instead, a corrections_run_id should be provided for fuse/WFSim-based runs.

Can you briefly describe how it works?

Add an extra key argument in the mini_analysis base class called "corrections_run_id". If this is provided, find the gain_model according to the corrections_run_id.

Can you give a minimal working example (or illustrate with a figure)?

import fuse
import cutax
import bokeh.plotting as bklt

st = fuse.context.full_chain_context(output_folder="./fuse_data",
                                     corrections_version='global_v14')

st.set_config({"path": "/project2/lgrandi/xenonnt/simulations/testing",
               "file_name": "pmt_neutrons_100.root",
               "entry_stop": 2,
               })

run_number = "mc_00"
st.make(run_number, "raw_records")
peaks = st.get_array(run_number,"peaks")
events = st.get_array(run_number,"event_basics")

fig = st.event_display_interactive(run_number, time_range=(events[0]['time'], events[0]['endtime']), corrections_run_id="026000")

bklt.output_file(filename="demo.html")
bklt.save(fig)

Before this PR straxen will try to load gain_model for run "mc_00", which will raise an error. Now it works.

@mhliu0001 mhliu0001 requested a review from dachengx February 28, 2024 23:54
@coveralls
Copy link

coveralls commented Feb 29, 2024

Coverage Status

coverage: 91.341% (+0.01%) from 91.328%
when pulling d729a8c on mc_mini_analysis
into 2075e4a on master.

Copy link
Collaborator

@dachengx dachengx left a comment

Choose a reason for hiding this comment

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

straxen should not touch anything related to simulation. So I would recommend processing corrections_run_id in fuse. The mini_analysis can be redefined in fuse and mini_analysis of fuse can call mini_analysis of straxen.

i made some comments below on how to redefine the mini_analysis in fuse.

@@ -39,7 +39,8 @@ def wrapped_f(context: strax.Context, run_id: str, **kwargs):
known_kwargs = (
"time_range seconds_range time_within time_selection "
"ignore_time_warning "
"selection_str t_reference to_pe config"
"selection_str t_reference to_pe config "
"corrections_run_id"
Copy link
Collaborator

@dachengx dachengx Mar 2, 2024

Choose a reason for hiding this comment

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

You can add another argument to straxen's mini_analysis function so that it can add additional known_kwargs to the default ones.

@@ -66,7 +67,12 @@ def wrapped_f(context: strax.Context, run_id: str, **kwargs):
if "to_pe" in parameters and "to_pe" not in kwargs:
to_pe = context.config["gain_model"]
if isinstance(to_pe, str):
to_pe = straxen.URLConfig.evaluate_dry(to_pe, run_id=run_id)
if "corrections_run_id" in kwargs:
Copy link
Collaborator

@dachengx dachengx Mar 2, 2024

Choose a reason for hiding this comment

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

This part should be a stand-alone function called process_to_pe or other proper names. For straxen, process_to_pe can be what it was. But for fuse, you can process corrections_run_id in process_to_pe.

@mhliu0001 mhliu0001 marked this pull request as draft March 5, 2024 17:38
@yuema137
Copy link
Collaborator

As being discussed above, this will be implemented in fuse instead of straxen

@yuema137 yuema137 closed this Oct 16, 2024
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.

4 participants