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