Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:00

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