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
 
 _noClones
 
 _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 196 of file helpers.py.

Constructor & Destructor Documentation

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

Definition at line 199 of file helpers.py.

200  def __init__(self, process, label, postfix, removePostfix="", noClones = []):
201  self._process = process
202  self._postfix = postfix
203  self._removePostfix = removePostfix
204  self._noClones = noClones
205  self._moduleLabels = []
206  self._clonedSequence = cms.Sequence()
207  setattr(process, self._newLabel(label), self._clonedSequence)

Member Function Documentation

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

Definition at line 239 of file helpers.py.

References helpers.CloneSequenceVisitor._clonedSequence.

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

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

Definition at line 231 of file helpers.py.

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

Referenced by helpers.CloneSequenceVisitor.enter().

232  def _newLabel(self, label):
233  if self._removePostfix != "":
234  if label[-len(self._removePostfix):] == self._removePostfix:
235  label = label[0:-len(self._removePostfix)]
236  else:
237  raise Exception("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
238  return label + self._postfix
def helpers.CloneSequenceVisitor.clonedSequence (   self)

Definition at line 225 of file helpers.py.

226  def clonedSequence(self):
227  for label in self._moduleLabels:
228  massSearchReplaceAnyInputTag(self._clonedSequence, label, self._newLabel(label), moduleLabelOnly=True, verbose=False)
229  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedSequence' function is called.
230  return self._clonedSequence
def massSearchReplaceAnyInputTag
Definition: helpers.py:271
def helpers.CloneSequenceVisitor.enter (   self,
  visitee 
)

Definition at line 208 of file helpers.py.

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

209  def enter(self, visitee):
210  if isinstance(visitee, cms._Module):
211  label = visitee.label()
212  newModule = None
213  if label in self._noClones: #keep unchanged
214  newModule = getattr(self._process, label)
215  elif label in self._moduleLabels: # has the module already been cloned ?
216  newModule = getattr(self._process, self._newLabel(label))
217  else:
218  self._moduleLabels.append(label)
219  newModule = visitee.clone()
220  setattr(self._process, self._newLabel(label), newModule)
221  self.__appendToTopSequence(newModule)
def helpers.CloneSequenceVisitor.leave (   self,
  visitee 
)

Definition at line 222 of file helpers.py.

223  def leave(self, visitee):
224  pass

Member Data Documentation

helpers.CloneSequenceVisitor._clonedSequence
private

Definition at line 205 of file helpers.py.

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

helpers.CloneSequenceVisitor._moduleLabels
private

Definition at line 204 of file helpers.py.

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

helpers.CloneSequenceVisitor._noClones
private

Definition at line 203 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter().

helpers.CloneSequenceVisitor._postfix
private

Definition at line 201 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 200 of file helpers.py.

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

helpers.CloneSequenceVisitor._removePostfix
private

Definition at line 202 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor._newLabel().