CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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__ (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 161 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 164 of file helpers.py.

164  def __init__(self, process, label, postfix, removePostfix="", noClones = [], addToTask = False, verbose = False):
165  self._process = process
166  self._postfix = postfix
167  self._removePostfix = removePostfix
168  self._noClones = noClones
169  self._addToTask = addToTask
170  self._verbose = verbose
171  self._moduleLabels = []
172  self._clonedSequence = cms.Sequence()
173  setattr(process, self._newLabel(label), self._clonedSequence)
174  if addToTask:
175  self._patAlgosToolsTask = getPatAlgosToolsTask(process)
176 
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 210 of file helpers.py.

References helpers.CloneSequenceVisitor._clonedSequence.

Referenced by helpers.CloneSequenceVisitor.enter().

210  def __appendToTopSequence(self, visitee):
211  self._clonedSequence += visitee
212 

◆ _newLabel()

def helpers.CloneSequenceVisitor._newLabel (   self,
  label 
)
private

Definition at line 202 of file helpers.py.

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

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

202  def _newLabel(self, label):
203  if self._removePostfix != "":
204  if label[-len(self._removePostfix):] == self._removePostfix:
205  label = label[0:-len(self._removePostfix)]
206  else:
207  raise Exception("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
208  return label + self._postfix
209 

◆ clonedSequence()

def helpers.CloneSequenceVisitor.clonedSequence (   self)

Definition at line 196 of file helpers.py.

196  def clonedSequence(self):
197  for label in self._moduleLabels:
198  massSearchReplaceAnyInputTag(self._clonedSequence, label, self._newLabel(label), moduleLabelOnly=True, verbose=self._verbose)
199  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedSequence' function is called.
200  return self._clonedSequence
201 
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 177 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.

177  def enter(self, visitee):
178  if isinstance(visitee, cms._Module):
179  label = visitee.label()
180  newModule = None
181  if label in self._noClones: #keep unchanged
182  newModule = getattr(self._process, label)
183  elif label in self._moduleLabels: # has the module already been cloned ?
184  newModule = getattr(self._process, self._newLabel(label))
185  else:
186  self._moduleLabels.append(label)
187  newModule = visitee.clone()
188  setattr(self._process, self._newLabel(label), newModule)
189  if self._addToTask:
190  self._patAlgosToolsTask.add(getattr(self._process, self._newLabel(label)))
191  self.__appendToTopSequence(newModule)
192 
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ leave()

def helpers.CloneSequenceVisitor.leave (   self,
  visitee 
)

Definition at line 193 of file helpers.py.

193  def leave(self, visitee):
194  pass
195 

Member Data Documentation

◆ _addToTask

helpers.CloneSequenceVisitor._addToTask
private

Definition at line 169 of file helpers.py.

Referenced by helpers.CloneSequenceVisitor.enter().

◆ _clonedSequence

helpers.CloneSequenceVisitor._clonedSequence
private

Definition at line 172 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 175 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 170 of file helpers.py.