Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-10 02:50:45

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 import copy 
0005 
0006 process = cms.Process("Demo")
0007 
0008 #prepare options
0009 
0010 options = VarParsing.VarParsing("analysis")
0011 
0012 options.register ('globalTag',
0013                   "auto:run2_data",
0014                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0015                   VarParsing.VarParsing.varType.string,          # string, int, or float
0016                   "GlobalTag")
0017 
0018 options.register ('runNumber',
0019                   306054,
0020                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0021                   VarParsing.VarParsing.varType.int,           # string, int, or float
0022                   "run number")
0023 
0024 options.parseArguments()
0025 
0026 
0027 ##
0028 ## MessageLogger
0029 ##
0030 process.load('FWCore.MessageService.MessageLogger_cfi')   
0031 process.MessageLogger.cerr.enable = False
0032 process.MessageLogger.SiStripNoisesFromDBMiscalibrator=dict()  
0033 process.MessageLogger.cout = cms.untracked.PSet(
0034     enable    = cms.untracked.bool(True),
0035     enableStatistics = cms.untracked.bool(True),
0036     threshold = cms.untracked.string("WARNING"),
0037     default   = cms.untracked.PSet(limit = cms.untracked.int32(0)),                       
0038     FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
0039                                    reportEvery = cms.untracked.int32(1000)
0040                                    ),                                                      
0041     SiStripNoisesFromDBMiscalibrator = cms.untracked.PSet( limit = cms.untracked.int32(-1))
0042     )
0043 
0044 process.load("Configuration.Geometry.GeometryRecoDB_cff") # Ideal geometry and interface 
0045 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0046 from Configuration.AlCa.GlobalTag import GlobalTag
0047 process.GlobalTag = GlobalTag(process.GlobalTag,options.globalTag, '')
0048 
0049 print("Using Global Tag:", process.GlobalTag.globaltag._value)
0050 
0051 ##
0052 ## Empty Source
0053 ##
0054 process.source = cms.Source("EmptySource",
0055                             firstRun = cms.untracked.uint32(options.runNumber),
0056                             numberEventsInRun = cms.untracked.uint32(1),
0057                             )
0058 
0059 
0060 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) )
0061 
0062 ##
0063 ## Example smearing configurations
0064 ##
0065 
0066 ########### Noise ##########
0067 # TEC: new = 5.985 old = 5.684  => ratio: 1.052
0068 # TOB: new = 6.628 old = 6.647  => ratio: 0.997
0069 # TIB: new = 5.491 old = 5.392  => ratio: 1.018
0070 # TID: new = 5.259 old = 5.080  => ratio: 1.035
0071 
0072 ##
0073 ## separately partition by partition
0074 ##
0075 byPartition = cms.VPSet(
0076     cms.PSet(partition = cms.string("TEC"),
0077              doScale   = cms.bool(True),
0078              doSmear   = cms.bool(False),
0079              scaleFactor = cms.double(1.2),
0080              smearFactor = cms.double(0.04)
0081              ),
0082     cms.PSet(partition = cms.string("TOB"),
0083              doScale   = cms.bool(True),
0084              doSmear   = cms.bool(False),
0085              scaleFactor = cms.double(0.94),
0086              smearFactor = cms.double(0.03)
0087              ),
0088     cms.PSet(partition = cms.string("TIB"),
0089              doScale   = cms.bool(True),
0090              doSmear   = cms.bool(False),
0091              scaleFactor = cms.double(1.1),
0092              smearFactor = cms.double(0.02)
0093              ),
0094     cms.PSet(partition = cms.string("TID"),
0095              doScale   = cms.bool(True),
0096              doSmear   = cms.bool(False),
0097              scaleFactor = cms.double(0.22),
0098              smearFactor = cms.double(0.01)
0099              )
0100     )
0101 
0102 ##
0103 ## whole Strip tracker
0104 ##
0105 
0106 wholeTracker = cms.VPSet(
0107     cms.PSet(partition = cms.string("Tracker"),
0108              doScale   = cms.bool(True),
0109              doSmear   = cms.bool(True),
0110              scaleFactor = cms.double(1.00),
0111              smearFactor = cms.double(0.00)
0112              )
0113     )
0114 
0115 ##
0116 ## by Layer only one partition
0117 ##
0118 
0119 byLayerOnlyTIB = cms.VPSet(
0120 
0121     ################## TIB ##################
0122 
0123     cms.PSet(partition = cms.string("TIB_1"),
0124              doScale   = cms.bool(True),
0125              doSmear   = cms.bool(True),
0126              scaleFactor = cms.double(1),
0127              smearFactor = cms.double(0.1)
0128              ),
0129     cms.PSet(partition = cms.string("TIB_2"),
0130              doScale   = cms.bool(True),
0131              doSmear   = cms.bool(True),
0132              scaleFactor = cms.double(2),
0133              smearFactor = cms.double(0.25)
0134              ),
0135     cms.PSet(partition = cms.string("TIB_3"),
0136              doScale   = cms.bool(True),
0137              doSmear   = cms.bool(True),
0138              scaleFactor = cms.double(3),
0139              smearFactor = cms.double(0.2)
0140              ),
0141     cms.PSet(partition = cms.string("TIB_4"),
0142              doScale   = cms.bool(True),
0143              doSmear   = cms.bool(True),
0144              scaleFactor = cms.double(4),
0145              smearFactor = cms.double(0.01)
0146              )
0147     )
0148 
0149 ##
0150 ## hierarchies
0151 ##
0152 
0153 subsets =  cms.VPSet(
0154     cms.PSet(partition = cms.string("Tracker"),
0155              doScale   = cms.bool(True),
0156              doSmear   = cms.bool(True),
0157              scaleFactor = cms.double(0.65),
0158              smearFactor = cms.double(0.05)
0159              ),
0160     cms.PSet(partition = cms.string("TEC"),
0161              doScale   = cms.bool(True),
0162              doSmear   = cms.bool(True),
0163              scaleFactor = cms.double(1.15),
0164              smearFactor = cms.double(0.02)
0165              ),
0166     cms.PSet(partition = cms.string("TECP"),
0167              doScale   = cms.bool(True),
0168              doSmear   = cms.bool(True),
0169              scaleFactor = cms.double(1.35),
0170              smearFactor = cms.double(0.02)
0171              ),
0172     cms.PSet(partition = cms.string("TECP_9"),
0173              doScale   = cms.bool(True),
0174              doSmear   = cms.bool(True),
0175              scaleFactor = cms.double(1.55),
0176              smearFactor = cms.double(0.02)
0177              )
0178     )
0179 
0180 #
0181 # just a silly example
0182 #
0183 autoparams=[]
0184 listOfLayers=["TIB_1","TIB_2","TIB_3","TIB_4","TOB_1","TOB_2","TOB_3","TOB_4","TOB_5","TOB_6","TIDM_1","TIDM_2","TIDM_3","TECM_1","TECM_2","TECM_3","TECM_4","TECM_5","TECM_6","TECM_7","TECM_8","TECM_9","TIDP_1","TIDP_2","TIDP_3","TECP_1","TECP_2","TECP_3","TECP_4","TECP_5","TECP_6","TECP_7","TECP_8","TECP_9"]
0185 
0186 for i,ll in enumerate(listOfLayers):
0187     autoparams.append(
0188         cms.PSet(
0189             partition = cms.string(ll),
0190             doScale   = cms.bool(True),
0191             doSmear   = cms.bool(True),
0192             scaleFactor = cms.double(i*0.1),
0193             smearFactor = cms.double((len(listOfLayers)-i)*0.01)
0194             )
0195         )
0196 
0197 # process.demo = cms.EDAnalyzer('SiStripNoisesFromDBMiscalibrator',
0198 #                               params = subsets, # as a cms.VPset
0199 #                               fillDefaults = cms.bool(False),
0200 #                               saveMaps = cms.bool(True)      
0201 #                               )
0202 
0203 
0204 ##
0205 ## Impot the thresholds configuration
0206 ##
0207 import CondTools.SiStrip.MiscalibrationSettings_cff as Settings
0208 eachLayer = copy.deepcopy(Settings.byLayer)
0209 
0210 process.load("CondTools.SiStrip.scaleAndSmearSiStripNoises_cfi")
0211 #process.scaleAndSmearSiStripNoises.params  = eachLayer      # as a cms.VPset
0212 #process.scaleAndSmearSiStripNoises.params  = wholeTracker   # as a cms.VPset
0213 #process.scaleAndSmearSiStripNoises.params  = byPartition    # as a cms.VPset
0214 #process.scaleAndSmearSiStripNoises.params  = subsets        # as a cms.VPset
0215 #process.scaleAndSmearSiStripNoises.params  = byLayerOnlyTIB # as a cms.VPset
0216 process.scaleAndSmearSiStripNoises.params  = autoparams
0217 process.scaleAndSmearSiStripNoises.fillDefaults = False      # to fill uncabled DetIds with default
0218 
0219 ##
0220 ## Output database (in this case local sqlite file)
0221 ##
0222 process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0223     BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService'),
0224     DBParameters = cms.PSet(
0225         messageLevel = cms.untracked.int32(3),
0226         authenticationPath = cms.untracked.string('/afs/cern.ch/cms/DB/conddb')
0227     ),
0228     timetype = cms.untracked.string('runnumber'),
0229     connect = cms.string('sqlite_file:modifiedSiStripNoise_%s_IOV_%s.db' % ( process.GlobalTag.globaltag._value, str(options.runNumber))),
0230     toPut = cms.VPSet(cms.PSet(
0231         record = cms.string('SiStripNoisesRcd'),
0232         tag = cms.string('modifiedNoise')
0233     ))
0234 )
0235 
0236 process.p = cms.Path(process.scaleAndSmearSiStripNoises)