CMS 3D CMS Logo

iterativeTkConfig.py
Go to the documentation of this file.
1 # This file is the authoritative source of the order of tracking
2 # iterations. It is used in RECO, DQM, and VALIDATION. Note that here
3 # InitialStepPreSplitting is not counted as an iteration.
4 import FWCore.ParameterSet.Config as cms
5 
6 _defaultEraName = ""
7 _nonDefaultEraNames = ["trackingLowPU", "trackingPhase1", "trackingPhase2PU140"]
8 
9 # name, postfix, era
10 _defaultEra = (_defaultEraName, "", None)
11 _nonDefaultEras = [
12  (_name, "_"+_name, getattr(__import__('Configuration.Eras.Modifier_'+_name+'_cff',globals(),locals(),[_name],0),_name)) \
13  for _name in _nonDefaultEraNames
14 ]
15 
16 _allEras = [_defaultEra] + _nonDefaultEras
17 
18 
19 _iterations = [
20  "InitialStep",
21  "DetachedTripletStep",
22  "LowPtTripletStep",
23  "PixelPairStep",
24  "MixedTripletStep",
25  "PixelLessStep",
26  "TobTecStep",
27  "JetCoreRegionalStep",
28 ]
29 _iterations_trackingLowPU = [
30  "InitialStep",
31  "LowPtTripletStep",
32  "PixelPairStep",
33  "DetachedTripletStep",
34  "MixedTripletStep",
35  "PixelLessStep",
36  "TobTecStep",
37 ]
38 _iterations_trackingPhase1 = [
39  "InitialStep",
40  "LowPtQuadStep",
41  "HighPtTripletStep",
42  "LowPtTripletStep",
43  "DetachedQuadStep",
44  "DetachedTripletStep",
45  "PixelPairStep",
46  "MixedTripletStep",
47  "PixelLessStep",
48  "TobTecStep",
49 ]
50 
51 from Configuration.ProcessModifiers.displacedTracking_cff import displacedTracking
52 displacedTracking.toModify(_iterations_trackingPhase1, func=lambda x: x.append('DisplacedGeneralStep'))
53 
54 _iterations_trackingPhase1.append('JetCoreRegionalStep')
55 
56 _iterations_trackingPhase2PU140_VS = cms.PSet(names = cms.vstring(
57  "InitialStep",
58  "HighPtTripletStep",
59  "LowPtQuadStep",
60  "LowPtTripletStep",
61  "DetachedQuadStep",
62  "PixelPairStep",
63 ))
64 from Configuration.ProcessModifiers.vectorHits_cff import vectorHits
65 vectorHits.toModify(_iterations_trackingPhase2PU140_VS.names, func=lambda x: x.append('PixelLessStep'))
66 from Configuration.ProcessModifiers.trackingIters01_cff import trackingIters01
67 trackingIters01.toModify(_iterations_trackingPhase2PU140_VS, names = ["InitialStep", "HighPtTripletStep"])
68 # apply all procModifiers before this
69 _iterations_trackingPhase2PU140 = _iterations_trackingPhase2PU140_VS.names.value()
70 
71 from Configuration.ProcessModifiers.jetCoreInPhase2_cff import jetCoreInPhase2
72 jetCoreInPhase2.toModify(_iterations_trackingPhase2PU140, func=lambda x: x.append('JetCoreRegionalStep'))
73 
74 _iterations_muonSeeded = [
75  "MuonSeededStepInOut",
76  "MuonSeededStepOutIn",
77 ]
78 _iterations_muonSeeded_trackingPhase1 = [
79  "MuonSeededStepInOut",
80  "MuonSeededStepOutIn",
81 ]
82 #Phase2
83 _iterations_muonSeeded_trackingPhase2PU140_VS = cms.PSet(names = cms.vstring(
84  "MuonSeededStepInOut",
85  "MuonSeededStepOutIn",
86 ))
87 trackingIters01.toModify(_iterations_muonSeeded_trackingPhase2PU140_VS, names = [])
88 _iterations_muonSeeded_trackingPhase2PU140 = _iterations_muonSeeded_trackingPhase2PU140_VS.names.value()
89 
90 _multipleSeedProducers = {
91  "MixedTripletStep": ["A", "B"],
92  "TobTecStep": ["Pair", "Tripl"],
93 }
94 _multipleSeedProducers_trackingLowPU = {
95  "MixedTripletStep": ["A", "B"],
96 }
97 _multipleSeedProducers_trackingPhase1 = {
98  "PixelPairStep": ["A", "B"],
99  "MixedTripletStep": ["A", "B"],
100  "TobTecStep": ["Pair", "Tripl"],
101 }
102 from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
103 seedingDeepCore.toModify(_multipleSeedProducers_trackingPhase1, func=lambda x: x.update({"JetCoreRegionalStep": ["Barrel","Endcap"]}))
104 
105 
106 _multipleSeedProducers_trackingPhase2PU140 = {}
107 _oldStyleHasSelector = set([
108  "InitialStep",
109  "HighPtTripletStep",
110  "LowPtQuadStep",
111  "LowPtTripletStep",
112  "PixelPairStep",
113  "PixelLessStep",
114  "TobTecStep",
115 ])
116 
117 from Configuration.ProcessModifiers.displacedRegionalTracking_cff import displacedRegionalTracking
118 displacedRegionalTracking.toModify(_iterations_muonSeeded_trackingPhase1, func=lambda x: x.append('DisplacedRegionalStep'))
119 displacedRegionalTracking.toModify(_multipleSeedProducers_trackingPhase1, func=lambda x: x.update({'DisplacedRegionalStep': ['Pair', 'Tripl']}))
120 
121 from RecoLocalTracker.SubCollectionProducers.trackClusterRemover_cfi import trackClusterRemover as _trackClusterRemover
122 _trackClusterRemoverBase = _trackClusterRemover.clone(
123  maxChi2 = 9.0,
124  pixelClusters = "siPixelClusters",
125  stripClusters = "siStripClusters",
126  TrackQuality = 'highPurity',
127  minNumberOfLayersWithMeasBeforeFiltering = 0,
128 )
129 
130 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
131 from Configuration.ProcessModifiers.trackdnn_cff import trackdnn
132 (pp_on_AA & (~trackdnn) ).toModify(_trackClusterRemoverBase, TrackQuality = 'tight')
133 
134 #Phase2 : configuring the phase2 track Cluster Remover
135 from RecoLocalTracker.SubCollectionProducers.phase2trackClusterRemover_cfi import phase2trackClusterRemover as _phase2trackClusterRemover
136 _trackClusterRemoverBase_trackingPhase2PU140 = _phase2trackClusterRemover.clone(
137  maxChi2 = 9.0,
138  phase2pixelClusters = "siPixelClusters",
139  phase2OTClusters = "siPhase2Clusters",
140  TrackQuality = 'highPurity',
141  minNumberOfLayersWithMeasBeforeFiltering = 0,
142 )
143 
144 def _modulePrefix(iteration):
145  return iteration[0].lower()+iteration[1:]
146 
147 def _clusterRemover(iteration):
148  return _modulePrefix(iteration)+"Clusters"
149 
150 def _tracks(iteration):
151  return _modulePrefix(iteration)+"Tracks"
152 
153 def _classifier(iteration, oldStyle=False, oldStyleQualityMasks=False):
154  pre = _modulePrefix(iteration)
155  if oldStyle:
156  if iteration in _oldStyleHasSelector:
157  return pre+"Selector:" + ("QualityMasks" if oldStyleQualityMasks else pre)
158  else:
159  return pre
160  else:
161  return pre+":QualityMasks"
162 
163 def allEras():
164  return _allEras
165 
167  return _nonDefaultEras
168 
169 def createEarlyTask(eraName, postfix, modDict):
170  task = cms.Task()
171  for it in globals()["_iterations"+postfix]:
172  task.add(modDict[it+'Task'])
173  return task
174 
175 def iterationAlgos(postfix, includeSequenceName=False):
176  muonVariable = "_iterations_muonSeeded"+postfix
177  iterations = globals()["_iterations"+postfix] + globals().get(muonVariable, _iterations_muonSeeded)
178 
179  if includeSequenceName:
180  return [(_modulePrefix(i), i) for i in iterations]
181  else:
182  return [_modulePrefix(i) for i in iterations]
183 
184 def _seedOrTrackProducers(postfix, typ):
185  ret = []
186  iters = globals()["_iterations"+postfix]
187  if typ == "Seeds":
188  multipleSeedProducers = globals()["_multipleSeedProducers"+postfix]
189  else:
190  multipleSeedProducers = None
191  for i in iters:
192  seeder = _modulePrefix(i)+typ
193  if multipleSeedProducers is not None and i in multipleSeedProducers:
194  ret.extend([seeder+m for m in multipleSeedProducers[i]])
195  else:
196  ret.append(seeder)
197 
198  for i in globals().get("_iterations_muonSeeded"+postfix, _iterations_muonSeeded):
199  if _modulePrefix(i).endswith("Step"):
200  ret.append(_modulePrefix(i)+typ)
201  else:
202  ret.append(_modulePrefix(i).replace("Step", typ))
203 
204  return ret
205 
206 def seedProducers(postfix):
207  return _seedOrTrackProducers(postfix, "Seeds")
208 
209 def trackProducers(postfix):
210  return _seedOrTrackProducers(postfix, "Tracks")
211 
212 def clusterRemoverForIter(iteration, eraName="", postfix="", module=None):
213  if module is None:
214  module = _trackClusterRemoverBase.clone()
215  if eraName == "trackingPhase2PU140":
216  module = globals().get("_trackClusterRemoverBase"+postfix, _trackClusterRemoverBase)
217 
218  iters = globals()["_iterations"+postfix]
219  try:
220  # DisplacedRegionalStep is a special case because it comes after the
221  # usual muon-seeded steps
222  ind = iters.index(iteration) if iteration != "DisplacedRegionalStep" else len(iters)
223  except ValueError:
224  # if the iteration is not active in era, just return the same
225  return module
226 
227  if ind == 0:
228  raise Exception("Iteration %s is the first iteration in era %s, asking cluster remover configuration does not make sense" % (iteration, eraName))
229  prevIter = iters[ind-1]
230  # JetCoreRegionalStep uses all clusters, so if that is the previous
231  # iteration, use the one before that for cluster removal
232  if prevIter == "JetCoreRegionalStep":
233  prevIter = iters[ind-2]
234 
235  customize = dict(
236  trajectories = _tracks(prevIter),
237  oldClusterRemovalInfo = _clusterRemover(prevIter) if ind >= 2 else "", # 1st iteration does not have cluster remover
238  )
239  if eraName in ["trackingPhase2PU140"]:
240  customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True) # old-style selector
241  elif eraName == "trackingLowPU":
242  customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True, oldStyleQualityMasks=True) # old-style selector with 'QualityMasks' instance label
243  else:
244  customize["trackClassifier"] = _classifier(prevIter)
245 
246  return module.clone(**customize)
def clusterRemoverForIter(iteration, eraName="", postfix="", module=None)
def iterationAlgos(postfix, includeSequenceName=False)
def _seedOrTrackProducers(postfix, typ)
def replace(string, replacements)
def _clusterRemover(iteration)
def trackProducers(postfix)
def seedProducers(postfix)
def _classifier(iteration, oldStyle=False, oldStyleQualityMasks=False)
def createEarlyTask(eraName, postfix, modDict)
def _modulePrefix(iteration)
def _tracks(iteration)