CMS 3D CMS Logo

TrackValidation_cff.py
Go to the documentation of this file.
1 from __future__ import absolute_import
2 import FWCore.ParameterSet.Config as cms
3 
8 from Validation.RecoTrack.trajectorySeedTracks_cfi import trajectorySeedTracks as _trajectorySeedTracks
10 import Validation.RecoTrack.cutsRecoTracks_cfi as cutsRecoTracks_cfi
11 #from . import cutsRecoTracks_cfi
12 
15 from CommonTools.RecoAlgos.trackingParticleRefSelector_cfi import trackingParticleRefSelector as _trackingParticleRefSelector
16 from CommonTools.RecoAlgos.trackingParticleConversionRefSelector_cfi import trackingParticleConversionRefSelector as _trackingParticleConversionRefSelector
17 from SimTracker.TrackHistory.trackingParticleBHadronRefSelector_cfi import trackingParticleBHadronRefSelector as _trackingParticleBHadronRefSelector
19 from CommonTools.RecoAlgos.recoChargedRefCandidateToTrackRefProducer_cfi import recoChargedRefCandidateToTrackRefProducer as _recoChargedRefCandidateToTrackRefProducer
20 
21 import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg
22 import RecoTracker.IterativeTracking.iterativeTkUtils as _utils
23 from Configuration.Eras.Modifier_fastSim_cff import fastSim
24 
25 
27 for _eraName, _postfix, _era in _cfg.allEras():
28  _seedProd = ["initialStepSeedsPreSplitting"]
29  _trackProd = ["initialStepTracksPreSplitting"]
30  if _eraName in ["trackingLowPU", "trackingPhase2PU140"]: # these don't have preSplitting
31  _seedProd = []
32  _trackProd = []
33 
34  locals()["_algos"+_postfix] = ["generalTracks"] + _cfg.iterationAlgos(_postfix) + ["duplicateMerge"]
35  locals()["_seedProducersPreSplitting"+_postfix] = _seedProd
36  locals()["_trackProducersPreSplitting"+_postfix] = _trackProd
37  locals()["_seedProducers"+_postfix] = _cfg.seedProducers(_postfix)
38  locals()["_trackProducers"+_postfix] = _cfg.trackProducers(_postfix)
39 
40  if _eraName != "trackingPhase2PU140":
41  locals()["_electronSeedProducers"+_postfix] = ["tripletElectronSeeds", "pixelPairElectronSeeds", "stripPairElectronSeeds"]
42  else:
43  locals()["_electronSeedProducers"+_postfix] = ["tripletElectronSeeds"]
44 
45 _removeForFastSimSeedProducers =["initialStepSeedsPreSplitting",
46  "jetCoreRegionalStepSeeds",
47  "jetCoreRegionalStepSeedsBarrel","jetCoreRegionalStepSeedsEndcap",
48  "displacedRegionalStepSeeds",
49  "muonSeededSeedsInOut",
50  "muonSeededSeedsOutIn"]
51 
52 _seedProducers_fastSim = [ x for x in _seedProducers if x not in _removeForFastSimSeedProducers]
53 
54 _removeForFastTrackProducers = ["initialStepTracksPreSplitting",
55  "jetCoreRegionalStepTracks",
56  "displacedRegionalStepTracks",
57  "muonSeededTracksInOut",
58  "muonSeededTracksOutIn"]
59 _trackProducers_fastSim = [ x for x in _trackProducers if x not in _removeForFastTrackProducers]
60 
61 def _algoToSelector(algo):
62  sel = ""
63  if algo != "generalTracks":
64  sel = algo[0].upper()+algo[1:]
65  return "cutsRecoTracks"+sel
66 
67 def _addSelectorsByAlgo(algos, modDict):
68  names = []
69  task = cms.Task()
70  for algo in algos:
71  if algo == "generalTracks":
72  continue
73  modName = _algoToSelector(algo)
74  if modName not in modDict:
75  mod = cutsRecoTracks_cfi.cutsRecoTracks.clone(
76 # src = [src],
77  algorithm=[algo]
78  )
79  modDict[modName] = mod
80  else:
81  mod = modDict[modName]
82  names.append(modName)
83  task.add(mod)
84  return (names, task)
85 def _addSelectorsByHp(algos, modDict):
86  task = cms.Task()
87  names = []
88  for algo in algos:
89  modName = _algoToSelector(algo)
90  modNameHp = modName+"Hp"
91  if modNameHp not in modDict:
92  if algo == "generalTracks":
93  mod = cutsRecoTracks_cfi.cutsRecoTracks.clone(quality=["highPurity"])
94  else:
95  mod = modDict[modName].clone(quality=["highPurity"])
96  modDict[modNameHp] = mod
97  else:
98  mod = modDict[modNameHp]
99  names.append(modNameHp)
100  task.add(mod)
101  return (names, task)
102 def _addSelectorsBySrc(modules, midfix, src, modDict):
103  task = cms.Task()
104  names = []
105  for modName in modules:
106  modNameNew = modName.replace("cutsRecoTracks", "cutsRecoTracks"+midfix)
107  if modNameNew not in modDict:
108  mod = modDict[modName].clone(src=src)
109  modDict[modNameNew] = mod
110  else:
111  mod = modDict[modNameNew]
112  names.append(modNameNew)
113  task.add(mod)
114  return (names, task)
115 def _addSelectorsByOriginalAlgoMask(modules, midfix, algoParam,modDict):
116  task = cms.Task()
117  names = []
118  for modName in modules:
119  if modName[-2:] == "Hp":
120  modNameNew = modName[:-2] + midfix + "Hp"
121  else:
122  modNameNew = modName + midfix
123  if modNameNew not in modDict:
124  mod = modDict[modName].clone()
125  setattr(mod, algoParam, mod.algorithm.value())
126  mod.algorithm = []
127  modDict[modNameNew] = mod
128  else:
129  mod = modDict[modNameNew]
130  names.append(modNameNew)
131  task.add(mod)
132  return (names, task)
133 def _addSeedToTrackProducers(seedProducers,modDict):
134  names = []
135  task = cms.Task()
136  for seed in seedProducers:
137  modName = "seedTracks"+seed
138  if modName not in modDict:
139  mod = _trajectorySeedTracks.clone(src=seed)
140  modDict[modName] = mod
141  else:
142  mod = modDict[modName]
143  names.append(modName)
144  task.add(mod)
145  return (names, task)
146 
147 _relevantEras = _cfg.allEras()
148 _relevantErasAndFastSim = _relevantEras + [("fastSim", "_fastSim", fastSim)]
149 def _translateArgs(args, postfix, modDict):
150  ret = []
151  for arg in args:
152  if isinstance(arg, list):
153  ret.append(_translateArgs(arg, postfix, modDict))
154  else:
155  ret.append(modDict[arg+postfix])
156  return ret
157 def _taskForEachEra(function, args, names, task, modDict, plainArgs=[], modifyTask=None, includeFastSim=False):
158  if task[0] != "_":
159  raise Exception("Task name is expected to begin with _")
160 
161  _eras = _relevantErasAndFastSim if includeFastSim else _relevantEras
162  for eraName, postfix, _era in _eras:
163  _args = _translateArgs(args, postfix, modDict)
164  _args.extend(plainArgs)
165  ret = function(*_args, modDict=modDict)
166  if len(ret) != 2:
167  raise Exception("_taskForEachEra is expected to return 2 values, but function returned %d" % len(ret))
168  modDict[names+postfix] = ret[0]
169  modDict[task+postfix] = ret[1]
170 
171  # The task of the first era will be the default one
172  defaultTaskName = task+_eras[0][0]
173  defaultTask = modDict[defaultTaskName]
174  modDict[defaultTaskName[1:]] = defaultTask # remove leading underscore
175 
176  # Optionally modify task before applying the era
177  if modifyTask is not None:
178  for eraName, postfix, _era in _eras:
179  modifyTask(modDict[task+postfix])
180 
181  # Apply eras
182  for _eraName, _postfix, _era in _eras[1:]:
183  _era.toReplaceWith(defaultTask, modDict[task+_postfix])
184 def _setForEra(module, eraName, era, **kwargs):
185  if eraName == "":
186  for key, value in kwargs.items():
187  setattr(module, key, value)
188  else:
189  era.toModify(module, **kwargs)
190 
191 # Seeding layer sets
192 def _getSeedingLayers(seedProducers, config):
193  def _findSeedingLayers(name):
194  prod = getattr(config, name)
195  if hasattr(prod, "triplets"):
196  if hasattr(prod, "layerList"): # merger
197  return prod.layerList.refToPSet_.value()
198  return _findSeedingLayers(prod.triplets.getModuleLabel())
199  elif hasattr(prod, "doublets"):
200  return _findSeedingLayers(prod.doublets.getModuleLabel())
201  label = prod.trackingRegionsSeedingLayers.getModuleLabel()
202  if label != "":
203  return label
204  return prod.seedingLayers.getModuleLabel()
205 
206  seedingLayersMerged = []
207  for seedName in seedProducers:
208  seedProd = getattr(config, seedName)
209  seedingLayersName = None
210  seedingLayers = None
211  if hasattr(seedProd, "OrderedHitsFactoryPSet"): # old seeding framework
212  seedingLayersName = seedProd.OrderedHitsFactoryPSet.SeedingLayers.getModuleLabel()
213  elif hasattr(seedProd, "seedingHitSets"): # new seeding framework
214  seedingLayersName = _findSeedingLayers(seedProd.seedingHitSets.getModuleLabel())
215  elif hasattr(seedProd, "layerList"): # FastSim:
216  seedingLayers = seedProd.layerList.value()
217  else:
218  continue
219 
220  if seedingLayersName is not None:
221  seedingLayers = getattr(config, seedingLayersName).layerList.value()
222  for layerSet in seedingLayers:
223  if layerSet not in seedingLayersMerged:
224  seedingLayersMerged.append(layerSet)
225 
226  return seedingLayersMerged
227 import RecoTracker.IterativeTracking.iterativeTk_cff as _iterativeTk_cff
228 import RecoTracker.IterativeTracking.ElectronSeeds_cff as _ElectronSeeds_cff
229 for _eraName, _postfix, _era in _relevantErasAndFastSim:
230  _stdLayers = _getSeedingLayers(locals()["_seedProducers"+_postfix], _iterativeTk_cff)
231  _eleLayers = []
232  if "_electronSeedProducers"+_postfix in locals(): # doesn't exist for FastSim
233  for _layer in _getSeedingLayers(locals()["_electronSeedProducers"+_postfix], _ElectronSeeds_cff):
234  if _layer not in _stdLayers:
235  _eleLayers.append(_layer)
236 
237  locals()["_seedingLayerSets"+_postfix] = _stdLayers
238  locals()["_seedingLayerSetsForElectrons"+_postfix] = _eleLayers
239 
240 
241 # MVA selectors
242 def _getMVASelectors(postfix):
243  mvaSel = _utils.getMVASelectors(postfix)
244 
245  pset = cms.untracked.PSet()
246  for iteration, (trackProducer, classifiers) in mvaSel.items():
247  setattr(pset, trackProducer, cms.untracked.vstring(classifiers))
248  return pset
249 for _eraName, _postfix, _era in _relevantEras:
250  locals()["_mvaSelectors"+_postfix] = _getMVASelectors(_postfix)
251 
252 # Validation iterative steps
253 _taskForEachEra(_addSelectorsByAlgo, args=["_algos"], names="_selectorsByAlgo", task="_tracksValidationSelectorsByAlgo", modDict=globals())
254 
255 # high purity
256 _taskForEachEra(_addSelectorsByHp, args=["_algos"], names="_selectorsByAlgoHp", task="_tracksValidationSelectorsByAlgoHp", modDict=globals())
257 
258 # by originalAlgo
259 for _eraName, _postfix, _era in _relevantEras:
260  locals()["_selectorsByAlgoAndHp"+_postfix] = locals()["_selectorsByAlgo"+_postfix] + locals()["_selectorsByAlgoHp"+_postfix]
261  # For ByAlgoMask
262  locals()["_selectorsByAlgoAndHpNoGenTk"+_postfix] = [n for n in locals()["_selectorsByAlgoAndHp"+_postfix] if n not in ["generalTracks", "cutsRecoTracksHp"]]
263  # For ByOriginalAlgo
264  locals()["_selectorsByAlgoAndHpNoGenTkDupMerge"+_postfix] = [n for n in locals()["_selectorsByAlgoAndHpNoGenTk"+_postfix] if n not in ["cutsRecoTracksDuplicateMerge", "cutsRecoTracksDuplicateMergeHp"]]
265 _taskForEachEra(_addSelectorsByOriginalAlgoMask, modDict = globals(),
266  args = ["_selectorsByAlgoAndHpNoGenTkDupMerge"], plainArgs = ["ByOriginalAlgo", "originalAlgorithm"],
267  names = "_selectorsByOriginalAlgo", task = "_tracksValidationSelectorsByOriginalAlgo")
268 
269 
270 for _eraName, _postfix, _era in _relevantEras:
271  selectors = locals()["_selectorsByAlgoHp"+_postfix]
272  locals()["_generalTracksHp"+_postfix] = selectors[0]
273  locals()["_selectorsByAlgoHp"+_postfix] = selectors[1:]
274 
275 # BTV-like selection
276 import PhysicsTools.RecoAlgos.btvTracks_cfi as btvTracks_cfi
277 cutsRecoTracksBtvLike = btvTracks_cfi.btvTrackRefs.clone()
278 
279 # Select tracks associated to AK4 jets
281 ak4JetTracksAssociatorExplicitAll = ak4JTA_cff.ak4JetTracksAssociatorExplicit.clone(
282  jets = "ak4PFJets"
283 )
285 import JetMETCorrections.JetCorrector.jetTracksAssociationToTrackRefs_cfi as jetTracksAssociationToTrackRefs_cfi
286 cutsRecoTracksAK4PFJets = jetTracksAssociationToTrackRefs_cfi.jetTracksAssociationToTrackRefs.clone(
287  association = "ak4JetTracksAssociatorExplicitAll",
288  jets = "ak4PFJets",
289  correctedPtMin = 10,
290 )
291 
292 
293 
294 trackingParticlesSignal = _trackingParticleRefSelector.clone(
295  signalOnly = True,
296  chargedOnly = False,
297  tip = 1e5,
298  lip = 1e5,
299  minRapidity = -10,
300  maxRapidity = 10,
301  ptMin = 0,
302 )
303 
304 trackingParticlesInTime = trackingParticlesSignal.clone(
305  signalOnly = False,
306  intimeOnly = True,
307 )
308 
309 # select tracks with pT > 0.9 GeV (for upgrade fake rates)
310 generalTracksPt09 = cutsRecoTracks_cfi.cutsRecoTracks.clone(ptMin=0.9)
311 # and then the selectors
312 _taskForEachEra(_addSelectorsBySrc, modDict=globals(),
313  args=[["_generalTracksHp"]],
314  plainArgs=["Pt09", "generalTracksPt09"],
315  names="_selectorsPt09", task="_tracksValidationSelectorsPt09",
316  modifyTask=lambda task:task.add(generalTracksPt09))
317 
318 # select tracks from the PV
319 from CommonTools.RecoAlgos.TrackWithVertexRefSelector_cfi import trackWithVertexRefSelector as _trackWithVertexRefSelector
320 generalTracksFromPV = _trackWithVertexRefSelector.clone(
321  src = "generalTracks",
322  ptMin = 0,
323  ptMax = 1e10,
324  ptErrorCut = 1e10,
325  quality = "loose",
326  vertexTag = "offlinePrimaryVertices",
327  nVertices = 1,
328  vtxFallback = False,
329  zetaVtx = 0.1, # 1 mm
330  rhoVtx = 1e10, # intentionally no dxy cut
331 )
332 # and then the selectors
333 _taskForEachEra(_addSelectorsBySrc, modDict=globals(),
334  args=[["_generalTracksHp"]],
335  plainArgs=["FromPV", "generalTracksFromPV"],
336  names="_selectorsFromPV", task="_tracksValidationSelectorsFromPV",
337  modifyTask=lambda task: task.add(generalTracksFromPV))
338 
339 # select tracks with pT > 0.9 GeV from the PV
340 generalTracksFromPVPt09 = generalTracksPt09.clone(src="generalTracksFromPV")
341 # and then the selectors
342 _taskForEachEra(_addSelectorsBySrc, modDict=globals(),
343  args=[["_generalTracksHp"]],
344  plainArgs=["FromPVPt09", "generalTracksFromPVPt09"],
345  names="_selectorsFromPVPt09", task="_tracksValidationSelectorsFromPVPt09",
346  modifyTask=lambda task: task.add(generalTracksFromPVPt09))
347 
348 
349 trackingParticlesConversion = _trackingParticleConversionRefSelector.clone()
350 
351 
352 trackingParticlesElectron = _trackingParticleRefSelector.clone(
353  pdgId = [-11, 11],
354  signalOnly = False,
355  tip = 1e5,
356  lip = 1e5,
357  minRapidity = -10,
358  maxRapidity = 10,
359  ptMin = 0,
360 )
361 
362 # Select jets for JetCore tracking
363 highPtJets = cms.EDFilter("CandPtrSelector", src = cms.InputTag("ak4CaloJets"), cut = cms.string("pt()>1000"))
364 highPtJetsForTrk = highPtJets.clone(src = "ak4CaloJetsForTrk")
365 
366 # Select B-hadron TPs
367 trackingParticlesBHadron = _trackingParticleBHadronRefSelector.clone()
368 
369 
370 trackValidator = Validation.RecoTrack.MultiTrackValidator_cfi.multiTrackValidator.clone(
371  useLogPt = cms.untracked.bool(True),
372  dodEdxPlots = True,
373  doPVAssociationPlots = True
374  #,minpT = cms.double(-1)
375  #,maxpT = cms.double(3)
376  #,nintpT = cms.int32(40)
377 )
378 fastSim.toModify(trackValidator,
379  dodEdxPlots = False)
380 
381 for _eraName, _postfix, _era in _relevantEras:
382  _setForEra(trackValidator, _eraName, _era,
383  label = ["generalTracks", locals()["_generalTracksHp"+_postfix]] +
384  locals()["_selectorsByAlgo"+_postfix] + locals()["_selectorsByAlgoHp"+_postfix] +
385  locals()["_selectorsByOriginalAlgo"+_postfix] +
386  ["generalTracksPt09"] + locals()["_selectorsPt09"+_postfix] +
387  [
388  "cutsRecoTracksBtvLike",
389  "cutsRecoTracksAK4PFJets"
390  ],
391  doResolutionPlotsForLabels = [
392  "generalTracks",
393  locals()["_generalTracksHp"+_postfix],
394  "generalTracksPt09",
395  "cutsRecoTracksBtvLike",
396  "cutsRecoTracksJetCoreRegionalStepByOriginalAlgo",
397  ]
398  )
399  _setForEra(trackValidator.histoProducerAlgoBlock, _eraName, _era, seedingLayerSets=locals()["_seedingLayerSets"+_postfix])
400 
401 # for low-pT
402 trackValidatorTPPtLess09 = trackValidator.clone(
403  dirName = "Tracking/TrackTPPtLess09/",
404  label = [x for x in trackValidator.label.value() if ("Pt09" not in x) and ("BtvLike" not in x) and ("AK4PFJets" not in x)],
405  ptMaxTP = 0.9, # set maximum pT globally
406  histoProducerAlgoBlock = dict(
407  TpSelectorForEfficiencyVsEta = dict(ptMin=0.05), # enough to set min pT here
408  TpSelectorForEfficiencyVsPhi = dict(ptMin=0.05),
409  TpSelectorForEfficiencyVsVTXR = dict(ptMin=0.05),
410  TpSelectorForEfficiencyVsVTXZ = dict(ptMin=0.05),
411  ),
412  doSimPlots = False, # same as in trackValidator, no need to repeat here
413  doRecoTrackPlots = False, # fake rates are same as in trackValidator, no need to repeat here
414  doResolutionPlotsForLabels = ["disabled"], # resolutions are same as in trackValidator, no need to repeat here
415 )
416 
417 
418 trackingParticlesEtaGreater2p7 = _trackingParticleRefSelector.clone(
419  signalOnly = cms.bool(False),
420  tip = 1e5,
421  lip = 1e5,
422  minRapidity = -2.7,
423  maxRapidity = 2.7,
424  invertRapidityCut = cms.bool(True),
425  ptMin = 0,
426 )
427 
428 
429 # select tracks with |eta| > 2.7
430 generalTracksEtaGreater2p7 = cutsRecoTracks_cfi.cutsRecoTracks.clone(
431  minRapidity = cms.double(-2.7),
432  maxRapidity = cms.double( 2.7),
433  invertRapidityCut = cms.bool(True)
434 )
435 
436 _taskForEachEra(_addSelectorsBySrc, modDict=globals(),
437  args=[["_generalTracksHp"]],
438  plainArgs=["EtaGreater2p7", "generalTracksEtaGreater2p7"],
439  names="_selectorsEtaGreater2p7", task="_tracksValidationSelectorsEtaGreater2p7",
440  modifyTask=lambda task: task.add(generalTracksEtaGreater2p7))
441 
442 # for high-eta (phase2 : |eta| > 2.7)
443 trackValidatorTPEtaGreater2p7 = trackValidator.clone(
444  dirName = "Tracking/TrackTPEtaGreater2p7/",
445  label_tp_effic = "trackingParticlesEtaGreater2p7",
446  label_tp_fake = "trackingParticlesEtaGreater2p7",
447  label_tp_effic_refvector = True,
448  label_tp_fake_refvector = True,
449  dodEdxPlots = False,
450 # doPVAssociationPlots = False,
451  minRapidityTP = -2.7,
452  maxRapidityTP = 2.7,
453  invertRapidityCutTP = True,
454 # ptMaxTP = 0.9, # set maximum pT globally
455  histoProducerAlgoBlock = dict(
456  TpSelectorForEfficiencyVsPt = dict(ptMin=0.005,minRapidity=-2.7,maxRapidity=2.7,invertRapidityCut=True), # enough to set min pT here
457  TpSelectorForEfficiencyVsEta = dict(ptMin=0.005,minRapidity=-2.7,maxRapidity=2.7,invertRapidityCut=True), # enough to set min pT here
458  TpSelectorForEfficiencyVsPhi = dict(ptMin=0.005,minRapidity=-2.7,maxRapidity=2.7,invertRapidityCut=True),
459  TpSelectorForEfficiencyVsVTXR = dict(ptMin=0.005,minRapidity=-2.7,maxRapidity=2.7,invertRapidityCut=True),
460  TpSelectorForEfficiencyVsVTXZ = dict(ptMin=0.005,minRapidity=-2.7,maxRapidity=2.7,invertRapidityCut=True),
461  generalTpSelector = dict(ptMin=0.005,minRapidity=-2.7,maxRapidity=2.7,invertRapidityCut=True),
462 # minEta = -4.5,
463 # maxEta = 4.5,
464 # nintEta = 90,
465  # minPt = 0.01,
466  ),
467  doSimPlots = True, # ####same as in trackValidator, no need to repeat here
468  doRecoTrackPlots = True, # ####fake rates are same as in trackValidator, no need to repeat here
469  doResolutionPlotsForLabels = ["disabled"] # resolutions are same as in trackValidator, no need to repeat here
470 )
471 for _eraName, _postfix, _era in _relevantEras:
472  _setForEra(trackValidatorTPEtaGreater2p7, _eraName, _era,
473  label = ["generalTracksEtaGreater2p7"] + locals()["_selectorsEtaGreater2p7"+_postfix] +
474  locals()["_selectorsByAlgo"+_postfix] + locals()["_selectorsByAlgoHp"+_postfix],
475  doResolutionPlotsForLabels = ["generalTracksEtaGreater2p7"] + locals()["_selectorsEtaGreater2p7"+_postfix]
476  )
477 
478 # For efficiency of signal TPs vs. signal tracks, and fake rate of
479 # signal tracks vs. signal TPs
480 trackValidatorFromPV = trackValidator.clone(
481  dirName = "Tracking/TrackFromPV/",
482  label_tp_effic = "trackingParticlesSignal",
483  label_tp_fake = "trackingParticlesSignal",
484  label_tp_effic_refvector = True,
485  label_tp_fake_refvector = True,
486  trackCollectionForDrCalculation = "generalTracksFromPV",
487  doPlotsOnlyForTruePV = True,
488  doPVAssociationPlots = False,
489  doResolutionPlotsForLabels = ["disabled"],
490 )
491 for _eraName, _postfix, _era in _relevantEras:
492  _setForEra(trackValidatorFromPV, _eraName, _era,
493  label = ["generalTracksFromPV"] + locals()["_selectorsFromPV"+_postfix] + ["generalTracksFromPVPt09"] + locals()["_selectorsFromPVPt09"+_postfix],
494  doResolutionPlotsForLabels = [] # for standard "FromPV" do resolution plots for all input collections as they are already limited
495  )
496 
497 # For fake rate of signal tracks vs. all TPs, and pileup rate of
498 # signal tracks vs. non-signal TPs
499 trackValidatorFromPVAllTP = trackValidatorFromPV.clone(
500  dirName = "Tracking/TrackFromPVAllTP/",
501  label_tp_effic = trackValidator.label_tp_effic.value(),
502  label_tp_fake = trackValidator.label_tp_fake.value(),
503  label_tp_effic_refvector = False,
504  label_tp_fake_refvector = False,
505  doSimPlots = False,
506  doSimTrackPlots = False,
507  doResolutionPlotsForLabels = ["disabled"], # resolution plots are the same as in "trackValidatorFromPV"
508 )
509 
510 # For efficiency of all TPs vs. all tracks
511 trackValidatorAllTPEffic = trackValidator.clone(
512  dirName = "Tracking/TrackAllTPEffic/",
513  label = [x for x in trackValidator.label.value() if "Pt09" not in x],
514  doSimPlots = False,
515  doRecoTrackPlots = True, # Fake rate of all tracks vs. all TPs is already included in trackValidator, but we want the reco plots for other reasons
516  doPVAssociationPlots = False,
517  doResolutionPlotsForLabels = ["disabled"], # resolution plots are the same as in "trackValidator"
518 )
519 trackValidatorAllTPEffic.histoProducerAlgoBlock.generalTpSelector.signalOnly = False
520 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsEta.signalOnly = False
521 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsPhi.signalOnly = False
522 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsPt.signalOnly = False
523 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsVTXR.signalOnly = False
524 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsVTXZ.signalOnly = False
525 for _eraName, _postfix, _era in _relevantEras:
526  _setForEra(trackValidatorAllTPEffic, _eraName, _era, label = ["generalTracks", locals()["_generalTracksHp"+_postfix]])
527 
528 # Built tracks, in the standard sequence mainly for monitoring the track selection MVA
529 tpClusterProducerPreSplitting = tpClusterProducer.clone(pixelClusterSrc = "siPixelClustersPreSplitting")
530 quickTrackAssociatorByHitsPreSplitting = quickTrackAssociatorByHits.clone(cluster2TPSrc = "tpClusterProducerPreSplitting")
531 _trackValidatorSeedingBuilding = trackValidator.clone( # common for built tracks and seeds (in trackingOnly)
532  associators = ["quickTrackAssociatorByHits"],
533  UseAssociators = True,
534  dodEdxPlots = False,
535  doPVAssociationPlots = False,
536  doSimPlots = False,
537  doResolutionPlotsForLabels = ["disabled"],
538 )
539 trackValidatorBuilding = _trackValidatorSeedingBuilding.clone(
540  dirName = "Tracking/TrackBuilding/",
541  doMVAPlots = True,
542  doResolutionPlotsForLabels = ['jetCoreRegionalStepTracks'],
543 )
544 trackValidatorBuildingPreSplitting = trackValidatorBuilding.clone(
545  associators = ["quickTrackAssociatorByHitsPreSplitting"],
546  doMVAPlots = False,
547  doSummaryPlots = False,
548 )
549 for _eraName, _postfix, _era in _relevantErasAndFastSim:
550  _setForEra(trackValidatorBuilding, _eraName, _era, label = locals()["_trackProducers"+_postfix])
551 fastSim.toModify(trackValidatorBuilding, doMVAPlots=False)
552 for _eraName, _postfix, _era in _relevantEras:
553  _setForEra(trackValidatorBuilding, _eraName, _era, mvaLabels = locals()["_mvaSelectors"+_postfix])
554  _setForEra(trackValidatorBuildingPreSplitting, _eraName, _era, label = locals()["_trackProducersPreSplitting"+_postfix])
555 
556 
557 # For conversions
558 trackValidatorConversion = trackValidator.clone(
559  dirName = "Tracking/TrackConversion/",
560  label = [
561  "convStepTracks",
562  "conversionStepTracks",
563  "ckfInOutTracksFromConversions",
564  "ckfOutInTracksFromConversions",
565  ],
566  label_tp_effic = "trackingParticlesConversion",
567  label_tp_effic_refvector = True,
568  associators = ["quickTrackAssociatorByHits"],
569  UseAssociators = True,
570  doSimPlots = True,
571  dodEdxPlots = False,
572  doPVAssociationPlots = False,
573  calculateDrSingleCollection = False,
574 )
575 from RecoTracker.ConversionSeedGenerators.ConversionStep_cff import convLayerPairs as _convLayerPairs
576 def _uniqueFirstLayers(layerList):
577  firstLayers = [layerSet.split("+")[0] for layerSet in layerList]
578  ret = []
579  for l in firstLayers:
580  if not l in ret:
581  ret.append(l)
582  # For conversions add also the mono-TEC to the list as 'TEC'
583  # is used for both matched and unmatched rphi/stereo hits
584  if l.startswith("TEC"):
585  ret.append("M"+l)
586  return ret
587 # PhotonConversionTrajectorySeedProducerFromSingleLeg keeps only the
588 # first hit of the pairs in the seed, bookkeeping those is the best we
589 # can do without major further development
590 trackValidatorConversion.histoProducerAlgoBlock.seedingLayerSets = _uniqueFirstLayers(_convLayerPairs.layerList.value())
591 # relax lip and tip
592 for n in ["Eta", "Phi", "Pt", "VTXR", "VTXZ"]:
593  pset = getattr(trackValidatorConversion.histoProducerAlgoBlock, "TpSelectorForEfficiencyVs"+n)
594  pset.lip = trackValidatorConversion.lipTP.value()
595  pset.tip = trackValidatorConversion.tipTP.value()
596 
597 # For electrons
598 trackValidatorGsfTracks = trackValidatorConversion.clone(
599  dirName = "Tracking/TrackGsf/",
600  label = ["electronGsfTracks"],
601  label_tp_effic = "trackingParticlesElectron",
602 )
603 # add the additional seeding layers from ElectronSeeds
604 for _eraName, _postfix, _era in _relevantEras:
605  _setForEra(trackValidatorGsfTracks.histoProducerAlgoBlock, _eraName, _era, seedingLayerSets=trackValidator.histoProducerAlgoBlock.seedingLayerSets.value()+locals()["_seedingLayerSetsForElectrons"+_postfix])
606 
607 # For jetCore tracks
608 trackValidatorJetCore = trackValidator.clone(#equivalent to trackBuilding case
609  dirName = "Tracking/JetCore/",
610  useLogPt = cms.untracked.bool(True),
611  dodEdxPlots = False,
612  associators= ["trackAssociatorByChi2"],#cms.untracked.VInputTag('MTVTrackAssociationByChi2'),
613  UseAssociators = True,
614  doPVAssociationPlots = True,
615  label_tp_effic = "trackingParticlesInTime",
616  label_tp_fake = "trackingParticlesInTime",
617  label_tp_effic_refvector = True,
618  label_tp_fake_refvector = True,
619 )
620 for _eraName, _postfix, _era in _relevantEras:
621  if 'jetCoreRegionalStep' in _cfg.iterationAlgos(_postfix) :
622  _setForEra(trackValidatorJetCore, _eraName, _era,
623  label = ["generalTracks", "jetCoreRegionalStepTracks",
624  "cutsRecoTracksJetCoreRegionalStepByOriginalAlgo","cutsRecoTracksJetCoreRegionalStepByOriginalAlgoHp",
625  "cutsRecoTracksJetCoreRegionalStep", "cutsRecoTracksJetCoreRegionalStepHp"],
626  doResolutionPlotsForLabels =["generalTracks", "jetCoreRegionalStepTracks",
627  "cutsRecoTracksJetCoreRegionalStepByOriginalAlgo","cutsRecoTracksJetCoreRegionalStepByOriginalAlgoHp",
628  "cutsRecoTracksJetCoreRegionalStep", "cutsRecoTracksJetCoreRegionalStepHp"],
629  )
630 
631 # for B-hadrons
632 trackValidatorBHadron = trackValidator.clone(
633  dirName = "Tracking/TrackBHadron/",
634  label_tp_effic = "trackingParticlesBHadron",
635  label_tp_effic_refvector = True,
636  doSimPlots = True,
637  doRecoTrackPlots = False, # Fake rate is defined wrt. all TPs, and that is already included in trackValidator
638  dodEdxPlots = False,
639 )
640 for _eraName, _postfix, _era in _relevantEras:
641  _setForEra(trackValidatorBHadron, _eraName, _era,
642  label = ["generalTracks", locals()["_generalTracksHp"+_postfix], "cutsRecoTracksBtvLike"]
643  )
644 
645 
646 # for displaced tracks
647 trackValidatorDisplaced = trackValidator.clone(
648  dirName = "Tracking/TrackDisplaced/",
649  label = [x for x in trackValidator.label.value() if ("Pt09" not in x) and ("BtvLike" not in x) and ("AK4PFJets" not in x)],
650  ptMaxTP = 1e5,
651  dodEdxPlots = False,
652  invertRapidityCutTP = False,
653  histoProducerAlgoBlock = dict(
654  TpSelectorForEfficiencyVsPt = dict(ptMin=0.005, signalOnly=True, tip=1e5, lip=1e5), # enough to set min pT here
655  TpSelectorForEfficiencyVsEta = dict(ptMin=0.005, signalOnly=True, tip=1e5, lip=1e5), # enough to set min pT here
656  TpSelectorForEfficiencyVsPhi = dict(ptMin=0.005, signalOnly=True, tip=1e5, lip=1e5),
657  TpSelectorForEfficiencyVsVTXR = dict(ptMin=0.005, signalOnly=True, tip=1e5, lip=1e5),
658  TpSelectorForEfficiencyVsVTXZ = dict(ptMin=0.005, signalOnly=True, tip=1e5, lip=1e5),
659  generalTpSelector = dict(ptMin=0.005, signalOnly=True, tip=1e5, lip=1e5),
660  minDxy = -60,
661  maxDxy = 60,
662  nintDxy = 120,
663  minDz = -30,
664  maxDz = 30,
665  nintDz = 60,
666  ),
667  signalOnlyTP = True,
668  lipTP = 1e5,
669  tipTP = 1e5,
670 )
671 
672 # the track selectors
673 tracksValidationSelectors = cms.Task(
674  tracksValidationSelectorsByAlgo,
675  tracksValidationSelectorsByAlgoHp,
676  tracksValidationSelectorsByOriginalAlgo,
677  cutsRecoTracksBtvLike,
678  ak4JetTracksAssociatorExplicitAll,
679  cutsRecoTracksAK4PFJets
680 )
681 phase2_tracker.toModify(tracksValidationSelectors, lambda x: x.add(generalTracksEtaGreater2p7))
682 phase2_tracker.toModify(tracksValidationSelectors, lambda x: x.add(cutsRecoTracksEtaGreater2p7Hp))
683 
684 # Validation iterative steps
685 _taskForEachEra(_addSelectorsByAlgo, modDict=globals(),
686  args=["_algos"],
687  names="_selectorsByAlgo", task="_tracksEtaGreater2p7ValidationSelectorsByAlgo"
688  )
689 
690 # high purity
691 _taskForEachEra(_addSelectorsByHp, modDict=globals(),
692  args=["_algos"],
693  names="_selectorsByAlgoHp", task="_tracksEtaGreater2p7ValidationSelectorsByAlgoHp"
694  )
695 
696 for _eraName, _postfix, _era in _relevantEras:
697  selectors = locals()["_selectorsByAlgoHp"+_postfix]
698  locals()["_generalTracksHp"+_postfix] = selectors[0]
699  locals()["_selectorsByAlgoHp"+_postfix] = selectors[1:]
700 
701 phase2_tracker.toModify(tracksValidationSelectors, lambda x: x.add(tracksEtaGreater2p7ValidationSelectorsByAlgo))
702 phase2_tracker.toModify(tracksValidationSelectors, lambda x: x.add(tracksEtaGreater2p7ValidationSelectorsByAlgoHp))
703 
704 tracksValidationTruth = cms.Task(
705  tpClusterProducer,
706  tpClusterProducerPreSplitting,
707  trackAssociatorByChi2,
708  quickTrackAssociatorByHits,
709  quickTrackAssociatorByHitsPreSplitting,
710  trackingParticleRecoTrackAsssociation,
711  VertexAssociatorByPositionAndTracks,
712  trackingParticleNumberOfLayersProducer
713 )
714 
715 # HIon modifiers
716 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
717 
718 trackingParticleHIPixelTrackAssociation = trackingParticleRecoTrackAsssociation.clone(
719  label_tr = "hiConformalPixelTracks",
720  associator = "quickTrackAssociatorByHits",
721 )
722 
723 from Configuration.ProcessModifiers.pixelNtupletFit_cff import pixelNtupletFit
724 
725 pixelNtupletFit.toModify(trackingParticleHIPixelTrackAssociation,
726  associator = "quickTrackAssociatorByHitsPreSplitting")
727 
728 HIPixelVertexAssociatorByPositionAndTracks = VertexAssociatorByPositionAndTracks.clone(
729  trackAssociation = "trackingParticleHIPixelTrackAssociation"
730 )
731 
732 pp_on_AA.toReplaceWith(tracksValidationTruth, cms.Task(
733  tracksValidationTruth.copy(),
734  trackingParticleHIPixelTrackAssociation,
735  HIPixelVertexAssociatorByPositionAndTracks
736 ))
737 fastSim.toModify(tracksValidationTruth, lambda x: x.remove(tpClusterProducer))
738 
739 tracksPreValidation = cms.Task(
740  highPtJetsForTrk,
741  tracksValidationSelectors,
742  tracksValidationSelectorsPt09,
743  tracksValidationSelectorsFromPV,
744  tracksValidationSelectorsFromPVPt09,
745  tracksValidationTruth,
746  trackingParticlesSignal,
747  trackingParticlesInTime,
748  trackingParticlesElectron,
749  trackingParticlesConversion
750 )
751 fastSim.toReplaceWith(tracksPreValidation, tracksPreValidation.copyAndExclude([
752  trackingParticlesElectron,
753  trackingParticlesConversion,
754 ]))
755 
756 
757 
758 tracksValidation = cms.Sequence(
759  trackValidator +
760  trackValidatorTPPtLess09 +
761  trackValidatorFromPV +
762  trackValidatorFromPVAllTP +
763  trackValidatorAllTPEffic +
764  trackValidatorBuilding +
765  trackValidatorBuildingPreSplitting +
766  trackValidatorConversion +
767  trackValidatorGsfTracks,
768  tracksPreValidation
769 )
770 
771 trackValidatorHILowPtConformalValidator = trackValidator.clone(
772  dirName = "Tracking/HIPixelTrack/",
773  label = [
774  "hiConformalPixelTracks",
775  ],
776  doResolutionPlotsForLabels = ["hiConformalPixelTracks"],
777  trackCollectionForDrCalculation = "hiConformalPixelTracks",
778  associators = ["trackingParticleHIPixelTrackAssociation"],
779  vertexAssociator = "HIPixelVertexAssociatorByPositionAndTracks",
780  dodEdxPlots = False,
781  cores = ""
782 )
783 
784 tracksValidationHIonTask = cms.Task(trackValidatorHILowPtConformalValidator)
785 
786 tracksValidationHIon = cms.Sequence(
787  tracksValidation.copy(),
788  tracksValidationHIonTask
789 )
790 
791 pp_on_AA.toReplaceWith(tracksValidation,tracksValidationHIon)
792 
793 
794 from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
795 seedingDeepCore.toReplaceWith(tracksValidation, cms.Sequence(tracksValidation.copy()+trackValidatorJetCore))
796 
797 from Configuration.ProcessModifiers.displacedTrackValidation_cff import displacedTrackValidation
798 displacedTrackValidation.toReplaceWith(tracksValidation, cms.Sequence(tracksValidation.copy()+trackValidatorDisplaced))
799 
800 from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
801 tracksPreValidationPhase2 = tracksPreValidation.copy()
802 tracksPreValidationPhase2.add(trackingParticlesEtaGreater2p7)
803 phase2_tracker.toReplaceWith(tracksPreValidation, tracksPreValidationPhase2)
804 
805 tracksValidationPhase2 = tracksValidation.copyAndExclude([
806  trackValidatorJetCore
807 ])
808 tracksValidationPhase2+=trackValidatorTPEtaGreater2p7
809 phase2_tracker.toReplaceWith(tracksValidation, tracksValidationPhase2)
810 
811 fastSim.toReplaceWith(tracksValidation, tracksValidation.copyAndExclude([
812  trackValidatorBuildingPreSplitting,
813  trackValidatorConversion,
814  trackValidatorGsfTracks,
815 ]))
816 
817 
818 
819 # Select by originalAlgo and algoMask
820 _taskForEachEra(_addSelectorsByOriginalAlgoMask, modDict = globals(),
821  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["ByAlgoMask", "algorithmMaskContains"],
822  names = "_selectorsByAlgoMask", task = "_tracksValidationSelectorsByAlgoMaskStandalone")
823 
824 # Select pT>0.9 by iteration
825 # Need to avoid generalTracks+HP because those are already included in the standard validator
826 _taskForEachEra(_addSelectorsBySrc, modDict = globals(),
827  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["Pt09", "generalTracksPt09"],
828  names = "_selectorsPt09Standalone", task = "_tracksValidationSelectorsPt09Standalone")
829 
830 # Select fromPV by iteration
831 # Need to avoid generalTracks+HP because those are already included in the standard validator
832 _taskForEachEra(_addSelectorsBySrc, modDict = globals(),
833  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["FromPV", "generalTracksFromPV"],
834  names = "_selectorsFromPVStandalone", task = "_tracksValidationSelectorsFromPVStandalone")
835 
836 # Select pt>0.9 and fromPV by iteration
837 # Need to avoid generalTracks+HP because those are already included in the standard validator
838 _taskForEachEra(_addSelectorsBySrc, modDict = globals(),
839  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["FromPVPt09", "generalTracksFromPVPt09"],
840  names = "_selectorsFromPVPt09Standalone", task = "_tracksValidationSelectorsFromPVPt09Standalone")
841 
842 # MTV instances
843 trackValidatorStandalone = trackValidator.clone(
844  cores = "highPtJets"
845 )
846 trackValidatorTPPtLess09Standalone = trackValidatorTPPtLess09.clone(
847  cores = "highPtJets"
848 )
849 for _eraName, _postfix, _era in _relevantEras:
850  _setForEra(trackValidatorStandalone, _eraName, _era, label = trackValidator.label + locals()["_selectorsByAlgoMask"+_postfix] + locals()["_selectorsPt09Standalone"+_postfix])
851  _setForEra(trackValidatorTPPtLess09Standalone, _eraName, _era, label = trackValidatorTPPtLess09.label + locals()["_selectorsByAlgoMask"+_postfix] + locals()["_selectorsPt09Standalone"+_postfix])
852 
853 trackValidatorFromPVStandalone = trackValidatorFromPV.clone(
854  cores = "highPtJets"
855 )
856 for _eraName, _postfix, _era in _relevantEras:
857  _setForEra(trackValidatorFromPVStandalone, _eraName, _era, label = trackValidatorFromPV.label + locals()["_selectorsFromPVStandalone"+_postfix] + locals()["_selectorsFromPVPt09Standalone"+_postfix])
858 # do resolutions as in the standard version
859 
860 trackValidatorFromPVAllTPStandalone = trackValidatorFromPVAllTP.clone(
861  label = trackValidatorFromPVStandalone.label.value(),
862  cores = "highPtJets"
863 
864 )
865 trackValidatorAllTPEfficStandalone = trackValidatorAllTPEffic.clone(
866  label = [ x for x in trackValidator.label.value() if x not in ["cutsRecoTracksBtvLike", "cutsRecoTracksAK4PFJets"] and "Pt09" not in x],
867  cores = "highPtJets"
868 )
869 
870 trackValidatorConversionStandalone = trackValidatorConversion.clone(
871  label = [x for x in trackValidatorConversion.label if x != "convStepTracks"],
872  cores = "highPtJets"
873 )
874 
875 trackValidatorBHadronStandalone = trackValidatorBHadron.clone(
876  label = [x for x in trackValidatorStandalone.label if "Pt09" not in x],
877  cores = "highPtJets"
878 )
879 
880 trackValidatorGsfTracksStandalone = trackValidatorGsfTracks.clone(
881  cores = "highPtJets"
882 )
883 
884 # sequences
885 tracksPreValidationStandalone = tracksPreValidation.copy()
886 tracksPreValidationStandalone.add(trackingParticlesBHadron)
887 tracksPreValidationStandalone.replace(highPtJetsForTrk,highPtJets)
888 fastSim.toReplaceWith(tracksPreValidationStandalone, tracksPreValidation)
889 
890 tracksValidationSelectorsStandalone = cms.Task(
891  tracksValidationSelectorsByAlgoMaskStandalone,
892  tracksValidationSelectorsPt09Standalone,
893  tracksValidationSelectorsFromPVStandalone,
894  tracksValidationSelectorsFromPVPt09Standalone
895 )
896 
897 # we copy this for both Standalone and TrackingOnly
898 # and later make modifications from it which change based on era
899 _trackValidatorsBase = cms.Sequence(
900  trackValidatorStandalone +
901  trackValidatorTPPtLess09Standalone +
902  trackValidatorFromPVStandalone +
903  trackValidatorFromPVAllTPStandalone +
904  trackValidatorAllTPEfficStandalone +
905  trackValidatorConversionStandalone +
906  trackValidatorGsfTracksStandalone +
907  trackValidatorBHadronStandalone
908 )
909 
910 _trackValidatorsBasePhase2 = _trackValidatorsBase.copy()
911 _trackValidatorsBasePhase2+=trackValidatorTPEtaGreater2p7
912 phase2_tracker.toReplaceWith(_trackValidatorsBase, _trackValidatorsBasePhase2)
913 
914 trackValidatorsStandalone = _trackValidatorsBase.copy()
915 fastSim.toModify(trackValidatorsStandalone, lambda x: x.remove(trackValidatorConversionStandalone) )
916 
917 tracksValidationStandalone = cms.Sequence(
918  ak4PFL1FastL2L3CorrectorChain +
919  trackValidatorsStandalone,
920  tracksPreValidationStandalone,
921  tracksValidationSelectorsStandalone
922 )
923 
924 
925 
926 # selectors
927 tracksValidationSelectorsTrackingOnly = tracksValidationSelectors.copyAndExclude([ak4JetTracksAssociatorExplicitAll,cutsRecoTracksAK4PFJets]) # selectors using track information only (i.e. no PF)
928 _taskForEachEra(_addSeedToTrackProducers, args=["_seedProducers"], names="_seedSelectors", task="_tracksValidationSeedSelectorsTrackingOnly", includeFastSim=True, modDict=globals())
929 _taskForEachEra(_addSeedToTrackProducers, args=["_seedProducersPreSplitting"], names="_seedSelectorsPreSplitting", task="_tracksValidationSeedSelectorsPreSplittingTrackingOnly", modDict=globals())
930 tracksValidationSeedSelectorsTrackingOnly.add(tracksValidationSeedSelectorsPreSplittingTrackingOnly)
931 
932 # MTV instances
933 trackValidatorTrackingOnly = trackValidatorStandalone.clone(
934  label = [ x for x in trackValidatorStandalone.label if x != "cutsRecoTracksAK4PFJets"],
935  cores = "highPtJetsForTrk"
936  )
937 
938 trackValidatorSeedingTrackingOnly = _trackValidatorSeedingBuilding.clone(
939  dirName = "Tracking/TrackSeeding/",
940  label = _seedSelectors,
941  doSeedPlots = True,
942  doResolutionPlotsForLabels = [ "seedTracksjetCoreRegionalStepSeeds" ]
943 )
944 seedingDeepCore.toModify(trackValidatorSeedingTrackingOnly, doResolutionPlotsForLabels = ["seedTracksjetCoreRegionalStepSeedsBarrel","seedTracksjetCoreRegionalStepSeedsEndcap"] )
945 
946 trackValidatorSeedingPreSplittingTrackingOnly = trackValidatorSeedingTrackingOnly.clone(
947  associators = ["quickTrackAssociatorByHitsPreSplitting"],
948  label = _seedSelectorsPreSplitting,
949  doSummaryPlots = False,
950 
951 )
952 
953 trackValidatorJetCoreSeedingTrackingOnly = trackValidatorSeedingTrackingOnly.clone(
954  dirName = "Tracking/JetCore/TrackSeeding/",
955  associators = ["trackAssociatorByChi2"],
956  UseAssociators = True,
957  doSeedPlots = True,
958 )
959 
960 for _eraName, _postfix, _era in _relevantEras:
961  if 'jetCoreRegionalStep' in _cfg.iterationAlgos(_postfix) :
962  _setForEra(trackValidatorJetCoreSeedingTrackingOnly, _eraName, _era,
963  label = [ "seedTracksjetCoreRegionalStepSeedsBarrel","seedTracksjetCoreRegionalStepSeedsEndcap" ],
964  doResolutionPlotsForLabels = [ "seedTracksjetCoreRegionalStepSeedsBarrel","seedTracksjetCoreRegionalStepSeedsEndcap" ]
965  )
966 
967 for _eraName, _postfix, _era in _relevantErasAndFastSim:
968  _setForEra(trackValidatorSeedingTrackingOnly, _eraName, _era, label = locals()["_seedSelectors"+_postfix])
969 for _eraName, _postfix, _era in _relevantEras:
970  _setForEra(trackValidatorSeedingPreSplittingTrackingOnly, _eraName, _era, label = locals()["_seedSelectorsPreSplitting"+_postfix])
971 
972 
973 trackValidatorConversionTrackingOnly = trackValidatorConversion.clone(label = [x for x in trackValidatorConversion.label if x not in ["ckfInOutTracksFromConversions", "ckfOutInTracksFromConversions"]])
974 
975 trackValidatorBHadronTrackingOnly = trackValidatorBHadron.clone(label = [x for x in trackValidatorTrackingOnly.label if "Pt09" not in x])
976 
977 trackValidatorTPPtLess09TrackingOnly = trackValidatorTPPtLess09Standalone.clone(cores = "highPtJetsForTrk")
978 trackValidatorFromPVTrackingOnly = trackValidatorFromPVStandalone.clone(cores = "highPtJetsForTrk")
979 trackValidatorFromPVAllTPTrackingOnly = trackValidatorFromPVAllTPStandalone.clone(cores = "highPtJetsForTrk")
980 trackValidatorAllTPEfficTrackingOnly = trackValidatorAllTPEfficStandalone.clone(cores = "highPtJetsForTrk")
981 # sequences
982 tracksPreValidationTrackingOnly = tracksPreValidationStandalone.copy()
983 tracksPreValidationTrackingOnly.replace(tracksValidationSelectors, tracksValidationSelectorsTrackingOnly)
984 tracksPreValidationTrackingOnly.replace(highPtJets,highPtJetsForTrk)
985 
986 trackValidatorsTrackingOnly = _trackValidatorsBase.copy()
987 trackValidatorsTrackingOnly.replace(trackValidatorStandalone, trackValidatorTrackingOnly)
988 trackValidatorsTrackingOnly.replace(trackValidatorTPPtLess09Standalone,trackValidatorTPPtLess09TrackingOnly)
989 trackValidatorsTrackingOnly.replace(trackValidatorFromPVStandalone,trackValidatorFromPVTrackingOnly)
990 trackValidatorsTrackingOnly.replace(trackValidatorFromPVAllTPStandalone,trackValidatorFromPVAllTPTrackingOnly)
991 trackValidatorsTrackingOnly.replace(trackValidatorAllTPEfficStandalone,trackValidatorAllTPEfficTrackingOnly)
992 trackValidatorsTrackingOnly += trackValidatorSeedingTrackingOnly
993 trackValidatorsTrackingOnly += trackValidatorSeedingPreSplittingTrackingOnly
994 trackValidatorsTrackingOnly += trackValidatorBuilding
995 trackValidatorsTrackingOnly += trackValidatorBuildingPreSplitting
996 trackValidatorsTrackingOnly.replace(trackValidatorConversionStandalone, trackValidatorConversionTrackingOnly)
997 trackValidatorsTrackingOnly.remove(trackValidatorGsfTracksStandalone)
998 trackValidatorsTrackingOnly.replace(trackValidatorBHadronStandalone, trackValidatorBHadronTrackingOnly)
999 
1000 (seedingDeepCore & ~fastSim).toReplaceWith(trackValidatorsTrackingOnly, cms.Sequence(
1001  trackValidatorsTrackingOnly.copy()+
1002  trackValidatorJetCore+
1003  trackValidatorJetCoreSeedingTrackingOnly
1004  )
1005  )
1006 phase2_tracker.toReplaceWith(trackValidatorsTrackingOnly, trackValidatorsTrackingOnly.copyAndExclude([ #must be done for each era which does not have jetcore in the iteration
1007  trackValidatorJetCore,
1008  trackValidatorJetCoreSeedingTrackingOnly
1009 ]))
1010 
1011 displacedTrackValidation.toReplaceWith(trackValidatorsTrackingOnly, cms.Sequence(trackValidatorsTrackingOnly.copy()+trackValidatorDisplaced))
1012 
1013 fastSim.toReplaceWith(trackValidatorsTrackingOnly, trackValidatorsTrackingOnly.copyAndExclude([
1014  trackValidatorBuildingPreSplitting,
1015  trackValidatorSeedingPreSplittingTrackingOnly,
1016  trackValidatorConversionTrackingOnly,
1017  trackValidatorBHadronTrackingOnly
1018 ]))
1019 tracksValidationTrackingOnly = cms.Sequence(
1020  trackValidatorsTrackingOnly,
1021  tracksPreValidationTrackingOnly,
1022  tracksValidationSelectorsStandalone,
1023  tracksValidationSeedSelectorsTrackingOnly
1024 )
1025 
1026 
1027 tracksValidationHIonTrackingOnly = cms.Sequence(
1028  tracksValidation.copy(),
1029  tracksValidationHIonTask
1030 )
1031 
1032 pp_on_AA.toReplaceWith(tracksValidationTrackingOnly,tracksValidationHIonTrackingOnly)
1033 
1034 
1035 
1037 trackingParticlePixelTrackAsssociation = trackingParticleRecoTrackAsssociation.clone(
1038  label_tr = "pixelTracks",
1039  associator = "quickTrackAssociatorByHitsPreSplitting",
1040 )
1041 PixelVertexAssociatorByPositionAndTracks = VertexAssociatorByPositionAndTracks.clone(
1042  trackAssociation = "trackingParticlePixelTrackAsssociation"
1043 )
1044 
1045 _pixelTracksCustom = dict(
1046  src = "pixelTracks",
1047  vertexTag = "pixelVertices",
1048 )
1049 
1050 trackRefSelector = cms.EDFilter('TrackRefSelector',
1051  src = cms.InputTag('pixelTracks'),
1052  cut = cms.string("")
1053 )
1054 
1055 trackSelector = cms.EDFilter('TrackSelector',
1056  src = cms.InputTag('pixelTracks'),
1057  cut = cms.string("")
1058 )
1059 
1060 cutstring = "hitPattern.trackerLayersWithMeasurement == 3"
1061 pixelTracks3hits = trackRefSelector.clone( cut = cutstring )
1062 
1063 cutstring = "hitPattern.trackerLayersWithMeasurement >= 4"
1064 pixelTracks4hits = trackRefSelector.clone( cut = cutstring )
1065 
1066 cutstring = "pt > 0.9"
1067 pixelTracksPt09 = trackRefSelector.clone( cut = cutstring )
1068 #pixelTracksPt09 = generalTracksPt09.clone(quality = ["undefQuality"], **_pixelTracksCustom)
1069 
1070 pixelTracksFromPV = generalTracksFromPV.clone(quality = "highPurity", ptMin = 0.0, ptMax = 99999., ptErrorCut = 99999., copyExtras = True, **_pixelTracksCustom)
1071 #pixelTracksFromPVPt09 = generalTracksPt09.clone(quality = ["loose","tight","highPurity"], vertexTag = "pixelVertices", src = "pixelTracksFromPV")
1072 pixelTracksFromPVPt09 = pixelTracksFromPV.clone(ptMin = 0.9)
1073 
1074 cutstring = "hitPattern.trackerLayersWithMeasurement >= 4"
1075 #pixelTracksFromPV4hits = trackRefSelector.clone( cut = cutstring, src = "pixelTracksFromPV" )
1076 pixelTracksFromPV4hits = pixelTracksFromPV.clone( numberOfValidPixelHits = 4 )
1077 
1078 
1079 trackValidatorPixelTrackingOnly = trackValidator.clone(
1080  dirName = "Tracking/PixelTrack/",
1081  label = [
1082  "pixelTracks", "pixelTracksPt09", "pixelTracks3hits", "pixelTracks4hits",
1083  "pixelTracksL", "pixelTracksPt09L", "pixelTracks3hitsL", "pixelTracks4hitsL",
1084  "pixelTracksT", "pixelTracksPt09T", "pixelTracks3hitsT", "pixelTracks4hitsT",
1085  "pixelTracksHP", "pixelTracksPt09HP", "pixelTracks3hitsHP", "pixelTracks4hitsHP",
1086  ],
1087  doResolutionPlotsForLabels = [],
1088  trackCollectionForDrCalculation = "pixelTracks",
1089  associators = ["trackingParticlePixelTrackAsssociation"],
1090  label_vertex = "pixelVertices",
1091  vertexAssociator = "PixelVertexAssociatorByPositionAndTracks",
1092  dodEdxPlots = False,
1093  cores = ""
1094 )
1095 
1096 trackValidatorFromPVPixelTrackingOnly = trackValidatorPixelTrackingOnly.clone(
1097  dirName = "Tracking/PixelTrackFromPV/",
1098  label = [
1099  "pixelTracksFromPV", "pixelTracksFromPVPt09", "pixelTracksFromPV4hits",
1100  "pixelTracksFromPVL", "pixelTracksFromPVT", "pixelTracksFromPVHP",
1101  "pixelTracksFromPVPt09L", "pixelTracksFromPVPt09T", "pixelTracksFromPVPt09HP",
1102  "pixelTracksFromPV4hitsL", "pixelTracksFromPV4hitsT", "pixelTracksFromPV4hitsHP",
1103  ],
1104  label_tp_effic = "trackingParticlesSignal",
1105  label_tp_fake = "trackingParticlesSignal",
1106  label_tp_effic_refvector = True,
1107  label_tp_fake_refvector = True,
1108  trackCollectionForDrCalculation = "pixelTracksFromPV",
1109  doPlotsOnlyForTruePV = True,
1110  doPVAssociationPlots = False,
1111  doResolutionPlotsForLabels = ["disabled"],
1112 )
1113 trackValidatorFromPVAllTPPixelTrackingOnly = trackValidatorFromPVPixelTrackingOnly.clone(
1114  dirName = "Tracking/PixelTrackFromPVAllTP/",
1115  label_tp_effic = trackValidatorPixelTrackingOnly.label_tp_effic.value(),
1116  label_tp_fake = trackValidatorPixelTrackingOnly.label_tp_fake.value(),
1117  label_tp_effic_refvector = False,
1118  label_tp_fake_refvector = False,
1119  doSimPlots = False,
1120  doSimTrackPlots = False,
1121 )
1122 trackValidatorBHadronPixelTrackingOnly = trackValidatorPixelTrackingOnly.clone(
1123  dirName = "Tracking/PixelTrackBHadron/",
1124  label = [
1125  "pixelTracks", "pixelTracksPt09",
1126  "pixelTracksL", "pixelTracks3hitsL", "pixelTracks4hitsL",
1127  "pixelTracksT", "pixelTracks3hitsT", "pixelTracks4hitsT",
1128  "pixelTracksHP", "pixelTracks3hitsHP", "pixelTracks4hitsHP",
1129  ],
1130  label_tp_effic = "trackingParticlesBHadron",
1131  label_tp_effic_refvector = True,
1132  doSimPlots = True,
1133  doRecoTrackPlots = False, # Fake rate is defined wrt. all TPs, and that is already included in trackValidator
1134  dodEdxPlots = False,
1135 )
1136 
1137 tracksValidationTruthPixelTrackingOnly = tracksValidationTruth.copy()
1138 tracksValidationTruthPixelTrackingOnly.replace(trackingParticleRecoTrackAsssociation, trackingParticlePixelTrackAsssociation)
1139 tracksValidationTruthPixelTrackingOnly.replace(VertexAssociatorByPositionAndTracks, PixelVertexAssociatorByPositionAndTracks)
1140 tracksValidationTruthPixelTrackingOnly.add(trackingParticlesBHadron)
1141 tracksValidationTruthPixelTrackingOnly.add( pixelTracks3hits )
1142 tracksValidationTruthPixelTrackingOnly.add( pixelTracks4hits )
1143 tracksValidationTruthPixelTrackingOnly.add( pixelTracksPt09 )
1144 tracksValidationTruthPixelTrackingOnly.add( pixelTracksFromPV )
1145 tracksValidationTruthPixelTrackingOnly.add( pixelTracksFromPVPt09 )
1146 tracksValidationTruthPixelTrackingOnly.add( pixelTracksFromPV4hits )
1147 
1148 tracksPreValidationPixelTrackingOnly = cms.Task(
1149  tracksValidationTruthPixelTrackingOnly,
1150  trackingParticlesSignal)
1151 
1152 
1153 quality = {
1154  "L" : (1,"loose", ["loose","tight","highPurity"]),
1155  "T" : (2,"tight", ["tight","highPurity"]),
1156  "HP" : (4,"highPurity",["highPurity"]),
1157 }
1158 
1159 for key,value in quality.items():
1160  qualityName = value[1]
1161  qualityBit = value[0]
1162  qualityList = value[2]
1163 
1164  label = "pixelTracks"+str(key)
1165  cutstring = "qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1166  locals()[label] = trackRefSelector.clone( cut = cutstring )
1167  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1168 
1169  label = "pixelTracksFromPV"+key
1170 # locals()[label] = generalTracksPt09.clone( ptMin = 0.0, vertexTag = "pixelVertices", src = "pixelTracksFromPV", quality = qualityList )
1171  locals()[label] = pixelTracksFromPV.clone( quality = qualityName )
1172  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1173 #-----------
1174  cutstring = "pt > 0.9 & qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1175  label = "pixelTracksPt09"+key
1176  locals()[label] = trackRefSelector.clone( cut = cutstring )
1177  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1178 
1179  label = "pixelTracksFromPVPt09"+key
1180  # locals()[label] = generalTracksPt09.clone( ptMin = 0.9, vertexTag = "pixelVertices", src = "pixelTracksFromPV", quality = qualityList )
1181  locals()[label] = pixelTracksFromPVPt09.clone( quality = qualityName )
1182  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1183 #-----------
1184  label = "pixelTracks4hits"+key
1185  cutstring = "hitPattern.trackerLayersWithMeasurement >= 4 & qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1186  locals()[label] = trackRefSelector.clone( cut = cutstring )
1187  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1188 
1189  label = "pixelTracksFromPV4hits"+key
1190 # locals()[label] = generalTracksPt09.clone( ptMin = 0.0, minHit = 4, vertexTag = "pixelVertices", src = "pixelTracksFromPV", quality = qualityList )
1191  locals()[label] = pixelTracksFromPV4hits.clone( quality = qualityName )
1192  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1193 #--------
1194  label = "pixelTracks3hits"+key
1195  cutstring = "hitPattern.trackerLayersWithMeasurement == 3 & qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1196  locals()[label] = trackRefSelector.clone( cut = cutstring )
1197  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1198 
1199 tracksValidationPixelTrackingOnly = cms.Sequence(
1200  trackValidatorPixelTrackingOnly +
1201  trackValidatorFromPVPixelTrackingOnly +
1202  trackValidatorFromPVAllTPPixelTrackingOnly +
1203  trackValidatorBHadronPixelTrackingOnly,
1204  tracksPreValidationPixelTrackingOnly
1205 )
1206 
1207 
1208 
1209 trackValidatorLite = trackValidator.clone(
1210  label = ["generalTracks", "cutsRecoTracksHp"]
1211 )
1212 tracksValidationLite = cms.Sequence(
1213  cutsRecoTracksHp +
1214  trackValidatorLite,
1215  tracksValidationTruth
1216 )
1217 
1218 
1219 from Configuration.Eras.Modifier_phase2_timing_layer_cff import phase2_timing_layer
1220 phase2_timing_layer.toModify( generalTracksFromPV,
1221  timesTag = cms.InputTag('tofPID:t0'),
1222  timeResosTag = cms.InputTag('tofPID:sigmat0'),
1223  nSigmaDtVertex = cms.double(3) )
1224 phase2_timing_layer.toModify( trackValidatorStandalone,
1225  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1226 phase2_timing_layer.toModify( trackValidatorFromPVStandalone,
1227  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1228 phase2_timing_layer.toModify( trackValidatorFromPVAllTPStandalone,
1229  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1230 phase2_timing_layer.toModify( trackValidatorConversionStandalone,
1231  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1232 phase2_timing_layer.toModify( trackValidatorGsfTracks,
1233  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
def _setForEra(module, eraName, era, kwargs)
def _translateArgs(args, postfix, modDict)
def _uniqueFirstLayers(layerList)
_addSelectorsByOriginalAlgoMask
Then define stuff for standalone mode (i.e.
def _getSeedingLayers(seedProducers, config)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def _taskForEachEra(function, args, names, task, modDict, plainArgs=[], modifyTask=None, includeFastSim=False)
#define str(s)