CMS 3D CMS Logo

Classes | Functions
earlyDeleteSettings_cff Namespace Reference

Classes

class  TestHasInputTagModuleLabel
 

Functions

def _hasInputTagModuleLabel (process, pset, psetModLabel, moduleLabels, result)
 
def customiseEarlyDelete (process)
 

Function Documentation

◆ _hasInputTagModuleLabel()

def earlyDeleteSettings_cff._hasInputTagModuleLabel (   process,
  pset,
  psetModLabel,
  moduleLabels,
  result 
)
private

Definition at line 12 of file earlyDeleteSettings_cff.py.

Referenced by customiseEarlyDelete().

12 def _hasInputTagModuleLabel(process, pset, psetModLabel, moduleLabels, result):
13  for name in pset.parameterNames_():
14  value = getattr(pset,name)
15  if isinstance(value, cms.PSet):
16  _hasInputTagModuleLabel(process, value, psetModLabel, moduleLabels, result)
17  elif isinstance(value, cms.VPSet):
18  for ps in value:
19  _hasInputTagModuleLabel(process, ps, psetModLabel, moduleLabels, result)
20  elif isinstance(value, cms.VInputTag):
21  for t in value:
22  t2 = t
23  if not isinstance(t, cms.InputTag):
24  t2 = cms.InputTag(t2)
25  for i,moduleLabel in enumerate(moduleLabels):
26  if result[i]: continue #no need
27  if t2.getModuleLabel() == moduleLabel:
28  result[i]=True
29  elif isinstance(value, cms.InputTag):
30  for i,moduleLabel in enumerate(moduleLabels):
31  if result[i]: continue #no need
32  if value.getModuleLabel() == moduleLabel:
33  result[i]=True
34  elif isinstance(value, cms.string) and name == "refToPSet_":
35  try:
36  ps = getattr(process, value.value())
37  except AttributeError:
38  raise RuntimeError("Module %s has a 'PSet(refToPSet_ = cms.string(\"%s\"))', but the referenced-to PSet does not exist in the Process." % (psetModLabel, value.value()))
39  _hasInputTagModuleLabel(process, ps, psetModLabel, moduleLabels, result)
40 
41 
def _hasInputTagModuleLabel(process, pset, psetModLabel, moduleLabels, result)

◆ customiseEarlyDelete()

def earlyDeleteSettings_cff.customiseEarlyDelete (   process)

Definition at line 42 of file earlyDeleteSettings_cff.py.

References _hasInputTagModuleLabel(), FastTimerService_cff.range, and contentValuesCheck.values.

Referenced by ConfigBuilder.ConfigBuilder.prepare().

42 def customiseEarlyDelete(process):
43  # Mapping label -> [branches]
44  # for the producers whose products are to be deleted early
45  products = collections.defaultdict(list)
46 
47  products = customiseEarlyDeleteForSeeding(process, products)
48  products = customiseEarlyDeleteForMkFit(process, products)
49  products = customiseEarlyDeleteForCKF(process, products)
50 
51  products = customiseEarlyDeleteForCandIsoDeposits(process, products)
52 
53  # Set process.options.canDeleteEarly
54  if not hasattr(process.options, "canDeleteEarly"):
55  process.options.canDeleteEarly = cms.untracked.vstring()
56 
57  branchSet = set()
58  for branches in products.values():
59  for branch in branches:
60  branchSet.add(branch)
61  branchList = sorted(branchSet)
62  process.options.canDeleteEarly.extend(branchList)
63 
64  # LogErrorHarvester should not wait for deleted items
65  for prod in process.producers_().values():
66  if prod.type_() == "LogErrorHarvester":
67  if not hasattr(prod,'excludeModules'):
68  prod.excludeModules = cms.untracked.vstring()
69  t = prod.excludeModules.value()
70  t.extend([b.split('_')[1] for b in branchList])
71  prod.excludeModules = t
72 
73  # Find the consumers
74  producers=[]
75  branchesList=[]
76  for producer, branches in products.items():
77  producers.append(producer)
78  branchesList.append(branches)
79 
80  for moduleType in [process.producers_(), process.filters_(), process.analyzers_()]:
81  for name, module in moduleType.items():
82  result=[]
83  for producer in producers:
84  result.append(False)
85 
86  _hasInputTagModuleLabel(process, module, name, producers, result)
87  for i in range(len(result)):
88  if result[i]:
89  #if it exists it might be optional or empty, both evaluate to False
90  if hasattr(module, "mightGet") and module.mightGet:
91  module.mightGet.extend(branchesList[i])
92  else:
93  module.mightGet = cms.untracked.vstring(branchesList[i])
94  return process
95 
96 
def _hasInputTagModuleLabel(process, pset, psetModLabel, moduleLabels, result)