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