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, verbose=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
 
 _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

◆ __init__()

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

Definition at line 158 of file helpers.py.

158  def __init__(self, process, label, postfix, removePostfix="", noClones = [], addToTask = False, verbose = False):
159  self._process = process
160  self._postfix = postfix
161  self._removePostfix = removePostfix
162  self._noClones = noClones
163  self._addToTask = addToTask
164  self._verbose = verbose
165  self._moduleLabels = []
166  self._clonedSequence = cms.Sequence()
167  setattr(process, self._newLabel(label), self._clonedSequence)
168  if addToTask:
169  self._patAlgosToolsTask = getPatAlgosToolsTask(process)
170 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def getPatAlgosToolsTask(process)
Definition: helpers.py:13

Member Function Documentation

◆ __appendToTopSequence()

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

Definition at line 204 of file helpers.py.

References helpers.CloneSequenceVisitor._clonedSequence.

Referenced by helpers.CloneSequenceVisitor.enter().

204  def __appendToTopSequence(self, visitee):
205  self._clonedSequence += visitee
206 

◆ _newLabel()

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().

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 

◆ clonedSequence()

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=self._verbose)
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:79

◆ enter()

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, helpers.CloneSequenceVisitor._patAlgosToolsTask, helpers.CloneSequenceVisitor._process, PVValHelper.add(), and mps_setup.append.

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 
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ leave()

def helpers.CloneSequenceVisitor.leave (   self,
  visitee 
)

Definition at line 187 of file helpers.py.

187  def leave(self, visitee):
188  pass
189 

Member Data Documentation

◆ _addToTask

helpers.CloneSequenceVisitor._addToTask
private

Definition at line 163 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter().

◆ _clonedSequence

helpers.CloneSequenceVisitor._clonedSequence
private

Definition at line 166 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.__appendToTopSequence().

◆ _moduleLabels

helpers.CloneSequenceVisitor._moduleLabels
private

◆ _noClones

helpers.CloneSequenceVisitor._noClones
private

◆ _patAlgosToolsTask

helpers.CloneSequenceVisitor._patAlgosToolsTask
private

Definition at line 169 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter().

◆ _postfix

helpers.CloneSequenceVisitor._postfix
private

◆ _process

helpers.CloneSequenceVisitor._process
private

◆ _removePostfix

helpers.CloneSequenceVisitor._removePostfix
private

◆ _verbose

helpers.CloneSequenceVisitor._verbose
private

Definition at line 164 of file helpers.py.