e15190.neutron_wall.geometry.Wall¶
- class e15190.neutron_wall.geometry.Wall(AB, contain_pyrex=False, refresh_from_inventor_readings=False)¶
Functions
__init__(AB[, contain_pyrex, ...])Construct a neutron wall, A or B.
get_geometry_efficiency(shadowed_bars, skip_bars)A simple wrapper around
_get_geometry_efficiency_from_cpp_executable().read_from_inventor_readings(filepath)Reads in Inventor measurements and returns a list of
Barobjects.save_pca_to_database(AB, filepath, bars)Save the principal components of the bars to database.
save_vertices_to_database(AB, filepath, bars)Saves the vertices of the bars to database.
Properties
Neutron wall name in uppercase.
Neutron wall name in lowercase.
'$PROJECT_DIR/database/neutron_wall/geometry'self.database_dir / f'inventor_readings_NW{self.AB}.txt'self.database_dir / f'NW{self.AB}_vertices.dat'self.database_dir / f'NW{self.AB}_pca.dat'Dataframe of vertices from all bars
A collection of
Barobjects.- __init__(AB, contain_pyrex=False, refresh_from_inventor_readings=False)¶
Construct a neutron wall, A or B.
A neutron wall is a collection of bars,
self.bars.- Parameters
AB ('A' or 'B') – The wall to construct. Currently only ‘B’ is actively maintained and tested.
contain_pyrex (bool, default False) – Whether the bars contain pyrex.
refresh_from_inventor_readings (bool, default False) – If True, the geometry will be loaded from the inventor readings; if False, the geometry will be loaded from the existing database, stored in
*.datfiles.
- AB¶
Neutron wall name in uppercase.
- Type
‘A’ or ‘B’
- ab¶
Neutron wall name in lowercase.
- Type
‘a’ or ‘b’
- database_dir¶
'$PROJECT_DIR/database/neutron_wall/geometry'- Type
pathlib.Path
- path_inventor_readings¶
self.database_dir / f'inventor_readings_NW{self.AB}.txt'- Type
pathlib.Path
- path_vertices¶
self.database_dir / f'NW{self.AB}_vertices.dat'- Type
pathlib.Path
- path_pca¶
self.database_dir / f'NW{self.AB}_pca.dat'- Type
pathlib.Path
- database¶
Dataframe of vertices from all bars
- Type
pandas.DataFrame
- bars¶
A collection of
Barobjects.The bottommost is bar 0, the topmost is bar 24. In the experiment, bar 0 was not used because it was shadowed.
- Type
dict[int, Bar]
- static read_from_inventor_readings(filepath)¶
Reads in Inventor measurements and returns a list of
Barobjects.- Parameters
filepath (str or pathlib.Path) – The path to the file containing the Inventor measurements, e.g.
self.path_inventor_readings.- Returns
bars – A list of
Barobjects, sorted from bottom to top.- Return type
list
- static save_vertices_to_database(AB, filepath, bars)¶
Saves the vertices of the bars to database.
- Parameters
AB ('A' or 'B') – Neutron wall A or B.
filepath (str or pathlib.Path) – Path to the database file, e.g.
self.path_vertices.bars (list of
Barobjects) – Sorted from bottom to top. The bottommost bar will be numbered 0; the topmost bar will be numbered 24.
- static save_pca_to_database(AB, filepath, bars)¶
Save the principal components of the bars to database.
- Parameters
AB (str) – Neutron wall A or B.
filepath (str or pathlib.Path) – Path to the database file, e.g.
self.path_pca.bars (list of Bar objects) – Sorted from bottom to top. The bottommost bar will be numbered 0; the topmost bar will be numbered 24.
- get_geometry_efficiency(shadowed_bars: bool, skip_bars: list[int], cut_edges=True, custom_cuts: Optional[dict[int, list[str]]] = None, method: Literal['monte-carlo', 'delta-phi'] = 'delta-phi', n_rays=1000000, n_steps=30) Callable[[float | np.ndarray], float | np.ndarray]¶
A simple wrapper around
_get_geometry_efficiency_from_cpp_executable(). The function has a persistent cache saved to $PROJECT_DIR/database/neutron_wall/geometry/efficiency_cache.pkl. Simply remove the file if you do not want to use the cached results.First time calling this function will take a while. Subsequent calls with the exact same arguments will be much faster due to caching.
- Parameters
shadowed_bars (bool) – If True, shadow bar cut will be applied to NWB bars 7, 8, 9, 10, 15, 16, 17. If False, no shadow bar cut is applied.
skip_bars (list of int) – Bars to be skipped. Remember, in the experiment, NWB-bar00 is the bottommost bar that was blocked by the ground.
cut_edges (bool, default True) – If
'all', edge cut will be applied to all bars. If a list of int, edge cut will only be applied to the bars in the list.custom_cuts (dict of int to list of str, default None) – When custom cuts are applied, all the other cuts are ignored, so users should make sure the cuts are complete, e.g. edge cut has to be included. The only cut variable being supported is
'x'.method ('monte-carlo' or 'delta-phi', default 'delta-phi') – Method to calculate the geometry efficiency.
n_rays (int, default 1_000_000) – Number of rays to be used in the Monte Carlo method. This argument is ignored if method is not ‘monte-carlo’.
n_steps (int, default 30) – Number of steps to be used in the delta-phi method. This argument is ignored if method is not ‘delta-phi’.
- Returns
geometry_efficiency – A function that takes a theta (radian) and returns the geometry efficiency.
- Return type
Callable[[float | np.ndarray], float | np.ndarray]