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 = [
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, func=lambda x: x.append('PixelLessStep'))
66 
67 from Configuration.ProcessModifiers.jetCoreInPhase2_cff import jetCoreInPhase2
68 jetCoreInPhase2.toModify(_iterations_trackingPhase2PU140, func=lambda x: x.append('JetCoreRegionalStep'))
69 
70 _iterations_muonSeeded = [
71  "MuonSeededStepInOut",
72  "MuonSeededStepOutIn",
73 ]
74 _iterations_muonSeeded_trackingPhase1 = [
75  "MuonSeededStepInOut",
76  "MuonSeededStepOutIn",
77 ]
78 #Phase2
79 _iterations_muonSeeded_trackingPhase2PU140 = [
80  "MuonSeededStepInOut",
81  "MuonSeededStepOutIn",
82 ]
83 _multipleSeedProducers = {
84  "MixedTripletStep": ["A", "B"],
85  "TobTecStep": ["Pair", "Tripl"],
86 }
87 _multipleSeedProducers_trackingLowPU = {
88  "MixedTripletStep": ["A", "B"],
89 }
90 _multipleSeedProducers_trackingPhase1 = {
91  "PixelPairStep": ["A", "B"],
92  "MixedTripletStep": ["A", "B"],
93  "TobTecStep": ["Pair", "Tripl"],
94 }
95 from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
96 seedingDeepCore.toModify(_multipleSeedProducers_trackingPhase1, func=lambda x: x.update({"JetCoreRegionalStep": ["Barrel","Endcap"]}))
97 
98 
99 _multipleSeedProducers_trackingPhase2PU140 = {}
100 _oldStyleHasSelector = set([
101  "InitialStep",
102  "HighPtTripletStep",
103  "LowPtQuadStep",
104  "LowPtTripletStep",
105  "PixelPairStep",
106  "PixelLessStep",
107  "TobTecStep",
108 ])
109 
110 from Configuration.ProcessModifiers.displacedRegionalTracking_cff import displacedRegionalTracking
111 displacedRegionalTracking.toModify(_iterations_muonSeeded_trackingPhase1, func=lambda x: x.append('DisplacedRegionalStep'))
112 displacedRegionalTracking.toModify(_multipleSeedProducers_trackingPhase1, func=lambda x: x.update({'DisplacedRegionalStep': ['Pair', 'Tripl']}))
113 
114 from RecoLocalTracker.SubCollectionProducers.trackClusterRemover_cfi import trackClusterRemover as _trackClusterRemover
115 _trackClusterRemoverBase = _trackClusterRemover.clone(
116  maxChi2 = 9.0,
117  pixelClusters = "siPixelClusters",
118  stripClusters = "siStripClusters",
119  TrackQuality = 'highPurity',
120  minNumberOfLayersWithMeasBeforeFiltering = 0,
121 )
122 
123 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
124 from Configuration.ProcessModifiers.trackdnn_cff import trackdnn
125 (pp_on_AA & (~trackdnn) ).toModify(_trackClusterRemoverBase, TrackQuality = 'tight')
126 
127 #Phase2 : configuring the phase2 track Cluster Remover
128 from RecoLocalTracker.SubCollectionProducers.phase2trackClusterRemover_cfi import phase2trackClusterRemover as _phase2trackClusterRemover
129 _trackClusterRemoverBase_trackingPhase2PU140 = _phase2trackClusterRemover.clone(
130  maxChi2 = 9.0,
131  phase2pixelClusters = "siPixelClusters",
132  phase2OTClusters = "siPhase2Clusters",
133  TrackQuality = 'highPurity',
134  minNumberOfLayersWithMeasBeforeFiltering = 0,
135 )
136 
137 def _modulePrefix(iteration):
138  return iteration[0].lower()+iteration[1:]
139 
140 def _clusterRemover(iteration):
141  return _modulePrefix(iteration)+"Clusters"
142 
143 def _tracks(iteration):
144  return _modulePrefix(iteration)+"Tracks"
145 
146 def _classifier(iteration, oldStyle=False, oldStyleQualityMasks=False):
147  pre = _modulePrefix(iteration)
148  if oldStyle:
149  if iteration in _oldStyleHasSelector:
150  return pre+"Selector:" + ("QualityMasks" if oldStyleQualityMasks else pre)
151  else:
152  return pre
153  else:
154  return pre+":QualityMasks"
155 
156 def allEras():
157  return _allEras
158 
160  return _nonDefaultEras
161 
162 def createEarlyTask(eraName, postfix, modDict):
163  task = cms.Task()
164  for it in globals()["_iterations"+postfix]:
165  task.add(modDict[it+'Task'])
166  return task
167 
168 def iterationAlgos(postfix, includeSequenceName=False):
169  muonVariable = "_iterations_muonSeeded"+postfix
170  iterations = globals()["_iterations"+postfix] + globals().get(muonVariable, _iterations_muonSeeded)
171 
172  if includeSequenceName:
173  return [(_modulePrefix(i), i) for i in iterations]
174  else:
175  return [_modulePrefix(i) for i in iterations]
176 
177 def _seedOrTrackProducers(postfix, typ):
178  ret = []
179  iters = globals()["_iterations"+postfix]
180  if typ == "Seeds":
181  multipleSeedProducers = globals()["_multipleSeedProducers"+postfix]
182  else:
183  multipleSeedProducers = None
184  for i in iters:
185  seeder = _modulePrefix(i)+typ
186  if multipleSeedProducers is not None and i in multipleSeedProducers:
187  ret.extend([seeder+m for m in multipleSeedProducers[i]])
188  else:
189  ret.append(seeder)
190 
191  for i in globals().get("_iterations_muonSeeded"+postfix, _iterations_muonSeeded):
192  if _modulePrefix(i).endswith("Step"):
193  ret.append(_modulePrefix(i)+typ)
194  else:
195  ret.append(_modulePrefix(i).replace("Step", typ))
196 
197  return ret
198 
199 def seedProducers(postfix):
200  return _seedOrTrackProducers(postfix, "Seeds")
201 
202 def trackProducers(postfix):
203  return _seedOrTrackProducers(postfix, "Tracks")
204 
205 def clusterRemoverForIter(iteration, eraName="", postfix="", module=None):
206  if module is None:
207  module = _trackClusterRemoverBase.clone()
208  if eraName == "trackingPhase2PU140":
209  module = globals().get("_trackClusterRemoverBase"+postfix, _trackClusterRemoverBase)
210 
211  iters = globals()["_iterations"+postfix]
212  try:
213  # DisplacedRegionalStep is a special case because it comes after the
214  # usual muon-seeded steps
215  ind = iters.index(iteration) if iteration != "DisplacedRegionalStep" else len(iters)
216  except ValueError:
217  # if the iteration is not active in era, just return the same
218  return module
219 
220  if ind == 0:
221  raise Exception("Iteration %s is the first iteration in era %s, asking cluster remover configuration does not make sense" % (iteration, eraName))
222  prevIter = iters[ind-1]
223  # JetCoreRegionalStep uses all clusters, so if that is the previous
224  # iteration, use the one before that for cluster removal
225  if prevIter == "JetCoreRegionalStep":
226  prevIter = iters[ind-2]
227 
228  customize = dict(
229  trajectories = _tracks(prevIter),
230  oldClusterRemovalInfo = _clusterRemover(prevIter) if ind >= 2 else "", # 1st iteration does not have cluster remover
231  )
232  if eraName in ["trackingPhase2PU140"]:
233  customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True) # old-style selector
234  elif eraName == "trackingLowPU":
235  customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True, oldStyleQualityMasks=True) # old-style selector with 'QualityMasks' instance label
236  else:
237  customize["trackClassifier"] = _classifier(prevIter)
238 
239  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)