Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-08 03:35:46

0001 import FWCore.ParameterSet.Config as cms
0002 import sys
0003  
0004 isDA = ISDATEMPLATE
0005 isMC = ISMCTEMPLATE
0006 allFromGT = ALLFROMGTTEMPLATE
0007 applyBows = APPLYBOWSTEMPLATE
0008 applyExtraConditions = EXTRACONDTEMPLATE
0009 useFileList = USEFILELISTTEMPLATE
0010 
0011 process = cms.Process("PrimaryVertexValidation") 
0012 
0013 ###################################################################
0014 def customiseAlignmentAndAPE(process):
0015 ###################################################################
0016     if not hasattr(process.GlobalTag,'toGet'):
0017         process.GlobalTag.toGet=cms.VPSet()
0018     process.GlobalTag.toGet.extend( cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentRcd"),
0019                                                        tag = cms.string("GEOMTAGTEMPLATE"),
0020                                                        connect = cms.string("ALIGNOBJTEMPLATE")
0021                                                        ),
0022                                               cms.PSet(record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0023                                                        tag = cms.string("ERRORTAGTEMPLATE"),
0024                                                        connect = cms.string("APEOBJTEMPLATE")
0025                                                        )
0026                                               )
0027                                     )
0028     return process
0029 
0030 ###################################################################
0031 def customiseKinksAndBows(process):
0032 ###################################################################
0033      if not hasattr(process.GlobalTag,'toGet'):
0034           process.GlobalTag.toGet=cms.VPSet()
0035      process.GlobalTag.toGet.extend(cms.VPSet(cms.PSet(record = cms.string("TrackerSurfaceDeformationRcd"),
0036                                                        tag = cms.string("BOWSTAGTEMPLATE"),
0037                                                        connect = cms.string("BOWSOBJECTTEMPLATE")
0038                                                        ),        
0039                                               )
0040                                     )
0041      return process
0042 
0043 ###################################################################
0044 # Event source and run selection
0045 ###################################################################
0046 if (useFileList):
0047      print("############ testPVValidation_cfg.py: msg%-i: Reading local input files list")
0048      readFiles = cms.untracked.vstring()
0049      readFiles.extend(FILESOURCETEMPLATE)
0050      process.source = cms.Source("PoolSource",
0051                                  fileNames = readFiles ,
0052                                  duplicateCheckMode = cms.untracked.string('checkAllFilesOpened')
0053                                  )
0054 else:
0055      print("############ testPVValidation_cfg.py: msg%-i: Reading from configuration fragment")
0056      process.load("Alignment.OfflineValidation.DATASETTEMPLATE")
0057 
0058 ###################################################################
0059 #  Runs and events
0060 ###################################################################
0061 runboundary = RUNBOUNDARYTEMPLATE
0062 process.source.firstRun = cms.untracked.uint32(int(runboundary))
0063 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(MAXEVENTSTEMPLATE) )
0064 
0065 ###################################################################
0066 # JSON Filtering
0067 ###################################################################
0068 if isMC:
0069      print("############ testPVValidation_cfg.py: msg%-i: This is simulation!")
0070      runboundary = 1
0071 else:
0072      print("############ testPVValidation_cfg.py: msg%-i: This is real DATA!")
0073      if ('LUMILISTTEMPLATE'):
0074           print("############ testPVValidation_cfg.py: msg%-i: JSON filtering with: LUMILISTTEMPLATE")
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 # Geometry load
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 and APE constants
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                print("############ testPVValidation_cfg.py: msg%-i: Applying extra calibration constants!")
0133 
0134                import CalibTracker.Configuration.Common.PoolDBESSource_cfi
0135 
0136                # Extra conditions to be plugged here
0137                ##### END OF EXTRA CONDITIONS
0138                
0139           else:
0140                print("############ testPVValidation_cfg.py: msg%-i: Not applying extra calibration constants!")
0141                
0142      
0143 ####################################################################
0144 # Load and Configure event selection
0145 ####################################################################
0146 process.primaryVertexFilter = cms.EDFilter("VertexSelector",
0147                                            src = cms.InputTag("VERTEXTYPETEMPLATE"),
0148                                            cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
0149                                            filter = cms.bool(True)
0150                                            )
0151 
0152 process.noscraping = cms.EDFilter("FilterOutScraping",
0153                                   applyfilter = cms.untracked.bool(True),
0154                                   src =  cms.untracked.InputTag("TRACKTYPETEMPLATE"),
0155                                   debugOn = cms.untracked.bool(False),
0156                                   numtrack = cms.untracked.uint32(10),
0157                                   thresh = cms.untracked.double(0.25)
0158                                   )
0159 
0160 process.load("Alignment.CommonAlignment.filterOutLowPt_cfi")
0161 process.filterOutLowPt.applyfilter = True
0162 process.filterOutLowPt.src = "TRACKTYPETEMPLATE"
0163 process.filterOutLowPt.numtrack = 0
0164 process.filterOutLowPt.thresh = 1
0165 process.filterOutLowPt.ptmin  = PTCUTTEMPLATE
0166 process.filterOutLowPt.runControl = RUNCONTROLTEMPLATE
0167 process.filterOutLowPt.runControlNumber = [runboundary]
0168 
0169 ###################################################################
0170 # Beamspot compatibility check
0171 ###################################################################
0172 from RecoVertex.BeamSpotProducer.beamSpotCompatibilityChecker_cfi import beamSpotCompatibilityChecker
0173 process.BeamSpotChecker = beamSpotCompatibilityChecker.clone(
0174     bsFromEvent = "offlineBeamSpot::RECO",  # source of the event beamspot (in the ALCARECO files)
0175     bsFromDB = "offlineBeamSpot",           # source of the DB beamspot (from Global Tag) NOTE: only if dbFromEvent is True!
0176     warningThr = 3, # significance threshold to emit a warning message
0177     errorThr = 5,    # significance threshold to abort the job
0178 )
0179 
0180 if isMC:
0181      process.goodvertexSkim = cms.Sequence(process.BeamSpotChecker + process.noscraping + process.filterOutLowPt)
0182 else:
0183      process.goodvertexSkim = cms.Sequence(process.BeamSpotChecker + process.primaryVertexFilter + process.noscraping + process.filterOutLowPt)
0184 
0185 ####################################################################
0186 # Load and Configure Measurement Tracker Event
0187 # (this would be needed in case NavigationSchool is set != from ''
0188 ####################################################################
0189 #process.load("RecoTracker.MeasurementDet.MeasurementTrackerEventProducer_cfi") 
0190 #process.MeasurementTrackerEvent.pixelClusterProducer = 'TRACKTYPETEMPLATE'
0191 #process.MeasurementTrackerEvent.stripClusterProducer = 'TRACKTYPETEMPLATE'
0192 #process.MeasurementTrackerEvent.inactivePixelDetectorLabels = cms.VInputTag()
0193 #process.MeasurementTrackerEvent.inactiveStripDetectorLabels = cms.VInputTag()
0194 
0195 ####################################################################
0196 # Load and Configure TrackRefitter
0197 ####################################################################
0198 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0199 import RecoTracker.TrackProducer.TrackRefitters_cff
0200 process.TrackRefitter = RecoTracker.TrackProducer.TrackRefitter_cfi.TrackRefitter.clone()
0201 process.TrackRefitter.src = "TRACKTYPETEMPLATE"
0202 process.TrackRefitter.TrajectoryInEvent = True
0203 process.TrackRefitter.NavigationSchool = ''
0204 process.TrackRefitter.TTRHBuilder = "WithAngleAndTemplate"
0205 
0206 ####################################################################
0207 # Load .SiPixelTemplateStoreESProducer
0208 ####################################################################
0209 process.load("RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi")
0210 
0211 ####################################################################
0212 # Output file
0213 ####################################################################
0214 process.TFileService = cms.Service("TFileService",
0215                                    fileName=cms.string("OUTFILETEMPLATE")
0216                                    )
0217 
0218 ####################################################################
0219 # Imports of parameters
0220 ####################################################################
0221 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices
0222 ## modify the parameters which differ
0223 FilteringParams = offlinePrimaryVertices.TkFilterParameters.clone(
0224      maxNormalizedChi2 = 5.0,  # chi2ndof < 5
0225      maxD0Significance = 5.0,  # fake cut (requiring 1 PXB hit)
0226      maxEta = 5.0,             # as per recommendation in PR #18330
0227 )
0228 
0229 ## MM 04.05.2017 (use settings as in: https://github.com/cms-sw/cmssw/pull/18330)
0230 from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import DA_vectParameters
0231 DAClusterizationParams = DA_vectParameters.clone()
0232 
0233 GapClusterizationParams = cms.PSet(algorithm   = cms.string('gap'),
0234                                    TkGapClusParameters = cms.PSet(zSeparation = cms.double(0.2))  # 0.2 cm max separation betw. clusters
0235                                    )
0236 
0237 ####################################################################
0238 # Deterministic annealing clustering or Gap clustering
0239 ####################################################################
0240 def switchClusterizerParameters(da):
0241      if da:
0242           print("############ testPVValidation_cfg.py: msg%-i: Running DA Algorithm!")
0243           return DAClusterizationParams
0244      else:
0245           print("############ testPVValidation_cfg.py: msg%-i: Running GAP Algorithm!")
0246           return GapClusterizationParams
0247 
0248 ####################################################################
0249 # Configure the PVValidation Analyzer module
0250 ####################################################################
0251 process.PVValidation = cms.EDAnalyzer("PrimaryVertexValidation",
0252                                       TrackCollectionTag = cms.InputTag("TrackRefitter"),
0253                                       VertexCollectionTag = cms.InputTag("VERTEXTYPETEMPLATE"),
0254                                       Debug = cms.bool(False),
0255                                       storeNtuple = cms.bool(False),
0256                                       useTracksFromRecoVtx = cms.bool(False),
0257                                       isLightNtuple = cms.bool(True),
0258                                       askFirstLayerHit = cms.bool(False),
0259                                       forceBeamSpot = cms.untracked.bool(False),
0260                                       probePt = cms.untracked.double(PTCUTTEMPLATE),
0261                                       runControl = cms.untracked.bool(RUNCONTROLTEMPLATE),
0262                                       runControlNumber = cms.untracked.vuint32(int(runboundary)),
0263                                       TkFilterParameters = FilteringParams,
0264                                       TkClusParameters = switchClusterizerParameters(isDA)
0265                                       )
0266 
0267 ####################################################################
0268 # Refitting Sequence
0269 ####################################################################
0270 process.seqTrackselRefit = cms.Sequence(process.offlineBeamSpot*
0271                                         process.TrackRefitter,
0272                                         cms.Task(process.SiPixelTemplateStoreESProducer))
0273 
0274 ####################################################################
0275 # Path
0276 ####################################################################
0277 process.p = cms.Path(process.goodvertexSkim*
0278                      process.seqTrackselRefit*
0279                      process.PVValidation)