Definition at line 51 of file detector_hierarchy.py.
◆ __init__()
def python.detector_hierarchy.DetectorHierarchy.__init__ |
( |
|
self, |
|
|
|
hierarchy, |
|
|
|
depth = 0 , |
|
|
|
parent = None |
|
) |
| |
Create a DetectorHierarchy object
Definition at line 52 of file detector_hierarchy.py.
52 def __init__(self, hierarchy, depth=0, parent=None):
54 Create a DetectorHierarchy object
60 if isinstance(hierarchy, str):
61 self.name, sub_hierarchy = hierarchy, []
63 self.name, sub_hierarchy = hierarchy
65 self.sub_hierarchy = [DetectorHierarchy(sub_part, depth+1, self)
66 for sub_part
in sub_hierarchy]
68 if self.sub_hierarchy:
69 self.max_sub_width =
max(len(x.name)
for x
in self.sub_hierarchy)
71 self.max_sub_width = 7
◆ __repr__()
def python.detector_hierarchy.DetectorHierarchy.__repr__ |
( |
|
self | ) |
|
String representation of the hierarchy
Definition at line 89 of file detector_hierarchy.py.
91 String representation of the hierarchy
94 if self.sub_hierarchy:
100 sub_part = indent, jstr.join(
repr(x)
for x
in self.sub_hierarchy)
102 width = self.parent.max_sub_width
if self.parent
else len(self.name)
103 indent =
" "*self.depth
if self.depth < 3
else ""
104 name = self.name.ljust(width)
106 return "".
join((indent, name) + sub_part)
◆ get_channels()
def python.detector_hierarchy.DetectorHierarchy.get_channels |
( |
|
self, |
|
|
|
name, |
|
|
|
selected = False , |
|
|
|
parts = () |
|
) |
| |
Accumulate the lowest parts of the hierarchy which contain "name"
Definition at line 73 of file detector_hierarchy.py.
73 def get_channels(self, name, selected=False, parts=()):
75 Accumulate the lowest parts of the hierarchy which contain "name"
80 if not self.sub_hierarchy:
81 return [(self.name, parts)]
if selected
else []
84 for sub_part
in self.sub_hierarchy:
85 breadcrumbs = parts + (self.name,)
86 result.extend(sub_part.get_channels(name, selected, breadcrumbs))
◆ depth
python.detector_hierarchy.DetectorHierarchy.depth |
◆ max_sub_width
python.detector_hierarchy.DetectorHierarchy.max_sub_width |
◆ name
python.detector_hierarchy.DetectorHierarchy.name |
◆ parent
python.detector_hierarchy.DetectorHierarchy.parent |
◆ sub_hierarchy
python.detector_hierarchy.DetectorHierarchy.sub_hierarchy |
The documentation for this class was generated from the following file: