ATLAS Offline Software
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 toToolInAnaAlg (self, anaAlg, handlename)
 
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()
 
dictionary _propTypes = {}
 
 _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 103 of file JetAnalysisCommon.py.

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

Member Function Documentation

◆ __setattr__()

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

Definition at line 110 of file JetAnalysisCommon.py.

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

◆ _setattrImpl()

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

Definition at line 116 of file JetAnalysisCommon.py.

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

◆ ancestors()

def python.JetAnalysisCommon.Configured.ancestors (   self)

Definition at line 147 of file JetAnalysisCommon.py.

147  def ancestors(self):
148  if self._parent is None : return [self]
149  return self._parent.ancestors()+[self]
150 

◆ asAnaAlg()

def python.JetAnalysisCommon.Configured.asAnaAlg (   self)
Returns this configured alg as an instance of Ana(Reentrant)AlgorithmConfig       


Definition at line 162 of file JetAnalysisCommon.py.

162  def asAnaAlg(self):
163  """Returns this configured alg as an instance of Ana(Reentrant)AlgorithmConfig
164  """
165  if issubclass(self._cppclass, ROOT.EL.AnaReentrantAlgorithm):
166  alg=ROOT.EL.AnaReentrantAlgorithmConfig()
167  else:
168  alg=ROOT.EL.AnaAlgorithmConfig()
169 
170  alg.setTypeAndName( self.typeAndName() )
171  self.assignAllProperties(alg)
172  return alg
173 
174 

◆ assignAllProperties()

def python.JetAnalysisCommon.Configured.assignAllProperties (   self,
  anaAlg 
)
Transfer all the configuration in self to anaAlg
where anaAlg is an AnaAlgorithmConfig.

Definition at line 187 of file JetAnalysisCommon.py.

187  def assignAllProperties(self, anaAlg):
188  """ Transfer all the configuration in self to anaAlg
189  where anaAlg is an AnaAlgorithmConfig."""
190  self._anaAlg = anaAlg
191  for (k,v) in self.properties():
192  self.setPropToAnaAlg(k,v)
193 

◆ fullname()

def python.JetAnalysisCommon.Configured.fullname (   self)

Definition at line 151 of file JetAnalysisCommon.py.

151  def fullname(self):
152  parents = self.ancestors()[1:]
153  return '.'.join([p._name for p in parents])
154 

◆ getName()

def python.JetAnalysisCommon.Configured.getName (   self)

Definition at line 137 of file JetAnalysisCommon.py.

137  def getName(self):
138  return self._name
139 

◆ getType()

def python.JetAnalysisCommon.Configured.getType (   self)

Definition at line 208 of file JetAnalysisCommon.py.

208  def getType(self):
209  return self.type
210 

◆ prefixed()

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

Definition at line 143 of file JetAnalysisCommon.py.

143  def prefixed(self, k):
144  if self._parent is None: return k
145  return self.fullname()+'.'+k
146 

◆ properties()

def python.JetAnalysisCommon.Configured.properties (   self)

Definition at line 155 of file JetAnalysisCommon.py.

155  def properties(self):
156  return [ (k, getattr(self,k)) for k in self._properties]
157 

◆ setparent()

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

Definition at line 140 of file JetAnalysisCommon.py.

140  def setparent(self, parent):
141  self._parent = parent
142 

◆ setPropToAnaAlg()

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

Definition at line 194 of file JetAnalysisCommon.py.

194  def setPropToAnaAlg(self, k, v):
195  alg=self._anaAlg
196  if isinstance(v , Configured):
197  # it must be a Tool :
198  alg.addPrivateTool(v.fullname(), v.type)
199  v.assignAllProperties(alg)
200  elif isinstance(v, ConfArray ):
201  # it is a Tool array
202  v.assignAllProperties(alg)
203  else:
204  # any other type :
205  cpptype = self._propTypes[k]
206  alg.setProperty[cpptype](self.prefixed(k) , v)
207 

◆ toToolInAnaAlg()

def python.JetAnalysisCommon.Configured.toToolInAnaAlg (   self,
  anaAlg,
  handlename 
)
If self represents a configured AlgTool,
this call will configure the AnaAlgorithmConfig 'anaAlg' so
its ToolHandle property 'handlename' is configured with self

Definition at line 175 of file JetAnalysisCommon.py.

175  def toToolInAnaAlg(self, anaAlg, handlename):
176  """If self represents a configured AlgTool,
177  this call will configure the AnaAlgorithmConfig 'anaAlg' so
178  its ToolHandle property 'handlename' is configured with self
179  """
180  props = {handlename:self, }
181  klass=type('TmpConf', (Configured,), dict(_allowed=self._allowed+[handlename], _propTypes={},
182  type=anaAlg.getType(),_cppclass='none') )
183 
184  c=klass(anaAlg.name(), **props)
185  c.assignAllProperties(anaAlg)
186 

◆ typeAndName()

def python.JetAnalysisCommon.Configured.typeAndName (   self)

Definition at line 158 of file JetAnalysisCommon.py.

158  def typeAndName(self):
159  return self.type+'/'+self._name
160 
161 

Member Data Documentation

◆ _allowed

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

Definition at line 101 of file JetAnalysisCommon.py.

◆ _anaAlg

python.JetAnalysisCommon.Configured._anaAlg = None
staticprivate

Definition at line 98 of file JetAnalysisCommon.py.

◆ _name

python.JetAnalysisCommon.Configured._name
private

Definition at line 105 of file JetAnalysisCommon.py.

◆ _parent

python.JetAnalysisCommon.Configured._parent = None
staticprivate

Definition at line 97 of file JetAnalysisCommon.py.

◆ _properties

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

Definition at line 95 of file JetAnalysisCommon.py.

◆ _propTypes

dictionary python.JetAnalysisCommon.Configured._propTypes = {}
staticprivate

Definition at line 96 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
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
dumpTruth.getName
getName
Definition: dumpTruth.py:34
klass
This class describe the base functionalities of a HypoTool used by the ComboAlg.
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.PyAthenaComps.__setattr__
__setattr__
Definition: PyAthenaComps.py:39
Ringer::getType
T getType(const char *cStr)
Return Ringer enumeration of type T identifying string type: