CMS 3D CMS Logo

Classes | Functions
HiHelperTools Namespace Reference

Classes

class  CloneSequenceVisitor
 
class  GatherAllModulesVisitor
 
class  TestModuleCommand
 

Functions

def __labelsInSequence (process, sequenceLabel, postfix="")
 
def applyPostfix (process, label, postfix)
 
def cloneProcessingSnippet (process, sequence, postfix)
 
def contains (sequence, moduleName)
 
def jetCollectionString (prefix='', algo='', type='')
 
def listModules (sequence)
 
def listSequences (sequence)
 
def removeIfInSequence (process, target, sequenceLabel, postfix="")
 

Function Documentation

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

Definition at line 32 of file HiHelperTools.py.

References listModules(), and listSequences().

Referenced by applyPostfix(), and removeIfInSequence().

32 def __labelsInSequence(process, sequenceLabel, postfix=""):
33  result = [ m.label()[:-len(postfix)] for m in listModules( getattr(process,sequenceLabel+postfix))]
34  result.extend([ m.label()[:-len(postfix)] for m in listSequences( getattr(process,sequenceLabel+postfix))] )
35  if postfix == "":
36  result = [ m.label() for m in listModules( getattr(process,sequenceLabel+postfix))]
37  result.extend([ m.label() for m in listSequences( getattr(process,sequenceLabel+postfix))] )
38  return result
39 
40 #FIXME name is not generic enough now
def listModules(sequence)
def listSequences(sequence)
def __labelsInSequence(process, sequenceLabel, postfix="")
def HiHelperTools.applyPostfix (   process,
  label,
  postfix 
)
If a module is in patHeavyIonDefaultSequence use the cloned module.
Will crash if patHeavyIonDefaultSequence has not been cloned with 'postfix' beforehand

Definition at line 11 of file HiHelperTools.py.

References __labelsInSequence().

11 def applyPostfix(process, label, postfix):
12  ''' If a module is in patHeavyIonDefaultSequence use the cloned module.
13  Will crash if patHeavyIonDefaultSequence has not been cloned with 'postfix' beforehand'''
14  result = None
15  defaultLabels = __labelsInSequence(process, "patHeavyIonDefaultSequence", postfix)
16  if hasattr(process, "patPF2PATSequence"):
17  defaultLabels = __labelsInSequence(process, "patPF2PATSequence", postfix)
18  if label in defaultLabels and hasattr(process, label+postfix):
19  result = getattr(process, label+postfix)
20  elif hasattr(process, label):
21  print "WARNING: called applyPostfix for module/sequence %s which is not in patHeavyIonDefaultSequence%s!"%(label,postfix)
22  result = getattr(process, label)
23  return result
24 
def applyPostfix(process, label, postfix)
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 165 of file HiHelperTools.py.

165 def cloneProcessingSnippet(process, sequence, postfix):
166  """
167  ------------------------------------------------------------------
168  copy a sequence plus the modules and sequences therein
169  both are renamed by getting a postfix
170  input tags are automatically adjusted
171  ------------------------------------------------------------------
172  """
173  result = sequence
174  if not postfix == "":
175  visitor = CloneSequenceVisitor(process,sequence.label(),postfix)
176  sequence.visit(visitor)
177  result = visitor.clonedSequence()
178  return result
179 
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 149 of file HiHelperTools.py.

References spr.find().

Referenced by HiHelperTools.TestModuleCommand.testContains().

149 def contains(sequence, moduleName):
150  """
151  ------------------------------------------------------------------
152  return True if a module with name 'module' is contained in the
153  sequence with name 'sequence' and False otherwise. This version
154  is not so nice as it also returns True for any substr of the name
155  of a contained module.
156 
157  sequence : sequence [e.g. process.patHeavyIonDefaultSequence]
158  module : module name as a string
159  ------------------------------------------------------------------
160  """
161  return not sequence.__str__().find(moduleName)==-1
162 
163 
164 
def contains(sequence, moduleName)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
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 125 of file HiHelperTools.py.

Referenced by HiHelperTools.TestModuleCommand.testJetCollectionString().

125 def jetCollectionString(prefix='', algo='', type=''):
126  """
127  ------------------------------------------------------------------
128  return the string of the jet collection module depending on the
129  input vaules. The default return value will be 'patAK5CaloJets'.
130 
131  algo : indicating the algorithm type of the jet [expected are
132  'AK5', 'IC5', 'SC7', ...]
133  type : indicating the type of constituents of the jet [expec-
134  ted are 'Calo', 'PFlow', 'JPT', ...]
135  prefix : prefix indicating the type of pat collection module (ex-
136  pected are '', 'selected', 'clean').
137  ------------------------------------------------------------------
138  """
139  if(prefix==''):
140  jetCollectionString ='pat'
141  else:
142  jetCollectionString =prefix
143  jetCollectionString+='Pat'
144  jetCollectionString+='Jets'
145  jetCollectionString+=algo
146  jetCollectionString+=type
147  return jetCollectionString
148 
def jetCollectionString(prefix='', algo='', type='')
def HiHelperTools.listModules (   sequence)

Definition at line 115 of file HiHelperTools.py.

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

115 def listModules(sequence):
116  visitor = GatherAllModulesVisitor(gatheredInstance=cms._Module)
117  sequence.visit(visitor)
118  return visitor.modules()
119 
def listModules(sequence)
def HiHelperTools.listSequences (   sequence)

Definition at line 120 of file HiHelperTools.py.

Referenced by __labelsInSequence().

120 def listSequences(sequence):
121  visitor = GatherAllModulesVisitor(gatheredInstance=cms.Sequence)
122  sequence.visit(visitor)
123  return visitor.modules()
124 
def listSequences(sequence)
def HiHelperTools.removeIfInSequence (   process,
  target,
  sequenceLabel,
  postfix = "" 
)

Definition at line 25 of file HiHelperTools.py.

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

25 def removeIfInSequence(process, target, sequenceLabel, postfix=""):
26  labels = __labelsInSequence(process, sequenceLabel, postfix)
27  if target+postfix in labels:
28  getattr(process, sequenceLabel+postfix).remove(
29  getattr(process, target+postfix)
30  )
31 
def removeIfInSequence(process, target, sequenceLabel, postfix="")
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:211
def __labelsInSequence(process, sequenceLabel, postfix="")