km3modules.k40
¶
A collection of k40 related functions and modules.
Module Contents¶
Classes¶
Subtracts random coincidence background from K40 data |
|
Intra DOM calibrator which performs the calibration from K40Counts. |
|
Counts twofold coincidences in timeslice hits per PMT combination. |
|
Creat a frame index lookup table which holds DOM IDs of frames with |
|
The module which can be attached to the pipeline |
|
The module which can be attached to the pipeline |
|
The module which can be attached to the pipeline |
Functions¶
|
Calibrate intra DOM PMT time offsets, efficiencies and sigmas |
|
|
|
Load k40 coincidences from hdf5 file |
|
Load k40 coincidences from JMonitorK40 ROOT file |
|
|
|
|
|
Fits gaussians to delta t for each PMT pair. |
|
Calculates angles between PMT combinations according to positions in |
|
|
|
|
|
Fits angular distribution of rates. |
|
Varies t0s to minimize the deviation of the gaussian means from zero. |
|
Varies sigmas to minimize gaussian sigma12 - sqrt(sigma1² + sigma2²). |
|
Varies QEs to minimize the deviation of the rates from the fitted_rates. |
|
Applies optimal t0s to gaussians means. |
|
Applies optimal qes to rates. |
|
Calculates RMS of means from zero before and after correction |
|
Calculates RMS of rates from fitted_rates before and after correction |
|
Return the index of PMT pair combinations |
|
Add counts to twofold coincidences for a given tmax. |
Attributes¶
- class km3modules.k40.K40BackgroundSubtractor(name=None, **parameters)[source]¶
Subtracts random coincidence background from K40 data
Notes
Requires servce ‘MedianPMTRates()’ Writes ‘K40Counts’ into the Blob: dict, Corrected K40 counts
- class km3modules.k40.IntraDOMCalibrator(name=None, **parameters)[source]¶
Intra DOM calibrator which performs the calibration from K40Counts.
- Parameters:
- det_id: int
Detector ID [default: 14]
- ctmin: float
Minimum cos(angle)
- mode: str (‘offline’ | ‘online’)
Calibration mode [default: ‘online’]
Notes
- Requires ‘TwofoldCounts’: dict
(key=dom_id, value=matrix of k40 counts 465x(dt*2+1))
- Requires ‘CorrectedTwofoldCounts’: dict
(key=dom_id, value=matrix of k40 counts 465x(dt*2+1))
Writes ‘IntraDOMCalibration’ into the blob: dict (key=dom_id, value=calibration)
- class km3modules.k40.TwofoldCounter(name=None, **parameters)[source]¶
Counts twofold coincidences in timeslice hits per PMT combination.
- Parameters:
- ‘tmax’: int
time window of twofold coincidences [ns]
- ‘dump_filename’: str
name for the dump file
Notes
Requires the key ‘TSHits’: RawHitSeries Provides the following services: ‘TwofoldCounts’: dict (key=dom_id, value=matrix (465,(dt*2+1))) ‘ResetTwofoldCounts’: reset the TwofoldCounts dict ‘GetLivetime()’: dict (key=dom_id, value=float) ‘DumpTwofoldCounts’: Writes twofold counts into ‘dump_filename’
- class km3modules.k40.HRVFIFOTimesliceFilter(name=None, **parameters)[source]¶
Creat a frame index lookup table which holds DOM IDs of frames with at least one PMT in HRV.
- class km3modules.k40.SummaryMedianPMTRateService(name=None, **parameters)[source]¶
The module which can be attached to the pipeline
- class km3modules.k40.MedianPMTRatesService(name=None, **parameters)[source]¶
The module which can be attached to the pipeline
- class km3modules.k40.ResetTwofoldCounts(name=None, **parameters)[source]¶
The module which can be attached to the pipeline
- km3modules.k40.calibrate_dom(dom_id, data, detector, livetime=None, fit_ang_dist=False, scale_mc_to_data=True, ad_fit_shape='pexp', fit_background=True, ctmin=-1.0)[source]¶
Calibrate intra DOM PMT time offsets, efficiencies and sigmas
- Parameters:
- dom_id: DOM ID
- data: dict of coincidences or root or hdf5 file
- detector: instance of detector class
- livetime: data-taking duration [s]
- fixed_ang_dist: fixing angular distribution e.g. for data mc comparison
- auto_scale: auto scales the fixed angular distribution to the data
- Returns:
- return_data: dictionary with fit results
- km3modules.k40.load_k40_coincidences_from_hdf5(filename, dom_id)[source]¶
Load k40 coincidences from hdf5 file
- Parameters:
- filename: filename of hdf5 file
- dom_id: DOM ID
- Returns:
- data: numpy array of coincidences
- livetime: duration of data-taking
- km3modules.k40.load_k40_coincidences_from_rootfile(filename, dom_id)[source]¶
Load k40 coincidences from JMonitorK40 ROOT file
- Parameters:
- filename: root file produced by JMonitorK40
- dom_id: DOM ID
- Returns:
- data: numpy array of coincidences
- dom_weight: weight to apply to coincidences to get rate in Hz
- km3modules.k40.fit_delta_ts(data, livetime, fit_background=True)[source]¶
Fits gaussians to delta t for each PMT pair.
- Parameters:
- data: 2d np.array: x = PMT combinations (465), y = time, entry = frequency
- livetime: length of data taking in seconds
- fit_background: if True: fits gaussian with offset, else without offset
- Returns:
- numpy arrays with rates and means for all PMT combinations
- km3modules.k40.calculate_angles(detector, combs)[source]¶
Calculates angles between PMT combinations according to positions in detector_file
- Parameters:
- detector: detector description (kp.hardware.Detector)
- combs: pmt combinations
- Returns:
- angles: numpy array of angles between all PMT combinations
- km3modules.k40.fit_angular_distribution(angles, rates, rate_errors, shape='pexp')[source]¶
Fits angular distribution of rates.
- Parameters:
- rates: numpy array
with rates for all PMT combinations
- angles: numpy array
with angles for all PMT combinations
- shape:
which function to fit; exp for exponential or pexp for exponential_polinomial
- Returns:
- fitted_rates: numpy array of fitted rates (fit_function(angles, popt…))
- km3modules.k40.minimize_t0s(means, weights, combs)[source]¶
Varies t0s to minimize the deviation of the gaussian means from zero.
- Parameters:
- means: numpy array of means of all PMT combinations
- weights: numpy array of weights for the squared sum
- combs: pmt combinations to use for minimization
- Returns:
- opt_t0s: optimal t0 values for all PMTs
- km3modules.k40.minimize_sigmas(sigmas, weights, combs)[source]¶
Varies sigmas to minimize gaussian sigma12 - sqrt(sigma1² + sigma2²).
- Parameters:
- sigmas: numpy array of fitted sigmas of gaussians
- weights: numpy array of weights for the squared sum
- combs: pmt combinations to use for minimization
- Returns:
- opt_sigmas: optimal sigma values for all PMTs
- km3modules.k40.minimize_qes(fitted_rates, rates, weights, combs)[source]¶
Varies QEs to minimize the deviation of the rates from the fitted_rates.
- Parameters:
- fitted_rates: numpy array of fitted rates from fit_angular_distribution
- rates: numpy array of rates of all PMT combinations
- weights: numpy array of weights for the squared sum
- combs: pmt combinations to use for minimization
- Returns:
- opt_qes: optimal qe values for all PMTs
- km3modules.k40.correct_means(means, opt_t0s, combs)[source]¶
Applies optimal t0s to gaussians means.
Should be around zero afterwards.
- Parameters:
- means: numpy array of means of gaussians of all PMT combinations
- opt_t0s: numpy array of optimal t0 values for all PMTs
- combs: pmt combinations used to correct
- Returns:
- corrected_means: numpy array of corrected gaussian means for all PMT combs
- km3modules.k40.correct_rates(rates, opt_qes, combs)[source]¶
Applies optimal qes to rates.
Should be closer to fitted_rates afterwards.
- Parameters:
- rates: numpy array of rates of all PMT combinations
- opt_qes: numpy array of optimal qe values for all PMTs
- combs: pmt combinations used to correct
- Returns:
- corrected_rates: numpy array of corrected rates for all PMT combinations
- km3modules.k40.calculate_rms_means(means, corrected_means)[source]¶
Calculates RMS of means from zero before and after correction
- Parameters:
- means: numpy array of means of gaussians of all PMT combinations
- corrected_means: numpy array of corrected gaussian means for all PMT combs
- Returns:
- rms_means: RMS of means from zero
- rms_corrected_means: RMS of corrected_means from zero
- km3modules.k40.calculate_rms_rates(rates, fitted_rates, corrected_rates)[source]¶
Calculates RMS of rates from fitted_rates before and after correction
- Parameters:
- rates: numpy array of rates of all PMT combinations
- corrected_rates: numpy array of corrected rates for all PMT combinations
- Returns:
- rms_rates: RMS of rates from fitted_rates
- rms_corrected_rates: RMS of corrected_ratesrates from fitted_rates
- km3modules.k40.add_to_twofold_matrix(times, tdcs, mat, tmax=10)[source]¶
Add counts to twofold coincidences for a given tmax.
- Parameters:
- times: np.ndarray of hit times (int32)
- tdcs: np.ndarray of channel_ids (uint8)
- mat: ref to a np.array((465, tmax * 2 + 1))
- tmax: int (time window)
- Returns:
- mat: coincidence matrix (np.array((465, tmax * 2 + 1)))