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
12 import Validation.RecoTrack.cutsRecoTracks_cfi as cutsRecoTracks_cfi
13 #from . import cutsRecoTracks_cfi
14 
17 from CommonTools.RecoAlgos.trackingParticleRefSelector_cfi import trackingParticleRefSelector as _trackingParticleRefSelector
18 from CommonTools.RecoAlgos.trackingParticleConversionRefSelector_cfi import trackingParticleConversionRefSelector as _trackingParticleConversionRefSelector
19 from SimTracker.TrackHistory.trackingParticleBHadronRefSelector_cfi import trackingParticleBHadronRefSelector as _trackingParticleBHadronRefSelector
21 from CommonTools.RecoAlgos.recoChargedRefCandidateToTrackRefProducer_cfi import recoChargedRefCandidateToTrackRefProducer as _recoChargedRefCandidateToTrackRefProducer
22 
23 import RecoTracker.IterativeTracking.iterativeTkConfig as _cfg
24 import RecoTracker.IterativeTracking.iterativeTkUtils as _utils
25 from Configuration.Eras.Modifier_fastSim_cff import fastSim
26 
27 
29 for _eraName, _postfix, _era in _cfg.allEras():
30  _seedProd = ["initialStepSeedsPreSplitting"]
31  _trackProd = ["initialStepTracksPreSplitting"]
32  if _eraName in ["trackingLowPU", "trackingPhase2PU140"]: # these don't have preSplitting
33  _seedProd = []
34  _trackProd = []
35 
36  locals()["_algos"+_postfix] = ["generalTracks"] + _cfg.iterationAlgos(_postfix) + ["duplicateMerge"]
37  locals()["_seedProducersPreSplitting"+_postfix] = _seedProd
38  locals()["_trackProducersPreSplitting"+_postfix] = _trackProd
39  locals()["_seedProducers"+_postfix] = _cfg.seedProducers(_postfix)
40  locals()["_trackProducers"+_postfix] = _cfg.trackProducers(_postfix)
41 
42  if _eraName != "trackingPhase2PU140":
43  locals()["_electronSeedProducers"+_postfix] = ["tripletElectronSeeds", "pixelPairElectronSeeds", "stripPairElectronSeeds"]
44  else:
45  locals()["_electronSeedProducers"+_postfix] = ["tripletElectronSeeds"]
46 
47 _removeForFastSimSeedProducers =["initialStepSeedsPreSplitting",
48  "jetCoreRegionalStepSeeds",
49  "jetCoreRegionalStepSeedsBarrel","jetCoreRegionalStepSeedsEndcap",
50  "muonSeededSeedsInOut",
51  "muonSeededSeedsOutIn"]
52 
53 _seedProducers_fastSim = [ x for x in _seedProducers if x not in _removeForFastSimSeedProducers]
54 
55 _removeForFastTrackProducers = ["initialStepTracksPreSplitting",
56  "jetCoreRegionalStepTracks",
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 fastSim.toModify(tracksValidationTruth, lambda x: x.remove(tpClusterProducer))
715 
716 tracksPreValidation = cms.Task(
717  highPtJetsForTrk,
718  tracksValidationSelectors,
719  tracksValidationSelectorsPt09,
720  tracksValidationSelectorsFromPV,
721  tracksValidationSelectorsFromPVPt09,
722  tracksValidationTruth,
723  trackingParticlesSignal,
724  trackingParticlesInTime,
725  trackingParticlesElectron,
726  trackingParticlesConversion
727 )
728 fastSim.toReplaceWith(tracksPreValidation, tracksPreValidation.copyAndExclude([
729  trackingParticlesElectron,
730  trackingParticlesConversion,
731 ]))
732 
733 
734 
735 tracksValidation = cms.Sequence(
736  trackValidator +
737  trackValidatorTPPtLess09 +
738  trackValidatorFromPV +
739  trackValidatorFromPVAllTP +
740  trackValidatorAllTPEffic +
741  trackValidatorBuilding +
742  trackValidatorBuildingPreSplitting +
743  trackValidatorConversion +
744  trackValidatorGsfTracks,
745  tracksPreValidation
746 )
747 
748 from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
749 seedingDeepCore.toReplaceWith(tracksValidation, cms.Sequence(tracksValidation.copy()+trackValidatorJetCore))
750 
751 from Configuration.ProcessModifiers.displacedTrackValidation_cff import displacedTrackValidation
752 displacedTrackValidation.toReplaceWith(tracksValidation, cms.Sequence(tracksValidation.copy()+trackValidatorDisplaced))
753 
754 from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
755 tracksPreValidationPhase2 = tracksPreValidation.copy()
756 tracksPreValidationPhase2.add(trackingParticlesEtaGreater2p7)
757 phase2_tracker.toReplaceWith(tracksPreValidation, tracksPreValidationPhase2)
758 
759 tracksValidationPhase2 = tracksValidation.copyAndExclude([
760  trackValidatorJetCore
761 ])
762 tracksValidationPhase2+=trackValidatorTPEtaGreater2p7
763 phase2_tracker.toReplaceWith(tracksValidation, tracksValidationPhase2)
764 
765 fastSim.toReplaceWith(tracksValidation, tracksValidation.copyAndExclude([
766  trackValidatorBuildingPreSplitting,
767  trackValidatorConversion,
768  trackValidatorGsfTracks,
769 ]))
770 
771 
772 
773 # Select by originalAlgo and algoMask
774 _taskForEachEra(_addSelectorsByOriginalAlgoMask, modDict = globals(),
775  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["ByAlgoMask", "algorithmMaskContains"],
776  names = "_selectorsByAlgoMask", task = "_tracksValidationSelectorsByAlgoMaskStandalone")
777 
778 # Select pT>0.9 by iteration
779 # Need to avoid generalTracks+HP because those are already included in the standard validator
780 _taskForEachEra(_addSelectorsBySrc, modDict = globals(),
781  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["Pt09", "generalTracksPt09"],
782  names = "_selectorsPt09Standalone", task = "_tracksValidationSelectorsPt09Standalone")
783 
784 # Select fromPV by iteration
785 # Need to avoid generalTracks+HP because those are already included in the standard validator
786 _taskForEachEra(_addSelectorsBySrc, modDict = globals(),
787  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["FromPV", "generalTracksFromPV"],
788  names = "_selectorsFromPVStandalone", task = "_tracksValidationSelectorsFromPVStandalone")
789 
790 # Select pt>0.9 and fromPV by iteration
791 # Need to avoid generalTracks+HP because those are already included in the standard validator
792 _taskForEachEra(_addSelectorsBySrc, modDict = globals(),
793  args = ["_selectorsByAlgoAndHpNoGenTk"], plainArgs = ["FromPVPt09", "generalTracksFromPVPt09"],
794  names = "_selectorsFromPVPt09Standalone", task = "_tracksValidationSelectorsFromPVPt09Standalone")
795 
796 # MTV instances
797 trackValidatorStandalone = trackValidator.clone(
798  cores = "highPtJets"
799 )
800 trackValidatorTPPtLess09Standalone = trackValidatorTPPtLess09.clone(
801  cores = "highPtJets"
802 )
803 for _eraName, _postfix, _era in _relevantEras:
804  _setForEra(trackValidatorStandalone, _eraName, _era, label = trackValidator.label + locals()["_selectorsByAlgoMask"+_postfix] + locals()["_selectorsPt09Standalone"+_postfix])
805  _setForEra(trackValidatorTPPtLess09Standalone, _eraName, _era, label = trackValidatorTPPtLess09.label + locals()["_selectorsByAlgoMask"+_postfix] + locals()["_selectorsPt09Standalone"+_postfix])
806 
807 trackValidatorFromPVStandalone = trackValidatorFromPV.clone(
808  cores = "highPtJets"
809 )
810 for _eraName, _postfix, _era in _relevantEras:
811  _setForEra(trackValidatorFromPVStandalone, _eraName, _era, label = trackValidatorFromPV.label + locals()["_selectorsFromPVStandalone"+_postfix] + locals()["_selectorsFromPVPt09Standalone"+_postfix])
812 # do resolutions as in the standard version
813 
814 trackValidatorFromPVAllTPStandalone = trackValidatorFromPVAllTP.clone(
815  label = trackValidatorFromPVStandalone.label.value(),
816  cores = "highPtJets"
817 
818 )
819 trackValidatorAllTPEfficStandalone = trackValidatorAllTPEffic.clone(
820  label = [ x for x in trackValidator.label.value() if x not in ["cutsRecoTracksBtvLike", "cutsRecoTracksAK4PFJets"] and "Pt09" not in x],
821  cores = "highPtJets"
822 )
823 
824 trackValidatorConversionStandalone = trackValidatorConversion.clone(
825  label = [x for x in trackValidatorConversion.label if x != "convStepTracks"],
826  cores = "highPtJets"
827 )
828 
829 trackValidatorBHadronStandalone = trackValidatorBHadron.clone(
830  label = [x for x in trackValidatorStandalone.label if "Pt09" not in x],
831  cores = "highPtJets"
832 )
833 
834 trackValidatorGsfTracksStandalone = trackValidatorGsfTracks.clone(
835  cores = "highPtJets"
836 )
837 
838 # sequences
839 tracksPreValidationStandalone = tracksPreValidation.copy()
840 tracksPreValidationStandalone.add(trackingParticlesBHadron)
841 tracksPreValidationStandalone.replace(highPtJetsForTrk,highPtJets)
842 fastSim.toReplaceWith(tracksPreValidationStandalone, tracksPreValidation)
843 
844 tracksValidationSelectorsStandalone = cms.Task(
845  tracksValidationSelectorsByAlgoMaskStandalone,
846  tracksValidationSelectorsPt09Standalone,
847  tracksValidationSelectorsFromPVStandalone,
848  tracksValidationSelectorsFromPVPt09Standalone
849 )
850 
851 # we copy this for both Standalone and TrackingOnly
852 # and later make modifications from it which change based on era
853 _trackValidatorsBase = cms.Sequence(
854  trackValidatorStandalone +
855  trackValidatorTPPtLess09Standalone +
856  trackValidatorFromPVStandalone +
857  trackValidatorFromPVAllTPStandalone +
858  trackValidatorAllTPEfficStandalone +
859  trackValidatorConversionStandalone +
860  trackValidatorGsfTracksStandalone +
861  trackValidatorBHadronStandalone
862 )
863 
864 _trackValidatorsBasePhase2 = _trackValidatorsBase.copy()
865 _trackValidatorsBasePhase2+=trackValidatorTPEtaGreater2p7
866 phase2_tracker.toReplaceWith(_trackValidatorsBase, _trackValidatorsBasePhase2)
867 
868 trackValidatorsStandalone = _trackValidatorsBase.copy()
869 fastSim.toModify(trackValidatorsStandalone, lambda x: x.remove(trackValidatorConversionStandalone) )
870 
871 tracksValidationStandalone = cms.Sequence(
872  ak4PFL1FastL2L3CorrectorChain +
873  trackValidatorsStandalone,
874  tracksPreValidationStandalone,
875  tracksValidationSelectorsStandalone
876 )
877 
878 
879 
880 # selectors
881 tracksValidationSelectorsTrackingOnly = tracksValidationSelectors.copyAndExclude([ak4JetTracksAssociatorExplicitAll,cutsRecoTracksAK4PFJets]) # selectors using track information only (i.e. no PF)
882 _taskForEachEra(_addSeedToTrackProducers, args=["_seedProducers"], names="_seedSelectors", task="_tracksValidationSeedSelectorsTrackingOnly", includeFastSim=True, modDict=globals())
883 _taskForEachEra(_addSeedToTrackProducers, args=["_seedProducersPreSplitting"], names="_seedSelectorsPreSplitting", task="_tracksValidationSeedSelectorsPreSplittingTrackingOnly", modDict=globals())
884 tracksValidationSeedSelectorsTrackingOnly.add(tracksValidationSeedSelectorsPreSplittingTrackingOnly)
885 
886 # MTV instances
887 trackValidatorTrackingOnly = trackValidatorStandalone.clone(
888  label = [ x for x in trackValidatorStandalone.label if x != "cutsRecoTracksAK4PFJets"],
889  cores = "highPtJetsForTrk"
890  )
891 
892 trackValidatorSeedingTrackingOnly = _trackValidatorSeedingBuilding.clone(
893  dirName = "Tracking/TrackSeeding/",
894  label = _seedSelectors,
895  doSeedPlots = True,
896  doResolutionPlotsForLabels = [ "seedTracksjetCoreRegionalStepSeeds" ]
897 )
898 seedingDeepCore.toModify(trackValidatorSeedingTrackingOnly, doResolutionPlotsForLabels = ["seedTracksjetCoreRegionalStepSeedsBarrel","seedTracksjetCoreRegionalStepSeedsEndcap"] )
899 
900 trackValidatorSeedingPreSplittingTrackingOnly = trackValidatorSeedingTrackingOnly.clone(
901  associators = ["quickTrackAssociatorByHitsPreSplitting"],
902  label = _seedSelectorsPreSplitting,
903  doSummaryPlots = False,
904 
905 )
906 
907 trackValidatorJetCoreSeedingTrackingOnly = trackValidatorSeedingTrackingOnly.clone(
908  dirName = "Tracking/JetCore/TrackSeeding/",
909  associators = ["trackAssociatorByChi2"],
910  UseAssociators = True,
911  doSeedPlots = True,
912 )
913 
914 for _eraName, _postfix, _era in _relevantEras:
915  if 'jetCoreRegionalStep' in _cfg.iterationAlgos(_postfix) :
916  _setForEra(trackValidatorJetCoreSeedingTrackingOnly, _eraName, _era,
917  label = [ "seedTracksjetCoreRegionalStepSeedsBarrel","seedTracksjetCoreRegionalStepSeedsEndcap" ],
918  doResolutionPlotsForLabels = [ "seedTracksjetCoreRegionalStepSeedsBarrel","seedTracksjetCoreRegionalStepSeedsEndcap" ]
919  )
920 
921 for _eraName, _postfix, _era in _relevantErasAndFastSim:
922  _setForEra(trackValidatorSeedingTrackingOnly, _eraName, _era, label = locals()["_seedSelectors"+_postfix])
923 for _eraName, _postfix, _era in _relevantEras:
924  _setForEra(trackValidatorSeedingPreSplittingTrackingOnly, _eraName, _era, label = locals()["_seedSelectorsPreSplitting"+_postfix])
925 
926 
927 trackValidatorConversionTrackingOnly = trackValidatorConversion.clone(label = [x for x in trackValidatorConversion.label if x not in ["ckfInOutTracksFromConversions", "ckfOutInTracksFromConversions"]])
928 
929 trackValidatorBHadronTrackingOnly = trackValidatorBHadron.clone(label = [x for x in trackValidatorTrackingOnly.label if "Pt09" not in x])
930 
931 trackValidatorTPPtLess09TrackingOnly = trackValidatorTPPtLess09Standalone.clone(cores = "highPtJetsForTrk")
932 trackValidatorFromPVTrackingOnly = trackValidatorFromPVStandalone.clone(cores = "highPtJetsForTrk")
933 trackValidatorFromPVAllTPTrackingOnly = trackValidatorFromPVAllTPStandalone.clone(cores = "highPtJetsForTrk")
934 trackValidatorAllTPEfficTrackingOnly = trackValidatorAllTPEfficStandalone.clone(cores = "highPtJetsForTrk")
935 # sequences
936 tracksPreValidationTrackingOnly = tracksPreValidationStandalone.copy()
937 tracksPreValidationTrackingOnly.replace(tracksValidationSelectors, tracksValidationSelectorsTrackingOnly)
938 tracksPreValidationTrackingOnly.replace(highPtJets,highPtJetsForTrk)
939 
940 trackValidatorsTrackingOnly = _trackValidatorsBase.copy()
941 trackValidatorsTrackingOnly.replace(trackValidatorStandalone, trackValidatorTrackingOnly)
942 trackValidatorsTrackingOnly.replace(trackValidatorTPPtLess09Standalone,trackValidatorTPPtLess09TrackingOnly)
943 trackValidatorsTrackingOnly.replace(trackValidatorFromPVStandalone,trackValidatorFromPVTrackingOnly)
944 trackValidatorsTrackingOnly.replace(trackValidatorFromPVAllTPStandalone,trackValidatorFromPVAllTPTrackingOnly)
945 trackValidatorsTrackingOnly.replace(trackValidatorAllTPEfficStandalone,trackValidatorAllTPEfficTrackingOnly)
946 trackValidatorsTrackingOnly += trackValidatorSeedingTrackingOnly
947 trackValidatorsTrackingOnly += trackValidatorSeedingPreSplittingTrackingOnly
948 trackValidatorsTrackingOnly += trackValidatorBuilding
949 trackValidatorsTrackingOnly += trackValidatorBuildingPreSplitting
950 trackValidatorsTrackingOnly.replace(trackValidatorConversionStandalone, trackValidatorConversionTrackingOnly)
951 trackValidatorsTrackingOnly.remove(trackValidatorGsfTracksStandalone)
952 trackValidatorsTrackingOnly.replace(trackValidatorBHadronStandalone, trackValidatorBHadronTrackingOnly)
953 
954 seedingDeepCore.toReplaceWith(trackValidatorsTrackingOnly, cms.Sequence(
955  trackValidatorsTrackingOnly.copy()+
956  trackValidatorJetCore+
957  trackValidatorJetCoreSeedingTrackingOnly
958  )
959  )
960 phase2_tracker.toReplaceWith(trackValidatorsTrackingOnly, trackValidatorsTrackingOnly.copyAndExclude([ #must be done for each era which does not have jetcore in the iteration
961  trackValidatorJetCore,
962  trackValidatorJetCoreSeedingTrackingOnly
963 ]))
964 
965 displacedTrackValidation.toReplaceWith(trackValidatorsTrackingOnly, cms.Sequence(trackValidatorsTrackingOnly.copy()+trackValidatorDisplaced))
966 
967 fastSim.toReplaceWith(trackValidatorsTrackingOnly, trackValidatorsTrackingOnly.copyAndExclude([
968  trackValidatorBuildingPreSplitting,
969  trackValidatorSeedingPreSplittingTrackingOnly,
970  trackValidatorConversionTrackingOnly,
971  trackValidatorBHadronTrackingOnly
972 ]))
973 tracksValidationTrackingOnly = cms.Sequence(
974  trackValidatorsTrackingOnly,
975  tracksPreValidationTrackingOnly,
976  tracksValidationSelectorsStandalone,
977  tracksValidationSeedSelectorsTrackingOnly
978 )
979 
980 
982 trackingParticlePixelTrackAsssociation = trackingParticleRecoTrackAsssociation.clone(
983  label_tr = "pixelTracks",
984  associator = "quickTrackAssociatorByHitsPreSplitting",
985 )
986 PixelVertexAssociatorByPositionAndTracks = VertexAssociatorByPositionAndTracks.clone(
987  trackAssociation = "trackingParticlePixelTrackAsssociation"
988 )
989 
990 _pixelTracksCustom = dict(
991  src = "pixelTracks",
992  vertexTag = "pixelVertices",
993 )
994 
995 trackRefSelector = cms.EDFilter('TrackRefSelector',
996  src = cms.InputTag('pixelTracks'),
997  cut = cms.string("")
998 )
999 
1000 trackSelector = cms.EDFilter('TrackSelector',
1001  src = cms.InputTag('pixelTracks'),
1002  cut = cms.string("")
1003 )
1004 
1005 cutstring = "numberOfValidHits == 3"
1006 pixelTracks3hits = trackRefSelector.clone( cut = cutstring )
1007 
1008 cutstring = "numberOfValidHits >= 4"
1009 pixelTracks4hits = trackRefSelector.clone( cut = cutstring )
1010 
1011 cutstring = "pt > 0.9"
1012 pixelTracksPt09 = trackRefSelector.clone( cut = cutstring )
1013 #pixelTracksPt09 = generalTracksPt09.clone(quality = ["undefQuality"], **_pixelTracksCustom)
1014 
1015 pixelTracksFromPV = generalTracksFromPV.clone(quality = "highPurity", ptMin = 0.0, ptMax = 99999., ptErrorCut = 99999., copyExtras = True, **_pixelTracksCustom)
1016 #pixelTracksFromPVPt09 = generalTracksPt09.clone(quality = ["loose","tight","highPurity"], vertexTag = "pixelVertices", src = "pixelTracksFromPV")
1017 pixelTracksFromPVPt09 = pixelTracksFromPV.clone(ptMin = 0.9)
1018 
1019 cutstring = "numberOfValidHits >= 4"
1020 #pixelTracksFromPV4hits = trackRefSelector.clone( cut = cutstring, src = "pixelTracksFromPV" )
1021 pixelTracksFromPV4hits = pixelTracksFromPV.clone( numberOfValidPixelHits = 4 )
1022 
1023 
1024 trackValidatorPixelTrackingOnly = trackValidator.clone(
1025  dirName = "Tracking/PixelTrack/",
1026  label = [
1027  "pixelTracks", "pixelTracksPt09", "pixelTracks3hits", "pixelTracks4hits",
1028  "pixelTracksL", "pixelTracksPt09L", "pixelTracks3hitsL", "pixelTracks4hitsL",
1029  "pixelTracksT", "pixelTracksPt09T", "pixelTracks3hitsT", "pixelTracks4hitsT",
1030  "pixelTracksHP", "pixelTracksPt09HP", "pixelTracks3hitsHP", "pixelTracks4hitsHP",
1031  ],
1032  doResolutionPlotsForLabels = [],
1033  trackCollectionForDrCalculation = "pixelTracks",
1034  associators = ["trackingParticlePixelTrackAsssociation"],
1035  label_vertex = "pixelVertices",
1036  vertexAssociator = "PixelVertexAssociatorByPositionAndTracks",
1037  dodEdxPlots = False,
1038  cores = cms.InputTag(""),
1039 )
1040 trackValidatorFromPVPixelTrackingOnly = trackValidatorPixelTrackingOnly.clone(
1041  dirName = "Tracking/PixelTrackFromPV/",
1042  label = [
1043  "pixelTracksFromPV", "pixelTracksFromPVPt09", "pixelTracksFromPV4hits",
1044  "pixelTracksFromPVL", "pixelTracksFromPVT", "pixelTracksFromPVHP",
1045  "pixelTracksFromPVPt09L", "pixelTracksFromPVPt09T", "pixelTracksFromPVPt09HP",
1046  "pixelTracksFromPV4hitsL", "pixelTracksFromPV4hitsT", "pixelTracksFromPV4hitsHP",
1047  ],
1048  label_tp_effic = "trackingParticlesSignal",
1049  label_tp_fake = "trackingParticlesSignal",
1050  label_tp_effic_refvector = True,
1051  label_tp_fake_refvector = True,
1052  trackCollectionForDrCalculation = "pixelTracksFromPV",
1053  doPlotsOnlyForTruePV = True,
1054  doPVAssociationPlots = False,
1055  doResolutionPlotsForLabels = ["disabled"],
1056 )
1057 trackValidatorFromPVAllTPPixelTrackingOnly = trackValidatorFromPVPixelTrackingOnly.clone(
1058  dirName = "Tracking/PixelTrackFromPVAllTP/",
1059  label_tp_effic = trackValidatorPixelTrackingOnly.label_tp_effic.value(),
1060  label_tp_fake = trackValidatorPixelTrackingOnly.label_tp_fake.value(),
1061  label_tp_effic_refvector = False,
1062  label_tp_fake_refvector = False,
1063  doSimPlots = False,
1064  doSimTrackPlots = False,
1065 )
1066 trackValidatorBHadronPixelTrackingOnly = trackValidatorPixelTrackingOnly.clone(
1067  dirName = "Tracking/PixelTrackBHadron/",
1068  label = [
1069  "pixelTracks", "pixelTracksPt09",
1070  "pixelTracksL", "pixelTracks3hitsL", "pixelTracks4hitsL",
1071  "pixelTracksT", "pixelTracks3hitsT", "pixelTracks4hitsT",
1072  "pixelTracksHP", "pixelTracks3hitsHP", "pixelTracks4hitsHP",
1073  ],
1074  label_tp_effic = "trackingParticlesBHadron",
1075  label_tp_effic_refvector = True,
1076  doSimPlots = True,
1077  doRecoTrackPlots = False, # Fake rate is defined wrt. all TPs, and that is already included in trackValidator
1078  dodEdxPlots = False,
1079 )
1080 
1081 tracksValidationTruthPixelTrackingOnly = tracksValidationTruth.copy()
1082 tracksValidationTruthPixelTrackingOnly.replace(trackingParticleRecoTrackAsssociation, trackingParticlePixelTrackAsssociation)
1083 tracksValidationTruthPixelTrackingOnly.replace(VertexAssociatorByPositionAndTracks, PixelVertexAssociatorByPositionAndTracks)
1084 tracksValidationTruthPixelTrackingOnly.add(trackingParticlesBHadron)
1085 tracksValidationTruthPixelTrackingOnly.add( pixelTracks3hits )
1086 tracksValidationTruthPixelTrackingOnly.add( pixelTracks4hits )
1087 tracksValidationTruthPixelTrackingOnly.add( pixelTracksPt09 )
1088 tracksValidationTruthPixelTrackingOnly.add( pixelTracksFromPV )
1089 tracksValidationTruthPixelTrackingOnly.add( pixelTracksFromPVPt09 )
1090 tracksValidationTruthPixelTrackingOnly.add( pixelTracksFromPV4hits )
1091 
1092 tracksPreValidationPixelTrackingOnly = cms.Task(
1093  tracksValidationTruthPixelTrackingOnly,
1094  trackingParticlesSignal)
1095 
1096 
1097 quality = {
1098  "L" : (1,"loose", ["loose","tight","highPurity"]),
1099  "T" : (2,"tight", ["tight","highPurity"]),
1100  "HP" : (4,"highPurity",["highPurity"]),
1101 }
1102 
1103 for key,value in quality.items():
1104  qualityName = value[1]
1105  qualityBit = value[0]
1106  qualityList = value[2]
1107 
1108  label = "pixelTracks"+str(key)
1109  cutstring = "qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1110  locals()[label] = trackRefSelector.clone( cut = cutstring )
1111  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1112 
1113  label = "pixelTracksFromPV"+key
1114 # locals()[label] = generalTracksPt09.clone( ptMin = 0.0, vertexTag = "pixelVertices", src = "pixelTracksFromPV", quality = qualityList )
1115  locals()[label] = pixelTracksFromPV.clone( quality = qualityName )
1116  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1117 #-----------
1118  cutstring = "pt > 0.9 & qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1119  label = "pixelTracksPt09"+key
1120  locals()[label] = trackRefSelector.clone( cut = cutstring )
1121  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1122 
1123  label = "pixelTracksFromPVPt09"+key
1124  # locals()[label] = generalTracksPt09.clone( ptMin = 0.9, vertexTag = "pixelVertices", src = "pixelTracksFromPV", quality = qualityList )
1125  locals()[label] = pixelTracksFromPVPt09.clone( quality = qualityName )
1126  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1127 #-----------
1128  label = "pixelTracks4hits"+key
1129  cutstring = "numberOfValidHits == 4 & qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1130  locals()[label] = trackRefSelector.clone( cut = cutstring )
1131  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1132 
1133  label = "pixelTracksFromPV4hits"+key
1134 # locals()[label] = generalTracksPt09.clone( ptMin = 0.0, minHit = 4, vertexTag = "pixelVertices", src = "pixelTracksFromPV", quality = qualityList )
1135  locals()[label] = pixelTracksFromPV4hits.clone( quality = qualityName )
1136  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1137 #--------
1138  label = "pixelTracks3hits"+key
1139  cutstring = "numberOfValidHits == 3 & qualityMask <= 7 & qualityMask >= " + str(qualityBit)
1140  locals()[label] = trackRefSelector.clone( cut = cutstring )
1141  tracksPreValidationPixelTrackingOnly.add(locals()[label])
1142 
1143 tracksValidationPixelTrackingOnly = cms.Sequence(
1144  trackValidatorPixelTrackingOnly +
1145  trackValidatorFromPVPixelTrackingOnly +
1146  trackValidatorFromPVAllTPPixelTrackingOnly +
1147  trackValidatorBHadronPixelTrackingOnly,
1148  tracksPreValidationPixelTrackingOnly
1149 )
1150 
1151 
1152 
1153 trackValidatorLite = trackValidator.clone(
1154  label = ["generalTracks", "cutsRecoTracksHp"]
1155 )
1156 tracksValidationLite = cms.Sequence(
1157  cutsRecoTracksHp +
1158  trackValidatorLite,
1159  tracksValidationTruth
1160 )
1161 
1162 
1163 from Configuration.Eras.Modifier_phase2_timing_layer_cff import phase2_timing_layer
1164 phase2_timing_layer.toModify( generalTracksFromPV,
1165  timesTag = cms.InputTag('tofPID:t0'),
1166  timeResosTag = cms.InputTag('tofPID:sigmat0'),
1167  nSigmaDtVertex = cms.double(3) )
1168 phase2_timing_layer.toModify( trackValidatorStandalone,
1169  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1170 phase2_timing_layer.toModify( trackValidatorFromPVStandalone,
1171  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1172 phase2_timing_layer.toModify( trackValidatorFromPVAllTPStandalone,
1173  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1174 phase2_timing_layer.toModify( trackValidatorConversionStandalone,
1175  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
1176 phase2_timing_layer.toModify( trackValidatorGsfTracks,
1177  label_vertex = cms.untracked.InputTag('offlinePrimaryVertices4D') )
TrackValidation_cff._addSelectorsBySrc
_addSelectorsBySrc
Definition: TrackValidation_cff.py:312
TrackWithVertexRefSelector_cfi
TrackValidation_cff._addSelectorsByAlgo
_addSelectorsByAlgo
Definition: TrackValidation_cff.py:253
ElectronSeeds_cff
LhcParametersDefinerForTP_cfi
TrackValidation_cff._getSeedingLayers
def _getSeedingLayers(seedProducers, config)
Definition: TrackValidation_cff.py:192
ak4JTA_cff
TrackValidation_cff._translateArgs
def _translateArgs(args, postfix, modDict)
Definition: TrackValidation_cff.py:149
trackAssociatorByChi2_cfi
TrackValidation_cff._addSelectorsByHp
_addSelectorsByHp
Definition: TrackValidation_cff.py:256
iterativeTk_cff
trackingParticleNumberOfLayersProducer_cff
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
MultiTrackValidator_cfi
str
#define str(s)
Definition: TestProcessor.cc:53
TrackValidation_cff._getMVASelectors
def _getMVASelectors(postfix)
Definition: TrackValidation_cff.py:242
TrackValidation_cff._addSelectorsByOriginalAlgoMask
_addSelectorsByOriginalAlgoMask
Then define stuff for standalone mode (i.e.
Definition: TrackValidation_cff.py:265
TrackValidation_cff._algoToSelector
def _algoToSelector(algo)
Definition: TrackValidation_cff.py:61
TrackValidation_cff.modifyTask
modifyTask
Definition: TrackValidation_cff.py:316
Exception
tpClusterProducer_cfi
JetCorrectors_cff
TrackValidation_cff._addSeedToTrackProducers
_addSeedToTrackProducers
Definition: TrackValidation_cff.py:882
TrackValidation_cff._taskForEachEra
def _taskForEachEra(function, args, names, task, modDict, plainArgs=[], modifyTask=None, includeFastSim=False)
Definition: TrackValidation_cff.py:157
TrackValidation_cff._setForEra
def _setForEra(module, eraName, era, **kwargs)
Definition: TrackValidation_cff.py:184
VertexAssociatorByPositionAndTracks_cfi
PostProcessorTracker_cfi
quickTrackAssociatorByHits_cfi
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
pileupCalc.upper
upper
Definition: pileupCalc.py:213
cutsRecoTracks_cfi
CosmicParametersDefinerForTP_cfi
trackingParticleRecoTrackAsssociation_cfi
TrackValidation_cff._uniqueFirstLayers
def _uniqueFirstLayers(layerList)
Definition: TrackValidation_cff.py:576
ConversionStep_cff