ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.detector_hierarchy.DetectorHierarchy Class Reference
Inheritance diagram for python.detector_hierarchy.DetectorHierarchy:
Collaboration diagram for python.detector_hierarchy.DetectorHierarchy:

Public Member Functions

def __init__ (self, hierarchy, depth=0, parent=None)
 
def get_channels (self, name, selected=False, parts=())
 
def __repr__ (self)
 

Public Attributes

 depth
 
 parent
 
 sub_hierarchy
 
 max_sub_width
 
 name
 

Detailed Description

Definition at line 51 of file detector_hierarchy.py.

Constructor & Destructor Documentation

◆ __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):
53  """
54  Create a DetectorHierarchy object
55  """
56 
57  self.depth = depth
58  self.parent = parent
59 
60  if isinstance(hierarchy, str):
61  self.name, sub_hierarchy = hierarchy, []
62  else:
63  self.name, sub_hierarchy = hierarchy
64 
65  self.sub_hierarchy = [DetectorHierarchy(sub_part, depth+1, self)
66  for sub_part in sub_hierarchy]
67 
68  if self.sub_hierarchy:
69  self.max_sub_width = max(len(x.name) for x in self.sub_hierarchy)
70  else:
71  self.max_sub_width = 7
72 

Member Function Documentation

◆ __repr__()

def python.detector_hierarchy.DetectorHierarchy.__repr__ (   self)
String representation of the hierarchy

Definition at line 89 of file detector_hierarchy.py.

89  def __repr__(self):
90  """
91  String representation of the hierarchy
92  """
93  sub_part = ()
94  if self.sub_hierarchy:
95  jstr = "\n"
96  indent = "\n"
97  if self.depth == 2:
98  jstr = " "
99  indent = " : "
100  sub_part = indent, jstr.join(repr(x) for x in self.sub_hierarchy)
101 
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)
105 
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=()):
74  """
75  Accumulate the lowest parts of the hierarchy which contain "name"
76  """
77  if self.name == name:
78  selected = True
79 
80  if not self.sub_hierarchy:
81  return [(self.name, parts)] if selected else []
82 
83  result = []
84  for sub_part in self.sub_hierarchy:
85  breadcrumbs = parts + (self.name,)
86  result.extend(sub_part.get_channels(name, selected, breadcrumbs))
87  return result
88 

Member Data Documentation

◆ depth

python.detector_hierarchy.DetectorHierarchy.depth

Definition at line 57 of file detector_hierarchy.py.

◆ max_sub_width

python.detector_hierarchy.DetectorHierarchy.max_sub_width

Definition at line 69 of file detector_hierarchy.py.

◆ name

python.detector_hierarchy.DetectorHierarchy.name

Definition at line 77 of file detector_hierarchy.py.

◆ parent

python.detector_hierarchy.DetectorHierarchy.parent

Definition at line 58 of file detector_hierarchy.py.

◆ sub_hierarchy

python.detector_hierarchy.DetectorHierarchy.sub_hierarchy

Definition at line 65 of file detector_hierarchy.py.


The documentation for this class was generated from the following file:
max
#define max(a, b)
Definition: cfImp.cxx:41
PyAthena::repr
std::string repr(PyObject *o)
returns the string representation of a python object equivalent of calling repr(o) in python
Definition: PyAthenaUtils.cxx:106
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18