File indexing completed on 2024-04-06 12:33:26
0001 import FWCore.ParameterSet.Config as cms
0002
0003 def _label(tag):
0004 if hasattr(tag, "getModuleLabel"):
0005 t = tag
0006 else:
0007 t = cms.InputTag(tag)
0008 return t.getModuleLabel()+t.getProductInstanceLabel()
0009
0010 def customiseTrackingNtupleTool(process, isRECO = True, mergeIters = False):
0011 process.load("Validation.RecoTrack.trackingNtuple_cff")
0012 process.TFileService = cms.Service("TFileService",
0013 fileName = cms.string('trackingNtuple.root')
0014 )
0015
0016 if process.trackingNtuple.includeSeeds.value():
0017 if isRECO:
0018 if not hasattr(process, "reconstruction_step"):
0019 raise Exception("TrackingNtuple includeSeeds=True needs reconstruction which is missing")
0020 else:
0021 if not hasattr(process, "HLTIterativeTrackingIter02"):
0022 raise Exception("TrackingNtuple includeSeeds=True needs HLTIterativeTrackingIter02 which is missing")
0023
0024
0025 if not hasattr(process, "validation_step"):
0026 raise Exception("TrackingNtuple customise assumes process.validation_step exists")
0027
0028
0029
0030 usePileupSimHits = hasattr(process, "mix") and hasattr(process.mix, "input") and len(process.mix.input.fileNames) > 0
0031
0032
0033 if not isRECO:
0034 if not hasattr(process,"hltMultiTrackValidation"):
0035 process.load("Validation.RecoTrack.HLTmultiTrackValidator_cff")
0036 process.trackingNtupleSequence = process.hltMultiTrackValidation.copy()
0037 import RecoLocalTracker.SiStripRecHitConverter.SiStripRecHitConverter_cfi as SiStripRecHitConverter_cfi
0038 process.hltSiStripRecHits = SiStripRecHitConverter_cfi.siStripMatchedRecHits.clone(
0039 ClusterProducer = "hltSiStripRawToClustersFacility",
0040 StripCPE = "hltESPStripCPEfromTrackAngle:hltESPStripCPEfromTrackAngle"
0041 )
0042 process.trackingNtupleSequence.insert(0,process.trackingParticlesIntime+process.simHitTPAssocProducer)
0043 process.trackingNtupleSequence.remove(process.hltTrackValidator)
0044 process.trackingNtupleSequence += process.hltSiStripRecHits + process.trackingNtuple
0045
0046
0047 if mergeIters and isRECO:
0048 import RecoTracker.FinalTrackSelectors.TrackCollectionMerger_cfi as _mod
0049 process.mergedStepTracks = _mod.TrackCollectionMerger.clone(
0050 trackProducers = cms.VInputTag(m.replace("Seeds", "Tracks").replace("seedTracks", "") for m in process.trackingNtuple.seedTracks),
0051 inputClassifiers = cms.vstring(m.replace("StepSeeds", "Step").replace("seedTracks", "").replace("dSeeds", "dTracks")
0052 .replace("InOut", "InOutClassifier").replace("tIn", "tInClassifier")
0053 for m in process.trackingNtuple.seedTracks),
0054 minQuality = "any",
0055 enableMerging = False
0056 )
0057 process.trackingNtupleSequence.insert(0,process.mergedStepTracks)
0058 process.trackingNtuple.tracks = "mergedStepTracks"
0059 process.trackingNtuple.includeMVA = True
0060 process.trackingNtuple.trackMVAs = ["mergedStepTracks"]
0061
0062 ntuplePath = cms.Path(process.trackingNtupleSequence)
0063
0064 if process.trackingNtuple.includeAllHits and process.trackingNtuple.includeTrackingParticles and usePileupSimHits:
0065 ntuplePath.insert(0, cms.SequencePlaceholder("mix"))
0066
0067 process.load("Validation.RecoTrack.crossingFramePSimHitToPSimHits_cfi")
0068 instanceLabels = [_label(tag) for tag in process.simHitTPAssocProducer.simHitSrc]
0069 process.crossingFramePSimHitToPSimHits.src = ["mix:"+l for l in instanceLabels]
0070 process.simHitTPAssocProducer.simHitSrc = ["crossingFramePSimHitToPSimHits:"+l for l in instanceLabels]
0071 process.trackingNtupleSequence.insert(0, process.crossingFramePSimHitToPSimHits)
0072
0073
0074 modifier = cms.Modifier()
0075 modifier._setChosen()
0076 modifier.toReplaceWith(process.prevalidation_step, ntuplePath)
0077 modifier.toReplaceWith(process.validation_step, cms.EndPath())
0078
0079
0080 for p in [process.paths_(), process.endpaths_()]:
0081 for pathName, path in p.items():
0082 if "prevalidation_step" in pathName:
0083 if len(pathName.replace("prevalidation_step", "")) > 0:
0084 modifier.toReplaceWith(path, cms.Path())
0085 elif "validation_step" in pathName:
0086 if len(pathName.replace("validation_step", "")) > 0:
0087 modifier.toReplaceWith(path, cms.EndPath())
0088
0089
0090 for outputModule in process.outputModules_().values():
0091 for path in process.paths_().values():
0092 path.remove(outputModule)
0093 for path in process.endpaths_().values():
0094 path.remove(outputModule)
0095
0096
0097 return process
0098
0099 def customiseTrackingNtuple(process):
0100 customiseTrackingNtupleTool(process, isRECO = True)
0101 return process
0102
0103 def customiseTrackingNtupleMergeIters(process):
0104 customiseTrackingNtupleTool(process, isRECO = True, mergeIters = True)
0105 return process
0106
0107 def customiseTrackingNtupleHLT(process):
0108 import Validation.RecoTrack.TrackValidation_cff as _TrackValidation_cff
0109 _seedProducers = [
0110 "hltIter0PFLowPixelSeedsFromPixelTracks",
0111 "hltIter1PFLowPixelSeedsFromPixelTracks",
0112 "hltIter2PFlowPixelSeeds",
0113 "hltDoubletRecoveryPFlowPixelSeeds"
0114 ]
0115 _candidatesProducers = [
0116 "hltIter0PFlowCkfTrackCandidates",
0117 "hltIter1PFlowCkfTrackCandidates",
0118 "hltIter2PFlowCkfTrackCandidates",
0119 "hltDoubletRecoveryPFlowCkfTrackCandidates"
0120 ]
0121 (_seedSelectors, _tmpTask) = _TrackValidation_cff._addSeedToTrackProducers(_seedProducers, globals())
0122 _seedSelectorsTask = cms.Task()
0123 for modName in _seedSelectors:
0124 if not hasattr(process, modName):
0125 setattr(process,modName, globals()[modName].clone(beamSpot = "hltOnlineBeamSpot"))
0126 _seedSelectorsTask.add(getattr(process, modName))
0127
0128 customiseTrackingNtupleTool(process, isRECO = False)
0129
0130 process.trackingNtupleSequence.insert(0,cms.Sequence(_seedSelectorsTask))
0131 if process.hltSiStripRawToClustersFacility.onDemand.value():
0132
0133 process.trackingNtupleSequence.insert(0,process.hltMergedTracks)
0134
0135 process.trackingNtuple.tracks = "hltMergedTracks"
0136 process.trackingNtuple.seedTracks = _seedSelectors
0137 process.trackingNtuple.trackCandidates = _candidatesProducers
0138 process.trackingNtuple.clusterTPMap = "hltTPClusterProducer"
0139 process.trackingNtuple.trackAssociator = "hltTrackAssociatorByHits"
0140 process.trackingNtuple.beamSpot = "hltOnlineBeamSpot"
0141 process.trackingNtuple.pixelRecHits = "hltSiPixelRecHits"
0142 process.trackingNtuple.stripRphiRecHits = "hltSiStripRecHits:rphiRecHit"
0143 process.trackingNtuple.stripStereoRecHits = "hltSiStripRecHits:stereoRecHit"
0144 process.trackingNtuple.stripMatchedRecHits = "hltSiStripRecHits:matchedRecHit"
0145 process.trackingNtuple.vertices = "hltPixelVertices"
0146 process.trackingNtuple.TTRHBuilder = "hltESPTTRHBWithTrackAngle"
0147 process.trackingNtuple.parametersDefiner = "hltLhcParametersDefinerForTP"
0148 process.trackingNtuple.includeMVA = False
0149
0150 return process
0151
0152 def extendedContent(process):
0153 process.trackingParticlesIntime.intimeOnly = False
0154 process.trackingNtuple.includeOOT = True
0155 process.trackingNtuple.keepEleSimHits = True
0156
0157 process.trackingNtuple.saveSimHitsP3 = True
0158 process.trackingNtuple.addSeedCurvCov = True
0159
0160 process.trackingNtuple.includeOnTrackHitData = True
0161 process.trackingNtuple.includeTrackCandidates = True
0162
0163 return process