Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-30 04:13:22

0001 # Example config to produce a merged bad components payload, e.g.
0002 # cmsRun makeMergeBadComponentPayload_example_cfg.py globalTag=auto:run3_data_prompt runNumber=319176 dqmFile=/eos/cms/store/group/comm_dqm/DQMGUI_data/Run2018/ZeroBias/R0003191xx/DQM_V0001_R000319176__ZeroBias__Run2018B-PromptReco-v2__DQMIO.root runStartTime=6574046031825076224
0003 
0004 import FWCore.ParameterSet.Config as cms
0005 from FWCore.ParameterSet.VarParsing import VarParsing as VP
0006 
0007 process = cms.Process("BadChannelMerge")
0008 
0009 opts = VP("python")
0010 opts.register("globalTag", "DONOTEXIST", VP.multiplicity.singleton, VP.varType.string, "GlobalTag")
0011 opts.register("dqmFile", "", VP.multiplicity.singleton, VP.varType.string, "DQM root file")
0012 opts.register("runNumber", 0, VP.multiplicity.singleton, VP.varType.int, "run number")
0013 opts.register("runStartTime", 0, VP.multiplicity.singleton, VP.varType.int, "run start time")
0014 opts.register("dbfile", "merged.db", VP.multiplicity.singleton, VP.varType.string, "SQLite output file")
0015 opts.register("outputTag", "SiStripBadComponents_merged_v0", VP.multiplicity.singleton, VP.varType.string, "Output tag name")
0016 opts.parseArguments()
0017 
0018 notAllSet = False
0019 if opts.globalTag == "DONOTEXIST":
0020     print("ERROR: Global tag must be set")
0021     notAllSet = True
0022 if opts.runStartTime == 0:
0023     print("ERROR: Run start time must be set (use the getRunStartTime.py script to get it)")
0024     notAllSet = True
0025 if opts.runNumber == 0:
0026     print("ERROR: Run number must be set")
0027 if opts.dqmFile == "":
0028     print("WARNING: no DQM file set, bad components from FED errors will not be included")
0029     notAllSet = True
0030 if notAllSet:
0031     raise RuntimeError("Not all required arguments have been passed, need globalTag, dqmFile, runNumber and runStartTime")
0032 
0033 process.MessageLogger = cms.Service("MessageLogger",
0034     destinations = cms.untracked.vstring("cout", "cerr", "MergedBadComponents"),
0035     cerr=cms.untracked.PSet(
0036         threshold=cms.untracked.string("ERROR")),
0037     cout=cms.untracked.PSet(
0038         threshold=cms.untracked.string("INFO"),
0039         default=cms.untracked.PSet(limit=cms.untracked.int32(0))
0040         ),
0041     MergedBadComponents=cms.untracked.PSet(
0042         threshold=cms.untracked.string("INFO"),
0043         default=cms.untracked.PSet(limit=cms.untracked.int32(0)),
0044         SiStripQualityStatistics=cms.untracked.PSet(limit=cms.untracked.int32(100000)),
0045         ),
0046     categories = cms.untracked.vstring(
0047         "SiStripQualityStatistics",
0048         "SiStripQuality"
0049         ),
0050     debugModules = cms.untracked.vstring(
0051         "SiStripQualityESProducer",
0052         "siStripBadStripFromQualityDBWriter"
0053         ),
0054 )
0055 
0056 process.load("Configuration.Geometry.GeometryRecoDB_cff")
0057 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0058 from Configuration.AlCa.GlobalTag import GlobalTag
0059 process.GlobalTag = GlobalTag(process.GlobalTag, opts.globalTag, "")
0060 
0061 process.source = cms.Source("EmptySource",
0062     firstRun = cms.untracked.uint32(opts.runNumber),
0063     numberEventsInRun = cms.untracked.uint32(1),
0064     numberEventsInLuminosityBlock = cms.untracked.uint32(1),
0065     firstTime = cms.untracked.uint64(opts.runStartTime),
0066     timeBetweenEvents = cms.untracked.uint64(1)
0067     )
0068 process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(1))
0069 
0070 process.siStripQualityESProducer.ListOfRecordToMerge = cms.VPSet(
0071     cms.PSet(record=cms.string("SiStripDetVOffRcd"), tag=cms.string("")),    # DCS information
0072     cms.PSet(record=cms.string("SiStripDetCablingRcd"), tag=cms.string("")), # Use Detector cabling information to exclude detectors not connected            
0073     cms.PSet(record=cms.string("SiStripBadChannelRcd"), tag=cms.string("")), # Online Bad components
0074     cms.PSet(record=cms.string("RunInfoRcd"), tag=cms.string("")),           # List of FEDs exluded during data taking          
0075     cms.PSet(record=cms.string("SiStripBadFiberRcd"), tag=cms.string("")),   # Bad Channel list from the selected IOV as done at PCL
0076     )
0077 process.siStripQualityESProducer.ReduceGranularity = cms.bool(False)
0078 process.siStripQualityESProducer.ThresholdForReducedGranularity = cms.double(0.3)
0079 process.siStripQualityESProducer.PrintDebugOutput = True
0080 
0081 # common config for adding bad components from FED errors
0082 from CalibTracker.SiStripQuality.siStripQualityStatistics_cfi import siStripQualityStatistics
0083 badCompFromFedErrors = siStripQualityStatistics.BadComponentsFromFedErrors.clone(
0084         Add=cms.bool(True),
0085         LegacyDQMFile=cms.string(opts.dqmFile),
0086         FileRunNumber=cms.uint32(opts.runNumber)
0087         )
0088 
0089 # Print list of Bad modules and create Tracker Map indicating Bad modules
0090 process.load("DQM.SiStripCommon.TkHistoMap_cff")  # to produce a tracker map
0091 process.stat = siStripQualityStatistics.clone(
0092         TkMapFileName=cms.untracked.string("TkMap_Jul04_2018_319176.png"),  #available filetypes: .pdf .png .jpg .svg
0093         BadComponentsFromFedErrors=badCompFromFedErrors
0094         )
0095 
0096 # Write Information into DB
0097 process.load("CalibTracker.SiStripQuality.siStripBadStripFromQualityDBWriter_cfi")
0098 #process.siStripBadStripFromQualityDBWriter.OpenIovAt = cms.untracked.string("currentTime")
0099 process.siStripBadStripFromQualityDBWriter.OpenIovAt = cms.untracked.string("beginTime")
0100 process.siStripBadStripFromQualityDBWriter.BadComponentsFromFedErrors = badCompFromFedErrors
0101 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0102     BlobStreamerName=cms.untracked.string("TBufferBlobStreamingService"),
0103     DBParameters=cms.PSet(
0104         authenticationPath=cms.untracked.string("/afs/cern.ch/cms/DB/conddb")
0105     ),
0106     timetype=cms.untracked.string("runnumber"),
0107     connect=cms.string("sqlite_file:"+opts.dbfile),
0108     toPut=cms.VPSet(cms.PSet(
0109         record=cms.string("SiStripBadModuleRcd"),
0110         tag=cms.string(opts.outputTag)
0111     )))
0112 process.siStripBadStripFromQualityDBWriter.record = process.PoolDBOutputService.toPut[0].record
0113 
0114 process.p = cms.Path(process.stat*process.siStripBadStripFromQualityDBWriter)