Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:08

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