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