CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
helpers.CloneSequenceVisitor Class Reference
Inheritance diagram for helpers.CloneSequenceVisitor:

Public Member Functions

def __init__ (self, process, label, postfix, removePostfix="", noClones=[], addToTask=False)
 
def clonedSequence (self)
 
def enter (self, visitee)
 
def leave (self, visitee)
 

Private Member Functions

def __appendToTopSequence (self, visitee)
 
def _newLabel (self, label)
 

Private Attributes

 _addToTask
 
 _clonedSequence
 
 _moduleLabels
 
 _noClones
 
 _patAlgosToolsTask
 
 _postfix
 
 _process
 
 _removePostfix
 

Detailed Description

Visitor that travels within a cms.Sequence, and returns a cloned version of the Sequence.
All modules and sequences are cloned and a postfix is added

Definition at line 156 of file helpers.py.

Constructor & Destructor Documentation

def helpers.CloneSequenceVisitor.__init__ (   self,
  process,
  label,
  postfix,
  removePostfix = "",
  noClones = [],
  addToTask = False 
)

Definition at line 159 of file helpers.py.

159  def __init__(self, process, label, postfix, removePostfix="", noClones = [], addToTask = False):
160  self._process = process
161  self._postfix = postfix
162  self._removePostfix = removePostfix
163  self._noClones = noClones
164  self._addToTask = addToTask
165  self._moduleLabels = []
166  self._clonedSequence = cms.Sequence()
167  setattr(process, self._newLabel(label), self._clonedSequence)
168  if addToTask:
170 
def _newLabel(self, label)
Definition: helpers.py:196
def __init__(self, process, label, postfix, removePostfix="", noClones=[], addToTask=False)
Definition: helpers.py:159
def getPatAlgosToolsTask(process)
Definition: helpers.py:14

Member Function Documentation

def helpers.CloneSequenceVisitor.__appendToTopSequence (   self,
  visitee 
)
private
def helpers.CloneSequenceVisitor._newLabel (   self,
  label 
)
private

Definition at line 196 of file helpers.py.

References helpers.CloneSequenceVisitor._postfix, and helpers.CloneSequenceVisitor._removePostfix.

Referenced by helpers.CloneSequenceVisitor.enter().

196  def _newLabel(self, label):
197  if self._removePostfix != "":
198  if label[-len(self._removePostfix):] == self._removePostfix:
199  label = label[0:-len(self._removePostfix)]
200  else:
201  raise Exception("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
202  return label + self._postfix
203 
def _newLabel(self, label)
Definition: helpers.py:196
def helpers.CloneSequenceVisitor.clonedSequence (   self)

Definition at line 190 of file helpers.py.

190  def clonedSequence(self):
191  for label in self._moduleLabels:
192  massSearchReplaceAnyInputTag(self._clonedSequence, label, self._newLabel(label), moduleLabelOnly=True, verbose=False)
193  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedSequence' function is called.
194  return self._clonedSequence
195 
def massSearchReplaceAnyInputTag(sequence, oldInputTag, newInputTag, verbose=False, moduleLabelOnly=False, skipLabelTest=False)
Definition: MassReplace.py:73
def _newLabel(self, label)
Definition: helpers.py:196
def helpers.CloneSequenceVisitor.enter (   self,
  visitee 
)

Definition at line 171 of file helpers.py.

References helpers.CloneSequenceVisitor.__appendToTopSequence(), helpers.CloneSequenceVisitor._addToTask, helpers.CloneSequenceVisitor._moduleLabels, helpers.CloneSequenceVisitor._newLabel(), helpers.CloneSequenceVisitor._noClones, and helpers.CloneSequenceVisitor._process.

171  def enter(self, visitee):
172  if isinstance(visitee, cms._Module):
173  label = visitee.label()
174  newModule = None
175  if label in self._noClones: #keep unchanged
176  newModule = getattr(self._process, label)
177  elif label in self._moduleLabels: # has the module already been cloned ?
178  newModule = getattr(self._process, self._newLabel(label))
179  else:
180  self._moduleLabels.append(label)
181  newModule = visitee.clone()
182  setattr(self._process, self._newLabel(label), newModule)
183  if self._addToTask:
184  self._patAlgosToolsTask.add(getattr(self._process, self._newLabel(label)))
185  self.__appendToTopSequence(newModule)
186 
def _newLabel(self, label)
Definition: helpers.py:196
def enter(self, visitee)
Definition: helpers.py:171
def __appendToTopSequence(self, visitee)
Definition: helpers.py:204
def helpers.CloneSequenceVisitor.leave (   self,
  visitee 
)

Definition at line 187 of file helpers.py.

187  def leave(self, visitee):
188  pass
189 
def leave(self, visitee)
Definition: helpers.py:187

Member Data Documentation

helpers.CloneSequenceVisitor._addToTask
private

Definition at line 164 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter().

helpers.CloneSequenceVisitor._clonedSequence
private
helpers.CloneSequenceVisitor._moduleLabels
private
helpers.CloneSequenceVisitor._noClones
private

Definition at line 163 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter().

helpers.CloneSequenceVisitor._patAlgosToolsTask
private

Definition at line 169 of file helpers.py.

helpers.CloneSequenceVisitor._postfix
private
helpers.CloneSequenceVisitor._process
private
helpers.CloneSequenceVisitor._removePostfix
private

Definition at line 162 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor._newLabel().