Skip to content

Commit

Permalink
Update early delete customise adding TrackListMerger, courtesy of M. …
Browse files Browse the repository at this point in the history
…Kortelainen
  • Loading branch information
fabiocos committed Feb 10, 2022
1 parent 0f3bf01 commit dda4ecb
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions RecoTracker/Configuration/python/customiseEarlyDeleteForCKF.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,47 @@ def customiseEarlyDeleteForCKF(process, products):
def _branchName(productType, moduleLabel, instanceLabel=""):
return "%s_%s_%s_%s" % (productType, moduleLabel, instanceLabel, process.name_())

trajectoryLabels = []
trackListMergers = []
def _addProduct(name):
products[name].append(_branchName("Trajectorys", name))
products[name].append(_branchName("TrajectorysToOnerecoTracksAssociation", name))
trajectoryLabels.append(name)

for name, module in process.producers_().items():
cppType = module._TypedParameterizable__type
cppType = module.type_()
if cppType == "TrackProducer":
if module.TrajectoryInEvent:
products[name].append(_branchName("Trajectorys", name))
products[name].append(_branchName("TrajectorysToOnerecoTracksAssociation", name))
_addProduct(name)
elif cppType == "DuplicateListMerger":
if module.copyTrajectories:
products[name].append(_branchName("Trajectorys", name))
products[name].append(_branchName("TrajectorysToOnerecoTracksAssociation", name))
_addProduct(name)
elif cppType == "TrackListMerger":
trackListMergers.append(module)

# TrackListMerger copies Trajectory collections silently, so we
# add its Trajectory products only if we know from above the input
# has Trajectory collections. Note that this property is transitive.
def _containsTrajectory(vinputtag):
for t in vinputtag:
t2 = t
if not isinstance(t, cms.VInputTag):
t2 = cms.InputTag(t)
for label in trajectoryLabels:
if t2.getModuleLabel() == label:
return True
return False

changed = True
while changed:
changed = False
noTrajectoryYet = []
for tlm in trackListMergers:
if _containsTrajectory(tlm.TrackProducers):
_addProduct(tlm.label())
changed = True
else:
noTrajectoryYet.append(tlm)
trackListMergers = noTrajectoryYet

return products

0 comments on commit dda4ecb

Please sign in to comment.