CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
helpers.CloneTaskVisitor Class Reference
Inheritance diagram for helpers.CloneTaskVisitor:

Public Member Functions

def __init__ (self, process, label, postfix, removePostfix="", noClones=[], verbose=False)
 
def clonedTask (self)
 
def enter (self, visitee)
 
def leave (self, visitee)
 

Private Member Functions

def __appendToTopTask (self, visitee)
 
def _newLabel (self, label)
 

Private Attributes

 _clonedTask
 
 _moduleLabels
 
 _noClones
 
 _postfix
 
 _process
 
 _removePostfix
 
 _verbose
 

Detailed Description

Visitor that travels within a cms.Task, and returns a cloned version of the Task.
All modules are cloned and a postfix is added

Definition at line 437 of file helpers.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 440 of file helpers.py.

440  def __init__(self, process, label, postfix, removePostfix="", noClones = [], verbose = False):
441  self._process = process
442  self._postfix = postfix
443  self._removePostfix = removePostfix
444  self._noClones = noClones
445  self._verbose = verbose
446  self._moduleLabels = []
447  self._clonedTask = cms.Task()
448  setattr(process, self._newLabel(label), self._clonedTask)
449 
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)

Member Function Documentation

◆ __appendToTopTask()

def helpers.CloneTaskVisitor.__appendToTopTask (   self,
  visitee 
)
private

Definition at line 481 of file helpers.py.

References helpers.CloneTaskVisitor._clonedTask, and PVValHelper.add().

Referenced by helpers.CloneTaskVisitor.enter().

481  def __appendToTopTask(self, visitee):
482  self._clonedTask.add(visitee)
483 
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ _newLabel()

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

Definition at line 473 of file helpers.py.

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

Referenced by helpers.CloneTaskVisitor.enter().

473  def _newLabel(self, label):
474  if self._removePostfix != "":
475  if label[-len(self._removePostfix):] == self._removePostfix:
476  label = label[0:-len(self._removePostfix)]
477  else:
478  raise Exception("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
479  return label + self._postfix
480 

◆ clonedTask()

def helpers.CloneTaskVisitor.clonedTask (   self)

Definition at line 467 of file helpers.py.

467  def clonedTask(self):#FIXME: can the following be used for Task?
468  for label in self._moduleLabels:
469  massSearchReplaceAnyInputTag(self._clonedTask, label, self._newLabel(label), moduleLabelOnly=True, verbose=self._verbose)
470  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedTask' function is called.
471  return self._clonedTask
472 
def massSearchReplaceAnyInputTag(sequence, oldInputTag, newInputTag, verbose=False, moduleLabelOnly=False, skipLabelTest=False)
Definition: MassReplace.py:79

◆ enter()

def helpers.CloneTaskVisitor.enter (   self,
  visitee 
)

Definition at line 450 of file helpers.py.

References helpers.CloneTaskVisitor.__appendToTopTask(), helpers.CloneSequenceVisitor._moduleLabels, helpers.CloneTaskVisitor._moduleLabels, helpers.CloneSequenceVisitor._newLabel(), helpers.CloneTaskVisitor._newLabel(), helpers.CloneSequenceVisitor._noClones, helpers.CloneTaskVisitor._noClones, helpers.CloneSequenceVisitor._process, helpers.CloneTaskVisitor._process, and mps_setup.append.

450  def enter(self, visitee):
451  if isinstance(visitee, cms._Module):
452  label = visitee.label()
453  newModule = None
454  if label in self._noClones: #keep unchanged
455  newModule = getattr(self._process, label)
456  elif label in self._moduleLabels: # has the module already been cloned ?
457  newModule = getattr(self._process, self._newLabel(label))
458  else:
459  self._moduleLabels.append(label)
460  newModule = visitee.clone()
461  setattr(self._process, self._newLabel(label), newModule)
462  self.__appendToTopTask(newModule)
463 

◆ leave()

def helpers.CloneTaskVisitor.leave (   self,
  visitee 
)

Definition at line 464 of file helpers.py.

464  def leave(self, visitee):
465  pass
466 

Member Data Documentation

◆ _clonedTask

helpers.CloneTaskVisitor._clonedTask
private

Definition at line 447 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.__appendToTopTask().

◆ _moduleLabels

helpers.CloneTaskVisitor._moduleLabels
private

Definition at line 446 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

◆ _noClones

helpers.CloneTaskVisitor._noClones
private

Definition at line 444 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

◆ _postfix

helpers.CloneTaskVisitor._postfix
private

Definition at line 442 of file helpers.py.

Referenced by helpers.CloneTaskVisitor._newLabel().

◆ _process

helpers.CloneTaskVisitor._process
private

Definition at line 441 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

◆ _removePostfix

helpers.CloneTaskVisitor._removePostfix
private

Definition at line 443 of file helpers.py.

Referenced by helpers.CloneTaskVisitor._newLabel().

◆ _verbose

helpers.CloneTaskVisitor._verbose
private

Definition at line 445 of file helpers.py.