.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_pmt_time_slewing.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_pmt_time_slewing.py: ================== PMT Time Slewing ================== Show different variants of PMT time slewing calculations. Time slewing corrects the hit time due to different rise times of the PMT signals depending on the number of photo electrons. The reference point is at 26.4ns and hits with a different ToT values are corrected to refer to comparable arrival times. The time slewing is subtracted from the measured hit time, in contrast to the time calibration (t0), which is added. The time slewing correction is automatically applied in `km3pipe` when using `kp.calib.Calibration().apply()`, however it can be turned off by providing `correct_slewing=False` and also the variant can be picked by `slewing_variant=X`. Variant 3 is currently (as of 2020-10-16) also used in Jpp. .. GENERATED FROM PYTHON SOURCE LINES 26-38 .. code-block:: Python # Author: Tamas Gal # License: BSD-3 import km3pipe as kp import numpy as np import matplotlib.pyplot as plt kp.style.use() tots = np.arange(256) .. GENERATED FROM PYTHON SOURCE LINES 39-42 The `kp.cali.slew()` function can be used to calculate the slew. It takes a single ToT or an array of ToTs and optionally a variant. Here is the docstring of the function: .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: Python help(kp.calib.slew) .. rst-class:: sphx-glr-script-out .. code-block:: none Help on function slew in module km3pipe.calib: slew(tot, variant=3) Calculate the time slewing of a PMT response for a given ToT Parameters ---------- tot: int or np.array(int) Time over threshold value of a hit variant: int, optional The variant of the slew calculation. 1: The first parametrisation approach 2: Jannik's improvement of the parametrisation 3: The latest lookup table approach based on lab measurements. Returns ------- time: int Time slewing, which has to be subtracted from the original hit time. .. GENERATED FROM PYTHON SOURCE LINES 46-47 Calculating the slew for all variants: .. GENERATED FROM PYTHON SOURCE LINES 47-61 .. code-block:: Python slews = {variant: kp.calib.slew(tots, variant=variant) for variant in (1, 2, 3)} fig, ax = plt.subplots() for variant, slew in slews.items(): ax.plot(tots, slew, label=f"Variant {variant}") ax.set_xlabel("ToT / ns") ax.set_ylabel("time slewing / ns") ax.legend() fig.tight_layout() plt.show() .. image-sg:: /auto_examples/images/sphx_glr_plot_pmt_time_slewing_001.png :alt: plot pmt time slewing :srcset: /auto_examples/images/sphx_glr_plot_pmt_time_slewing_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.798 seconds) .. _sphx_glr_download_auto_examples_plot_pmt_time_slewing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_pmt_time_slewing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_pmt_time_slewing.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_