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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 446 of file helpers.py.

446  def __init__(self, process, label, postfix, removePostfix="", noClones = [], verbose = False):
447  self._process = process
448  self._postfix = postfix
449  self._removePostfix = removePostfix
450  self._noClones = noClones
451  self._verbose = verbose
452  self._moduleLabels = []
453  self._clonedTask = cms.Task()
454  setattr(process, self._newLabel(label), self._clonedTask)
455 
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 487 of file helpers.py.

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

Referenced by helpers.CloneTaskVisitor.enter().

487  def __appendToTopTask(self, visitee):
488  self._clonedTask.add(visitee)
489 
void add(std::map< std::string, TH1 *> &h, TH1 *hist)

◆ _newLabel()

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

Definition at line 479 of file helpers.py.

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

Referenced by helpers.CloneTaskVisitor.enter().

479  def _newLabel(self, label):
480  if self._removePostfix != "":
481  if label[-len(self._removePostfix):] == self._removePostfix:
482  label = label[0:-len(self._removePostfix)]
483  else:
484  raise Exception("Tried to remove postfix %s from label %s, but it wasn't there" % (self._removePostfix, label))
485  return label + self._postfix
486 

◆ clonedTask()

def helpers.CloneTaskVisitor.clonedTask (   self)

Definition at line 473 of file helpers.py.

473  def clonedTask(self):#FIXME: can the following be used for Task?
474  for label in self._moduleLabels:
475  massSearchReplaceAnyInputTag(self._clonedTask, label, self._newLabel(label), moduleLabelOnly=True, verbose=self._verbose)
476  self._moduleLabels = [] # prevent the InputTag replacement next time the 'clonedTask' function is called.
477  return self._clonedTask
478 
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 456 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.

456  def enter(self, visitee):
457  if isinstance(visitee, cms._Module):
458  label = visitee.label()
459  newModule = None
460  if label in self._noClones: #keep unchanged
461  newModule = getattr(self._process, label)
462  elif label in self._moduleLabels: # has the module already been cloned ?
463  newModule = getattr(self._process, self._newLabel(label))
464  else:
465  self._moduleLabels.append(label)
466  newModule = visitee.clone()
467  setattr(self._process, self._newLabel(label), newModule)
468  self.__appendToTopTask(newModule)
469 

◆ leave()

def helpers.CloneTaskVisitor.leave (   self,
  visitee 
)

Definition at line 470 of file helpers.py.

470  def leave(self, visitee):
471  pass
472 

Member Data Documentation

◆ _clonedTask

helpers.CloneTaskVisitor._clonedTask
private

Definition at line 453 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.__appendToTopTask().

◆ _moduleLabels

helpers.CloneTaskVisitor._moduleLabels
private

Definition at line 452 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

◆ _noClones

helpers.CloneTaskVisitor._noClones
private

Definition at line 450 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

◆ _postfix

helpers.CloneTaskVisitor._postfix
private

Definition at line 448 of file helpers.py.

Referenced by helpers.CloneTaskVisitor._newLabel().

◆ _process

helpers.CloneTaskVisitor._process
private

Definition at line 447 of file helpers.py.

Referenced by helpers.CloneTaskVisitor.enter().

◆ _removePostfix

helpers.CloneTaskVisitor._removePostfix
private

Definition at line 449 of file helpers.py.

Referenced by helpers.CloneTaskVisitor._newLabel().

◆ _verbose

helpers.CloneTaskVisitor._verbose
private

Definition at line 451 of file helpers.py.