diff --git a/docs/source/manual/processors.md b/docs/source/manual/processors.md index 0ecd0994..281d6af1 100644 --- a/docs/source/manual/processors.md +++ b/docs/source/manual/processors.md @@ -40,6 +40,8 @@ hits_by_evtid = group_by_evtid(data) hits_by_time = group_by_time(data, window=10) # unit is us ``` +(processors-contract)= + ## Other processors Additional _reboost_ processors compute further quantities of interest. This diff --git a/docs/source/tutorial/config.md b/docs/source/tutorial/config.md index daefa775..96f5ec4b 100644 --- a/docs/source/tutorial/config.md +++ b/docs/source/tutorial/config.md @@ -92,7 +92,7 @@ config: first_evtid: ak.fill_none(ak.firsts(HITS.evtid, axis=-1), np.nan) truth_energy: ak.sum(HITS.edep, axis=-1) distance_to_nplus: reboost.hpge.surface.distance_to_surface(HITS.xloc, HITS.yloc, HITS.zloc, DETECTOR_OBJECTS.pyobj, DETECTOR_OBJECTS.phyvol.position.eval(), surface_type='nplus') - activeness: reboost.math.functions.piecewise_linear_activeness(HITS.distance_to_nplus,fccd=DETECTOR_OBJECTS.det_pars.fccd_in_mm, dlf=DETECTOR_OBJECTS.det_pars.dlf) + activeness: reboost.math.functions.piecewise_linear_activeness(HITS.distance_to_nplus,fccd_in_mm=DETECTOR_OBJECTS.det_pars.fccd_in_mm, dlf=DETECTOR_OBJECTS.det_pars.dlf) active_energy: ak.sum(HITS.edep*HITS.activeness, axis=-1) smeared_energy: reboost.math.stats.gaussian_sample(HITS.active_energy,DETECTOR_OBJECTS.det_pars.reso_fwhm_in_keV/2.355) r90: reboost.hpge.psd.r90(HITS.edep,HITS.xloc*1000,HITS.yloc*1000,HITS.zloc*1000) @@ -339,7 +339,7 @@ operations: first_evtid: ak.fill_none(ak.firsts(HITS.evtid, axis=-1), np.nan) truth_energy: ak.sum(HITS.edep, axis=-1) distance_to_nplus: reboost.hpge.surface.distance_to_surface(HITS.xloc, HITS.yloc, HITS.zloc, DETECTOR_OBJECTS.pyobj, DETECTOR_OBJECTS.phyvol.position.eval(), surface_type='nplus') - activeness: reboost.math.functions.piecewise_linear_activeness(HITS.distance_to_nplus,fccd=DETECTOR_OBJECTS.det_pars.fccd_in_mm, dlf=DETECTOR_OBJECTS.det_pars.dlf) + activeness: reboost.math.functions.piecewise_linear_activeness(HITS.distance_to_nplus,fccd_in_mm=DETECTOR_OBJECTS.det_pars.fccd_in_mm, dlf=DETECTOR_OBJECTS.det_pars.dlf) active_energy: ak.sum(HITS.edep*HITS.activeness, axis=-1) smeared_energy: reboost.math.stats.gaussian_sample(HITS.active_energy,DETECTOR_OBJECTS.det_pars.reso_fwhm_in_keV/2.355) r90: reboost.hpge.psd.r90(HITS.edep,HITS.xloc*1000,HITS.yloc*1000,HITS.zloc*1000) diff --git a/docs/source/tutorial/simple.md b/docs/source/tutorial/simple.md index 08bd3404..ec6c5617 100644 --- a/docs/source/tutorial/simple.md +++ b/docs/source/tutorial/simple.md @@ -116,7 +116,7 @@ data, ideal for working with data with a "jagged" structure, i.e. many vectors of different lengths. ```python -stp = lh5.read_as("stp/det001", "stp_out.lh5", "ak") +stp = lh5.read_as("stp/det001", "stp_out.lh5", "ak", with_units=True) ``` ## Processors @@ -133,14 +133,13 @@ row of the output table). The only requirements are: -- the function should return an `LGDO.VectorOfVectors`, `LGDO.Array` or - `LGDO.ArrayOfEqualSizedArrays` - [documentation](https://legend-pydataobj.readthedocs.io/en/latest/api/lgdo.types.html) - object, or something able to be converted to this (awkward arrays for example), +- the function should return an {class}`awkward.Array` object, - the returned object should have the same length as the original stp table, i.e. the processors act on every row but they cannot add, remove or merge rows. +{ref}`More details (how to deal with physical units etc.) ` can be found in the manual. + ### Active energy One of the main steps in the post-processing of HPGe simulations consists of @@ -157,11 +156,11 @@ of the HPGe detector [documentation](https://reboost.readthedocs.io/en/stable/api/reboost.hpge.html#reboost-hpge-surface-module). ```python -dist_all = reboost.hpge.surface.distance_to_surface( +dist_all_in_mm = reboost.hpge.surface.distance_to_surface( stp.xloc * 1000, stp.yloc * 1000, stp.zloc * 1000, hpge_pyobj, position ).view_as("ak") -dist_nplus = reboost.hpge.surface.distance_to_surface( +dist_nplus_in_mm = reboost.hpge.surface.distance_to_surface( stp.xloc * 1000, stp.yloc * 1000, stp.zloc * 1000, @@ -186,11 +185,11 @@ r = rng.choice([-1, 1], p=[0.5, 0.5], size=len(r)) * r fig, ax = plt.subplots(figsize=(8, 4)) pygeomhpges.draw.plot_profile(hpge_pyobj, axes=ax, split_by_type=True) -cut = ak.flatten(dist_nplus) < 2 +cut = ak.flatten(dist_nplus_in_mm) < 2 s = ax.scatter( r[cut], z[cut], - c=ak.flatten(dist_nplus)[cut], + c=ak.flatten(dist_nplus_in_mm)[cut], marker=".", cmap="BuPu", ) @@ -229,7 +228,7 @@ fig, ax = plt.subplots(figsize=(8, 4)) ax.plot( np.linspace(0, 2, 1000), reboost.math.functions.piecewise_linear_activeness( - np.linspace(0, 2, 1000), fccd=1, dlf=0.2 + np.linspace(0, 2, 1000), fccd_in_mm=1, dlf=0.2 ), ) ax.set_xlabel("Distance to n-plus surface [mm]") @@ -249,7 +248,7 @@ We then plot the energy spectra: ```python activeness = reboost.math.functions.piecewise_linear_activeness( - dist_all, fccd=1, dlf=0.4 + dist_all_in_mm, fccd_in_mm=1, dlf=0.4 ) # compute the energy diff --git a/src/reboost/build_hit.py b/src/reboost/build_hit.py index c695fd35..17201bee 100644 --- a/src/reboost/build_hit.py +++ b/src/reboost/build_hit.py @@ -51,14 +51,15 @@ t0: ak.fill_none(ak.firsts(HITS.time, axis=-1), np.nan) - evtid: ak.fill_none(ak.firsts(HITS.__evtid, axis=-1), np.nan) + evtid: ak.fill_none(ak.firsts(HITS.evtid, axis=-1), np.nan) # distance to the nplus surface in mm distance_to_nplus_surface_mm: reboost.hpge.distance_to_surface( - HITS.__xloc, HITS.__yloc, HITS.__zloc, + HITS.xloc, HITS.yloc, HITS.zloc, DETECTOR_OBJECTS.pyobj, DETECTOR_OBJECTS.phyvol.position.eval(), - surface_type='nplus') + surface_type='nplus', + unit='m') # activness based on FCCD (no TL) activeness: ak.where( @@ -75,7 +76,7 @@ ) # summed energy of the hit accounting for activeness - energy_raw: ak.sum(HITS.__edep * HITS.activeness, axis=-1) + energy_raw: ak.sum(HITS.edep * HITS.activeness, axis=-1) # energy with smearing energy: reboost.math.sample_convolve( @@ -92,7 +93,7 @@ ) # example of low level reduction on clusters - energy_clustered: ak.sum(ak.unflatten(HITS.__edep, HITS.clusters_lengths), axis=-1) + energy_clustered: ak.sum(ak.unflatten(HITS.edep, HITS.clusters_lengths), axis=-1) # example of using a reboost helper steps_clustered: reboost.shape.reduction.energy_weighted_average(HITS, HITS.clusters_lengths) @@ -115,7 +116,7 @@ - num_scint_ph_lar operations: - tot_edep_wlsr: ak.sum(HITS.edep[np.abs(HITS.zloc) < 3000], axis=-1) + tot_edep_wlsr: ak.sum(HITS.edep[np.abs(HITS.zloc) < 3], axis=-1) - name: spms