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 #Phase2 : configuring the phase2 track Cluster Remover
101 from RecoLocalTracker.SubCollectionProducers.phase2trackClusterRemover_cfi import phase2trackClusterRemover as _phase2trackClusterRemover
102 _trackClusterRemoverBase_trackingPhase2PU140 = _phase2trackClusterRemover.clone(
103  maxChi2 = 9.0,
104  phase2pixelClusters = "siPixelClusters",
105  phase2OTClusters = "siPhase2Clusters",
106  TrackQuality = 'highPurity',
107  minNumberOfLayersWithMeasBeforeFiltering = 0,
108 )
109 
110 def _modulePrefix(iteration):
111  return iteration[0].lower()+iteration[1:]
112 
113 def _clusterRemover(iteration):
114  return _modulePrefix(iteration)+"Clusters"
115 
116 def _tracks(iteration):
117  return _modulePrefix(iteration)+"Tracks"
118 
119 def _classifier(iteration, oldStyle=False, oldStyleQualityMasks=False):
120  pre = _modulePrefix(iteration)
121  if oldStyle:
122  if iteration in _oldStyleHasSelector:
123  return pre+"Selector:" + ("QualityMasks" if oldStyleQualityMasks else pre)
124  else:
125  return pre
126  else:
127  return pre+":QualityMasks"
128 
129 def allEras():
130  return _allEras
131 
133  return _nonDefaultEras
134 
135 def createEarlyTask(eraName, postfix, modDict):
136  task = cms.Task()
137  for it in globals()["_iterations"+postfix]:
138  task.add(modDict[it+'Task'])
139  return task
140 
141 def iterationAlgos(postfix, includeSequenceName=False):
142  muonVariable = "_iterations_muonSeeded"+postfix
143  iterations = globals()["_iterations"+postfix] + globals().get(muonVariable, _iterations_muonSeeded)
144 
145  if includeSequenceName:
146  return [(_modulePrefix(i), i) for i in iterations]
147  else:
148  return [_modulePrefix(i) for i in iterations]
149 
150 def _seedOrTrackProducers(postfix, typ):
151  ret = []
152  iters = globals()["_iterations"+postfix]
153  if typ == "Seeds":
154  multipleSeedProducers = globals()["_multipleSeedProducers"+postfix]
155  else:
156  multipleSeedProducers = None
157  for i in iters:
158  seeder = _modulePrefix(i)+typ
159  if multipleSeedProducers is not None and i in multipleSeedProducers:
160  ret.extend([seeder+m for m in multipleSeedProducers[i]])
161  else:
162  ret.append(seeder)
163 
164  for i in globals().get("_iterations_muonSeeded"+postfix, _iterations_muonSeeded):
165  ret.append(_modulePrefix(i).replace("Step", typ))
166 
167  return ret
168 
169 def seedProducers(postfix):
170  return _seedOrTrackProducers(postfix, "Seeds")
171 
172 def trackProducers(postfix):
173  return _seedOrTrackProducers(postfix, "Tracks")
174 
175 def clusterRemoverForIter(iteration, eraName="", postfix="", module=None):
176  if module is None:
177  module = _trackClusterRemoverBase.clone()
178  if eraName == "trackingPhase2PU140":
179  module = globals().get("_trackClusterRemoverBase"+postfix, _trackClusterRemoverBase)
180 
181  iters = globals()["_iterations"+postfix]
182  try:
183  ind = iters.index(iteration)
184  except ValueError:
185  # if the iteration is not active in era, just return the same
186  return module
187 
188  if ind == 0:
189  raise Exception("Iteration %s is the first iteration in era %s, asking cluster remover configuration does not make sense" % (iteration, eraName))
190  prevIter = iters[ind-1]
191 
192  customize = dict(
193  trajectories = _tracks(prevIter),
194  oldClusterRemovalInfo = _clusterRemover(prevIter) if ind >= 2 else "", # 1st iteration does not have cluster remover
195  )
196  if eraName in ["trackingPhase2PU140"]:
197  customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True) # old-style selector
198  elif eraName == "trackingLowPU":
199  customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True, oldStyleQualityMasks=True) # old-style selector with 'QualityMasks' instance label
200  else:
201  customize["trackClassifier"] = _classifier(prevIter)
202 
203  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)
T get(const Candidate &c)
Definition: component.h:55
def _tracks(iteration)