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 import six
10 
11 def _hasInputTagModuleLabel(process, pset, moduleLabels,result):
12  for name in pset.parameterNames_():
13  value = getattr(pset,name)
14  if isinstance(value, cms.PSet):
15  _hasInputTagModuleLabel(process, value, moduleLabels,result)
16  elif isinstance(value, cms.VPSet):
17  for ps in value:
18  _hasInputTagModuleLabel(process, ps, moduleLabels,result)
19  elif isinstance(value, cms.VInputTag):
20  for t in value:
21  t2 = t
22  if not isinstance(t, cms.InputTag):
23  t2 = cms.InputTag(t2)
24  for i,moduleLabel in enumerate(moduleLabels):
25  if result[i]: continue #no need
26  if t2.getModuleLabel() == moduleLabel:
27  result[i]=True
28  elif isinstance(value, cms.InputTag):
29  for i,moduleLabel in enumerate(moduleLabels):
30  if result[i]: continue #no need
31  if value.getModuleLabel() == moduleLabel:
32  result[i]=True
33  elif isinstance(value, cms.string) and name == "refToPSet_":
34  _hasInputTagModuleLabel(process, getattr(process, value.value()), moduleLabels,result)
35 
36 
37 def customiseEarlyDelete(process):
38  # Mapping label -> [branches]
39  # for the producers whose products are to be deleted early
40  products = collections.defaultdict(list)
41 
42  products = customiseEarlyDeleteForSeeding(process, products)
43 
44  products = customiseEarlyDeleteForCandIsoDeposits(process, products)
45 
46  # Set process.options.canDeleteEarly
47  if not hasattr(process.options, "canDeleteEarly"):
48  process.options.canDeleteEarly = cms.untracked.vstring()
49 
50  branchSet = set()
51  for branches in six.itervalues(products):
52  for branch in branches:
53  branchSet.add(branch)
54  process.options.canDeleteEarly.extend(list(branchSet))
55 
56  # LogErrorHarvester should not wait for deleted items
57  for prod in six.itervalues(process.producers_()):
58  if prod.type_() == "LogErrorHarvester":
59  if not hasattr(prod,'excludeModules'):
60  prod.excludeModules = cms.untracked.vstring()
61  t = prod.excludeModules.value()
62  t.extend([b.split('_')[1] for b in branchSet])
63  prod.excludeModules = t
64 
65  # Find the consumers
66  producers=[]
67  branchesList=[]
68  for producer, branches in six.iteritems(products):
69  producers.append(producer)
70  branchesList.append(branches)
71 
72  for moduleType in [process.producers_(), process.filters_(), process.analyzers_()]:
73  for name, module in six.iteritems(moduleType):
74  result=[]
75  for producer in producers:
76  result.append(False)
77 
78  _hasInputTagModuleLabel(process, module, producers,result)
79  for i in range(len(result)):
80  if result[i]:
81  if hasattr(module, "mightGet"):
82  module.mightGet.extend(branchesList[i])
83  else:
84  module.mightGet = cms.untracked.vstring(branchesList[i])
85  return process
86 
87 
88 if __name__=="__main__":
89  import unittest
90 
91  class TestHasInputTagModuleLabel(unittest.TestCase):
92  def setUp(self):
93  """Nothing to do """
94  None
96  p = cms.Process("A")
97  p.pset = cms.PSet(a=cms.InputTag("a"),a2=cms.untracked.InputTag("a2"))
98  p.prod = cms.EDProducer("Producer",
99  foo = cms.InputTag("foo"),
100  foo2 = cms.InputTag("foo2", "instance"),
101  foo3 = cms.InputTag("foo3", "instance", "PROCESS"),
102  foo4 = cms.untracked.InputTag("foo4"),
103  nested = cms.PSet(
104  bar = cms.InputTag("bar"),
105  bar2 = cms.untracked.InputTag("bar2"),
106  ),
107  nested2 = cms.untracked.PSet(
108  bar3 = cms.untracked.InputTag("bar3"),
109  ),
110  flintstones = cms.VPSet(
111  cms.PSet(fred=cms.InputTag("fred")),
112  cms.PSet(wilma=cms.InputTag("wilma"))
113  ),
114  flintstones2 = cms.VPSet(
115  cms.PSet(fred2=cms.untracked.InputTag("fred2")),
116  cms.PSet(wilma2=cms.InputTag("wilma2"))
117  ),
118  ref = cms.PSet(
119  refToPSet_ = cms.string("pset")
120  ),
121  ref2 = cms.untracked.PSet(
122  refToPSet_ = cms.string("pset")
123  ),
124  )
125 
126  result=[False,False,False,False,False,False,False,False,False,False,False,False,False,False]
127  _hasInputTagModuleLabel(p, p.prod, ["foo","foo2","foo3","bar","fred","wilma","a","foo4","bar2","bar3","fred2","wilma2","a2","joe"],result)
128  for i in range (0,13):
129  self.assert_(result[i])
130  self.assert_(not result[13])
131 
132  unittest.main()
def _hasInputTagModuleLabel(process, pset, moduleLabels, result)
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