e15190.hira.spectra.HiraFile¶
- class e15190.hira.spectra.HiraFile(reaction: str)¶
Functions
__init__(reaction)Create a file object to interact with ROOT files produced by Rensheng that contains HiRA spectra.
convert_particle(notation)Convert particle notation into Rensheng's convention.
get_all_histogram_names([particle])Return a list of all histogram names in the file.
Return a list of all particles symbols in the file.
get_root_histogram([h_name, particle, ...])Return a ROOT histogram object.
Properties
DIRECTORY- __init__(reaction: str)¶
Create a file object to interact with ROOT files produced by Rensheng that contains HiRA spectra.
- Parameters
reaction (str) – Reaction notation, e.g. “ca40ni58e140”. Some intellisense has been implemented in
e15190.runlog.query.ReactionParserto automatically convert the reaction notation into the correct format.
- get_all_particles() list[str]¶
Return a list of all particles symbols in the file.
- convert_particle(notation: str) str¶
Convert particle notation into Rensheng’s convention.
The ROOT file contains spectra for multiple particles. This function converts user’s particle notation into the one that is used to named to spectra in the ROOT file.
- Parameters
notation (str) – Particle notation, e.g. “H1”, “He4”.
- Returns
converted – Converted particle notation.
- Return type
str
:raises KeyError : If the particle is not found in the file.:
Example
>>> file = HiraFile('ca48ni64e140') >>> file.convert_particle('H1') 'p'
- get_all_histogram_names(particle=None) list[str]¶
Return a list of all histogram names in the file.
- Parameters
particle (str, default None) – If None, return all histogram names. Otherwise, return only histogram names for the specified particle. The particle notation has some intellisense implemented.
- Returns
histogram_names – List of histogram names.
- Return type
list[str]
- get_root_histogram(h_name: Optional[str] = None, particle: Optional[str] = None, keyword: Optional[Union[str, list[str]]] = None, ignore_multiple_matches: bool = False) cppyy.gbl.TH2D¶
Return a ROOT histogram object.
Provide either the exact histogram name, or a particle with one or more keywords, to specify the histogram.
- Parameters
h_name (str, default None) – Histogram name. If None, the histogram name will be inferred from the particle and keyword(s). If specified, the particle and keyword(s) will be ignored.
particle (str, default None) – Particle notation, e.g. “H1”, “He4”. Intellisense implemented. Keyword(s) must be provided too if this is specified.
keyword (str or list[str], default None) – Keyword(s) to search for in the histogram name.
ignore_multiple_matches (bool, default False) – If True, ignore the case where multiple histograms are found with the same keyword(s); only the one with the longest matching name will be returned. If False, raise an error if multiple histograms are found with the same keyword(s).
- Returns
hist – ROOT’s 2D histogram object.
- Return type
ROOT.TH2D
:raises KeyError : No histogram found for …: :raises KeyError : Multiple histograms found for …: