Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-01-31 03:00:02

0001 import FWCore.ParameterSet.Config as cms
0002 from enum import Enum
0003 import sys
0004  
0005 class RefitType(Enum):
0006      STANDARD = 1
0007      COMMON   = 2
0008 
0009 isDA = ISDATEMPLATE
0010 isMC = ISMCTEMPLATE
0011 allFromGT = ALLFROMGTTEMPLATE
0012 applyBows = APPLYBOWSTEMPLATE
0013 applyExtraConditions = EXTRACONDTEMPLATE
0014 theRefitter = REFITTERTEMPLATE
0015 
0016 process = cms.Process("PrimaryVertexValidation") 
0017 
0018 ###################################################################
0019 # Set the process to run multi-threaded
0020 ###################################################################
0021 process.options.numberOfThreads = 8
0022 
0023 ###################################################################
0024 def customiseAlignmentAndAPE(process):
0025 ###################################################################
0026     if not hasattr(process.GlobalTag,'toGet'):
0027         process.GlobalTag.toGet=cms.VPSet()
0028     process.GlobalTag.toGet.extend( cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentRcd"),
0029                                                        tag = cms.string("GEOMTAGTEMPLATE"),
0030                                                        connect = cms.string("ALIGNOBJTEMPLATE")
0031                                                        ),
0032                                               cms.PSet(record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0033                                                        tag = cms.string("ERRORTAGTEMPLATE"),
0034                                                        connect = cms.string("APEOBJTEMPLATE")
0035                                                        )
0036                                               )
0037                                     )
0038     return process
0039 
0040 ###################################################################
0041 def customiseKinksAndBows(process):
0042 ###################################################################
0043      if not hasattr(process.GlobalTag,'toGet'):
0044           process.GlobalTag.toGet=cms.VPSet()
0045      process.GlobalTag.toGet.extend(cms.VPSet(cms.PSet(record = cms.string("TrackerSurfaceDeformationRcd"),
0046                                                        tag = cms.string("BOWSTAGTEMPLATE"),
0047                                                        connect = cms.string("BOWSOBJECTTEMPLATE")
0048                                                        ),        
0049                                               )
0050                                     )
0051      return process
0052 
0053 ###################################################################
0054 # Event source and run selection
0055 ###################################################################
0056 readFiles = cms.untracked.vstring()
0057 readFiles.extend(FILESOURCETEMPLATE)
0058 process.source = cms.Source("PoolSource",
0059                             fileNames = readFiles ,
0060                             duplicateCheckMode = cms.untracked.string('checkAllFilesOpened')
0061                             )
0062 
0063 runboundary = RUNBOUNDARYTEMPLATE
0064 process.source.firstRun = cms.untracked.uint32(int(runboundary))
0065 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(MAXEVENTSTEMPLATE) )
0066 
0067 ###################################################################
0068 # JSON Filtering
0069 ###################################################################
0070 if isMC:
0071      print("############ testPVValidation_cfg.py: msg%-i: This is Simulation!")
0072      runboundary = 1
0073 else:
0074      print("############ testPVValidation_cfg.py: msg%-i: This is DATA!")
0075      import FWCore.PythonUtilities.LumiList as LumiList
0076      process.source.lumisToProcess = LumiList.LumiList(filename ='LUMILISTTEMPLATE').getVLuminosityBlockRange()
0077 
0078 ###################################################################
0079 # Messages
0080 ###################################################################
0081 process.load("FWCore.MessageService.MessageLogger_cfi")
0082 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
0083 
0084 ####################################################################
0085 # Produce the Transient Track Record in the event
0086 ####################################################################
0087 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
0088 
0089 ####################################################################
0090 # Get the Magnetic Field
0091 ####################################################################
0092 process.load('Configuration.StandardSequences.MagneticField_cff')
0093 
0094 ###################################################################
0095 # Standard loads
0096 ###################################################################
0097 process.load("Configuration.Geometry.GeometryRecoDB_cff")
0098 
0099 ####################################################################
0100 # Get the BeamSpot
0101 ####################################################################
0102 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
0103 
0104 ####################################################################
0105 # Get the GlogalTag
0106 ####################################################################
0107 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0108 from Configuration.AlCa.GlobalTag import GlobalTag
0109 process.GlobalTag = GlobalTag(process.GlobalTag, 'GLOBALTAGTEMPLATE', '')
0110 
0111 if allFromGT:
0112      print("############ testPVValidation_cfg.py: msg%-i: All is taken from GT")
0113 else:
0114      ####################################################################
0115      # Get Alignment constants and APE
0116      ####################################################################
0117      process=customiseAlignmentAndAPE(process)
0118 
0119      ####################################################################
0120      # Kinks and Bows (optional)
0121      ####################################################################
0122      if applyBows:
0123           print("############ testPVValidation_cfg.py: msg%-i: Applying TrackerSurfaceDeformations!")
0124           process=customiseKinksAndBows(process)
0125      else:
0126           print("############ testPVValidation_cfg.py: msg%-i: MultiPVValidation: Not applying TrackerSurfaceDeformations!")
0127 
0128      ####################################################################
0129      # Extra corrections not included in the GT
0130      ####################################################################
0131      if applyExtraConditions:
0132 
0133           import CalibTracker.Configuration.Common.PoolDBESSource_cfi
0134           ##### END OF EXTRA CONDITIONS
0135  
0136      else:
0137           print("############ testPVValidation_cfg.py: msg%-i: Not applying extra calibration constants!")
0138      
0139 ####################################################################
0140 # Load and Configure event selection
0141 ####################################################################
0142 process.primaryVertexFilter = cms.EDFilter("VertexSelector",
0143                                              src = cms.InputTag("VERTEXTYPETEMPLATE"),
0144                                              cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
0145                                              filter = cms.bool(True)
0146                                              )
0147 
0148 process.noscraping = cms.EDFilter("FilterOutScraping",
0149                                   applyfilter = cms.untracked.bool(True),
0150                                   src =  cms.untracked.InputTag("TRACKTYPETEMPLATE"),
0151                                   debugOn = cms.untracked.bool(False),
0152                                   numtrack = cms.untracked.uint32(10),
0153                                   thresh = cms.untracked.double(0.25)
0154                                   )
0155 
0156 process.load("Alignment.CommonAlignment.filterOutLowPt_cfi")
0157 process.filterOutLowPt.applyfilter = True
0158 process.filterOutLowPt.src = "TRACKTYPETEMPLATE"
0159 process.filterOutLowPt.numtrack = 0
0160 process.filterOutLowPt.thresh = 1
0161 process.filterOutLowPt.ptmin  = PTCUTTEMPLATE
0162 process.filterOutLowPt.runControl = RUNCONTROLTEMPLATE
0163 process.filterOutLowPt.runControlNumber = [runboundary]
0164 
0165 if isMC:
0166      process.goodvertexSkim = cms.Sequence(process.noscraping+process.filterOutLowPt)
0167 else:
0168      process.goodvertexSkim = cms.Sequence(process.primaryVertexFilter + process.noscraping + process.filterOutLowPt)
0169 
0170 ####################################################################
0171 # Load and Configure Measurement Tracker Event
0172 # (this would be needed in case NavigationSchool is set != from ''
0173 ####################################################################
0174 # process.load("RecoTracker.MeasurementDet.MeasurementTrackerEventProducer_cfi") 
0175 # process.MeasurementTrackerEvent.pixelClusterProducer = 'TRACKTYPETEMPLATE'
0176 # process.MeasurementTrackerEvent.stripClusterProducer = 'TRACKTYPETEMPLATE'
0177 # process.MeasurementTrackerEvent.inactivePixelDetectorLabels = cms.VInputTag()
0178 # process.MeasurementTrackerEvent.inactiveStripDetectorLabels = cms.VInputTag()
0179 
0180 ####################################################################
0181 # Load and Configure TrackRefitter
0182 ####################################################################
0183 # process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0184 # import RecoTracker.TrackProducer.TrackRefitters_cff
0185 # process.FinalTrackRefitter = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone()
0186 # process.FinalTrackRefitter.src = "TRACKTYPETEMPLATE"
0187 # process.FinalTrackRefitter.TrajectoryInEvent = True
0188 # process.FinalTrackRefitter.NavigationSchool = ''
0189 # process.FinalTrackRefitter.TTRHBuilder = "WithAngleAndTemplate"
0190 
0191 ####################################################################
0192 # Load and Configure common selection sequence
0193 ####################################################################
0194 # import Alignment.CommonAlignment.tools.trackselectionRefitting as trackselRx1efit
0195 # process.seqTrackselRefit = trackselRefit.getSequence(process,'TRACKTYPETEMPLATE')
0196 # process.HighPurityTrackSelector.trackQualities = cms.vstring()
0197 # process.HighPurityTrackSelector.pMin     = cms.double(0.)
0198 # #process.TrackerTrackHitFilter.usePixelQualityFlag = cms.bool(False)    # do not use the pixel quality flag
0199 # #process.TrackerTrackHitFilter.commands   = cms.vstring("drop PXB 1")   # drop BPix1 hits
0200 # process.AlignmentTrackSelector.pMin      = cms.double(0.)
0201 # process.AlignmentTrackSelector.ptMin     = cms.double(0.)
0202 # process.AlignmentTrackSelector.nHitMin2D = cms.uint32(0)
0203 # process.AlignmentTrackSelector.nHitMin   = cms.double(0.)
0204 # process.AlignmentTrackSelector.d0Min     = cms.double(-999999.0)
0205 # process.AlignmentTrackSelector.d0Max     = cms.double(+999999.0)
0206 # process.AlignmentTrackSelector.dzMin     = cms.double(-999999.0)
0207 # process.AlignmentTrackSelector.dzMax     = cms.double(+999999.0)
0208 
0209 if(theRefitter == RefitType.COMMON):
0210 
0211      print("############ testPVValidation_cfg.py: msg%-i: using the common track selection and refit sequence!")
0212      ####################################################################
0213      # Load and Configure Common Track Selection and refitting sequence
0214      ####################################################################
0215      import Alignment.CommonAlignment.tools.trackselectionRefitting as trackselRefit
0216      process.seqTrackselRefit = trackselRefit.getSequence(process, 'TRACKTYPETEMPLATE',
0217                                                           isPVValidation=True,
0218                                                           TTRHBuilder='TTRHBUILDERTEMPLATE',
0219                                                           usePixelQualityFlag=True,
0220                                                           openMassWindow=False,
0221                                                           cosmicsDecoMode=True,
0222                                                           cosmicsZeroTesla=False,
0223                                                           momentumConstraint=None,
0224                                                           cosmicTrackSplitting=False,
0225                                                           use_d0cut=False,
0226                                                           )
0227      if((process.TrackerTrackHitFilter.usePixelQualityFlag.value()==True) and (process.FirstTrackRefitter.TTRHBuilder.value()=="WithTrackAngle")):
0228           print(" \n\n","*"*70,"\n *\t\t\t\t WARNING!!!!!\t\t\t\n *\n * Found an inconsistent configuration!\n * TTRHBuilder = WithTrackAngle requires usePixelQualityFlag = False.\n * Going to reset it! \n *\n","*"*70)
0229           process.TrackerTrackHitFilter.usePixelQualityFlag = False
0230 
0231 elif (theRefitter == RefitType.STANDARD):
0232 
0233      print("############ testPVValidation_cfg.py: msg%-i: using the standard single refit sequence!")
0234      ####################################################################
0235      # Load and Configure Measurement Tracker Event
0236      # (needed in case NavigationSchool is set != '')
0237      ####################################################################
0238      # process.load("RecoTracker.MeasurementDet.MeasurementTrackerEventProducer_cfi")
0239      # process.MeasurementTrackerEvent.pixelClusterProducer = 'TRACKTYPETEMPLATE'
0240      # process.MeasurementTrackerEvent.stripClusterProducer = 'TRACKTYPETEMPLATE'
0241      # process.MeasurementTrackerEvent.inactivePixelDetectorLabels = cms.VInputTag()
0242      # process.MeasurementTrackerEvent.inactiveStripDetectorLabels = cms.VInputTag()
0243 
0244      ####################################################################
0245      # Load and Configure TrackRefitter
0246      ####################################################################
0247      process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0248      import RecoTracker.TrackProducer.TrackRefitters_cff
0249      process.FinalTrackRefitter = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone()
0250      process.FinalTrackRefitter.src = "TRACKTYPETEMPLATE"
0251      process.FinalTrackRefitter.TrajectoryInEvent = True
0252      process.FinalTrackRefitter.NavigationSchool = ''
0253      process.FinalTrackRefitter.TTRHBuilder = "TTRHBUILDERTEMPLATE"
0254 
0255      ####################################################################
0256      # Sequence
0257      ####################################################################
0258      process.load("RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi")
0259      process.seqTrackselRefit = cms.Sequence(process.offlineBeamSpot*
0260                                              # in case NavigatioSchool is set !=''
0261                                              #process.MeasurementTrackerEvent*
0262                                              process.FinalTrackRefitter,
0263                                              cms.Task(process.SiPixelTemplateStoreESProducer))
0264 
0265 ####################################################################
0266 # Output file
0267 ####################################################################
0268 process.TFileService = cms.Service("TFileService",fileName=cms.string("OUTFILETEMPLATE"))
0269 
0270 ####################################################################
0271 # Imports of parameters
0272 ####################################################################
0273 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
0274 ## modify the parameters which differ
0275 FilteringParams = offlinePrimaryVertices.TkFilterParameters.clone(
0276      maxNormalizedChi2 = 5.0,  # chi2ndof < 5
0277      maxD0Significance = 5.0,  # fake cut (requiring 1 PXB hit)
0278      maxEta = 5.0,             # as per recommendation in PR #18330
0279 )
0280 
0281 ## MM 04.05.2017 (use settings as in: https://github.com/cms-sw/cmssw/pull/18330)
0282 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import DA_vectParameters
0283 DAClusterizationParams = DA_vectParameters.clone()
0284 
0285 GapClusterizationParams = cms.PSet(algorithm   = cms.string('gap'),
0286                                    TkGapClusParameters = cms.PSet(zSeparation = cms.double(0.2))  # 0.2 cm max separation betw. clusters
0287                                    )
0288 
0289 ####################################################################
0290 # Deterministic annealing clustering or Gap clustering
0291 ####################################################################
0292 def switchClusterizerParameters(da):
0293      if da:
0294           print("############ testPVValidation_cfg.py: msg%-i: Running DA Algorithm!")
0295           return DAClusterizationParams
0296      else:
0297           print("############ testPVValidation_cfg.py: msg%-i: Running GAP Algorithm!")
0298           return GapClusterizationParams
0299 
0300 ####################################################################
0301 # Configure the PVValidation Analyzer module
0302 ####################################################################
0303 process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
0304                                       numberOfBins = cms.untracked.int32(48),
0305                                       TrackCollectionTag = cms.InputTag("FinalTrackRefitter"),
0306                                       VertexCollectionTag = cms.InputTag("VERTEXTYPETEMPLATE"),
0307                                       Debug = cms.bool(False),
0308                                       storeNtuple = cms.bool(False),
0309                                       useTracksFromRecoVtx = cms.bool(False),
0310                                       isLightNtuple = cms.bool(True),
0311                                       askFirstLayerHit = cms.bool(False),
0312                                       forceBeamSpot = cms.untracked.bool(False),
0313                                       probePt = cms.untracked.double(PTCUTTEMPLATE),
0314                                       probeEta = cms.untracked.double(2.7),
0315                                       runControl = cms.untracked.bool(RUNCONTROLTEMPLATE),
0316                                       intLumi = cms.untracked.double(INTLUMITEMPLATE),
0317                                       runControlNumber = cms.untracked.vuint32(int(runboundary)),
0318                                       TkFilterParameters = FilteringParams,
0319                                       TkClusParameters = switchClusterizerParameters(isDA)
0320                                       )
0321 
0322 ####################################################################
0323 # Path
0324 ####################################################################
0325 process.p = cms.Path(process.goodvertexSkim*
0326                      # in case the common refitting sequence is removed
0327                      #process.offlineBeamSpot*
0328                      process.seqTrackselRefit*
0329                      # in case the navigation shool is removed
0330                      #process.MeasurementTrackerEvent*
0331                      # in case the common refitting sequence is removed
0332                      #process.TrackRefitter*
0333                      process.PVValidation)