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