CMS 3D CMS Logo

customiseEarlyDeleteForCKF.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 import collections
4 
5 def customiseEarlyDeleteForCKF(process, products):
6 
7  references = collections.defaultdict(list)
8 
9  if "trackExtenderWithMTD" not in process.producerNames():
10  return (products, references)
11 
12  def _branchName(productType, moduleLabel, instanceLabel=""):
13  return "%s_%s_%s_%s" % (productType, moduleLabel, instanceLabel, process.name_())
14 
15  trajectoryLabels = []
16  trackListMergers = []
17  def _addProduct(name):
18  products[name].append(_branchName("Trajectorys", name))
19  products[name].append(_branchName("TrajectorysToOnerecoTracksAssociation", name))
20  references[_branchName("TrajectorysToOnerecoTracksAssociation", name)] = [_branchName("Trajectorys", name)]
21  trajectoryLabels.append(name)
22 
23  for name, module in process.producers_().items():
24  cppType = module.type_()
25  if cppType == "TrackProducer":
26  if module.TrajectoryInEvent:
27  _addProduct(name)
28  elif cppType == "DuplicateListMerger":
29  if module.copyTrajectories:
30  _addProduct(name)
31  elif cppType == "TrackListMerger":
32  trackListMergers.append(module)
33 
34  # TrackListMerger copies Trajectory collections silently, so we
35  # add its Trajectory products only if we know from above the input
36  # has Trajectory collections. Note that this property is transitive.
37  def _containsTrajectory(vinputtag):
38  for t in vinputtag:
39  t2 = t
40  if not isinstance(t, cms.VInputTag):
41  t2 = cms.InputTag(t)
42  for label in trajectoryLabels:
43  if t2.getModuleLabel() == label:
44  return True
45  return False
46 
47  changed = True
48  while changed:
49  changed = False
50  noTrajectoryYet = []
51  for tlm in trackListMergers:
52  if _containsTrajectory(tlm.TrackProducers):
53  _addProduct(tlm.label())
54  changed = True
55  else:
56  noTrajectoryYet.append(tlm)
57  trackListMergers = noTrajectoryYet
58 
59  return (products, references)
def customiseEarlyDeleteForCKF(process, products)