XENONnT / straxen

Streaming analysis for XENON
BSD 3-Clause "New" or "Revised" License
21 stars 32 forks source link

Add corrections_run_id for mini analysis #1339

Open mhliu0001 opened 6 months ago

mhliu0001 commented 6 months ago

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.

coveralls commented 6 months ago

Coverage Status

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