Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-19 23:20:19

0001 # This file is the authoritative source of the order of tracking
0002 # iterations. It is used in RECO, DQM, and VALIDATION. Note that here
0003 # InitialStepPreSplitting is not counted as an iteration.
0004 import FWCore.ParameterSet.Config as cms
0005 
0006 _defaultEraName = ""
0007 _nonDefaultEraNames = ["trackingLowPU", "trackingPhase1", "trackingPhase2PU140"]
0008 
0009 # name, postfix, era
0010 _defaultEra = (_defaultEraName, "", None)
0011 _nonDefaultEras = [
0012     (_name, "_"+_name, getattr(__import__('Configuration.Eras.Modifier_'+_name+'_cff',globals(),locals(),[_name],0),_name)) \
0013     for _name in _nonDefaultEraNames
0014 ]
0015 
0016 _allEras = [_defaultEra] + _nonDefaultEras
0017 
0018 
0019 _iterations = [
0020     "InitialStep",
0021     "DetachedTripletStep",
0022     "LowPtTripletStep",
0023     "PixelPairStep",
0024     "MixedTripletStep",
0025     "PixelLessStep",
0026     "TobTecStep",
0027     "JetCoreRegionalStep",
0028 ]
0029 _iterations_trackingLowPU = [
0030     "InitialStep",
0031     "LowPtTripletStep",
0032     "PixelPairStep",
0033     "DetachedTripletStep",
0034     "MixedTripletStep",
0035     "PixelLessStep",
0036     "TobTecStep",
0037 ]
0038 _iterations_trackingPhase1 = [
0039     "InitialStep",
0040     "LowPtQuadStep",
0041     "HighPtTripletStep",
0042     "LowPtTripletStep",
0043     "DetachedQuadStep",
0044     "DetachedTripletStep",
0045     "PixelPairStep",
0046     "MixedTripletStep",
0047     "PixelLessStep",
0048     "TobTecStep",
0049 ]
0050 
0051 from Configuration.ProcessModifiers.displacedTracking_cff import displacedTracking
0052 displacedTracking.toModify(_iterations_trackingPhase1, func=lambda x: x.append('DisplacedGeneralStep'))
0053 
0054 _iterations_trackingPhase1.append('JetCoreRegionalStep')
0055 
0056 _iterations_trackingPhase2PU140_VS = cms.PSet(names = cms.vstring(
0057     "InitialStep",
0058     "HighPtTripletStep",
0059     "LowPtQuadStep",
0060     "LowPtTripletStep",
0061     "DetachedQuadStep",
0062     "PixelPairStep",
0063 ))
0064 from Configuration.ProcessModifiers.vectorHits_cff import vectorHits
0065 vectorHits.toModify(_iterations_trackingPhase2PU140_VS.names, func=lambda x: x.append('PixelLessStep'))
0066 from Configuration.ProcessModifiers.trackingIters01_cff import trackingIters01
0067 trackingIters01.toModify(_iterations_trackingPhase2PU140_VS, names = ["InitialStep", "HighPtTripletStep"])
0068 # apply all procModifiers before this
0069 _iterations_trackingPhase2PU140 = _iterations_trackingPhase2PU140_VS.names.value()
0070 
0071 from Configuration.ProcessModifiers.jetCoreInPhase2_cff import jetCoreInPhase2
0072 jetCoreInPhase2.toModify(_iterations_trackingPhase2PU140, func=lambda x: x.append('JetCoreRegionalStep'))
0073 
0074 _iterations_muonSeeded = [
0075     "MuonSeededStepInOut",
0076     "MuonSeededStepOutIn",
0077 ]
0078 _iterations_muonSeeded_trackingPhase1 = [
0079     "MuonSeededStepInOut",
0080     "MuonSeededStepOutIn",
0081 ]
0082 #Phase2
0083 _iterations_muonSeeded_trackingPhase2PU140_VS = cms.PSet(names = cms.vstring(
0084     "MuonSeededStepInOut",
0085     "MuonSeededStepOutIn",
0086 ))
0087 trackingIters01.toModify(_iterations_muonSeeded_trackingPhase2PU140_VS, names = [])
0088 _iterations_muonSeeded_trackingPhase2PU140 = _iterations_muonSeeded_trackingPhase2PU140_VS.names.value()
0089 
0090 _multipleSeedProducers = {
0091     "MixedTripletStep": ["A", "B"],
0092     "TobTecStep": ["Pair", "Tripl"],
0093 }
0094 _multipleSeedProducers_trackingLowPU = {
0095     "MixedTripletStep": ["A", "B"],
0096 }
0097 _multipleSeedProducers_trackingPhase1 = {
0098     "PixelPairStep": ["A", "B"],
0099     "MixedTripletStep": ["A", "B"],
0100     "TobTecStep": ["Pair", "Tripl"],
0101 }
0102 from Configuration.ProcessModifiers.seedingDeepCore_cff import seedingDeepCore
0103 seedingDeepCore.toModify(_multipleSeedProducers_trackingPhase1, func=lambda x: x.update({"JetCoreRegionalStep": ["Barrel","Endcap"]}))
0104 
0105 
0106 _multipleSeedProducers_trackingPhase2PU140 = {}
0107 _oldStyleHasSelector = set([
0108     "InitialStep",
0109     "HighPtTripletStep",
0110     "LowPtQuadStep",
0111     "LowPtTripletStep",
0112     "PixelPairStep",
0113     "PixelLessStep",
0114     "TobTecStep",
0115 ])
0116 
0117 from Configuration.ProcessModifiers.displacedRegionalTracking_cff import displacedRegionalTracking
0118 displacedRegionalTracking.toModify(_iterations_muonSeeded_trackingPhase1, func=lambda x: x.append('DisplacedRegionalStep'))
0119 displacedRegionalTracking.toModify(_multipleSeedProducers_trackingPhase1, func=lambda x: x.update({'DisplacedRegionalStep': ['Pair', 'Tripl']}))
0120 
0121 from RecoLocalTracker.SubCollectionProducers.trackClusterRemover_cfi import trackClusterRemover as _trackClusterRemover
0122 _trackClusterRemoverBase = _trackClusterRemover.clone(
0123     maxChi2                                  = 9.0,
0124     pixelClusters                            = "siPixelClusters",
0125     stripClusters                            = "siStripClusters",
0126     TrackQuality                             = 'highPurity',
0127     minNumberOfLayersWithMeasBeforeFiltering = 0,
0128 )
0129 
0130 from Configuration.ProcessModifiers.pp_on_AA_cff import pp_on_AA
0131 from Configuration.ProcessModifiers.trackdnn_cff import trackdnn
0132 (pp_on_AA & (~trackdnn) ).toModify(_trackClusterRemoverBase, TrackQuality = 'tight')
0133 
0134 #Phase2 : configuring the phase2 track Cluster Remover
0135 from RecoLocalTracker.SubCollectionProducers.phase2trackClusterRemover_cfi import phase2trackClusterRemover as _phase2trackClusterRemover
0136 _trackClusterRemoverBase_trackingPhase2PU140 = _phase2trackClusterRemover.clone(
0137     maxChi2                                  = 9.0,
0138     phase2pixelClusters                      = "siPixelClusters",
0139     phase2OTClusters                         = "siPhase2Clusters",
0140     TrackQuality                             = 'highPurity',
0141     minNumberOfLayersWithMeasBeforeFiltering = 0,
0142 )
0143 
0144 def _modulePrefix(iteration):
0145     return iteration[0].lower()+iteration[1:]
0146 
0147 def _clusterRemover(iteration):
0148     return _modulePrefix(iteration)+"Clusters"
0149 
0150 def _tracks(iteration):
0151     return _modulePrefix(iteration)+"Tracks"
0152 
0153 def _classifier(iteration, oldStyle=False, oldStyleQualityMasks=False):
0154     pre = _modulePrefix(iteration)
0155     if oldStyle:
0156         if iteration in _oldStyleHasSelector:
0157             return pre+"Selector:" + ("QualityMasks" if oldStyleQualityMasks else pre)
0158         else:
0159             return pre
0160     else:
0161         return pre+":QualityMasks"
0162 
0163 def allEras():
0164     return _allEras
0165 
0166 def nonDefaultEras():
0167     return _nonDefaultEras
0168 
0169 def createEarlyTask(eraName, postfix, modDict):
0170     task = cms.Task()
0171     for it in globals()["_iterations"+postfix]:
0172         task.add(modDict[it+'Task'])
0173     return task
0174 
0175 def iterationAlgos(postfix, includeSequenceName=False):
0176     muonVariable = "_iterations_muonSeeded"+postfix
0177     iterations = globals()["_iterations"+postfix] + globals().get(muonVariable, _iterations_muonSeeded)
0178 
0179     if includeSequenceName:
0180         return [(_modulePrefix(i), i) for i in iterations]
0181     else:
0182         return [_modulePrefix(i) for i in iterations]
0183 
0184 def _seedOrTrackProducers(postfix, typ):
0185     ret = []
0186     iters = globals()["_iterations"+postfix]
0187     if typ == "Seeds":
0188         multipleSeedProducers = globals()["_multipleSeedProducers"+postfix]
0189     else:
0190         multipleSeedProducers = None
0191     for i in iters:
0192         seeder = _modulePrefix(i)+typ
0193         if multipleSeedProducers is not None and i in multipleSeedProducers:
0194             ret.extend([seeder+m for m in multipleSeedProducers[i]])
0195         else:
0196             ret.append(seeder)
0197 
0198     for i in globals().get("_iterations_muonSeeded"+postfix, _iterations_muonSeeded):
0199         if _modulePrefix(i).endswith("Step"):
0200             ret.append(_modulePrefix(i)+typ)
0201         else:
0202             ret.append(_modulePrefix(i).replace("Step", typ))
0203 
0204     return ret
0205 
0206 def seedProducers(postfix):
0207     return _seedOrTrackProducers(postfix, "Seeds")
0208 
0209 def trackProducers(postfix):
0210     return _seedOrTrackProducers(postfix, "Tracks")
0211 
0212 def clusterRemoverForIter(iteration, eraName="", postfix="", module=None):
0213     if module is None:
0214         module = _trackClusterRemoverBase.clone()
0215     if eraName == "trackingPhase2PU140":
0216         module = globals().get("_trackClusterRemoverBase"+postfix, _trackClusterRemoverBase)
0217 
0218     iters = globals()["_iterations"+postfix]
0219     try:
0220         # DisplacedRegionalStep is a special case because it comes after the
0221         # usual muon-seeded steps
0222         ind = iters.index(iteration) if iteration != "DisplacedRegionalStep" else len(iters)
0223     except ValueError:
0224         # if the iteration is not active in era, just return the same
0225         return module
0226 
0227     if ind == 0:
0228         raise Exception("Iteration %s is the first iteration in era %s, asking cluster remover configuration does not make sense" % (iteration, eraName))
0229     prevIter = iters[ind-1]
0230     # JetCoreRegionalStep uses all clusters, so if that is the previous
0231     # iteration, use the one before that for cluster removal
0232     if prevIter == "JetCoreRegionalStep":
0233         prevIter = iters[ind-2]
0234 
0235     customize = dict(
0236         trajectories          = _tracks(prevIter),
0237         oldClusterRemovalInfo = _clusterRemover(prevIter) if ind >= 2 else "", # 1st iteration does not have cluster remover
0238     )
0239     if eraName in ["trackingPhase2PU140"]:
0240         customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True) # old-style selector
0241     elif eraName == "trackingLowPU":
0242         customize["overrideTrkQuals"] = _classifier(prevIter, oldStyle=True, oldStyleQualityMasks=True) # old-style selector with 'QualityMasks' instance label
0243     else:
0244         customize["trackClassifier"] = _classifier(prevIter)
0245 
0246     return module.clone(**customize)