Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:50:19

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 
0004 # Define here the BeamSpotOnline record name,
0005 # it will be used both in BeamMonitor setup and in payload creation/upload
0006 BSOnlineRecordName = 'BeamSpotOnlineLegacyObjectsRcd'
0007 BSOnlineTag = 'BeamSpotOnlineLegacy'
0008 BSOnlineJobName = 'BeamSpotOnlineLegacy'
0009 BSOnlineOmsServiceUrl = 'http://cmsoms-services.cms:9949/urn:xdaq-application:lid=100/getRunAndLumiSection'
0010 useLockRecords = True
0011 
0012 import sys
0013 from Configuration.Eras.Era_Run3_cff import Run3
0014 process = cms.Process("BeamMonitor", Run3)
0015 
0016 process.MessageLogger = cms.Service("MessageLogger",
0017     debugModules = cms.untracked.vstring('*'),
0018     cerr = cms.untracked.PSet(
0019         threshold = cms.untracked.string('WARNING')
0020     ),
0021     destinations = cms.untracked.vstring('cerr')
0022 )
0023 
0024 # switch
0025 live = True # FIXME
0026 unitTest = False
0027 
0028 if 'unitTest=True' in sys.argv:
0029     live=False
0030     unitTest=True
0031     useLockRecords = False
0032 
0033 #---------------
0034 # Input sources
0035 if unitTest:
0036     process.load("DQM.Integration.config.unittestinputsource_cfi")
0037     from DQM.Integration.config.unittestinputsource_cfi import options
0038 elif live:
0039     process.load("DQM.Integration.config.inputsource_cfi")
0040     from DQM.Integration.config.inputsource_cfi import options
0041 else:
0042     process.load("DQM.Integration.config.fileinputsource_cfi")
0043     from DQM.Integration.config.fileinputsource_cfi import options
0044 
0045 #--------------------------
0046 # HLT Filter
0047 process.hltTriggerTypeFilter = cms.EDFilter("HLTTriggerTypeFilter",
0048     SelectedTriggerType = cms.int32(1) # physics
0049 )
0050 
0051 #----------------------------
0052 # DQM Live Environment
0053 process.load("DQM.Integration.config.environment_cfi")
0054 process.dqmEnv.subSystemFolder = 'BeamMonitorLegacy'
0055 process.dqmSaver.tag           = 'BeamMonitorLegacy'
0056 process.dqmSaver.runNumber     = options.runNumber
0057 process.dqmSaverPB.tag         = 'BeamMonitorLegacy'
0058 process.dqmSaverPB.runNumber   = options.runNumber
0059 
0060 process.dqmEnvPixelLess = process.dqmEnv.clone(
0061   subSystemFolder = 'BeamMonitor_PixelLess'
0062 )
0063 
0064 # Configure tag and jobName if running Playback system
0065 if process.isDqmPlayback.value :
0066     BSOnlineTag = BSOnlineTag + 'Playback'
0067     BSOnlineJobName = BSOnlineJobName + 'Playback'
0068     BSOnlineOmsServiceUrl = ''
0069     useLockRecords = False
0070 #
0071 
0072 #---------------
0073 # Conditions
0074 if (live):
0075     process.load("DQM.Integration.config.FrontierCondition_GT_cfi")
0076     process.GlobalTag.DBParameters.authenticationPath = '.'
0077 else:
0078     process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0079     from Configuration.AlCa.GlobalTag import GlobalTag as gtCustomise
0080     process.GlobalTag = gtCustomise(process.GlobalTag, 'auto:run2_data', '')
0081     process.GlobalTag.DBParameters.authenticationPath = '.'
0082     # you may need to set manually the GT in the line below
0083     #process.GlobalTag.globaltag = '100X_upgrade2018_realistic_v10'
0084 
0085 #--------------------------------------------------------
0086 # Swap offline <-> online BeamSpot as in Express and HLT
0087 import RecoVertex.BeamSpotProducer.onlineBeamSpotESProducer_cfi as _mod
0088 process.BeamSpotESProducer = _mod.onlineBeamSpotESProducer.clone()
0089 import RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi
0090 process.offlineBeamSpot = RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi.onlineBeamSpotProducer.clone()
0091 
0092 #----------------------------
0093 # BeamMonitor
0094 process.load("DQM.BeamMonitor.BeamMonitor_Pixel_cff")
0095 process.load("DQM.BeamMonitor.BeamSpotProblemMonitor_cff")
0096 process.load("DQM.BeamMonitor.BeamConditionsMonitor_cff")
0097 
0098 if process.dqmRunConfig.type.value() == "production":
0099   process.dqmBeamMonitor.BeamFitter.WriteAscii = True
0100   process.dqmBeamMonitor.BeamFitter.AsciiFileName = '/nfshome0/yumiceva/BeamMonitorDQM/BeamFitResultsOld.txt'
0101   process.dqmBeamMonitor.BeamFitter.WriteDIPAscii = True
0102   process.dqmBeamMonitor.BeamFitter.DIPFileName = '/nfshome0/dqmpro/BeamMonitorDQM/BeamFitResultsOld.txt'
0103 else:
0104   process.dqmBeamMonitor.BeamFitter.WriteAscii = False
0105   process.dqmBeamMonitor.BeamFitter.AsciiFileName = '/nfshome0/yumiceva/BeamMonitorDQM/BeamFitResultsOld.txt'
0106   process.dqmBeamMonitor.BeamFitter.WriteDIPAscii = True
0107   if (live):
0108     process.dqmBeamMonitor.BeamFitter.DIPFileName = '/nfshome0/dqmdev/BeamMonitorDQM/BeamFitResultsOld.txt'
0109   else:
0110     process.dqmBeamMonitor.BeamFitter.DIPFileName = 'BeamFitResultsOld.txt'
0111 
0112 #----------------
0113 # Setup tracking
0114 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
0115 process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
0116 process.load("Configuration.StandardSequences.RawToDigi_Data_cff")
0117 process.load("RecoLocalTracker.Configuration.RecoLocalTracker_cff")
0118 process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
0119 from RecoPixelVertexing.PixelLowPtUtilities.siPixelClusterShapeCache_cfi import *
0120 process.siPixelClusterShapeCachePreSplitting = siPixelClusterShapeCache.clone(
0121   src = 'siPixelClustersPreSplitting'
0122 )
0123 process.load("RecoLocalTracker.SiPixelRecHits.PixelCPEGeneric_cfi")
0124 
0125 #-----------------
0126 
0127 # TrackingMonitor
0128 process.pixelTracksCutClassifier = cms.EDProducer( "TrackCutClassifier",
0129     src = cms.InputTag( "pixelTracks" ),
0130     beamspot = cms.InputTag( "offlineBeamSpot" ),
0131     vertices = cms.InputTag( "" ),
0132     qualityCuts = cms.vdouble( -0.7, 0.1, 0.7 ),
0133     mva = cms.PSet(
0134       minPixelHits = cms.vint32( 0, 3, 3 ),
0135       maxDzWrtBS = cms.vdouble( 3.40282346639E38, 3.40282346639E38, 60.0 ),
0136       dr_par = cms.PSet(
0137         d0err = cms.vdouble( 0.003, 0.003, 3.40282346639E38 ),
0138         dr_par2 = cms.vdouble( 0.3, 0.3, 3.40282346639E38 ),
0139         dr_par1 = cms.vdouble( 0.4, 0.4, 3.40282346639E38 ),
0140         dr_exp = cms.vint32( 4, 4, 4 ),
0141         d0err_par = cms.vdouble( 0.001, 0.001, 3.40282346639E38 )
0142       ),
0143       maxLostLayers = cms.vint32( 99, 99, 99 ),
0144       min3DLayers = cms.vint32( 0, 2, 3 ),
0145       dz_par = cms.PSet(
0146         dz_par1 = cms.vdouble( 0.4, 0.4, 3.40282346639E38 ),
0147         dz_par2 = cms.vdouble( 0.35, 0.35, 3.40282346639E38 ),
0148         dz_exp = cms.vint32( 4, 4, 4 )
0149       ),
0150       minNVtxTrk = cms.int32( 3 ),
0151       maxDz = cms.vdouble( 3.40282346639E38, 3.40282346639E38, 3.40282346639E38 ),
0152       minNdof = cms.vdouble( 1.0E-5, 1.0E-5, 1.0E-5 ),
0153       maxChi2 = cms.vdouble( 9999., 9999., 30.0 ),
0154       maxDr = cms.vdouble( 99., 99., 1. ),
0155       minLayers = cms.vint32( 0, 2, 3 )
0156     ),
0157     ignoreVertices = cms.bool( True ),
0158 )
0159 
0160 #
0161 process.pixelTracksHP = cms.EDProducer( "TrackCollectionFilterCloner",
0162     minQuality = cms.string( "highPurity" ),
0163     copyExtras = cms.untracked.bool( True ),
0164     copyTrajectories = cms.untracked.bool( False ),
0165     originalSource = cms.InputTag( "pixelTracks" ),
0166     originalQualVals = cms.InputTag( 'pixelTracksCutClassifier','QualityMasks' ),
0167     originalMVAVals = cms.InputTag( 'pixelTracksCutClassifier','MVAValues' )
0168 )
0169 
0170 #-------------------------------------
0171 # PixelTracksMonitor
0172 
0173 import DQM.TrackingMonitor.TrackerCollisionTrackingMonitor_cfi
0174 process.pixelTracksMonitor = DQM.TrackingMonitor.TrackerCollisionTrackingMonitor_cfi.TrackerCollisionTrackMon.clone(
0175    FolderName                = 'BeamMonitorLegacy/Tracking/pixelTracks',
0176    TrackProducer             = 'pixelTracks',
0177    allTrackProducer          = 'pixelTracks',
0178    beamSpot                  = "offlineBeamSpot",
0179    primaryVertex             = "pixelVertices",
0180 
0181    doAllPlots                = False,
0182    doLumiAnalysis            = False,
0183    doProfilesVsLS            = True,
0184    doDCAPlots                = True,
0185    doPlotsVsGoodPVtx         = True,
0186 
0187    doEffFromHitPatternVsPU   = False,
0188    doEffFromHitPatternVsBX   = True,
0189    doEffFromHitPatternVsLUMI = False,
0190    doPlotsVsLUMI             = True,
0191    doPlotsVsBX               = True,
0192 
0193    AbsDxyMax                 = 1.2,
0194    AbsDxyBin                 = 12,
0195    DxyMin                    = -1.2,
0196    DxyMax                    = 1.2,
0197    DxyBin                    = 60,
0198 
0199    Chi2NDFMax                = 35.,
0200    Chi2NDFMin                = 0.,
0201    Chi2NDFBin                = 70,
0202 
0203    VZBin                     = 124,
0204    VZMin                     = -62.,
0205    VZMax                     =  62.,
0206 
0207    TrackPtMin                =  0.,
0208    TrackPtMax                =  50.,
0209    TrackPtBin                =  250
0210 )
0211 #
0212 process.tracks2monitor = cms.EDFilter('TrackSelector',
0213     src = cms.InputTag('pixelTracks'),
0214     cut = cms.string("")
0215 )
0216 process.tracks2monitor.src = 'pixelTracksHP'
0217 process.tracks2monitor.cut = 'pt > 1 & abs(eta) < 2.4' 
0218 
0219 
0220 #
0221 process.selectedPixelTracksMonitor = process.pixelTracksMonitor.clone(
0222    FolderName       = 'BeamMonitorLegacy/Tracking/selectedPixelTracks',
0223    TrackProducer    = 'tracks2monitor',
0224    allTrackProducer = 'tracks2monitor'
0225 )
0226 
0227 process.selectedPixelTracksMonitorSequence = cms.Sequence(
0228     process.pixelTracksCutClassifier
0229   + process.pixelTracksHP
0230   + process.tracks2monitor
0231   + process.selectedPixelTracksMonitor
0232 )
0233 
0234 
0235 #---------------------------------
0236 # Putting together combined paths
0237 
0238 #
0239 process.dqmTKStatus = cms.EDAnalyzer("TKStatus",
0240     BeamFitter = cms.PSet(
0241         DIPFileName = process.dqmBeamMonitor.BeamFitter.DIPFileName
0242     )
0243 )
0244 
0245 #
0246 process.dqmcommon = cms.Sequence(process.dqmEnv
0247                                * process.dqmSaver*process.dqmSaverPB)
0248 
0249 #
0250 process.monitor = cms.Sequence(process.dqmBeamMonitor
0251                              + process.selectedPixelTracksMonitorSequence)
0252 
0253 #------------------------
0254 # BeamSpotProblemMonitor
0255 
0256 #
0257 process.dqmBeamSpotProblemMonitor.monitorName = "BeamMonitorLegacy/BeamSpotProblemMonitor"
0258 process.dqmBeamSpotProblemMonitor.AlarmONThreshold  = 15 # was 10
0259 process.dqmBeamSpotProblemMonitor.AlarmOFFThreshold = 17 # was 12
0260 process.dqmBeamSpotProblemMonitor.nCosmicTrk        = 10
0261 process.dqmBeamSpotProblemMonitor.doTest            = False
0262 process.dqmBeamSpotProblemMonitor.pixelTracks  = 'pixelTracks'
0263 
0264 #
0265 from DQMServices.Core.DQMQualityTester import DQMQualityTester
0266 process.qTester = DQMQualityTester(
0267     qtList = cms.untracked.FileInPath('DQM/BeamMonitor/test/BeamSpotAvailableTest.xml'),
0268     prescaleFactor = cms.untracked.int32(1),                               
0269     qtestOnEndLumi = cms.untracked.bool(True),
0270     testInEventloop = cms.untracked.bool(False),
0271     verboseQT =  cms.untracked.bool(True)                 
0272 )
0273 
0274 #
0275 process.BeamSpotProblemModule = cms.Sequence(process.qTester
0276                                    * process.dqmBeamSpotProblemMonitor)
0277 
0278 # make it off for cosmic run
0279 if ( process.runType.getRunType() == process.runType.cosmic_run or
0280      process.runType.getRunType() == process.runType.cosmic_run_stage1):
0281     process.dqmBeamSpotProblemMonitor.AlarmOFFThreshold = 5 # <AlarmONThreshold
0282 
0283 #------------------------
0284 # Process customizations
0285 from DQM.Integration.config.online_customizations_cfi import *
0286 process = customise(process)
0287 
0288 # Digitisation: produce the TCDS digis containing BST record
0289 from EventFilter.OnlineMetaDataRawToDigi.tcdsRawToDigi_cfi import *
0290 process.tcdsDigis = tcdsRawToDigi.clone()
0291 
0292 #------------------------
0293 # Set rawDataRepacker (HI and live) or rawDataCollector (for all the rest)
0294 if (process.runType.getRunType() == process.runType.hi_run and live):
0295     rawDataInputTag = "rawDataRepacker"
0296 else:
0297     rawDataInputTag = "rawDataCollector"
0298 
0299 process.castorDigis.InputLabel           = rawDataInputTag
0300 process.csctfDigis.producer              = rawDataInputTag 
0301 process.dttfDigis.DTTF_FED_Source        = rawDataInputTag
0302 process.ecalDigis.cpu.InputLabel         = rawDataInputTag
0303 process.ecalPreshowerDigis.sourceTag     = rawDataInputTag
0304 process.gctDigis.inputLabel              = rawDataInputTag
0305 process.gtDigis.DaqGtInputTag            = rawDataInputTag
0306 process.hcalDigis.InputLabel             = rawDataInputTag
0307 process.muonCSCDigis.InputObjects        = rawDataInputTag
0308 process.muonDTDigis.inputLabel           = rawDataInputTag
0309 process.muonRPCDigis.InputLabel          = rawDataInputTag
0310 process.scalersRawToDigi.scalersInputTag = rawDataInputTag
0311 process.siPixelDigis.cpu.InputLabel      = rawDataInputTag
0312 process.siStripDigis.ProductLabel        = rawDataInputTag
0313 process.tcdsDigis.InputLabel             = rawDataInputTag
0314 
0315 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi")
0316 
0317 process.dqmBeamMonitor.OnlineMode = True
0318 process.dqmBeamMonitor.monitorName = "BeamMonitorLegacy"
0319 process.dqmBeamMonitor.recordName = BSOnlineRecordName
0320 process.dqmBeamMonitor.useLockRecords = useLockRecords
0321 
0322 process.dqmBeamMonitor.resetEveryNLumi   = 5 # was 10 for HI
0323 process.dqmBeamMonitor.resetPVEveryNLumi = 5 # was 10 for HI
0324 
0325 process.dqmBeamMonitor.PVFitter.minNrVerticesForFit = 20
0326 process.dqmBeamMonitor.PVFitter.minVertexNdf = 10
0327 process.dqmBeamMonitor.PVFitter.errorScale = 1.22
0328 
0329 #----------------------------
0330 # Pixel tracks/vertices reco
0331 process.load("RecoPixelVertexing.Configuration.RecoPixelVertexing_cff")
0332 from RecoVertex.PrimaryVertexProducer.OfflinePixel3DPrimaryVertices_cfi import *
0333 process.pixelVertices = pixelVertices.clone(
0334   TkFilterParameters = dict( minPt = process.pixelTracksTrackingRegions.RegionPSet.ptMin)
0335 )
0336 #process.pixelTracksTrackingRegions.RegionPSet.ptMin = 0.1       # used in PilotBeam 2021, but not ok for standard collisions
0337 process.pixelTracksTrackingRegions.RegionPSet.originRadius = 0.4 # used in PilotBeam 2021, to be checked again for standard collisions
0338 # The following parameters were used in 2018 HI:
0339 #process.pixelTracksTrackingRegions.RegionPSet.originHalfLength = 12
0340 #process.pixelTracksTrackingRegions.RegionPSet.originXPos =  0.08
0341 #process.pixelTracksTrackingRegions.RegionPSet.originYPos = -0.03
0342 #process.pixelTracksTrackingRegions.RegionPSet.originZPos = 0.
0343 
0344 process.tracking_FirstStep = cms.Sequence(
0345       process.siPixelDigis 
0346     * process.siStripDigis
0347     * process.striptrackerlocalreco
0348     * process.offlineBeamSpot
0349     * process.siPixelClustersPreSplitting
0350     * process.siPixelRecHitsPreSplitting
0351     * process.siPixelClusterShapeCachePreSplitting
0352     * process.recopixelvertexing)
0353 
0354 # triggerName for selecting pv for DIP publication, no wildcard needed here
0355 # it will pick all triggers which have these strings in their name
0356 process.dqmBeamMonitor.jetTrigger  = [
0357          "HLT_PAZeroBias_v", "HLT_ZeroBias_v", "HLT_QuadJet",
0358          "HLT_ZeroBias_",
0359          "HLT_HI",
0360          "HLT_PixelClusters"]
0361 
0362 # for HI only: select events based on the pixel cluster multiplicity
0363 if (process.runType.getRunType() == process.runType.hi_run):
0364     import HLTrigger.special.hltPixelActivityFilter_cfi
0365     process.multFilter = HLTrigger.special.hltPixelActivityFilter_cfi.hltPixelActivityFilter.clone(
0366         inputTag  = 'siPixelClustersPreSplitting',
0367         minClusters = 150,
0368         maxClusters = 50000 # was 10000
0369     )
0370        
0371     process.filter_step = cms.Sequence( process.siPixelDigis
0372                                       * process.siPixelClustersPreSplitting
0373                                       * process.multFilter
0374     )
0375 
0376 process.dqmBeamMonitor.hltResults = "TriggerResults::HLT"
0377 
0378 #---------
0379 # Upload BeamSpotOnlineObject (LegacyRcd) to CondDB
0380 if unitTest == False:
0381     process.OnlineDBOutputService = cms.Service("OnlineDBOutputService",
0382 
0383         DBParameters = cms.PSet(
0384                                 messageLevel = cms.untracked.int32(0),
0385                                 authenticationPath = cms.untracked.string('.')
0386                             ),
0387 
0388         # Upload to CondDB
0389         connect = cms.string('oracle://cms_orcon_prod/CMS_CONDITIONS'),
0390         preLoadConnectionString = cms.untracked.string('frontier://FrontierProd/CMS_CONDITIONS'),
0391 
0392         runNumber = cms.untracked.uint64(options.runNumber),
0393         omsServiceUrl = cms.untracked.string(BSOnlineOmsServiceUrl),
0394         latency = cms.untracked.uint32(2),
0395         autoCommit = cms.untracked.bool(True),
0396         saveLogsOnDB = cms.untracked.bool(True),
0397         jobName = cms.untracked.string(BSOnlineJobName), # name of the DB log record
0398         toPut = cms.VPSet(cms.PSet(
0399             record = cms.string(BSOnlineRecordName),
0400             tag = cms.string(BSOnlineTag),
0401             timetype = cms.untracked.string('Lumi'),
0402             onlyAppendUpdatePolicy = cms.untracked.bool(True)
0403         )),
0404         frontierKey = cms.untracked.string(options.runUniqueKey)
0405     )
0406 
0407 else:
0408     process.OnlineDBOutputService = cms.Service("OnlineDBOutputService",
0409 
0410         DBParameters = cms.PSet(
0411                                 messageLevel = cms.untracked.int32(0),
0412                                 authenticationPath = cms.untracked.string('.')
0413                             ),
0414 
0415         # Upload to CondDB
0416         connect = cms.string('sqlite_file:BeamSpotOnlineLegacy.db'),
0417         preLoadConnectionString = cms.untracked.string('sqlite_file:BeamSpotOnlineLegacy.db'),
0418         runNumber = cms.untracked.uint64(options.runNumber),
0419         lastLumiFile = cms.untracked.string('last_lumi.txt'),
0420         latency = cms.untracked.uint32(2),
0421         autoCommit = cms.untracked.bool(True),
0422         toPut = cms.VPSet(cms.PSet(
0423             record = cms.string(BSOnlineRecordName),
0424             tag = cms.string(BSOnlineTag),
0425             timetype = cms.untracked.string('Lumi'),
0426             onlyAppendUpdatePolicy = cms.untracked.bool(True)
0427         )),
0428         frontierKey = cms.untracked.string(options.runUniqueKey)
0429     )
0430 print("Configured frontierKey", options.runUniqueKey)
0431 #---------
0432 # Final path
0433 if (not process.runType.getRunType() == process.runType.hi_run):
0434     process.p = cms.Path(process.scalersRawToDigi
0435                        * process.tcdsDigis
0436                        * process.onlineMetaDataDigis
0437                        * process.dqmTKStatus
0438                        * process.hltTriggerTypeFilter
0439                        * process.dqmcommon
0440                        * process.tracking_FirstStep
0441                        * process.monitor
0442                        * process.BeamSpotProblemModule)
0443 else:
0444     process.p = cms.Path(process.scalersRawToDigi
0445                        * process.tcdsDigis
0446                        * process.onlineMetaDataDigis
0447                        * process.dqmTKStatus
0448                        * process.hltTriggerTypeFilter
0449                        * process.filter_step # the only extra: pix-multi filter
0450                        * process.dqmcommon
0451                        * process.tracking_FirstStep
0452                        * process.monitor
0453                        * process.BeamSpotProblemModule)
0454 
0455 print("Final Source settings:", process.source)
0456