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