ATLAS Offline Software
Loading...
Searching...
No Matches
python.AlgSequence.AlgSequence Class Reference
Inheritance diagram for python.AlgSequence.AlgSequence:
Collaboration diagram for python.AlgSequence.AlgSequence:

Public Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

 __init__ (self, name="AlgSequence")
 name (self)
 insert (self, index, algOrSeq)
 addSelfToJob (self, job)
 __getitem__ (self, index)
 __getattr__ (self, name)
 __delattr__ (self, name)
 __iter__ (self)
 __iadd__ (self, algOrSeq, index=None)
 __eq__ (self, other)
 __ne__ (self, other)
 __str__ (self)
 __len__ (self)

Protected Attributes

 _name = name
list _algsAndSequences = []

Detailed Description

Standalone algorithm sequence

This is a light-weight emulation of Athena's AthSequencer class,
implementing a simple algorithm sequence for EventLoop jobs.

Definition at line 19 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

python.AlgSequence.AlgSequence.__init__ ( self,
name = "AlgSequence" )
Algorithm sequence constructor

Keyword arguments:
  name -- The name of the algorithm sequence (for debugging)

Definition at line 26 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

26 def __init__( self, name = "AlgSequence" ):
27 """Algorithm sequence constructor
28
29 Keyword arguments:
30 name -- The name of the algorithm sequence (for debugging)
31 """
32
33 # Set up the member variables:
34 self._name = name
35 self._algsAndSequences = []
36
37 return
38

Member Function Documentation

◆ __delattr__()

python.AlgSequence.AlgSequence.__delattr__ ( self,
name )
Remove one algorithm/sequence from this sequence, by name

This is to allow removing algorithms (or even sequences) from this
sequence in case that would be needed.

Keyword arguments:
  name -- The name of the algorithm/sequence to delete from the
          sequence

Definition at line 107 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

107 def __delattr__( self, name ):
108 """Remove one algorithm/sequence from this sequence, by name
109
110 This is to allow removing algorithms (or even sequences) from this
111 sequence in case that would be needed.
112
113 Keyword arguments:
114 name -- The name of the algorithm/sequence to delete from the
115 sequence
116 """
117
118 # Look up the algorithm by name:
119 for algOrSeq in self._algsAndSequences:
120 if algOrSeq.name() == name:
121 # If we found it, remove it:
122 self._algsAndSequences.remove( algOrSeq )
123 return
124 pass
125
126 # If no algorithm/sequence with this name was found, that's a
127 # problem:
128 raise AttributeError( 'Algorithm/sequence with name "%s" was not ' \
129 'found' % name )
130

◆ __eq__()

python.AlgSequence.AlgSequence.__eq__ ( self,
other )
Check for equality with another object

The implementation of this is very simple. We only check that
the name of the sequences would match.

Keyword arguments:
  other -- The object to compare this one against

Definition at line 177 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

177 def __eq__( self, other ):
178 """Check for equality with another object
179
180 The implementation of this is very simple. We only check that
181 the name of the sequences would match.
182
183 Keyword arguments:
184 other -- The object to compare this one against
185 """
186
187 # First check that the other object is also an AlgSequence one:
188 if not isinstance( other, AlgSequence ):
189 return False
190
191 # Base the equality purely on the name of the sequence. This may
192 # need to be made smarter at one point.
193 return ( self.name() == other.name() )
194

◆ __getattr__()

python.AlgSequence.AlgSequence.__getattr__ ( self,
name )
Access one algorithm/sequence in this sequence, by name

This is to allow modifying the properties of algorithms in a
sequence that was set up centrally.

Keyword arguments:
  name -- The name of the algorithm/sequence to look up in the
          sequence

Definition at line 86 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

86 def __getattr__( self, name ):
87 """Access one algorithm/sequence in this sequence, by name
88
89 This is to allow modifying the properties of algorithms in a
90 sequence that was set up centrally.
91
92 Keyword arguments:
93 name -- The name of the algorithm/sequence to look up in the
94 sequence
95 """
96
97 # Look up the algorithm by name:
98 for algOrSeq in self._algsAndSequences:
99 if algOrSeq.name() == name:
100 return algOrSeq
101 pass
102
103 # If no algorithm with this name was found, that's a problem:
104 raise AttributeError( 'Algorithm/sequence with name "%s" was not ' \
105 'found' % name )
106

◆ __getitem__()

python.AlgSequence.AlgSequence.__getitem__ ( self,
index )
Return one algorithm/sequence from the sequence by index

This is to allow getting the n'th element of an algorithm sequence
(which itself may either be an algorithm or a sequence),
including the n'th element from the back of it if needed.

Keyword arguments:
  index -- The index of the algorithm/sequence to get from the
           sequence

Definition at line 72 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

72 def __getitem__( self, index ):
73 """Return one algorithm/sequence from the sequence by index
74
75 This is to allow getting the n'th element of an algorithm sequence
76 (which itself may either be an algorithm or a sequence),
77 including the n'th element from the back of it if needed.
78
79 Keyword arguments:
80 index -- The index of the algorithm/sequence to get from the
81 sequence
82 """
83
84 return self._algsAndSequences[ index ]
85

◆ __iadd__()

python.AlgSequence.AlgSequence.__iadd__ ( self,
algOrSeq,
index = None )
Add one algorithm/sequence to the sequence

This function is used to add one algorithm (or algorithm sequence)
to the sequence object, using the '+=' operator.

Keyword arguments:
  algOrSeq -- The algorithm/sequence to add to the sequence

Definition at line 142 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

142 def __iadd__( self, algOrSeq, index = None ):
143 """Add one algorithm/sequence to the sequence
144
145 This function is used to add one algorithm (or algorithm sequence)
146 to the sequence object, using the '+=' operator.
147
148 Keyword arguments:
149 algOrSeq -- The algorithm/sequence to add to the sequence
150 """
151
152 # Check that the received object is of the right type:
153 if not isinstance( algOrSeq, AnaAlgorithmConfig ) and \
154 not isinstance( algOrSeq, PythonConfig ) and \
155 not isinstance( algOrSeq, AlgSequence ):
156 raise TypeError( 'The received object is not of type ' \
157 'AnaAlgorithmConfig or PythonConfig or AlgSequence' )
158 pass
159
160 # Now check if an equivalent algorithm/sequence is already in the
161 # list. As that's also an error.
162 if algOrSeq in self:
163 raise RuntimeError( 'Algorithm/sequence %s is already in ' \
164 'this sequence' % algOrSeq.name() )
165 pass
166
167 # Add the algorithm/sequence to the internal list:
168 if not index:
169 self._algsAndSequences.append( algOrSeq )
170 else:
171 self._algsAndSequences.insert( index, algOrSeq )
172 pass
173
174 # Return the modified object:
175 return self
176

◆ __iter__()

python.AlgSequence.AlgSequence.__iter__ ( self)
Create an iterator over all the algorithms of this sequence

This is to allow for a Python-like iteration over all algorithms
that are part of the sequence. This includes iterating over the
algorithms that may be in sub-sequences of this sequence.

Definition at line 131 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

131 def __iter__( self ):
132 """Create an iterator over all the algorithms of this sequence
133
134 This is to allow for a Python-like iteration over all algorithms
135 that are part of the sequence. This includes iterating over the
136 algorithms that may be in sub-sequences of this sequence.
137 """
138
139 # Create the iterator to process the internal list of algorithms:
140 return AlgSequenceIterator( self._algsAndSequences )
141

◆ __len__()

python.AlgSequence.AlgSequence.__len__ ( self)
Return the size/length of the algorithm sequence

Just returning the number of algorithms and sequences that are in
this sequence. So this is not a recursive count.

Definition at line 223 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

223 def __len__( self ):
224 """Return the size/length of the algorithm sequence
225
226 Just returning the number of algorithms and sequences that are in
227 this sequence. So this is not a recursive count.
228 """
229
230 return len( self._algsAndSequences )
231

◆ __ne__()

python.AlgSequence.AlgSequence.__ne__ ( self,
other )
Check for an inequality with another object

This is just defined to make the '!=' operator of Python behave
consistently with the '==' operator for such objects.

Keyword arguments:
  other -- The object to compare this one against

Definition at line 195 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

195 def __ne__( self, other ):
196 """Check for an inequality with another object
197
198 This is just defined to make the '!=' operator of Python behave
199 consistently with the '==' operator for such objects.
200
201 Keyword arguments:
202 other -- The object to compare this one against
203 """
204 return not self.__eq__( other )
205

◆ __str__()

python.AlgSequence.AlgSequence.__str__ ( self)
Print the algorithm sequence in a user-friendly way

This function takes care of printing the full configuration of every
algorithm in the sequence.

Definition at line 206 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

206 def __str__( self ):
207 """Print the algorithm sequence in a user-friendly way
208
209 This function takes care of printing the full configuration of every
210 algorithm in the sequence.
211 """
212
213 result = AnaAlgorithmConfig._printHeader( 'AlgSequence/%s' %
214 self.name() )
215 result += '\n'
216 for algOrSeq in self._algsAndSequences:
217 result += '| %s\n' % indentBy( str( algOrSeq ), '| ' )
218 pass
219 result += AnaAlgorithmConfig._printFooter( 'AlgSequence/%s' %
220 self.name() )
221 return result
222

◆ addSelfToJob()

python.AlgSequence.AlgSequence.addSelfToJob ( self,
job )
add a copy of this config to the EventLoop job object

Keyword arguments:
  job      -- The job object to add ourself to

Definition at line 61 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

61 def addSelfToJob( self, job ):
62 """add a copy of this config to the EventLoop job object
63
64 Keyword arguments:
65 job -- The job object to add ourself to
66 """
67 for alg in self:
68 alg.addSelfToJob (job)
69 pass
70 pass
71

◆ insert()

python.AlgSequence.AlgSequence.insert ( self,
index,
algOrSeq )
Insert one algorithm/sequence into this sequence

This allows us to extend existing sequences with a greater
flexibility.

Keyword arguments:
  index    -- The index to insert the algorithm/sequence under
  algOrSeq -- The object to insert

Definition at line 48 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

48 def insert( self, index, algOrSeq ):
49 """Insert one algorithm/sequence into this sequence
50
51 This allows us to extend existing sequences with a greater
52 flexibility.
53
54 Keyword arguments:
55 index -- The index to insert the algorithm/sequence under
56 algOrSeq -- The object to insert
57 """
58
59 return self.__iadd__( algOrSeq, index = index )
60

◆ name()

python.AlgSequence.AlgSequence.name ( self)
Return the name of this sequence

Mainly for debugging purposes, and for when we are embedding
one sequence into another one.

Definition at line 39 of file PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py.

39 def name( self ):
40 """Return the name of this sequence
41
42 Mainly for debugging purposes, and for when we are embedding
43 one sequence into another one.
44 """
45
46 return self._name
47

Member Data Documentation

◆ _algsAndSequences

python.AlgSequence.AlgSequence._algsAndSequences = []
protected

◆ _name

python.AlgSequence.AlgSequence._name = name
protected

The documentation for this class was generated from the following file: