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

Constructor & Destructor Documentation

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

Definition at line 193 of file helpers.py.

194  def __init__(self, process, label, postfix, removePostfix=""):
195  self._process = process
196  self._postfix = postfix
197  self._removePostfix = removePostfix
198  self._moduleLabels = []
199  self._clonedSequence = cms.Sequence()
200  setattr(process, self._newLabel(label), self._clonedSequence)

Member Function Documentation

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

Definition at line 230 of file helpers.py.

References helpers.CloneSequenceVisitor._clonedSequence.

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

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

Definition at line 222 of file helpers.py.

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

Referenced by helpers.CloneSequenceVisitor.enter().

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

Definition at line 216 of file helpers.py.

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

Definition at line 201 of file helpers.py.

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

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

Definition at line 213 of file helpers.py.

214  def leave(self, visitee):
215  pass

Member Data Documentation

helpers.CloneSequenceVisitor._clonedSequence
private

Definition at line 198 of file helpers.py.

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

helpers.CloneSequenceVisitor._moduleLabels
private

Definition at line 197 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 195 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 194 of file helpers.py.

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

helpers.CloneSequenceVisitor._removePostfix
private

Definition at line 196 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor._newLabel().