Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-01 23:53:47

0001 #! /bin/env cmsRun
0002 
0003 import FWCore.ParameterSet.Config as cms
0004 import FWCore.ParameterSet.VarParsing as VarParsing
0005 from fnmatch import fnmatch
0006 from pdb import set_trace
0007 
0008 #################################################
0009 options = VarParsing.VarParsing("analysis")
0010 
0011 options.register ('outputRootFile',
0012                   "",
0013                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0014                   VarParsing.VarParsing.varType.string,         # string, int, or float
0015                   "output root file")
0016 options.register ('records',
0017                   [],
0018                   VarParsing.VarParsing.multiplicity.list, # singleton or list
0019                   VarParsing.VarParsing.varType.string,    # string, int, or float
0020                   "record:tag names to be used/changed from GT")
0021 options.register ('external',
0022                   [],
0023                   VarParsing.VarParsing.multiplicity.list, # singleton or list
0024                   VarParsing.VarParsing.varType.string,    # string, int, or float
0025                   "record:fle.db picks the following record from this external file")
0026 options.register ('runNumber',
0027                   1,
0028                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0029                   VarParsing.VarParsing.varType.int,            # string, int, or float
0030                   "run number")
0031 options.register ('runStartTime',
0032                   1,
0033                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0034                   VarParsing.VarParsing.varType.int,            # string, int, or float
0035                   "run start time")
0036 options.register ('GlobalTag',
0037                   '',
0038                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0039                   VarParsing.VarParsing.varType.string,         # string, int, or float
0040                   "Correct noise for APV gain?")
0041 
0042 options.parseArguments()
0043 
0044 process = cms.Process("Reader")
0045 process.load('Configuration.StandardSequences.GeometryRecoDB_cff') 
0046 
0047 ###################################################################
0048 # Messages
0049 ###################################################################
0050 process.load("FWCore.MessageService.MessageLogger_cfi")
0051 process.MessageLogger.cerr.enable = False
0052 process.MessageLogger.SiStripDB2Tree=dict()
0053 process.MessageLogger.RecordInfo=dict()
0054 process.MessageLogger.cout = cms.untracked.PSet(
0055     enable = cms.untracked.bool(True),
0056     threshold = cms.untracked.string("INFO"),
0057     default   = cms.untracked.PSet(limit = cms.untracked.int32(0)),                       
0058     FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
0059                                    reportEvery = cms.untracked.int32(1000)
0060                                    ),                                                      
0061     SiStripDB2Tree = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
0062     RecordInfo     = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
0063     enableStatistics = cms.untracked.bool(True)
0064 )
0065 
0066 process.maxEvents = cms.untracked.PSet(
0067     input = cms.untracked.int32(1)
0068     #input = cms.untracked.int32(-1) ### shall be -1 for the EmptyIOVSource
0069     )
0070 
0071 # process.source = cms.Source("EmptyIOVSource",
0072 #                             firstValue = cms.uint64(options.runNumber),
0073 #                             lastValue = cms.uint64(options.runNumber),
0074 #                             timetype = cms.string('runnumber'),
0075 #                             interval = cms.uint64(1)
0076 #                             )
0077 
0078 process.source = cms.Source("EmptySource",
0079                             firstRun = cms.untracked.uint32(options.runNumber),
0080                             numberEventsInRun = cms.untracked.uint32(1),
0081                             numberEventsInLuminosityBlock = cms.untracked.uint32(1),
0082                             firstTime = cms.untracked.uint64(options.runStartTime),
0083                             timeBetweenEvents = cms.untracked.uint64(1)
0084                             )
0085 
0086 connection_map = [
0087     ('SiStrip*', 'frontier://PromptProd/CMS_CONDITIONS'),
0088     ]
0089 if options.external:
0090     connection_map.extend(
0091         (i.split(':')[0], 'sqlite_file:%s' % i.split(':')[1]) for i in options.external
0092         )
0093 
0094 connection_map.sort(key=lambda x: -1*len(x[0]))
0095 def best_match(rcd):
0096     print(rcd)
0097     for pattern, string in connection_map:
0098         print(pattern, fnmatch(rcd, pattern))
0099         if fnmatch(rcd, pattern):
0100             return string
0101 records = []
0102 if options.records:
0103     for record in options.records:
0104         rcd, tag = tuple(record.split(':'))
0105         records.append(
0106             cms.PSet(
0107                 record = cms.string(rcd),
0108                 tag    = cms.string(tag),
0109                 connect = cms.untracked.string(best_match(rcd))
0110                 )
0111             )
0112 
0113 if options.GlobalTag:
0114     process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0115     from Configuration.AlCa.GlobalTag import GlobalTag
0116     process.GlobalTag = GlobalTag(process.GlobalTag, options.GlobalTag, '')
0117     print("using global tag: %s" % process.GlobalTag.globaltag.value())
0118     #process.GlobalTag.DumpStat = cms.untracked.bool(True)  #to dump what records have been accessed
0119     process.GlobalTag.toGet = cms.VPSet(*records)
0120 else:
0121     print("overriding using local conditions: %s" %records)
0122     process.poolDBESSource = cms.ESSource(
0123         "PoolDBESSource",
0124         BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService'),
0125         DBParameters = cms.PSet(
0126             messageLevel = cms.untracked.int32(1),  # it used to be 2
0127             authenticationPath = cms.untracked.string('/afs/cern.ch/cms/DB/conddb')
0128             ),
0129         #DumpStat = cms.untracked.bool(True),
0130         timetype = cms.untracked.string('runnumber'),
0131         toGet = cms.VPSet(records),
0132         connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS')
0133         )
0134 
0135 
0136 from CalibTracker.SiStripESProducers.SiStripQualityESProducer_cfi import*
0137 siStripQualityESProducer.ListOfRecordToMerge = cms.VPSet(
0138     cms.PSet(record = cms.string("SiStripDetVOffRcd"), tag = cms.string('')),    # DCS information
0139     cms.PSet(record = cms.string('SiStripDetCablingRcd'), tag = cms.string('')), # Use Detector cabling information to exclude detectors not connected            
0140     cms.PSet(record = cms.string('SiStripBadChannelRcd'), tag = cms.string('')), # Online Bad components
0141     cms.PSet(record = cms.string('SiStripBadFiberRcd'), tag = cms.string('')),   # Bad Channel list from the selected IOV as done at PCL
0142     cms.PSet(record = cms.string('RunInfoRcd'), tag = cms.string(''))            # List of FEDs exluded during data taking          
0143     )
0144 
0145 siStripQualityESProducer.ReduceGranularity = cms.bool(False)
0146 siStripQualityESProducer.ThresholdForReducedGranularity = cms.double(0.3)
0147 siStripQualityESProducer.appendToDataLabel = 'MergedBadComponent'
0148 siStripQualityESProducer.PrintDebugOutput = cms.bool(True)
0149 
0150 process.TFileService = cms.Service(
0151     "TFileService",
0152     fileName = cms.string(options.outputRootFile)
0153 )
0154 process.treeDump = cms.EDAnalyzer('SiStripDB2Tree',
0155                                   StripQualityLabel = cms.string('MergedBadComponent') 
0156                                   )
0157 process.p = cms.Path(process.treeDump)