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