CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackValidation_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
10 import cutsRecoTracks_cfi
11 
14 from PhysicsTools.RecoAlgos.trackingParticleSelector_cfi import trackingParticleSelector as _trackingParticleSelector
15 from CommonTools.RecoAlgos.sortedPrimaryVertices_cfi import sortedPrimaryVertices as _sortedPrimaryVertices
16 from CommonTools.RecoAlgos.recoChargedRefCandidateToTrackRefProducer_cfi import recoChargedRefCandidateToTrackRefProducer as _recoChargedRefCandidateToTrackRefProducer
17 
18 ## Track selectors
19 # Validation iterative steps
20 cutsRecoTracksInitialStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["initialStep"])
21 cutsRecoTracksLowPtTripletStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["lowPtTripletStep"])
22 cutsRecoTracksPixelPairStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["pixelPairStep"])
23 cutsRecoTracksDetachedTripletStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["detachedTripletStep"])
24 cutsRecoTracksMixedTripletStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["mixedTripletStep"])
25 cutsRecoTracksPixelLessStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["pixelLessStep"])
26 cutsRecoTracksTobTecStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["tobTecStep"])
27 cutsRecoTracksJetCoreRegionalStep = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["jetCoreRegionalStep"])
28 cutsRecoTracksMuonSeededStepInOut = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["muonSeededStepInOut"])
29 cutsRecoTracksMuonSeededStepOutIn = cutsRecoTracks_cfi.cutsRecoTracks.clone(algorithm=["muonSeededStepOutIn"])
30 
31 # high purity
32 cutsRecoTracksHp = cutsRecoTracks_cfi.cutsRecoTracks.clone(quality=["highPurity"])
33 cutsRecoTracksInitialStepHp = cutsRecoTracksInitialStep.clone(quality=["highPurity"])
34 cutsRecoTracksLowPtTripletStepHp = cutsRecoTracksLowPtTripletStep.clone(quality=["highPurity"])
35 cutsRecoTracksPixelPairStepHp = cutsRecoTracksPixelPairStep.clone(quality=["highPurity"])
36 cutsRecoTracksDetachedTripletStepHp = cutsRecoTracksDetachedTripletStep.clone(quality=["highPurity"])
37 cutsRecoTracksMixedTripletStepHp = cutsRecoTracksMixedTripletStep.clone(quality=["highPurity"])
38 cutsRecoTracksPixelLessStepHp = cutsRecoTracksPixelLessStep.clone(quality=["highPurity"])
39 cutsRecoTracksTobTecStepHp = cutsRecoTracksTobTecStep.clone(quality=["highPurity"])
40 cutsRecoTracksJetCoreRegionalStepHp = cutsRecoTracksJetCoreRegionalStep.clone(quality=["highPurity"])
41 cutsRecoTracksMuonSeededStepInOutHp = cutsRecoTracksMuonSeededStepInOut.clone(quality=["highPurity"])
42 cutsRecoTracksMuonSeededStepOutInHp = cutsRecoTracksMuonSeededStepOutIn.clone(quality=["highPurity"])
43 
44 # BTV-like selection
45 import PhysicsTools.RecoAlgos.btvTracks_cfi as btvTracks_cfi
46 cutsRecoTracksBtvLike = btvTracks_cfi.btvTrackRefs.clone()
47 
48 # Select tracks associated to AK4 jets
50 ak4JetTracksAssociatorAtVertexPFAll = ak4JTA_cff.ak4JetTracksAssociatorAtVertexPF.clone(
51  jets = "ak4PFJets"
52 )
54 import CommonTools.RecoAlgos.jetTracksAssociationToTrackRefs_cfi as jetTracksAssociationToTrackRefs_cfi
55 cutsRecoTracksAK4PFJets = jetTracksAssociationToTrackRefs_cfi.jetTracksAssociationToTrackRefs.clone(
56  association = "ak4JetTracksAssociatorAtVertexPFAll",
57  jets = "ak4PFJets",
58  correctedPtMin = 10,
59 )
60 
61 
62 ## Select signal TrackingParticles, and do the corresponding associations
63 trackingParticlesSignal = _trackingParticleSelector.clone(
64  signalOnly = True,
65  chargedOnly = False,
66  tip = 1e5,
67  lip = 1e5,
68  minRapidity = -10,
69  maxRapidity = 10,
70  ptMin = 0,
71 )
72 tpClusterProducerSignal = tpClusterProducer.clone(
73  trackingParticleSrc = "trackingParticlesSignal"
74 )
75 quickTrackAssociatorByHitsSignal = quickTrackAssociatorByHits.clone(
76  cluster2TPSrc = "tpClusterProducerSignal"
77 )
78 trackingParticleRecoTrackAsssociationSignal = trackingParticleRecoTrackAsssociation.clone(
79  label_tp = "trackingParticlesSignal",
80  associator = "quickTrackAssociatorByHitsSignal"
81 )
82 
83 # select tracks from the PV
84 # first convert to RecoChargedRefCandidates
85 trackRefsForValidation = cms.EDProducer("ChargedRefCandidateProducer",
86  particleType = cms.string('pi+'),
87  src = cms.InputTag("generalTracks")
88 )
89 # then use the "PV sorting" module to select the candidates associated to PV
90 trackRefsFromPV = _sortedPrimaryVertices.clone(
91  particles = "trackRefsForValidation",
92  produceAssociationToOriginalVertices = True,
93  produceNoPileUpCollection = True,
94  produceSortedVertices = False,
95  jets = "ak4CaloJets",
96  vertices = "offlinePrimaryVertices"
97 )
98 # and finally extract tracks from there
99 generalTracksFromPV = _recoChargedRefCandidateToTrackRefProducer.clone(
100  src = cms.InputTag("trackRefsFromPV", "originalNoPileUp")
101 )
102 # and then the selectors
103 cutsRecoTracksFromPVInitialStep = cutsRecoTracksInitialStep.clone(src="generalTracksFromPV")
104 cutsRecoTracksFromPVLowPtTripletStep = cutsRecoTracksLowPtTripletStep.clone(src="generalTracksFromPV")
105 cutsRecoTracksFromPVPixelPairStep = cutsRecoTracksPixelPairStep.clone(src="generalTracksFromPV")
106 cutsRecoTracksFromPVDetachedTripletStep = cutsRecoTracksDetachedTripletStep.clone(src="generalTracksFromPV")
107 cutsRecoTracksFromPVMixedTripletStep = cutsRecoTracksMixedTripletStep.clone(src="generalTracksFromPV")
108 cutsRecoTracksFromPVPixelLessStep = cutsRecoTracksPixelLessStep.clone(src="generalTracksFromPV")
109 cutsRecoTracksFromPVTobTecStep = cutsRecoTracksTobTecStep.clone(src="generalTracksFromPV")
110 cutsRecoTracksFromPVJetCoreRegionalStep = cutsRecoTracksJetCoreRegionalStep.clone(src="generalTracksFromPV")
111 cutsRecoTracksFromPVMuonSeededStepInOut = cutsRecoTracksMuonSeededStepInOut.clone(src="generalTracksFromPV")
112 cutsRecoTracksFromPVMuonSeededStepOutIn = cutsRecoTracksMuonSeededStepOutIn.clone(src="generalTracksFromPV")
113 # high purity
114 cutsRecoTracksFromPVHp = cutsRecoTracksHp.clone(src="generalTracksFromPV")
115 cutsRecoTracksFromPVInitialStepHp = cutsRecoTracksInitialStepHp.clone(src="generalTracksFromPV")
116 cutsRecoTracksFromPVLowPtTripletStepHp = cutsRecoTracksLowPtTripletStepHp.clone(src="generalTracksFromPV")
117 cutsRecoTracksFromPVPixelPairStepHp = cutsRecoTracksPixelPairStepHp.clone(src="generalTracksFromPV")
118 cutsRecoTracksFromPVDetachedTripletStepHp = cutsRecoTracksDetachedTripletStepHp.clone(src="generalTracksFromPV")
119 cutsRecoTracksFromPVMixedTripletStepHp = cutsRecoTracksMixedTripletStepHp.clone(src="generalTracksFromPV")
120 cutsRecoTracksFromPVPixelLessStepHp = cutsRecoTracksPixelLessStepHp.clone(src="generalTracksFromPV")
121 cutsRecoTracksFromPVTobTecStepHp = cutsRecoTracksTobTecStepHp.clone(src="generalTracksFromPV")
122 cutsRecoTracksFromPVJetCoreRegionalStepHp = cutsRecoTracksJetCoreRegionalStepHp.clone(src="generalTracksFromPV")
123 cutsRecoTracksFromPVMuonSeededStepInOutHp = cutsRecoTracksMuonSeededStepInOutHp.clone(src="generalTracksFromPV")
124 cutsRecoTracksFromPVMuonSeededStepOutInHp = cutsRecoTracksMuonSeededStepOutInHp.clone(src="generalTracksFromPV")
125 
126 
127 ## MTV instances
128 trackValidator= Validation.RecoTrack.MultiTrackValidator_cfi.multiTrackValidator.clone()
129 
130 trackValidator.label=cms.VInputTag(cms.InputTag("generalTracks"),
131  cms.InputTag("cutsRecoTracksHp"),
132  cms.InputTag("cutsRecoTracksInitialStep"),
133  cms.InputTag("cutsRecoTracksInitialStepHp"),
134  cms.InputTag("cutsRecoTracksLowPtTripletStep"),
135  cms.InputTag("cutsRecoTracksLowPtTripletStepHp"),
136  cms.InputTag("cutsRecoTracksPixelPairStep"),
137  cms.InputTag("cutsRecoTracksPixelPairStepHp"),
138  cms.InputTag("cutsRecoTracksDetachedTripletStep"),
139  cms.InputTag("cutsRecoTracksDetachedTripletStepHp"),
140  cms.InputTag("cutsRecoTracksMixedTripletStep"),
141  cms.InputTag("cutsRecoTracksMixedTripletStepHp"),
142  cms.InputTag("cutsRecoTracksPixelLessStep"),
143  cms.InputTag("cutsRecoTracksPixelLessStepHp"),
144  cms.InputTag("cutsRecoTracksTobTecStep"),
145  cms.InputTag("cutsRecoTracksTobTecStepHp"),
146  cms.InputTag("cutsRecoTracksJetCoreRegionalStep"),
147  cms.InputTag("cutsRecoTracksJetCoreRegionalStepHp"),
148  cms.InputTag("cutsRecoTracksMuonSeededStepInOut"),
149  cms.InputTag("cutsRecoTracksMuonSeededStepInOutHp"),
150  cms.InputTag("cutsRecoTracksMuonSeededStepOutIn"),
151  cms.InputTag("cutsRecoTracksMuonSeededStepOutInHp"),
152  cms.InputTag("cutsRecoTracksBtvLike"),
153  cms.InputTag("cutsRecoTracksAK4PFJets"),
154  )
155 trackValidator.useLogPt=cms.untracked.bool(True)
156 trackValidator.dodEdxPlots = True
157 trackValidator.doPVAssociationPlots = True
158 #trackValidator.minpT = cms.double(-1)
159 #trackValidator.maxpT = cms.double(3)
160 #trackValidator.nintpT = cms.int32(40)
161 
162 from Configuration.StandardSequences.Eras import eras
163 if eras.fastSim.isChosen():
164  trackValidator.dodEdxPlots = False
165 
166 # For efficiency of signal TPs vs. signal tracks, and fake rate of
167 # signal tracks vs. signal TPs
168 trackValidatorFromPV = trackValidator.clone(
169  dirName = "Tracking/TrackFromPV/",
170  label = [
171  "generalTracksFromPV",
172  "cutsRecoTracksFromPVHp",
173  ],
174  label_tp_effic = "trackingParticlesSignal",
175  label_tp_fake = "trackingParticlesSignal",
176  associators = ["trackingParticleRecoTrackAsssociationSignal"],
177  trackCollectionForDrCalculation = "generalTracksFromPV",
178  doPlotsOnlyForTruePV = True,
179  doPVAssociationPlots = False,
180 )
181 trackValidatorFromPVStandalone = trackValidatorFromPV.clone()
182 trackValidatorFromPVStandalone.label.extend([
183  "cutsRecoTracksFromPVInitialStep",
184  "cutsRecoTracksFromPVInitialStepHp",
185  "cutsRecoTracksFromPVLowPtTripletStep",
186  "cutsRecoTracksFromPVLowPtTripletStepHp",
187  "cutsRecoTracksFromPVPixelPairStep",
188  "cutsRecoTracksFromPVPixelPairStepHp",
189  "cutsRecoTracksFromPVDetachedTripletStep",
190  "cutsRecoTracksFromPVDetachedTripletStepHp",
191  "cutsRecoTracksFromPVMixedTripletStep",
192  "cutsRecoTracksFromPVMixedTripletStepHp",
193  "cutsRecoTracksFromPVPixelLessStep",
194  "cutsRecoTracksFromPVPixelLessStepHp",
195  "cutsRecoTracksFromPVTobTecStep",
196  "cutsRecoTracksFromPVTobTecStepHp",
197  "cutsRecoTracksFromPVJetCoreRegionalStep",
198  "cutsRecoTracksFromPVJetCoreRegionalStepHp",
199  "cutsRecoTracksFromPVMuonSeededStepInOut",
200  "cutsRecoTracksFromPVMuonSeededStepInOutHp",
201  "cutsRecoTracksFromPVMuonSeededStepOutIn",
202  "cutsRecoTracksFromPVMuonSeededStepOutInHp",
203 ])
204 
205 # For fake rate of signal tracks vs. all TPs, and pileup rate of
206 # signal tracks vs. non-signal TPs
207 trackValidatorFromPVAllTP = trackValidatorFromPV.clone(
208  dirName = "Tracking/TrackFromPVAllTP/",
209  label_tp_effic = trackValidator.label_tp_effic.value(),
210  label_tp_fake = trackValidator.label_tp_fake.value(),
211  associators = trackValidator.associators.value(),
212  doSimPlots = False,
213  doSimTrackPlots = False,
214 )
215 trackValidatorFromPVAllTPStandalone = trackValidatorFromPVAllTP.clone(
216  label = trackValidatorFromPVStandalone.label.value()
217 )
218 
219 # For efficiency of all TPs vs. all tracks
220 trackValidatorAllTPEffic = trackValidator.clone(
221  dirName = "Tracking/TrackAllTPEffic/",
222  label = [
223  "generalTracks",
224  "cutsRecoTracksHp",
225  ],
226  doSimPlots = False,
227  doRecoTrackPlots = False, # Fake rate of all tracks vs. all TPs is already included in trackValidator
228  doPVAssociationPlots = False,
229 )
230 trackValidatorAllTPEffic.histoProducerAlgoBlock.generalTpSelector.signalOnly = False
231 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsEta.signalOnly = False
232 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsPhi.signalOnly = False
233 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsPt.signalOnly = False
234 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsVTXR.signalOnly = False
235 trackValidatorAllTPEffic.histoProducerAlgoBlock.TpSelectorForEfficiencyVsVTXZ.signalOnly = False
236 trackValidatorAllTPEfficStandalone = trackValidatorAllTPEffic.clone(
237  label = trackValidator.label.value()
238 )
239 
240 
241 # the track selectors
242 tracksValidationSelectors = cms.Sequence(
243  cutsRecoTracksHp*
244  cutsRecoTracksInitialStep*
245  cutsRecoTracksInitialStepHp*
246  cutsRecoTracksLowPtTripletStep*
247  cutsRecoTracksLowPtTripletStepHp*
248  cutsRecoTracksPixelPairStep*
249  cutsRecoTracksPixelPairStepHp*
250  cutsRecoTracksDetachedTripletStep*
251  cutsRecoTracksDetachedTripletStepHp*
252  cutsRecoTracksMixedTripletStep*
253  cutsRecoTracksMixedTripletStepHp*
254  cutsRecoTracksPixelLessStep*
255  cutsRecoTracksPixelLessStepHp*
256  cutsRecoTracksTobTecStep*
257  cutsRecoTracksTobTecStepHp*
258  cutsRecoTracksJetCoreRegionalStep*
259  cutsRecoTracksJetCoreRegionalStepHp*
260  cutsRecoTracksMuonSeededStepInOut*
261  cutsRecoTracksMuonSeededStepInOutHp*
262  cutsRecoTracksMuonSeededStepOutIn*
263  cutsRecoTracksMuonSeededStepOutInHp*
264  cutsRecoTracksBtvLike*
265  ak4JetTracksAssociatorAtVertexPFAll*
266  cutsRecoTracksAK4PFJets
267 )
268 tracksValidationSelectorsFromPV = cms.Sequence(
269  trackRefsForValidation*
270  trackRefsFromPV*
271  generalTracksFromPV*
272  cutsRecoTracksFromPVHp
273 )
274 tracksValidationSelectorsFromPVStandalone = cms.Sequence(
275  cutsRecoTracksFromPVInitialStep*
276  cutsRecoTracksFromPVInitialStepHp*
277  cutsRecoTracksFromPVLowPtTripletStep*
278  cutsRecoTracksFromPVLowPtTripletStepHp*
279  cutsRecoTracksFromPVPixelPairStep*
280  cutsRecoTracksFromPVPixelPairStepHp*
281  cutsRecoTracksFromPVDetachedTripletStep*
282  cutsRecoTracksFromPVDetachedTripletStepHp*
283  cutsRecoTracksFromPVMixedTripletStep*
284  cutsRecoTracksFromPVMixedTripletStepHp*
285  cutsRecoTracksFromPVPixelLessStep*
286  cutsRecoTracksFromPVPixelLessStepHp*
287  cutsRecoTracksFromPVTobTecStep*
288  cutsRecoTracksFromPVTobTecStepHp*
289  cutsRecoTracksFromPVJetCoreRegionalStep*
290  cutsRecoTracksFromPVJetCoreRegionalStepHp*
291  cutsRecoTracksFromPVMuonSeededStepInOut*
292  cutsRecoTracksFromPVMuonSeededStepInOutHp*
293  cutsRecoTracksFromPVMuonSeededStepOutIn*
294  cutsRecoTracksFromPVMuonSeededStepOutInHp
295 )
296 tracksValidationTruth = cms.Sequence(
297  tpClusterProducer +
298  quickTrackAssociatorByHits +
299  trackingParticleRecoTrackAsssociation +
300  VertexAssociatorByPositionAndTracks
301 )
302 
303 tracksValidationTruthSignal = cms.Sequence(
304  cms.ignore(trackingParticlesSignal) +
305  tpClusterProducerSignal +
306  quickTrackAssociatorByHitsSignal +
307  trackingParticleRecoTrackAsssociationSignal
308 )
309 
310 if eras.fastSim.isChosen():
311  tracksValidationTruth.remove(tpClusterProducer)
312  tracksValidationTruthSignal.remove(tpClusterProducerSignal)
313 
314 
315 tracksPreValidation = cms.Sequence(
316  tracksValidationSelectors +
317  tracksValidationSelectorsFromPV +
318  tracksValidationTruth +
319  tracksValidationTruthSignal
320 )
321 tracksPreValidationStandalone = cms.Sequence(
322  tracksPreValidation +
323  tracksValidationSelectorsFromPVStandalone
324 )
325 
326 # selectors go into separate "prevalidation" sequence
327 tracksValidation = cms.Sequence(
328  trackValidator +
329  trackValidatorFromPV +
330  trackValidatorFromPVAllTP +
331  trackValidatorAllTPEffic
332 )
333 
334 tracksValidationStandalone = cms.Sequence(
335  ak4PFL1FastL2L3CorrectorChain+
336  tracksPreValidationStandalone+
337  trackValidator +
338  trackValidatorFromPVStandalone +
339  trackValidatorFromPVAllTPStandalone +
340  trackValidatorAllTPEfficStandalone
341 )
342 
343 # 'slim' sequences that only depend on track and tracking particle collections
344 tracksValidationSelectorsSlim = tracksValidationSelectors.copyAndExclude([cutsRecoTracksBtvLike,ak4JetTracksAssociatorAtVertexPFAll,cutsRecoTracksAK4PFJets])
345 
346 tracksPreValidationSlim = cms.Sequence(
347  tracksValidationSelectorsSlim +
348  tracksValidationTruth
349 )
350 
351 trackValidatorSlim = trackValidator.clone(
352  doPVAssociationPlots = cms.untracked.bool(False),
353  dodEdxPlots = False
354 )
355 for _label in [cms.InputTag("cutsRecoTracksBtvLike"),cms.InputTag("cutsRecoTracksAK4PFJets")]:
356  trackValidatorSlim.label.remove(_label)
357 
358 tracksValidationSlim = cms.Sequence(
359  tracksPreValidationSlim+
360  trackValidatorSlim
361 )