12Functions related to building or using the simulation/reconstruction geometry
18ALLOWED_COMPONENTS = [
'PXD',
'SVD',
'CDC',
'ECL',
'TOP',
'ARICH',
'KLM',
'TRG']
21def check_components(components):
23 Check list of geometry components. This function is used by the standard
24 scripts, for example `simulation.add_simulation()`. Thus, only the detector
25 components corresponding to subdetectors are allowed. In addition, TRG is
26 included. Trigger is not a geometry component, but it is used as an
27 additional component in raw-data and DQM scripts.
29 If there is a unsupported component in the list the function will raise a
30 FATAL error and is guaranteed to not return.
33 components (list(str)): List of geometry components.
36 if components
is None:
38 for component
in components:
39 if not (component
in ALLOWED_COMPONENTS):
40 basf2.B2FATAL(f
'Geometry component {component} is unknown or it cannot be used in standard scripts.')
43def is_detector_present(component: str, components: list[str] |
None =
None) -> bool:
45 Check whether a detector component is contained in the list of components AND if it is an allowed component,
46 or if components is None.
48 Returns True, if components is None, or if the component is contained in the list of components and if the component is allowed,
52 :param component (str): Detector componet
53 :param components (list(str)): List of geometry components present in the current setting.
54 :returns Bool indicating whether the detector component is contained and valid.
55 Returning True if the components list is None.
58 if (components
is None)
or ((component
in components)
and (component
in ALLOWED_COMPONENTS)):
64def are_detectors_present(components_to_check: list[str], components: list[str] |
None =
None) -> bool:
66 Check whether all detectors in the list "components_to_check" are present in the list of components,
67 or if components is None.
69 Returns True if all detector components in "components_to_check are contained in components, else, returns False.
72 :param components_to_check (list(str)): List of detector componets to be checked
73 :param components (list(str)): List of geometry components present in the current setting.
74 :returns Bool indicating whether all the detectors are contained
77 if components
is None:
80 for component
in components_to_check:
81 if not is_detector_present(component, components):
87def is_any_detector_present(components_to_check: list[str], components: list[str] |
None =
None) -> bool:
89 Check whether any detector in the list "components_to_check" is present in the list of components,
90 or if components is None.
92 Returns True if any detector components in "components_to_check is contained in components, else, returns False.
95 :param components_to_check (list(str)): List of detector componets to be checked
96 :param components (list(str)): List of geometry components present in the current setting.
97 :returns Bool indicating whether all the detectors are contained
100 if components
is None:
103 for component
in components_to_check:
104 if is_detector_present(component, components):