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 10 of file earlyDeleteSettings_cff.py.

10 def _hasInputTagModuleLabel(process, pset, psetModLabel, moduleLabels, result):
11  for name in pset.parameterNames_():
12  value = getattr(pset,name)
13  if isinstance(value, cms.PSet):
14  _hasInputTagModuleLabel(process, value, psetModLabel, moduleLabels, result)
15  elif isinstance(value, cms.VPSet):
16  for ps in value:
17  _hasInputTagModuleLabel(process, ps, psetModLabel, moduleLabels, result)
18  elif isinstance(value, cms.VInputTag):
19  for t in value:
20  t2 = t
21  if not isinstance(t, cms.InputTag):
22  t2 = cms.InputTag(t2)
23  for i,moduleLabel in enumerate(moduleLabels):
24  if result[i]: continue #no need
25  if t2.getModuleLabel() == moduleLabel:
26  result[i]=True
27  elif isinstance(value, cms.InputTag):
28  for i,moduleLabel in enumerate(moduleLabels):
29  if result[i]: continue #no need
30  if value.getModuleLabel() == moduleLabel:
31  result[i]=True
32  elif isinstance(value, cms.string) and name == "refToPSet_":
33  try:
34  ps = getattr(process, value.value())
35  except AttributeError:
36  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()))
37  _hasInputTagModuleLabel(process, ps, psetModLabel, moduleLabels, result)
38 
39 

Referenced by customiseEarlyDelete().

◆ customiseEarlyDelete()

def earlyDeleteSettings_cff.customiseEarlyDelete (   process)

Definition at line 40 of file earlyDeleteSettings_cff.py.

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

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

Referenced by ConfigBuilder.ConfigBuilder.prepare().

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
earlyDeleteSettings_cff.customiseEarlyDelete
def customiseEarlyDelete(process)
Definition: earlyDeleteSettings_cff.py:40
customiseEarlyDeleteForSeeding
Definition: customiseEarlyDeleteForSeeding.py:1
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
customiseEarlyDeleteForCandIsoDeposits
Definition: customiseEarlyDeleteForCandIsoDeposits.py:1
earlyDeleteSettings_cff._hasInputTagModuleLabel
def _hasInputTagModuleLabel(process, pset, psetModLabel, moduleLabels, result)
Definition: earlyDeleteSettings_cff.py:10