Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
python.JetAnalysisCommon.Configured Class Reference
Collaboration diagram for python.JetAnalysisCommon.Configured:

Public Member Functions

def __init__ (self, name, **props)
 
def __setattr__ (self, k, v)
 
def getName (self)
 
def setparent (self, parent)
 
def prefixed (self, k)
 
def ancestors (self)
 
def fullname (self)
 
def properties (self)
 
def typeAndName (self)
 
def asAnaAlg (self)
 
def assignAllProperties (self, anaAlg)
 
def setPropToAnaAlg (self, k, v)
 
def getType (self)
 

Private Member Functions

def _setattrImpl (self, k, v)
 

Private Attributes

 _name
 

Static Private Attributes

 _properties = set()
 
 _parent = None
 
 _anaAlg = None
 
list _allowed = ['_properties', '_name', '_parent', '_anaAlg']
 

Detailed Description

A replacement for Athena auto-generated Configured python class.
Configured has the same interface as its Athena counterpart and can describe both Tools and Algorithms

This is a base class. The system replacing CompFactory will generate a derived class for each c++ Tool/Algorithm
to hold the configuration of such tool/alg  (see generateConfigured())

Definition at line 87 of file JetAnalysisCommon.py.

Constructor & Destructor Documentation

◆ __init__()

def python.JetAnalysisCommon.Configured.__init__ (   self,
  name,
**  props 
)

Definition at line 101 of file JetAnalysisCommon.py.

101  def __init__(self, name, **props):
102  self._name = name
103  self._properties = set()
104  for k,v in props.items():
105  setattr(self,k,v)
106 

Member Function Documentation

◆ __setattr__()

def python.JetAnalysisCommon.Configured.__setattr__ (   self,
  k,
  v 
)

Definition at line 107 of file JetAnalysisCommon.py.

107  def __setattr__(self, k, v):
108  if k in self._allowed:
109  self._setattrImpl(k,v)
110  else:
111  raise AttributeError("Configuration of Tool {} / {} . can't set attribute : {}".format(self.type, self._name, k) )
112 

◆ _setattrImpl()

def python.JetAnalysisCommon.Configured._setattrImpl (   self,
  k,
  v 
)
private

Definition at line 113 of file JetAnalysisCommon.py.

113  def _setattrImpl(self, k, v) :
114  super().__setattr__(k,v)
115  if k[0] == '_' :
116  # this is not a Property
117  return
118 
119  if isinstance(v, Configured):
120  if k in self._properties:
121  raise RuntimeError( "Configuring {} / {} : Tool for property {} already exists".format(self.type, self._name, k) )
122  # it's a tool:
123  v.setparent(self)
124  v._name = k
125  elif isinstance(v, (list, tuple) ):
126  if isinstance(v[0], Configured):
127  v = ConfArray(k,v, self)
128  super().__setattr__(k,v)
129  self._properties.add(k)
130  if self._anaAlg:
131  self.setPropToAnaAlg( k , v)
132 
133 

◆ ancestors()

def python.JetAnalysisCommon.Configured.ancestors (   self)

Definition at line 144 of file JetAnalysisCommon.py.

144  def ancestors(self):
145  if self._parent is None : return [self]
146  return self._parent.ancestors()+[self]
147 

◆ asAnaAlg()

def python.JetAnalysisCommon.Configured.asAnaAlg (   self)

Definition at line 158 of file JetAnalysisCommon.py.

158  def asAnaAlg(self):
159  if issubclass(self._cppclass, ROOT.EL.AnaReentrantAlgorithm):
160  alg=ROOT.EL.AnaReentrantAlgorithmConfig()
161  else:
162  alg=ROOT.EL.AnaAlgorithmConfig()
163 
164  alg.setTypeAndName( self.typeAndName() )
165  self.assignAllProperties(alg)
166  return alg
167 

◆ assignAllProperties()

def python.JetAnalysisCommon.Configured.assignAllProperties (   self,
  anaAlg 
)

Definition at line 168 of file JetAnalysisCommon.py.

168  def assignAllProperties(self, anaAlg):
169  self._anaAlg = anaAlg
170  for (k,v) in self.properties():
171  self.setPropToAnaAlg(k,v)
172 

◆ fullname()

def python.JetAnalysisCommon.Configured.fullname (   self)

Definition at line 148 of file JetAnalysisCommon.py.

148  def fullname(self):
149  parents = self.ancestors()[1:]
150  return '.'.join([p._name for p in parents])
151 

◆ getName()

def python.JetAnalysisCommon.Configured.getName (   self)

Definition at line 134 of file JetAnalysisCommon.py.

134  def getName(self):
135  return self._name
136 

◆ getType()

def python.JetAnalysisCommon.Configured.getType (   self)

Definition at line 186 of file JetAnalysisCommon.py.

186  def getType(self):
187  return self.type
188 

◆ prefixed()

def python.JetAnalysisCommon.Configured.prefixed (   self,
  k 
)

Definition at line 140 of file JetAnalysisCommon.py.

140  def prefixed(self, k):
141  if self._parent is None: return k
142  return self.fullname()+'.'+k
143 

◆ properties()

def python.JetAnalysisCommon.Configured.properties (   self)

Definition at line 152 of file JetAnalysisCommon.py.

152  def properties(self):
153  return [ (k, getattr(self,k)) for k in self._properties]
154 

◆ setparent()

def python.JetAnalysisCommon.Configured.setparent (   self,
  parent 
)

Definition at line 137 of file JetAnalysisCommon.py.

137  def setparent(self, parent):
138  self._parent = parent
139 

◆ setPropToAnaAlg()

def python.JetAnalysisCommon.Configured.setPropToAnaAlg (   self,
  k,
  v 
)

Definition at line 173 of file JetAnalysisCommon.py.

173  def setPropToAnaAlg(self, k, v):
174  alg=self._anaAlg
175  if isinstance(v , Configured):
176  # it must be a Tool :
177  alg.createPrivateTool(v.fullname(), v.type)
178  v.assignAllProperties(alg)
179  elif isinstance(v, ConfArray ):
180  # it is a Tool array
181  v.assignAllProperties(alg)
182  else:
183  # any other type :
184  alg.setPropertyFromString(self.prefixed(k) , stringPropValue( v ) )
185 

◆ typeAndName()

def python.JetAnalysisCommon.Configured.typeAndName (   self)

Definition at line 155 of file JetAnalysisCommon.py.

155  def typeAndName(self):
156  return self.type+'/'+self._name
157 

Member Data Documentation

◆ _allowed

list python.JetAnalysisCommon.Configured._allowed = ['_properties', '_name', '_parent', '_anaAlg']
staticprivate

Definition at line 99 of file JetAnalysisCommon.py.

◆ _anaAlg

python.JetAnalysisCommon.Configured._anaAlg = None
staticprivate

Definition at line 96 of file JetAnalysisCommon.py.

◆ _name

python.JetAnalysisCommon.Configured._name
private

Definition at line 102 of file JetAnalysisCommon.py.

◆ _parent

python.JetAnalysisCommon.Configured._parent = None
staticprivate

Definition at line 95 of file JetAnalysisCommon.py.

◆ _properties

python.JetAnalysisCommon.Configured._properties = set()
staticprivate

Definition at line 94 of file JetAnalysisCommon.py.


The documentation for this class was generated from the following file:
vtune_athena.format
format
Definition: vtune_athena.py:14
python.TestDriveDummies.properties
dictionary properties
Definition: TestDriveDummies.py:14
dumpTruth.getName
getName
Definition: dumpTruth.py:34
python.JetAnalysisCommon.stringPropValue
def stringPropValue(value)
Definition: JetAnalysisCommon.py:50
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
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
python.PyAthenaComps.__setattr__
__setattr__
Definition: PyAthenaComps.py:39
Ringer::getType
T getType(const char *cStr)
Return Ringer enumeration of type T identifying string type: