e15190.neutron_wall.spectra.LabKinergyTheta¶
- class e15190.neutron_wall.spectra.LabKinergyTheta(runs: list[int])¶
Functions
__init__(runs)build_rdataframe([tree_name, implicit_mt, ...])Build the RDataFrame and store it as
self.rdf.define_energy([name, rdf, inplace])Define the total relativistic energy of the neutron.
define_neutron_cut([name, light_bias, ...])Define the neutron cut,
cut.filter_charged_particles([rdf, inplace])Veto charged particles.
filter_microball_multiplicity([bhat_range, ...])Filter the RDataFrame by microball multiplicity.
filter_tdc(tdc_range[, tdc_branch_name, ...])Filter the RDataFrame by TDC.
get_coincidence_peak([branch_name, rdf, ...])Get the coincidence peak of the TDC.
get_spectrum(theta_deg_range[, range, bins])Get the lab kinetic energy spectrum at a given theta range.
Properties
ROOT_FILE_DIR- __init__(runs: list[int])¶
- get_spectrum(theta_deg_range: tuple[float, float], range=(0.0, 300.0), bins=300) pandas.core.frame.DataFrame¶
Get the lab kinetic energy spectrum at a given theta range.
Returns a histogram represented by a DataFrame with columns: x, y, yerr, yferr.
- Parameters
theta_deg_range (tuple[float, float]) – The theta range in degrees.
range (tuple[float, float], default (0.0, 300.0)) – The (kinetic) energy range in MeV.
bins (int, default 300) – The number of bins.
- Returns
spectrum – DataFrame with columns ‘x’, ‘y’, ‘yerr’ and ‘yferr’.
- Return type
pandas.DataFrame
- static _drop_spectrum_outliers(df: pandas.core.frame.DataFrame, drop_outliers: float, yname='y') pandas.core.frame.DataFrame¶
Drop outliers in the dataframe.
This function assumes outliers only occur at the ends of the spectrum. In other words, if a point in the middle is an outlier, it will not be dropped. This decision is made to keep the resulting spectrum continuous. Empirically, for this purpose, if an outlier happens in the middle, it is likely that there is some problem with the data anyway.
- Parameters
df (pandas.DataFrame) – The dataframe to drop outliers from. Must have a column named defined by yname.
drop_outliers (float) – Outliers are defined as points whose ratio to the neighboring point is larger than drop_outliers.
yname (str, default 'y') – The name of the column in df that contains the values to check for outliers.
- Returns
df – The dataframe with outliers dropped.
- Return type
pandas.DataFrame
- static _infer_reaction(runs: list[int]) dict[Literal['target', 'beam', 'beam_energy'], str | float]¶
Infer the reaction from the runs.
- Parameters
runs (list[int]) – A list of runs.
- Returns
reaction – A dictionary containing the reaction information.
- Return type
dict[Literal[‘target’, ‘beam’, ‘beam_energy’], str | float]
- Raises
ValueError – If the runs are not from the same reaction.
- static _infer_shadow_bar_present(runs: list[int]) bool¶
Infer whether the shadow bar is present.
- Parameters
runs (list[int]) – A list of runs.
- Returns
presence – True if the shadow bar is present for all runs, False otherwise.
- Return type
bool
- Raises
ValueError – If the runs have different shadow bar presence.
- build_rdataframe(tree_name: Optional[str] = None, implicit_mt=True, inplace=False) cppyy.gbl.ROOT.RDataFrame¶
Build the RDataFrame and store it as
self.rdf.- Parameters
tree_name (str, optional) – Name of the tree, by default None. If None, the tree name will be inferred from the root file paths.
implicit_mt (bool, default True) – Whether to enable implicit multi-threading.
inplace (bool, default False) – Whether to build the RDataFrame in place.
- define_energy(name='energy', rdf: Optional[cppyy.gbl.ROOT.RDataFrame] = None, inplace=False) Optional[cppyy.gbl.ROOT.RDataFrame]¶
Define the total relativistic energy of the neutron.
This function will define a new column
energyin the RDataFrame. It first computes the relativistic beta using time-of-flight and distance between the target and the hit position on NWB. Then it calculates the total energy assuming a mass of neutron. If charged particles and gamma rays have not been excluded, the energies for those hits will be off because they are not neutrons.- Parameters
name (str, default 'energy') – Name of the new column. The values will be in MeV.
rdf (ROOT.RDataFrame, optional) – The RDataFrame to be filtered. If None, the RDataFrame stored in
self.rdfwill be used.inplace (bool, default False) – Whether to apply the definition in place.
- Returns
rdf – The RDataFrame with the new column. If
inplace=True, returns None.- Return type
ROOT.RDataFrame or None
- define_neutron_cut(name='cut', light_bias=3.0, position_cut=True, positive_adc_cut=True, extra_cuts: Optional[list[str]] = None, rdf: Optional[cppyy.gbl.ROOT.RDataFrame] = None, inplace=False) Optional[cppyy.gbl.ROOT.RDataFrame]¶
Define the neutron cut,
cut.- Parameters
name (str, default 'cut') – Name of the new column.
light_bias (float, default 3.0) – The light output bias in MeVee.
position_cut (bool, default True) – Whether to apply the position cut. Shadow bar cuts are applied automatically if shadow bars are present in those runs. See
self.shadow_bar_present.positive_adc_cut (bool, default True) – Whether to apply the positive ADC cut. If
True, all the fast and total ADCs must be positive.extra_cuts (list[str], optional) – Extra cuts to be applied. Each cut should be a string that can be parsed by PyROOT. Any columns that are defined in the RDF can be used in the cut. The cuts will be joined by
&&.rdf (ROOT.RDataFrame, optional) – The RDataFrame to be filtered. If None, the RDataFrame stored in
inplace (bool, default False) – Whether to apply the cut in place.
- filter_charged_particles(rdf: Optional[cppyy.gbl.ROOT.RDataFrame] = None, inplace=False) Optional[cppyy.gbl.ROOT.RDataFrame]¶
Veto charged particles.
This function will filter out charged particles by requiring the multiplicity of veto wall to be 0.
- Parameters
rdf (ROOT.RDataFrame, optional) – The RDataFrame to be filtered. If None, the RDataFrame stored in
self.rdfwill be used.inplace (bool, default False) – Whether to apply the filter in place.
- Returns
rdf – The filtered RDataFrame. If
inplace=True, returns None.- Return type
ROOT.RDataFrame or None
- filter_microball_multiplicity(bhat_range: Optional[tuple[float, float]] = None, multi_range: Optional[tuple[int, int]] = None, inplace=False) Optional[cppyy.gbl.ROOT.RDataFrame]¶
Filter the RDataFrame by microball multiplicity.
- Parameters
bhat_range (tuple[float, float], optional) – The range of normalized impact parameter, e.g. (0.0, 0.4). If this is not provided,
multi_rangemust be provided.multi_range (tuple[int, int], optional) – The inclusive range of microball multiplicity, e.g. (14, 30). If
bhat_rangeis provided, this will be ignored.inplace (bool, default False) – Whether to apply the filter in place.
- Returns
rdf – The filtered RDataFrame. If
inplace=True, returns None.- Return type
ROOT.RDataFrame or None
- filter_tdc(tdc_range: tuple[float, float], tdc_branch_name='TDC_mb_nw', rdf: Optional[cppyy.gbl.ROOT.RDataFrame] = None, inplace=False) Optional[cppyy.gbl.ROOT.RDataFrame]¶
Filter the RDataFrame by TDC.
- Parameters
tdc_range (tuple[float, float]) – The range of TDC.
rdf (ROOT.RDataFrame, optional) – The RDataFrame to be filtered. If None, the RDataFrame stored in
self.rdfwill be used.inplace (bool, default False) – Whether to apply the filter in place.
- Returns
rdf – The filtered RDataFrame. If
inplace=True, returns None.- Return type
ROOT.RDataFrame or None
- get_coincidence_peak(branch_name='TDC_mb_nw', rdf: Optional[ROOT.RDataFrame] = None, return_histogram=False) dict[Literal['mean', 'stdev'], float] | ROOT.TH1¶
Get the coincidence peak of the TDC.
You may want to apply the microball multiplicity filter before calling this function.