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 33 of file HiHelperTools.py.

References listModules(), and listSequences().

Referenced by applyPostfix(), and removeIfInSequence().

33 def __labelsInSequence(process, sequenceLabel, postfix=""):
34  result = [ m.label()[:-len(postfix)] for m in listModules( getattr(process,sequenceLabel+postfix))]
35  result.extend([ m.label()[:-len(postfix)] for m in listSequences( getattr(process,sequenceLabel+postfix))] )
36  if postfix == "":
37  result = [ m.label() for m in listModules( getattr(process,sequenceLabel+postfix))]
38  result.extend([ m.label() for m in listSequences( getattr(process,sequenceLabel+postfix))] )
39  return result
40 
41 #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 12 of file HiHelperTools.py.

References __labelsInSequence(), and edm.print().

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

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

References spr.find().

Referenced by HiHelperTools.TestModuleCommand.testContains().

150 def contains(sequence, moduleName):
151  """
152  ------------------------------------------------------------------
153  return True if a module with name 'module' is contained in the
154  sequence with name 'sequence' and False otherwise. This version
155  is not so nice as it also returns True for any substr of the name
156  of a contained module.
157 
158  sequence : sequence [e.g. process.patHeavyIonDefaultSequence]
159  module : module name as a string
160  ------------------------------------------------------------------
161  """
162  return not sequence.__str__().find(moduleName)==-1
163 
164 
165 
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 126 of file HiHelperTools.py.

Referenced by HiHelperTools.TestModuleCommand.testJetCollectionString().

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

Definition at line 116 of file HiHelperTools.py.

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

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

Definition at line 121 of file HiHelperTools.py.

Referenced by __labelsInSequence().

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

Definition at line 26 of file HiHelperTools.py.

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

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