CMS 3D CMS Logo

TrackValidation_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
7 from Validation.RecoTrack.trajectorySeedTracks_cfi import trajectorySeedTracks as _trajectorySeedTracks
11 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 from Configuration.Eras.Modifier_fastSim_cff import fastSim
23 
24 ### First define the stuff for the standard validation sequence
25 ## Track selectors
26 for _eraName, _postfix, _era in _cfg.allEras():
27  _seedProd = ["initialStepSeedsPreSplitting"]
28  _trackProd = ["initialStepTracksPreSplitting"]
29  if _eraName in ["trackingLowPU", "trackingPhase1PU70", "trackingPhase2PU140"]: # these don't have preSplitting
30  _seedProd = []
31  _trackProd = []
32 
33  locals()["_algos"+_postfix] = ["generalTracks"] + _cfg.iterationAlgos(_postfix) + ["duplicateMerge"]
34  locals()["_seedProducers"+_postfix] = _seedProd + _cfg.seedProducers(_postfix)
35  locals()["_trackProducers"+_postfix] = _trackProd + _cfg.trackProducers(_postfix)
36 
37 _removeForFastSimSeedProducers =["initialStepSeedsPreSplitting",
38  "jetCoreRegionalStepSeeds",
39  "muonSeededSeedsInOut",
40  "muonSeededSeedsOutIn"]
41 _seedProducers_fastSim = [ x for x in _seedProducers if x not in _removeForFastSimSeedProducers]
42 
43 _removeForFastTrackProducers = ["initialStepTracksPreSplitting",
44  "jetCoreRegionalStepTracks",
45  "muonSeededTracksInOut",
46  "muonSeededTracksOutIn"]
47 _trackProducers_fastSim = [ x for x in _trackProducers if x not in _removeForFastTrackProducers]
48 
49 def _algoToSelector(algo):
50  sel = ""
51  if algo != "generalTracks":
52  sel = algo[0].upper()+algo[1:]
53  return "cutsRecoTracks"+sel
54 
55 def _addSelectorsByAlgo(algos, modDict):
56  names = []
57  seq = cms.Sequence()
58  for algo in algos:
59  if algo == "generalTracks":
60  continue
61  modName = _algoToSelector(algo)
62  if modName not in modDict:
63  mod = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=[algo])
64  modDict[modName] = mod
65  else:
66  mod = modDict[modName]
67  names.append(modName)
68  seq += mod
69  return (names, seq)
70 def _addSelectorsByHp(algos, modDict):
71  seq = cms.Sequence()
72  names = []
73  for algo in algos:
74  modName = _algoToSelector(algo)
75  modNameHp = modName+"Hp"
76  if modNameHp not in modDict:
77  if algo == "generalTracks":
78  mod = cutsRecoTracks_cfi.cutsRecoTracks.clone(quality=["highPurity"])
79  else:
80  mod = modDict[modName].clone(quality=["highPurity"])
81  modDict[modNameHp] = mod
82  else:
83  mod = modDict[modNameHp]
84  names.append(modNameHp)
85  seq += mod
86  return (names, seq)
87 def _addSelectorsBySrc(modules, midfix, src, modDict):
88  seq = cms.Sequence()
89  names = []
90  for modName in modules:
91  modNameNew = modName.replace("cutsRecoTracks", "cutsRecoTracks"+midfix)
92  if modNameNew not in modDict:
93  mod = modDict[modName].clone(src=src)
94  modDict[modNameNew] = mod
95  else:
96  mod = modDict[modNameNew]
97  names.append(modNameNew)
98  seq += mod
99  return (names, seq)
100 def _addSelectorsByOriginalAlgoMask(modules, midfix, algoParam,modDict):
101  seq = cms.Sequence()
102  names = []
103  for modName in modules:
104  if modName[-2:] == "Hp":
105  modNameNew = modName[:-2] + midfix + "Hp"
106  else:
107  modNameNew = modName + midfix
108  if modNameNew not in modDict:
109  mod = modDict[modName].clone()
110  setattr(mod, algoParam, mod.algorithm.value())
111  mod.algorithm = []
112  modDict[modNameNew] = mod
113  else:
114  mod = modDict[modNameNew]
115  names.append(modNameNew)
116  seq += mod
117  return (names, seq)
118 def _addSeedToTrackProducers(seedProducers,modDict):
119  names = []
120  seq = cms.Sequence()
121  for seed in seedProducers:
122  modName = "seedTracks"+seed
123  if modName not in modDict:
124  mod = _trajectorySeedTracks.clone(src=seed)
125  modDict[modName] = mod
126  else:
127  mod = modDict[modName]
128  names.append(modName)
129  seq += mod
130  return (names, seq)
131 
132 _relevantEras = _cfg.allEras()
133 _relevantErasAndFastSim = _relevantEras + [("fastSim", "_fastSim", fastSim)]
134 def _translateArgs(args, postfix, modDict):
135  ret = []
136  for arg in args:
137  if isinstance(arg, list):
138  ret.append(_translateArgs(arg, postfix, modDict))
139  else:
140  ret.append(modDict[arg+postfix])
141  return ret
142 def _sequenceForEachEra(function, args, names, sequence, modDict, plainArgs=[], modifySequence=None, includeFastSim=False):
143  if sequence[0] != "_":
144  raise Exception("Sequence name is expected to begin with _")
145 
146  _eras = _relevantErasAndFastSim if includeFastSim else _relevantEras
147  for eraName, postfix, _era in _eras:
148  _args = _translateArgs(args, postfix, modDict)
149  _args.extend(plainArgs)
150  ret = function(*_args, modDict=modDict)
151  if len(ret) != 2:
152  raise Exception("_sequenceForEachEra is expected to return 2 values, but function returned %d" % len(ret))
153  modDict[names+postfix] = ret[0]
154  modDict[sequence+postfix] = ret[1]
155 
156  # The sequence of the first era will be the default one
157  defaultSequenceName = sequence+_eras[0][0]
158  defaultSequence = modDict[defaultSequenceName]
159  modDict[defaultSequenceName[1:]] = defaultSequence # remove leading underscore
160 
161  # Optionally modify sequences before applying the era
162  if modifySequence is not None:
163  for eraName, postfix, _era in _eras:
164  modifySequence(modDict[sequence+postfix])
165 
166  # Apply eras
167  for _eraName, _postfix, _era in _eras[1:]:
168  _era.toReplaceWith(defaultSequence, modDict[sequence+_postfix])
169 def _setForEra(module, eraName, era, **kwargs):
170  if eraName == "":
171  for key, value in kwargs.iteritems():
172  setattr(module, key, value)
173  else:
174  era.toModify(module, **kwargs)
175 
176 # Seeding layer sets
177 def _getSeedingLayers(seedProducers):
178  import RecoTracker.IterativeTracking.iterativeTk_cff as _iterativeTk_cff
179 
180  def _findSeedingLayers(name):
181  prod = getattr(_iterativeTk_cff, name)
182  if hasattr(prod, "triplets"):
183  if hasattr(prod, "layerList"): # merger
184  return prod.layerList.refToPSet_.value()
185  return _findSeedingLayers(prod.triplets.getModuleLabel())
186  elif hasattr(prod, "doublets"):
187  return _findSeedingLayers(prod.doublets.getModuleLabel())
188  return prod.seedingLayers.getModuleLabel()
189 
190  seedingLayersMerged = []
191  for seedName in seedProducers:
192  seedProd = getattr(_iterativeTk_cff, seedName)
193  if hasattr(seedProd, "OrderedHitsFactoryPSet"):
194  if hasattr(seedProd, "SeedMergerPSet"):
195  seedingLayersName = seedProd.SeedMergerPSet.layerList.refToPSet_.value()
196  else:
197  seedingLayersName = seedProd.OrderedHitsFactoryPSet.SeedingLayers.getModuleLabel()
198  elif hasattr(seedProd, "seedingHitSets"):
199  seedingLayersName = _findSeedingLayers(seedProd.seedingHitSets.getModuleLabel())
200  else:
201  continue
202 
203  seedingLayers = getattr(_iterativeTk_cff, seedingLayersName).layerList.value()
204  for layerSet in seedingLayers:
205  if layerSet not in seedingLayersMerged:
206  seedingLayersMerged.append(layerSet)
207  return seedingLayersMerged
208 for _eraName, _postfix, _era in _relevantEras:
209  locals()["_seedingLayerSets"+_postfix] = _getSeedingLayers(locals()["_seedProducers"+_postfix])
210 
211 # MVA selectors
212 def _getMVASelectors(postfix):
213  import RecoTracker.IterativeTracking.iterativeTk_cff as _iterativeTk_cff
214 
215  # assume naming convention that the iteration name (when first
216  # letter in lower case) is the selector name
217  pset = cms.untracked.PSet()
218  for iterName, seqName in _cfg.iterationAlgos(postfix, includeSequenceName=True):
219  if hasattr(_iterativeTk_cff, iterName):
220  mod = getattr(_iterativeTk_cff, iterName)
221  seq = getattr(_iterativeTk_cff, seqName)
222 
223  # Ignore iteration if the MVA selector module is not in the sequence
224  try:
225  seq.index(mod)
226  except:
227  continue
228 
229  typeName = mod._TypedParameterizable__type
230  classifiers = []
231  if typeName == "ClassifierMerger":
232  classifiers = mod.inputClassifiers.value()
233  elif "TrackMVAClassifier" in typeName:
234  classifiers = [iterName]
235  if len(classifiers) > 0:
236  setattr(pset, iterName+"Tracks", cms.untracked.vstring(classifiers))
237 
238  return pset
239 for _eraName, _postfix, _era in _relevantEras:
240  locals()["_mvaSelectors"+_postfix] = _getMVASelectors(_postfix)
241 
242 # Validation iterative steps
243 _sequenceForEachEra(_addSelectorsByAlgo, args=["_algos"], names="_selectorsByAlgo", sequence="_tracksValidationSelectorsByAlgo", modDict=globals())
244 
245 # high purity
246 _sequenceForEachEra(_addSelectorsByHp, args=["_algos"], names="_selectorsByAlgoHp", sequence="_tracksValidationSelectorsByAlgoHp", modDict=globals())
247 
248 for _eraName, _postfix, _era in _relevantEras:
249  selectors = locals()["_selectorsByAlgoHp"+_postfix]
250  locals()["_generalTracksHp"+_postfix] = selectors[0]
251  locals()["_selectorsByAlgoHp"+_postfix] = selectors[1:]
252 
253 # BTV-like selection
254 import PhysicsTools.RecoAlgos.btvTracks_cfi as btvTracks_cfi
255 cutsRecoTracksBtvLike = btvTracks_cfi.btvTrackRefs.clone()
256 
257 # Select tracks associated to AK4 jets
259 ak4JetTracksAssociatorExplicitAll = ak4JTA_cff.ak4JetTracksAssociatorExplicit.clone(
260  jets = "ak4PFJets"
261 )
263 import CommonTools.RecoAlgos.jetTracksAssociationToTrackRefs_cfi as jetTracksAssociationToTrackRefs_cfi
264 cutsRecoTracksAK4PFJets = jetTracksAssociationToTrackRefs_cfi.jetTracksAssociationToTrackRefs.clone(
265  association = "ak4JetTracksAssociatorExplicitAll",
266  jets = "ak4PFJets",
267  correctedPtMin = 10,
268 )
269 
270 
271 ## Select signal TrackingParticles, and do the corresponding associations
272 trackingParticlesSignal = _trackingParticleRefSelector.clone(
273  signalOnly = True,
274  chargedOnly = False,
275  tip = 1e5,
276  lip = 1e5,
277  minRapidity = -10,
278  maxRapidity = 10,
279  ptMin = 0,
280 )
281 
282 # select tracks with pT > 0.9 GeV (for upgrade fake rates)
283 generalTracksPt09 = cutsRecoTracks_cfi.cutsRecoTracks.clone(ptMin=0.9)
284 # and then the selectors
285 _sequenceForEachEra(_addSelectorsBySrc, modDict=globals(),
286  args=[["_generalTracksHp"]],
287  plainArgs=["Pt09", "generalTracksPt09"],
288  names="_selectorsPt09", sequence="_tracksValidationSelectorsPt09",
289  modifySequence=lambda seq:seq.insert(0, generalTracksPt09))
290 
291 # select tracks from the PV
292 from CommonTools.RecoAlgos.TrackWithVertexRefSelector_cfi import trackWithVertexRefSelector as _trackWithVertexRefSelector
293 generalTracksFromPV = _trackWithVertexRefSelector.clone(
294  src = "generalTracks",
295  ptMin = 0,
296  ptMax = 1e10,
297  ptErrorCut = 1e10,
298  quality = "loose",
299  vertexTag = "offlinePrimaryVertices",
300  nVertices = 1,
301  vtxFallback = False,
302  zetaVtx = 0.1, # 1 mm
303  rhoVtx = 1e10, # intentionally no dxy cut
304 )
305 # and then the selectors
306 _sequenceForEachEra(_addSelectorsBySrc, modDict=globals(),
307  args=[["_generalTracksHp"]],
308  plainArgs=["FromPV", "generalTracksFromPV"],
309  names="_selectorsFromPV", sequence="_tracksValidationSelectorsFromPV",
310  modifySequence=lambda seq: seq.insert(0, generalTracksFromPV))
311 
312 # select tracks with pT > 0.9 GeV from the PV
313 generalTracksFromPVPt09 = generalTracksPt09.clone(src="generalTracksFromPV")
314 # and then the selectors
315 _sequenceForEachEra(_addSelectorsBySrc, modDict=globals(),
316  args=[["_generalTracksHp"]],
317  plainArgs=["FromPVPt09", "generalTracksFromPVPt09"],
318  names="_selectorsFromPVPt09", sequence="_tracksValidationSelectorsFromPVPt09",
319  modifySequence=lambda seq: seq.insert(0, generalTracksFromPVPt09))
320 
321 ## Select conversion TrackingParticles, and define the corresponding associator
322 trackingParticlesConversion = _trackingParticleConversionRefSelector.clone()
323 
324 ## Select electron TPs
325 trackingParticlesElectron = _trackingParticleRefSelector.clone(
326  pdgId = [-11, 11],
327  signalOnly = False,
328  tip = 1e5,
329  lip = 1e5,
330  minRapidity = -10,
331  maxRapidity = 10,
332  ptMin = 0,
333 )
334 
335 # Select B-hadron TPs
336 trackingParticlesBHadron = _trackingParticleBHadronRefSelector.clone()
337 
338 ## MTV instances
339 trackValidator = Validation.RecoTrack.MultiTrackValidator_cfi.multiTrackValidator.clone(
340  useLogPt = cms.untracked.bool(True),
341  dodEdxPlots = True,
342  doPVAssociationPlots = True
343  #,minpT = cms.double(-1)
344  #,maxpT = cms.double(3)
345  #,nintpT = cms.int32(40)
346 )
347 fastSim.toModify(trackValidator,
348  dodEdxPlots = False)
349 
350 for _eraName, _postfix, _era in _relevantEras:
351  _setForEra(trackValidator, _eraName, _era,
352  label = ["generalTracks", locals()["_generalTracksHp"+_postfix]] +
353  locals()["_selectorsByAlgo"+_postfix] + locals()["_selectorsByAlgoHp"+_postfix] +
354  ["generalTracksPt09"] + locals()["_selectorsPt09"+_postfix] +
355  [
356  "cutsRecoTracksBtvLike",
357  "cutsRecoTracksAK4PFJets"
358  ]
359  )
360  _setForEra(trackValidator.histoProducerAlgoBlock, _eraName, _era, seedingLayerSets=locals()["_seedingLayerSets"+_postfix])
361 
362 # For efficiency of signal TPs vs. signal tracks, and fake rate of
363 # signal tracks vs. signal TPs
364 trackValidatorFromPV = trackValidator.clone(
365  dirName = "Tracking/TrackFromPV/",
366  label_tp_effic = "trackingParticlesSignal",
367  label_tp_fake = "trackingParticlesSignal",
368  label_tp_effic_refvector = True,
369  label_tp_fake_refvector = True,
370  trackCollectionForDrCalculation = "generalTracksFromPV",
371  doPlotsOnlyForTruePV = True,
372  doPVAssociationPlots = False,
373 )
374 for _eraName, _postfix, _era in _relevantEras:
375  _setForEra(trackValidatorFromPV, _eraName, _era, label = ["generalTracksFromPV"] + locals()["_selectorsFromPV"+_postfix] + ["generalTracksFromPVPt09"] + locals()["_selectorsFromPVPt09"+_postfix])
376 
377 # For fake rate of signal tracks vs. all TPs, and pileup rate of
378 # signal tracks vs. non-signal TPs
379 trackValidatorFromPVAllTP = trackValidatorFromPV.clone(
380  dirName = "Tracking/TrackFromPVAllTP/",
381  label_tp_effic = trackValidator.label_tp_effic.value(),
382  label_tp_fake = trackValidator.label_tp_fake.value(),
383  label_tp_effic_refvector = False,
384  label_tp_fake_refvector = False,
385  doSimPlots = False,
386  doSimTrackPlots = False,
387 )
388 
389 # For efficiency of all TPs vs. all tracks
390 trackValidatorAllTPEffic = trackValidator.clone(
391  dirName = "Tracking/TrackAllTPEffic/",
392  label = [x for x in trackValidator.label.value() if "Pt09" not in x],
393  doSimPlots = False,
394  doRecoTrackPlots = True, # Fake rate of all tracks vs. all TPs is already included in trackValidator, but we want the reco plots for other reasons
395  doPVAssociationPlots = False,
396 )
397 trackValidatorAllTPEffic.histoProducerAlgoBlock.generalTpSelector.signalOnly = False
398 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsEta.signalOnly = False
399 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsPhi.signalOnly = False
400 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsPt.signalOnly = False
401 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsVTXR.signalOnly = False
402 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsVTXZ.signalOnly = False
403 for _eraName, _postfix, _era in _relevantEras:
404  _setForEra(trackValidatorAllTPEffic, _eraName, _era, label = ["generalTracks", locals()["_generalTracksHp"+_postfix]])
405 
406 # For conversions
407 trackValidatorConversion = trackValidator.clone(
408  dirName = "Tracking/TrackConversion/",
409  label = [
410  "convStepTracks",
411  "conversionStepTracks",
412  "ckfInOutTracksFromConversions",
413  "ckfOutInTracksFromConversions",
414  ],
415  label_tp_effic = "trackingParticlesConversion",
416  label_tp_effic_refvector = True,
417  associators = ["quickTrackAssociatorByHits"],
418  UseAssociators = True,
419  doSimPlots = True,
420  dodEdxPlots = False,
421  doPVAssociationPlots = False,
422  calculateDrSingleCollection = False,
423 )
424 # relax lip and tip
425 for n in ["Eta", "Phi", "Pt", "VTXR", "VTXZ"]:
426  pset = getattr(trackValidatorConversion.histoProducerAlgoBlock, "TpSelectorForEfficiencyVs"+n)
427  pset.lip = trackValidatorConversion.lipTP.value()
428  pset.tip = trackValidatorConversion.tipTP.value()
429 
430 # For electrons
431 trackValidatorGsfTracks = trackValidatorConversion.clone(
432  dirName = "Tracking/TrackGsf/",
433  label = ["electronGsfTracks"],
434  label_tp_effic = "trackingParticlesElectron",
435 )
436 
437 # for B-hadrons
438 trackValidatorBHadron = trackValidator.clone(
439  dirName = "Tracking/TrackBHadron/",
440  label_tp_effic = "trackingParticlesBHadron",
441  label_tp_effic_refvector = True,
442  doSimPlots = True,
443  doRecoTrackPlots = False, # Fake rate is defined wrt. all TPs, and that is already included in trackValidator
444  dodEdxPlots = False,
445 )
446 for _eraName, _postfix, _era in _relevantEras:
447  _setForEra(trackValidatorBHadron, _eraName, _era,
448  label = ["generalTracks", locals()["_generalTracksHp"+_postfix], "cutsRecoTracksBtvLike"]
449  )
450 
451 
452 # the track selectors
453 tracksValidationSelectors = cms.Sequence(
454  tracksValidationSelectorsByAlgo +
455  tracksValidationSelectorsByAlgoHp +
456  cutsRecoTracksBtvLike +
457  ak4JetTracksAssociatorExplicitAll +
458  cutsRecoTracksAK4PFJets
459 )
460 tracksValidationTruth = cms.Sequence(
461  tpClusterProducer +
462  quickTrackAssociatorByHits +
463  trackingParticleRecoTrackAsssociation +
464  VertexAssociatorByPositionAndTracks +
465  trackingParticleNumberOfLayersProducer
466 )
467 fastSim.toModify(tracksValidationTruth, lambda x: x.remove(tpClusterProducer))
468 
469 tracksPreValidation = cms.Sequence(
470  tracksValidationSelectors +
471  tracksValidationSelectorsPt09 +
472  tracksValidationSelectorsFromPV +
473  tracksValidationSelectorsFromPVPt09 +
474  tracksValidationTruth +
475  cms.ignore(trackingParticlesSignal) +
476  cms.ignore(trackingParticlesElectron) +
477  trackingParticlesConversion
478 )
479 fastSim.toReplaceWith(tracksPreValidation, tracksPreValidation.copyAndExclude([
480  trackingParticlesElectron,
481  trackingParticlesConversion,
482 ]))
483 
484 tracksValidation = cms.Sequence(
485  tracksPreValidation +
486  trackValidator +
487  trackValidatorFromPV +
488  trackValidatorFromPVAllTP +
489  trackValidatorAllTPEffic +
490  trackValidatorConversion +
491  trackValidatorGsfTracks
492 )
493 fastSim.toReplaceWith(tracksValidation, tracksValidation.copyAndExclude([
494  trackValidatorConversion,
495  trackValidatorGsfTracks,
496 ]))
497 
498 ### Then define stuff for standalone mode (i.e. MTV with RECO+DIGI input)
499 
500 # Select by originalAlgo and algoMask
501 for _eraName, _postfix, _era in _relevantEras:
502  locals()["_selectorsByAlgoAndHp"+_postfix] = locals()["_selectorsByAlgo"+_postfix] + locals()["_selectorsByAlgoHp"+_postfix]
503 _sequenceForEachEra(_addSelectorsByOriginalAlgoMask, modDict = globals(),
504  args = ["_selectorsByAlgoAndHp"], plainArgs = ["ByOriginalAlgo", "originalAlgorithm"],
505  names = "_selectorsByOriginalAlgo", sequence = "_tracksValidationSelectorsByOriginalAlgoStandalone")
506 _sequenceForEachEra(_addSelectorsByOriginalAlgoMask, modDict = globals(),
507  args = ["_selectorsByAlgoAndHp"], plainArgs = ["ByAlgoMask", "algorithmMaskContains"],
508  names = "_selectorsByAlgoMask", sequence = "_tracksValidationSelectorsByAlgoMaskStandalone")
509 
510 # Select pT>0.9 by iteration
511 _sequenceForEachEra(_addSelectorsBySrc, modDict = globals(),
512  args = ["_selectorsByAlgoAndHp"], plainArgs = ["Pt09", "generalTracksPt09"],
513  names = "_selectorsPt09Standalone", sequence = "_tracksValidationSelectorsPt09Standalone")
514 
515 # Select fromPV by iteration
516 _sequenceForEachEra(_addSelectorsBySrc, modDict = globals(),
517  args = ["_selectorsByAlgoAndHp"], plainArgs = ["FromPV", "generalTracksFromPV"],
518  names = "_selectorsFromPVStandalone", sequence = "_tracksValidationSelectorsFromPVStandalone")
519 
520 # Select pt>0.9 and fromPV by iteration
521 _sequenceForEachEra(_addSelectorsBySrc, modDict = globals(),
522  args = ["_selectorsByAlgoAndHp"], plainArgs = ["FromPVPt09", "generalTracksFromPVPt09"],
523  names = "_selectorsFromPVPt09Standalone", sequence = "_tracksValidationSelectorsFromPVPt09Standalone")
524 
525 # MTV instances
526 trackValidatorStandalone = trackValidator.clone()
527 for _eraName, _postfix, _era in _relevantEras:
528  _setForEra(trackValidatorStandalone, _eraName, _era, label = trackValidator.label + locals()["_selectorsByOriginalAlgo"+_postfix] + locals()["_selectorsByAlgoMask"+_postfix] + locals()["_selectorsPt09Standalone"+_postfix])
529 
530 trackValidatorFromPVStandalone = trackValidatorFromPV.clone()
531 for _eraName, _postfix, _era in _relevantEras:
532  _setForEra(trackValidatorFromPVStandalone, _eraName, _era, label = trackValidatorFromPV.label + locals()["_selectorsFromPVStandalone"+_postfix] + locals()["_selectorsFromPVPt09Standalone"+_postfix])
533 
534 trackValidatorFromPVAllTPStandalone = trackValidatorFromPVAllTP.clone(
535  label = trackValidatorFromPVStandalone.label.value()
536 )
537 trackValidatorAllTPEfficStandalone = trackValidatorAllTPEffic.clone(
538  label = [ x for x in trackValidator.label.value() if x not in ["cutsRecoTracksBtvLike", "cutsRecoTracksAK4PFJets"] and "Pt09" not in x]
539 )
540 
541 trackValidatorConversionStandalone = trackValidatorConversion.clone( label = [x for x in trackValidatorConversion.label if x != "convStepTracks"])
542 
543 trackValidatorBHadronStandalone = trackValidatorBHadron.clone(label = [x for x in trackValidatorStandalone.label if "Pt09" not in x])
544 
545 # sequences
546 tracksPreValidationStandalone = tracksPreValidation.copy()
547 tracksPreValidationStandalone += trackingParticlesBHadron
548 fastSim.toReplaceWith(tracksPreValidationStandalone, tracksPreValidation)
549 
550 tracksValidationSelectorsStandalone = cms.Sequence(
551  tracksValidationSelectorsByOriginalAlgoStandalone +
552  tracksValidationSelectorsByAlgoMaskStandalone +
553  tracksValidationSelectorsPt09Standalone +
554  tracksValidationSelectorsFromPVStandalone +
555  tracksValidationSelectorsFromPVPt09Standalone
556 )
557 
558 # we copy this for both Standalone and TrackingOnly
559 # and later make modifications from it which change based on era
560 _trackValidatorsBase = cms.Sequence(
561  trackValidatorStandalone +
562  trackValidatorFromPVStandalone +
563  trackValidatorFromPVAllTPStandalone +
564  trackValidatorAllTPEfficStandalone +
565  trackValidatorConversionStandalone +
566  trackValidatorGsfTracks +
567  trackValidatorBHadronStandalone
568 )
569 trackValidatorsStandalone = _trackValidatorsBase.copy()
570 fastSim.toModify(trackValidatorsStandalone, lambda x: x.remove(trackValidatorConversionStandalone) )
571 
572 tracksValidationStandalone = cms.Sequence(
573  ak4PFL1FastL2L3CorrectorChain +
574  tracksPreValidationStandalone +
575  tracksValidationSelectorsStandalone +
576  trackValidatorsStandalone
577 )
578 
579 ### TrackingOnly mode (i.e. MTV with DIGI input + tracking-only reconstruction)
580 
581 # selectors
582 tracksValidationSelectorsTrackingOnly = tracksValidationSelectors.copyAndExclude([ak4JetTracksAssociatorExplicitAll,cutsRecoTracksAK4PFJets]) # selectors using track information only (i.e. no PF)
583 _sequenceForEachEra(_addSeedToTrackProducers, args=["_seedProducers"], names="_seedSelectors", sequence="_tracksValidationSeedSelectorsTrackingOnly", includeFastSim=True, modDict=globals())
584 
585 # MTV instances
586 trackValidatorTrackingOnly = trackValidatorStandalone.clone(label = [ x for x in trackValidatorStandalone.label if x != "cutsRecoTracksAK4PFJets"] )
587 
588 _trackValidatorSeedingBuildingTrackingOnly = trackValidatorTrackingOnly.clone( # common for seeds and built tracks
589  associators = ["quickTrackAssociatorByHits"],
590  UseAssociators = True,
591  dodEdxPlots = False,
592  doPVAssociationPlots = False,
593  doSimPlots = False,
594 )
595 trackValidatorBuildingTrackingOnly = _trackValidatorSeedingBuildingTrackingOnly.clone(
596  dirName = "Tracking/TrackBuilding/",
597  doMVAPlots = True,
598 )
599 for _eraName, _postfix, _era in _relevantErasAndFastSim:
600  _setForEra(trackValidatorBuildingTrackingOnly, _eraName, _era, label = locals()["_trackProducers"+_postfix])
601 fastSim.toModify(trackValidatorBuildingTrackingOnly, doMVAPlots=False)
602 for _eraName, _postfix, _era in _relevantEras:
603  _setForEra(trackValidatorBuildingTrackingOnly, _eraName, _era, mvaLabels = locals()["_mvaSelectors"+_postfix])
604 
605 trackValidatorSeedingTrackingOnly = _trackValidatorSeedingBuildingTrackingOnly.clone(
606  dirName = "Tracking/TrackSeeding/",
607  label = _seedSelectors,
608  doSeedPlots = True,
609 )
610 for _eraName, _postfix, _era in _relevantErasAndFastSim:
611  _setForEra(trackValidatorSeedingTrackingOnly, _eraName, _era, label = locals()["_seedSelectors"+_postfix])
612 
613 
614 trackValidatorConversionTrackingOnly = trackValidatorConversion.clone(label = [x for x in trackValidatorConversion.label if x not in ["ckfInOutTracksFromConversions", "ckfOutInTracksFromConversions"]])
615 
616 trackValidatorBHadronTrackingOnly = trackValidatorBHadron.clone(label = [x for x in trackValidatorTrackingOnly.label if "Pt09" not in x])
617 
618 # sequences
619 tracksPreValidationTrackingOnly = tracksPreValidationStandalone.copy()
620 tracksPreValidationTrackingOnly.replace(tracksValidationSelectors, tracksValidationSelectorsTrackingOnly)
621 
622 trackValidatorsTrackingOnly = _trackValidatorsBase.copy()
623 trackValidatorsTrackingOnly.replace(trackValidatorStandalone, trackValidatorTrackingOnly)
624 trackValidatorsTrackingOnly += (
625  trackValidatorSeedingTrackingOnly +
626  trackValidatorBuildingTrackingOnly
627 )
628 trackValidatorsTrackingOnly.replace(trackValidatorConversionStandalone, trackValidatorConversionTrackingOnly)
629 trackValidatorsTrackingOnly.remove(trackValidatorGsfTracks)
630 trackValidatorsTrackingOnly.replace(trackValidatorBHadronStandalone, trackValidatorBHadronTrackingOnly)
631 fastSim.toModify(trackValidatorsTrackingOnly, lambda x: x.remove(trackValidatorConversionTrackingOnly))
632 fastSim.toModify(trackValidatorsTrackingOnly, lambda x: x.remove(trackValidatorBHadronTrackingOnly))
633 
634 
635 tracksValidationTrackingOnly = cms.Sequence(
636  tracksPreValidationTrackingOnly +
637  tracksValidationSelectorsStandalone +
638  tracksValidationSeedSelectorsTrackingOnly +
639  trackValidatorsTrackingOnly
640 )
641 
642 
643 
644 ### Lite mode (only generalTracks and HP)
645 trackValidatorLite = trackValidator.clone(
646  label = ["generalTracks", "cutsRecoTracksHp"]
647 )
648 tracksValidationLite = cms.Sequence(
649  cutsRecoTracksHp +
650  tracksValidationTruth +
651  trackValidatorLite
652 )
Definition: vlib.h:256
def _sequenceForEachEra(function, args, names, sequence, modDict, plainArgs=[], modifySequence=None, includeFastSim=False)
def _setForEra(module, eraName, era, kwargs)
def _translateArgs(args, postfix, modDict)
_addSelectorsByOriginalAlgoMask
Then define stuff for standalone mode (i.e.
def _getSeedingLayers(seedProducers)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135