CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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__
 
def clonedSequence
 
def enter
 
def leave
 

Private Member Functions

def __appendToTopSequence
 
def _newLabel
 

Private Attributes

 _addToTask
 
 _clonedSequence
 
 _moduleLabels
 
 _noClones
 
 _patAlgosToolsTask
 
 _postfix
 
 _process
 
 _removePostfix
 
 _verbose
 

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 155 of file helpers.py.

Constructor & Destructor Documentation

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

Definition at line 158 of file helpers.py.

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

Member Function Documentation

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

Definition at line 204 of file helpers.py.

References helpers.CloneSequenceVisitor._clonedSequence.

Referenced by helpers.CloneSequenceVisitor.enter().

205  def __appendToTopSequence(self, visitee):
206  self._clonedSequence += visitee
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(), and helpers.CloneTaskVisitor.enter().

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

Definition at line 190 of file helpers.py.

191  def clonedSequence(self):
192  for label in self._moduleLabels:
193  massSearchReplaceAnyInputTag(self._clonedSequence, label, self._newLabel(label), moduleLabelOnly=True, verbose=self._verbose)
194  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedSequence' function is called.
195  return self._clonedSequence
def massSearchReplaceAnyInputTag
Definition: MassReplace.py:79
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.

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

Definition at line 187 of file helpers.py.

188  def leave(self, visitee):
189  pass

Member Data Documentation

helpers.CloneSequenceVisitor._addToTask
private

Definition at line 163 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter().

helpers.CloneSequenceVisitor._clonedSequence
private

Definition at line 166 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.__appendToTopSequence(), and helpers.CloneSequenceVisitor.clonedSequence().

helpers.CloneSequenceVisitor._moduleLabels
private

Definition at line 165 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.clonedSequence(), helpers.CloneSequenceVisitor.enter(), and helpers.CloneTaskVisitor.enter().

helpers.CloneSequenceVisitor._noClones
private

Definition at line 162 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter(), and helpers.CloneTaskVisitor.enter().

helpers.CloneSequenceVisitor._patAlgosToolsTask
private

Definition at line 169 of file helpers.py.

helpers.CloneSequenceVisitor._postfix
private

Definition at line 160 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor._newLabel(), and helpers.CloneTaskVisitor._newLabel().

helpers.CloneSequenceVisitor._process
private

Definition at line 159 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter(), and helpers.CloneTaskVisitor.enter().

helpers.CloneSequenceVisitor._removePostfix
private

Definition at line 161 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor._newLabel(), and helpers.CloneTaskVisitor._newLabel().

helpers.CloneSequenceVisitor._verbose
private

Definition at line 164 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.clonedSequence().