CMS 3D CMS Logo

earlyDeleteSettings_cff.py
Go to the documentation of this file.
1 # Abstract all early deletion settings here
2 
3 import collections
4 
5 import FWCore.ParameterSet.Config as cms
6 
7 from RecoTracker.Configuration.customiseEarlyDeleteForSeeding import customiseEarlyDeleteForSeeding
8 from CommonTools.ParticleFlow.Isolation.customiseEarlyDeleteForCandIsoDeposits import customiseEarlyDeleteForCandIsoDeposits
9 
10 def _hasInputTagModuleLabel(process, pset, moduleLabel):
11  for name in pset.parameterNames_():
12  value = getattr(pset,name)
13  if isinstance(value, cms.PSet):
14  if _hasInputTagModuleLabel(process, value, moduleLabel):
15  return True
16  elif isinstance(value, cms.VPSet):
17  for ps in value:
18  if _hasInputTagModuleLabel(process, ps, moduleLabel):
19  return True
20  elif isinstance(value, cms.VInputTag):
21  for t in value:
22  t2 = t
23  if not isinstance(t, cms.InputTag):
24  t2 = cms.InputTag(t2)
25  if t2.getModuleLabel() == moduleLabel:
26  return True
27  elif isinstance(value, cms.InputTag):
28  if value.getModuleLabel() == moduleLabel:
29  return True
30  if isinstance(value, cms.string) and name == "refToPSet_":
31  return _hasInputTagModuleLabel(process, getattr(process, value.value()), moduleLabel)
32  return False
33 
34 def customiseEarlyDelete(process):
35  # Mapping label -> [branches]
36  # for the producers whose products are to be deleted early
37  products = collections.defaultdict(list)
38 
39  products = customiseEarlyDeleteForSeeding(process, products)
40 
41  products = customiseEarlyDeleteForCandIsoDeposits(process, products)
42 
43  # Set process.options.canDeleteEarly
44  if not hasattr(process.options, "canDeleteEarly"):
45  process.options.canDeleteEarly = cms.untracked.vstring()
46 
47  branchSet = set()
48  for branches in products.itervalues():
49  for branch in branches:
50  branchSet.add(branch)
51  process.options.canDeleteEarly.extend(list(branchSet))
52 
53  # Find the consumers
54  for moduleType in [process.producers_(), process.filters_(), process.analyzers_()]:
55  for name, module in moduleType.iteritems():
56  for producer, branches in products.iteritems():
57  if _hasInputTagModuleLabel(process, module, producer):
58  #print "Module %s mightGet %s" % (name, str(branches))
59  if hasattr(module, "mightGet"):
60  module.mightGet.extend(branches)
61  else:
62  module.mightGet = cms.untracked.vstring(branches)
63  return process
64 
65 
66 if __name__=="__main__":
67  import unittest
68 
69  class TestHasInputTagModuleLabel(unittest.TestCase):
70  def setUp(self):
71  """Nothing to do """
72  None
74  p = cms.Process("A")
75  p.pset = cms.PSet(a=cms.InputTag("a"),a2=cms.untracked.InputTag("a2"))
76  p.prod = cms.EDProducer("Producer",
77  foo = cms.InputTag("foo"),
78  foo2 = cms.InputTag("foo2", "instance"),
79  foo3 = cms.InputTag("foo3", "instance", "PROCESS"),
80  foo4 = cms.untracked.InputTag("foo4"),
81  nested = cms.PSet(
82  bar = cms.InputTag("bar"),
83  bar2 = cms.untracked.InputTag("bar2"),
84  ),
85  nested2 = cms.untracked.PSet(
86  bar3 = cms.untracked.InputTag("bar3"),
87  ),
88  flintstones = cms.VPSet(
89  cms.PSet(fred=cms.InputTag("fred")),
90  cms.PSet(wilma=cms.InputTag("wilma"))
91  ),
92  flintstones2 = cms.VPSet(
93  cms.PSet(fred2=cms.untracked.InputTag("fred2")),
94  cms.PSet(wilma2=cms.InputTag("wilma2"))
95  ),
96  ref = cms.PSet(
97  refToPSet_ = cms.string("pset")
98  ),
99  ref2 = cms.untracked.PSet(
100  refToPSet_ = cms.string("pset")
101  ),
102  )
103 
104  self.assert_(_hasInputTagModuleLabel(p, p.prod, "foo"))
105  self.assert_(_hasInputTagModuleLabel(p, p.prod, "foo2"))
106  self.assert_(_hasInputTagModuleLabel(p, p.prod, "foo3"))
107  self.assert_(_hasInputTagModuleLabel(p, p.prod, "bar"))
108  self.assert_(_hasInputTagModuleLabel(p, p.prod, "fred"))
109  self.assert_(_hasInputTagModuleLabel(p, p.prod, "wilma"))
110  self.assert_(_hasInputTagModuleLabel(p, p.prod, "a"))
111  self.assert_(_hasInputTagModuleLabel(p, p.prod, "foo4"))
112  self.assert_(_hasInputTagModuleLabel(p, p.prod, "bar2"))
113  self.assert_(_hasInputTagModuleLabel(p, p.prod, "bar3"))
114  self.assert_(_hasInputTagModuleLabel(p, p.prod, "fred2"))
115  self.assert_(_hasInputTagModuleLabel(p, p.prod, "wilma2"))
116  self.assert_(_hasInputTagModuleLabel(p, p.prod, "a2"))
117  self.assert_(not _hasInputTagModuleLabel(p, p.prod, "joe"))
118 
119  unittest.main()
def _hasInputTagModuleLabel(process, pset, moduleLabel)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run