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