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