CMS 3D CMS Logo

Classes | Functions
HiHelperTools Namespace Reference

Classes

class  CloneSequenceVisitor
 
class  GatherAllModulesVisitor
 
class  MassSearchParamVisitor
 
class  MassSearchReplaceAnyInputTagVisitor
 
class  MassSearchReplaceParamVisitor
 
class  TestModuleCommand
 

Functions

def __labelsInSequence (process, sequenceLabel, postfix="")
 
def applyPostfix (process, label, postfix)
 Helpers to perform some technically boring tasks like looking for all modules with a given parameter and replacing that to a given value. More...
 
def cloneProcessingSnippet (process, sequence, postfix)
 
def contains (sequence, moduleName)
 
def jetCollectionString (prefix='', algo='', type='')
 
def listModules (sequence)
 
def listSequences (sequence)
 
def massSearchReplaceAnyInputTag (sequence, oldInputTag, newInputTag, verbose=False, moduleLabelOnly=False)
 
def massSearchReplaceParam (sequence, paramName, paramOldValue, paramValue)
 
def removeIfInSequence (process, target, sequenceLabel, postfix="")
 

Function Documentation

def HiHelperTools.__labelsInSequence (   process,
  sequenceLabel,
  postfix = "" 
)
private

Definition at line 27 of file HiHelperTools.py.

References listModules(), and listSequences().

Referenced by applyPostfix(), and removeIfInSequence().

27 def __labelsInSequence(process, sequenceLabel, postfix=""):
28  result = [ m.label()[:-len(postfix)] for m in listModules( getattr(process,sequenceLabel+postfix))]
29  result.extend([ m.label()[:-len(postfix)] for m in listSequences( getattr(process,sequenceLabel+postfix))] )
30  if postfix == "":
31  result = [ m.label() for m in listModules( getattr(process,sequenceLabel+postfix))]
32  result.extend([ m.label() for m in listSequences( getattr(process,sequenceLabel+postfix))] )
33  return result
34 
def listModules(sequence)
def listSequences(sequence)
def __labelsInSequence(process, sequenceLabel, postfix="")
def HiHelperTools.applyPostfix (   process,
  label,
  postfix 
)

Helpers to perform some technically boring tasks like looking for all modules with a given parameter and replacing that to a given value.

If a module is in patHeavyIonDefaultSequence use the cloned module.
Will crash if patHeavyIonDefaultSequence has not been cloned with 'postfix' beforehand

Definition at line 6 of file HiHelperTools.py.

References __labelsInSequence().

6 def applyPostfix(process, label, postfix):
7  ''' If a module is in patHeavyIonDefaultSequence use the cloned module.
8  Will crash if patHeavyIonDefaultSequence has not been cloned with 'postfix' beforehand'''
9  result = None
10  defaultLabels = __labelsInSequence(process, "patHeavyIonDefaultSequence", postfix)
11  if hasattr(process, "patPF2PATSequence"):
12  defaultLabels = __labelsInSequence(process, "patPF2PATSequence", postfix)
13  if label in defaultLabels and hasattr(process, label+postfix):
14  result = getattr(process, label+postfix)
15  elif hasattr(process, label):
16  print "WARNING: called applyPostfix for module/sequence %s which is not in patHeavyIonDefaultSequence%s!"%(label,postfix)
17  result = getattr(process, label)
18  return result
19 
def applyPostfix(process, label, postfix)
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
Definition: HiHelperTools.py:6
def __labelsInSequence(process, sequenceLabel, postfix="")
def HiHelperTools.cloneProcessingSnippet (   process,
  sequence,
  postfix 
)
------------------------------------------------------------------
copy a sequence plus the modules and sequences therein 
both are renamed by getting a postfix
input tags are automatically adjusted
------------------------------------------------------------------

Definition at line 257 of file HiHelperTools.py.

257 def cloneProcessingSnippet(process, sequence, postfix):
258  """
259  ------------------------------------------------------------------
260  copy a sequence plus the modules and sequences therein
261  both are renamed by getting a postfix
262  input tags are automatically adjusted
263  ------------------------------------------------------------------
264  """
265  result = sequence
266  if not postfix == "":
267  visitor = CloneSequenceVisitor(process,sequence.label(),postfix)
268  sequence.visit(visitor)
269  result = visitor.clonedSequence()
270  return result
271 
def cloneProcessingSnippet(process, sequence, postfix)
def HiHelperTools.contains (   sequence,
  moduleName 
)
------------------------------------------------------------------
return True if a module with name 'module' is contained in the 
sequence with name 'sequence' and False otherwise. This version
is not so nice as it also returns True for any substr of the name
of a contained module.

sequence : sequence [e.g. process.patHeavyIonDefaultSequence]
module   : module name as a string
------------------------------------------------------------------    

Definition at line 241 of file HiHelperTools.py.

References spr.find().

Referenced by HiHelperTools.TestModuleCommand.testContains().

241 def contains(sequence, moduleName):
242  """
243  ------------------------------------------------------------------
244  return True if a module with name 'module' is contained in the
245  sequence with name 'sequence' and False otherwise. This version
246  is not so nice as it also returns True for any substr of the name
247  of a contained module.
248 
249  sequence : sequence [e.g. process.patHeavyIonDefaultSequence]
250  module : module name as a string
251  ------------------------------------------------------------------
252  """
253  return not sequence.__str__().find(moduleName)==-1
254 
255 
256 
def contains(sequence, moduleName)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
def HiHelperTools.jetCollectionString (   prefix = '',
  algo = '',
  type = '' 
)
------------------------------------------------------------------
return the string of the jet collection module depending on the
input vaules. The default return value will be 'patAK5CaloJets'.

algo   : indicating the algorithm type of the jet [expected are
         'AK5', 'IC5', 'SC7', ...]
type   : indicating the type of constituents of the jet [expec-
         ted are 'Calo', 'PFlow', 'JPT', ...]
prefix : prefix indicating the type of pat collection module (ex-
         pected are '', 'selected', 'clean').
------------------------------------------------------------------    

Definition at line 217 of file HiHelperTools.py.

References reco.if().

Referenced by HiHelperTools.TestModuleCommand.testJetCollectionString().

217 def jetCollectionString(prefix='', algo='', type=''):
218  """
219  ------------------------------------------------------------------
220  return the string of the jet collection module depending on the
221  input vaules. The default return value will be 'patAK5CaloJets'.
222 
223  algo : indicating the algorithm type of the jet [expected are
224  'AK5', 'IC5', 'SC7', ...]
225  type : indicating the type of constituents of the jet [expec-
226  ted are 'Calo', 'PFlow', 'JPT', ...]
227  prefix : prefix indicating the type of pat collection module (ex-
228  pected are '', 'selected', 'clean').
229  ------------------------------------------------------------------
230  """
231  if(prefix==''):
232  jetCollectionString ='pat'
233  else:
234  jetCollectionString =prefix
235  jetCollectionString+='Pat'
236  jetCollectionString+='Jets'
237  jetCollectionString+=algo
238  jetCollectionString+=type
239  return jetCollectionString
240 
def jetCollectionString(prefix='', algo='', type='')
if(dp >Float(M_PI)) dp-
def HiHelperTools.listModules (   sequence)

Definition at line 203 of file HiHelperTools.py.

Referenced by __labelsInSequence(), and HiHelperTools.TestModuleCommand.testListModules().

203 def listModules(sequence):
204  visitor = GatherAllModulesVisitor(gatheredInstance=cms._Module)
205  sequence.visit(visitor)
206  return visitor.modules()
207 
def listModules(sequence)
def HiHelperTools.listSequences (   sequence)

Definition at line 208 of file HiHelperTools.py.

Referenced by __labelsInSequence().

208 def listSequences(sequence):
209  visitor = GatherAllModulesVisitor(gatheredInstance=cms.Sequence)
210  sequence.visit(visitor)
211  return visitor.modules()
212 
def listSequences(sequence)
def HiHelperTools.massSearchReplaceAnyInputTag (   sequence,
  oldInputTag,
  newInputTag,
  verbose = False,
  moduleLabelOnly = False 
)
Replace InputTag oldInputTag with newInputTag, at any level of nesting within PSets, VPSets, VInputTags...

Definition at line 213 of file HiHelperTools.py.

Referenced by HiHelperTools.CloneSequenceVisitor.clonedSequence().

213 def massSearchReplaceAnyInputTag(sequence, oldInputTag, newInputTag,verbose=False,moduleLabelOnly=False) :
214  """Replace InputTag oldInputTag with newInputTag, at any level of nesting within PSets, VPSets, VInputTags..."""
215  sequence.visit(MassSearchReplaceAnyInputTagVisitor(oldInputTag,newInputTag,verbose=verbose,moduleLabelOnly=moduleLabelOnly))
216 
def massSearchReplaceAnyInputTag(sequence, oldInputTag, newInputTag, verbose=False, moduleLabelOnly=False)
def HiHelperTools.massSearchReplaceParam (   sequence,
  paramName,
  paramOldValue,
  paramValue 
)

Definition at line 200 of file HiHelperTools.py.

Referenced by HiHelperTools.TestModuleCommand.testMassSearchReplaceParam().

200 def massSearchReplaceParam(sequence,paramName,paramOldValue,paramValue):
201  sequence.visit(MassSearchReplaceParamVisitor(paramName,paramOldValue,paramValue))
202 
def massSearchReplaceParam(sequence, paramName, paramOldValue, paramValue)
def HiHelperTools.removeIfInSequence (   process,
  target,
  sequenceLabel,
  postfix = "" 
)

Definition at line 20 of file HiHelperTools.py.

References __labelsInSequence(), and MatrixUtil.remove().

20 def removeIfInSequence(process, target, sequenceLabel, postfix=""):
21  labels = __labelsInSequence(process, sequenceLabel, postfix)
22  if target+postfix in labels:
23  getattr(process, sequenceLabel+postfix).remove(
24  getattr(process, target+postfix)
25  )
26 
def removeIfInSequence(process, target, sequenceLabel, postfix="")
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:209
def __labelsInSequence(process, sequenceLabel, postfix="")