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