CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
customiseEarlyDeleteForSeeding.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 import collections
4 import six
5 
6 def customiseEarlyDeleteForSeeding(process, products):
7  # Find the producers
8  depends = collections.defaultdict(list)
9 
10  def _branchName(productType, moduleLabel, instanceLabel=""):
11  return "%s_%s_%s_%s" % (productType, moduleLabel, instanceLabel, process.name_())
12 
13  for name, module in six.iteritems(process.producers_()):
14  cppType = module._TypedParameterizable__type
15  if cppType == "HitPairEDProducer":
16  if module.produceSeedingHitSets:
17  products[name].append(_branchName("RegionsSeedingHitSets", name))
18  if module.produceIntermediateHitDoublets:
19  products[name].append(_branchName("IntermediateHitDoublets", name))
20  elif cppType in ["PixelTripletHLTEDProducer", "PixelTripletLargeTipEDProducer"]:
21  if module.produceSeedingHitSets:
22  products[name].append(_branchName("RegionsSeedingHitSets", name))
23  if module.produceIntermediateHitTriplets:
24  products[name].append(_branchName("IntermediateHitTriplets", name))
25  # LayerHitMapCache of the doublets is forwarded to both
26  # products, hence the dependency
27  depends[name].append(module.doublets.getModuleLabel())
28  elif cppType in ["MultiHitFromChi2EDProducer"]:
29  products[name].extend([
30  _branchName("RegionsSeedingHitSets", name),
31  _branchName("BaseTrackerRecHitsOwned", name)
32  ])
33  elif cppType in ["CAHitQuadrupletEDProducer", "CAHitTripletEDProducer"]:
34  products[name].append(_branchName("RegionsSeedingHitSets", name))
35 
36  if len(products) == 0:
37  return products
38 
39  # Resolve data dependencies
40  #
41  # If a productB depends on productA (e.g. by ref or pointer), then
42  # everybody that mightGet's producB, must also mightGet productA
43  def _resolve(keys, name):
44  for dependsOn in depends[name]:
45  if dependsOn in keys:
46  _resolve(keys, dependsOn)
47  keys.remove(dependsOn)
48  products[name].extend(products[dependsOn])
49 
50  keys = set(depends.keys())
51  while len(keys) > 0:
52  name = keys.pop()
53  _resolve(keys, name)
54 
55  return products
def customiseEarlyDeleteForSeeding(process, products)