File indexing completed on 2024-11-25 02:29:25
0001
0002
0003
0004 import os, shlex, shutil, getpass
0005
0006 import FWCore.ParameterSet.Config as cms
0007 from Configuration.StandardSequences.Eras import eras
0008
0009
0010 run = 313000
0011 era = eras.Run2_2017
0012 verbose = False
0013 threshold = 'INFO' if verbose else 'WARNING'
0014 print(">>> run = %s"%run)
0015
0016
0017 process = cms.Process("SiPixelVCalDB",era)
0018 process.load("FWCore.MessageService.MessageLogger_cfi")
0019 process.load("Configuration.StandardSequences.GeometryDB_cff")
0020
0021
0022 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0023
0024
0025
0026
0027 process.load("CondTools.SiPixel.SiPixelGainCalibrationService_cfi")
0028
0029 process.load("CondCore.CondDB.CondDB_cfi")
0030
0031
0032 from Configuration.AlCa.GlobalTag import GlobalTag
0033
0034
0035
0036
0037
0038
0039 process.GlobalTag = GlobalTag(process.GlobalTag,'auto:run2_data','')
0040
0041
0042 print(">>> globaltag = '%s'"%(process.GlobalTag.globaltag))
0043
0044
0045 process.source = cms.Source("EmptyIOVSource",
0046 firstValue = cms.uint64(run),
0047 lastValue = cms.uint64(run),
0048
0049 timetype = cms.string('runnumber'),
0050 interval = cms.uint64(1),
0051 )
0052 process.maxEvents = cms.untracked.PSet(
0053 input = cms.untracked.int32(1)
0054 )
0055
0056
0057 process.MessageLogger.cerr.enable = False
0058 process.MessageLogger.cout = dict(enable = True, threshold = threshold)
0059
0060
0061 user = getpass.getuser()
0062
0063
0064
0065
0066
0067
0068 file = "siPixelVCal.db"
0069 sqlfile = "sqlite_file:" + file
0070 print(">>> Uploading as user %s into file %s, i.e. %s"%(user,file,sqlfile))
0071 if os.path.exists("siPixelVCal.db"):
0072 oldfile = file.replace(".db","_old.db")
0073 print(">>> Backing up locally existing '%s' -> '%s'"%(file,oldfile))
0074 shutil.move(file,oldfile)
0075
0076
0077 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0078 BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService'),
0079 DBParameters = cms.PSet(
0080 authenticationPath = cms.untracked.string('.'),
0081 connectionRetrialPeriod = cms.untracked.int32(10),
0082 idleConnectionCleanupPeriod = cms.untracked.int32(10),
0083 messageLevel = cms.untracked.int32(1),
0084 enablePoolAutomaticCleanUp = cms.untracked.bool(False),
0085 enableConnectionSharing = cms.untracked.bool(True),
0086 connectionRetrialTimeOut = cms.untracked.int32(60),
0087 connectionTimeOut = cms.untracked.int32(0),
0088 enableReadOnlySessionOnUpdateConnection = cms.untracked.bool(False)
0089 ),
0090 timetype = cms.untracked.string('runnumber'),
0091 connect = cms.string(sqlfile),
0092 toPut = cms.VPSet(
0093 cms.PSet(
0094 record = cms.string('SiPixelVCalRcd'),
0095 tag = cms.string('SiPixelVCal_v1')
0096 ),
0097
0098
0099
0100
0101 )
0102 )
0103
0104
0105
0106
0107 slope = 47.
0108 slope_L1 = 50.
0109 offset = -60.
0110 offset_L1 = -670.
0111 corrs_bpix = { 1: 1.110, 2: 1.036, 3: 1.023, 4: 1.011 }
0112 corrs_fpix = { 1: 1.1275, 2: 1.1275, 3: 1.1275 }
0113 layers = [1,2,3,4]
0114 nladders = { 1: 12, 2: 28, 3: 44, 4: 64, }
0115 sides = [1,2]
0116 disks = [1,2,3]
0117 rings = [1,2]
0118 bpixpars = cms.untracked.VPSet()
0119 fpixpars = cms.untracked.VPSet()
0120 print(">>> %8s %8s %10s %10s %10s"%('layer','ladder','slope','offset','corr'))
0121 for layer in layers:
0122 for ladder in range(1,nladders[layer]+1):
0123 corr = corrs_bpix[layer]
0124 slope_ = (slope_L1 if layer==1 else slope)*corr
0125 offset_ = (offset_L1 if layer==1 else offset)
0126 print(">>> %8d %8d %10.4f %10.3f %10.4f"%(layer,ladder,slope_,offset_,corr))
0127 bpixpars.append(cms.PSet(
0128 layer = cms.int32(layer),
0129 ladder = cms.int32(ladder),
0130 slope = cms.double(slope_),
0131 offset = cms.double(offset_),
0132 ))
0133 print(">>> %8s %8s %8s %10s %10s %10s"%('side','disk','ring','slope','offset','corr'))
0134 for side in sides:
0135 for disk in disks:
0136 for ring in rings:
0137 corr = corrs_fpix[ring]
0138 slope_ = slope*corr
0139 offset_ = offset
0140 print(">>> %8d %8d %8d %10.4f %10.3f %10.4f"%(side,disk,ring,slope_,offset_,corr))
0141 fpixpars.append(cms.PSet(
0142 side = cms.int32(side),
0143 disk = cms.int32(disk),
0144 ring = cms.int32(ring),
0145 slope = cms.double(slope_),
0146 offset = cms.double(offset_),
0147 ))
0148
0149
0150 process.SiPixelVCal = cms.EDAnalyzer("SiPixelVCalDB",
0151 BPixParameters = bpixpars,
0152 FPixParameters = fpixpars,
0153 record = cms.untracked.string('SiPixelVCalRcd'),
0154 )
0155 process.p = cms.Path(process.SiPixelVCal)