Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-21 23:14:05

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 import collections
0004 
0005 def customiseEarlyDeleteForCKF(process, products):
0006 
0007     if "trackExtenderWithMTD" not in process.producerNames():
0008         return products
0009 
0010     def _branchName(productType, moduleLabel, instanceLabel=""):
0011         return "%s_%s_%s_%s" % (productType, moduleLabel, instanceLabel, process.name_())
0012 
0013     trajectoryLabels = []
0014     trackListMergers = []
0015     def _addProduct(name):
0016         products[name].append(_branchName("Trajectorys", name))
0017         products[name].append(_branchName("TrajectorysToOnerecoTracksAssociation", name))
0018         trajectoryLabels.append(name)
0019 
0020     for name, module in process.producers_().items():
0021         cppType = module.type_()
0022         if cppType == "TrackProducer":
0023             if module.TrajectoryInEvent:
0024                 _addProduct(name)
0025         elif cppType == "DuplicateListMerger":
0026             if module.copyTrajectories:
0027                 _addProduct(name)
0028         elif cppType == "TrackListMerger":
0029             trackListMergers.append(module)
0030 
0031     # TrackListMerger copies Trajectory collections silently, so we
0032     # add its Trajectory products only if we know from above the input
0033     # has Trajectory collections. Note that this property is transitive.
0034     def _containsTrajectory(vinputtag):
0035         for t in vinputtag:
0036             t2 = t
0037             if not isinstance(t, cms.VInputTag):
0038                 t2 = cms.InputTag(t)
0039             for label in trajectoryLabels:
0040                 if t2.getModuleLabel() == label:
0041                     return True
0042         return False
0043 
0044     changed = True
0045     while changed:
0046         changed = False
0047         noTrajectoryYet = []
0048         for tlm in trackListMergers:
0049             if _containsTrajectory(tlm.TrackProducers):
0050                 _addProduct(tlm.label())
0051                 changed = True
0052             else:
0053                 noTrajectoryYet.append(tlm)
0054         trackListMergers = noTrajectoryYet
0055 
0056     return products