CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
egammaGainSwitchFixTools Namespace Reference

Functions

def checkTag
 
def customiseForAODGainSwitchFix
 
def replaceInputTagModuleLabel
 
def replaceInputTags
 
def replaceModulesInSeq
 

Function Documentation

def egammaGainSwitchFixTools.checkTag (   tag,
  names_dict 
)

Definition at line 9 of file egammaGainSwitchFixTools.py.

Referenced by pos::PixelROCDACSettings.read(), and replaceInputTags().

9 
10 def checkTag(tag,names_dict):
11  new_names=[names_dict[key] for key in names_dict]
12  if tag.getModuleLabel() in new_names and tag.getProcessName()!="@skipCurrentProcess":
13  return False
14  return True
def egammaGainSwitchFixTools.customiseForAODGainSwitchFix (   process,
  newNameSuffex = "" 
)

Definition at line 41 of file egammaGainSwitchFixTools.py.

References clone(), replaceInputTags(), and replaceModulesInSeq().

41 
42 def customiseForAODGainSwitchFix(process,newNameSuffex=""):
43  process.load("RecoEgamma.EgammaTools.egammaGainSwitchFix_cff")
44  names_dict = {"ecalMultiAndGSGlobalRecHitEB" : "reducedEcalRecHitsEB" + newNameSuffex,
45  "particleFlowRecHitECALGSFixed" : "particleFlowRecHitECAL" + newNameSuffex,
46  "particleFlowRecHitPSGSFixed" : "particleFlowRecHitPS" + newNameSuffex,
47  "particleFlowClusterPSGSFixed" : "particleFlowClusterPS" + newNameSuffex,
48  "particleFlowClusterECALUncorrectedGSFixed" : "particleFlowClusterECALUncorrected" + newNameSuffex,
49  "particleFlowClusterECALGSFixed" : "particleFlowClusterECAL" + newNameSuffex,
50  "particleFlowSuperClusterECALGSFixed" : "particleFlowSuperClusterECAL" + newNameSuffex,
51  "gsFixedRefinedSuperClusters" : "particleFlowEGamma" + newNameSuffex,
52  "gsFixedGsfElectronCores" : "gedGsfElectronCores" + newNameSuffex,
53  "gsFixedGsfElectrons" : "gedGsfElectrons" + newNameSuffex,
54  "gsFixedGedPhotonCores" : "gedPhotonCore" + newNameSuffex,
55  "gsFixedGedPhotons" : "gedPhotons" + newNameSuffex}
56 
57 
58 
59 
60  for org_name in names_dict.keys():
61  setattr(process,names_dict[org_name],getattr(process,org_name).clone())
62 
63 
64  for seqname in process.sequences:
65  seq = getattr(process,seqname)
66  replaceModulesInSeq(process,seq,names_dict)
67 
68  mods_done=[] #keeps track of which modules we have done
69  #useful as module might be in multiple paths
70  for pathname in process.pathNames() :
71  try:
72  path = getattr(process,pathname)
73  for modulename in path.moduleNames():
74  if modulename not in mods_done:
75  mod = getattr(process,modulename)
76  replaceInputTags(process,modulename,mod,names_dict)
77  mods_done.append(modulename)
78  except AttributeError:
79  pass
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def egammaGainSwitchFixTools.replaceInputTagModuleLabel (   tag,
  names_dict 
)

Definition at line 4 of file egammaGainSwitchFixTools.py.

Referenced by replaceInputTags().

4 
5 def replaceInputTagModuleLabel(tag,names_dict):
6  if tag.getModuleLabel() in names_dict:
7  # print "replacing",tag.getModuleLabel(),"with ",names_dict[tag.getModuleLabel()]
8  tag.setModuleLabel(names_dict[tag.getModuleLabel()])
def egammaGainSwitchFixTools.replaceInputTags (   process,
  modname,
  pset,
  names_dict 
)

Definition at line 15 of file egammaGainSwitchFixTools.py.

References checkTag(), and replaceInputTagModuleLabel().

Referenced by customiseForAODGainSwitchFix().

15 
16 def replaceInputTags(process,modname,pset,names_dict):
17  for paraname in pset.parameterNames_():
18  para = pset.getParameter(paraname)
19  if para.pythonTypeName()=="cms.PSet":
20  replaceInputTags(process,modname,para,names_dict)
21  elif para.pythonTypeName()=="cms.VPSet":
22  for newpset in para:
23  replaceInputTags(process,modname,newpset,names_dict)
24  elif para.pythonTypeName()=="cms.InputTag":
25  if not checkTag(para,names_dict):
26  print "WARNING: {0}.{1} : {2} does not properly ignore the current process".format(modname,paraname,para.getModuleLabel())
27  replaceInputTagModuleLabel(para,names_dict)
28 
29  elif para.pythonTypeName()=="cms.VInputTag":
30  for tag in para:
31  if not checkTag(tag,names_dict):
32  print "WARNING: {0}.{1} does not properly ignore the current process".format(modname,paraname,tag.getModuleLabel())
33  if tag.getModuleLabel() in names_dict:
34  replaceInputTagModuleLabel(tag,names_dict)
def egammaGainSwitchFixTools.replaceModulesInSeq (   process,
  seq,
  names_dict 
)

Definition at line 35 of file egammaGainSwitchFixTools.py.

Referenced by customiseForAODGainSwitchFix().

35 
36 def replaceModulesInSeq(process,seq,names_dict):
37  for org_name in names_dict.keys():
38  seq.replace(getattr(process,org_name),getattr(process,names_dict[org_name]))
39 
40