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