CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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

 _clonedSequence
 
 _moduleLabels
 
 _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 186 of file helpers.py.

Constructor & Destructor Documentation

def helpers.CloneSequenceVisitor.__init__ (   self,
  process,
  label,
  postfix,
  removePostfix = "" 
)

Definition at line 189 of file helpers.py.

190  def __init__(self, process, label, postfix, removePostfix=""):
191  self._process = process
192  self._postfix = postfix
193  self._removePostfix = removePostfix
194  self._moduleLabels = []
195  self._clonedSequence = cms.Sequence()
196  setattr(process, self._newLabel(label), self._clonedSequence)

Member Function Documentation

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

Definition at line 226 of file helpers.py.

References helpers.CloneSequenceVisitor._clonedSequence.

Referenced by HiHelperTools.CloneSequenceVisitor.enter(), helpers.CloneSequenceVisitor.enter(), and HiHelperTools.CloneSequenceVisitor.leave().

227  def __appendToTopSequence(self, visitee):
228  self._clonedSequence += visitee
def helpers.CloneSequenceVisitor._newLabel (   self,
  label 
)
private

Definition at line 218 of file helpers.py.

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

Referenced by helpers.CloneSequenceVisitor.enter().

219  def _newLabel(self, label):
220  if self._removePostfix != "":
221  if label[-len(self._removePostfix):] == self._removePostfix:
222  label = label[0:-len(self._removePostfix)]
223  else:
224  raise StandardError("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
225  return label + self._postfix
def helpers.CloneSequenceVisitor.clonedSequence (   self)

Definition at line 212 of file helpers.py.

213  def clonedSequence(self):
214  for label in self._moduleLabels:
215  massSearchReplaceAnyInputTag(self._clonedSequence, label, self._newLabel(label), moduleLabelOnly=True, verbose=False)
216  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedSequence' function is called.
217  return self._clonedSequence
def massSearchReplaceAnyInputTag
Definition: helpers.py:258
def helpers.CloneSequenceVisitor.enter (   self,
  visitee 
)

Definition at line 197 of file helpers.py.

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

198  def enter(self, visitee):
199  if isinstance(visitee, cms._Module):
200  label = visitee.label()
201  newModule = None
202  if label in self._moduleLabels: # has the module already been cloned ?
203  newModule = getattr(self._process, self._newLabel(label))
204  else:
205  self._moduleLabels.append(label)
206  newModule = visitee.clone()
207  setattr(self._process, self._newLabel(label), newModule)
208  self.__appendToTopSequence(newModule)
def helpers.CloneSequenceVisitor.leave (   self,
  visitee 
)

Definition at line 209 of file helpers.py.

210  def leave(self, visitee):
211  pass

Member Data Documentation

helpers.CloneSequenceVisitor._clonedSequence
private

Definition at line 194 of file helpers.py.

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

helpers.CloneSequenceVisitor._moduleLabels
private

Definition at line 193 of file helpers.py.

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

helpers.CloneSequenceVisitor._postfix
private

Definition at line 191 of file helpers.py.

Referenced by HiHelperTools.CloneSequenceVisitor.__appendToTopSequence(), helpers.CloneSequenceVisitor._newLabel(), HiHelperTools.CloneSequenceVisitor.clonedSequence(), and HiHelperTools.CloneSequenceVisitor.enter().

helpers.CloneSequenceVisitor._process
private

Definition at line 190 of file helpers.py.

Referenced by HiHelperTools.CloneSequenceVisitor.__appendToTopSequence(), HiHelperTools.CloneSequenceVisitor.enter(), and helpers.CloneSequenceVisitor.enter().

helpers.CloneSequenceVisitor._removePostfix
private

Definition at line 192 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor._newLabel().