Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:07

0001 import FWCore.ParameterSet.Config as cms
0002 import FWCore.ParameterSet.VarParsing as VarParsing
0003 import copy, sys, os
0004 
0005 import Configuration.Geometry.defaultPhase2ConditionsEra_cff as _settings
0006 GLOBAL_TAG, ERA = _settings.get_era_and_conditions(_settings.DEFAULT_VERSION)
0007 process = cms.Process("Misaligner", ERA)
0008 
0009 ###################################################################
0010 # Setup 'standard' options
0011 ###################################################################
0012 options = VarParsing.VarParsing()
0013 
0014 options.register('myScenario',
0015                  "MisalignmentScenario10MuPixelPhase2", # default value
0016                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0017                  VarParsing.VarParsing.varType.string, # string, int, or float
0018                  "scenario to apply")
0019 
0020 options.register('mySigma',
0021                  -1, # default value
0022                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0023                  VarParsing.VarParsing.varType.float, # string, int, or float
0024                  "sigma for random misalignment in um")
0025 
0026 options.register('inputDB',
0027                  None, # default value
0028                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0029                  VarParsing.VarParsing.varType.string, # string, int, or float
0030                  "input database file to override GT (optional)")
0031 
0032 options.parseArguments()
0033 
0034 ###################################################################
0035 # Message logger service
0036 ###################################################################
0037 process.load("FWCore.MessageService.MessageLogger_cfi")
0038 process.MessageLogger.cout = cms.untracked.PSet(
0039     threshold = cms.untracked.string('INFO'),
0040     default = cms.untracked.PSet(
0041         limit = cms.untracked.int32(10000000)
0042     )
0043 )
0044 # replace MessageLogger.debugModules = { "*" }
0045 # service = Tracer {}
0046 
0047 ###################################################################
0048 # Ideal geometry producer and standard includes
0049 ###################################################################
0050 process.load('Configuration.Geometry.GeometryExtendedRun4DefaultReco_cff')
0051 process.trackerGeometry.applyAlignment = True
0052 
0053 ###################################################################
0054 # Just state the Global Tag (and pick some run)
0055 ###################################################################
0056 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0057 from Configuration.AlCa.GlobalTag import GlobalTag
0058 #process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T25', '') # using realistic Phase 2 geom
0059 process.GlobalTag = GlobalTag(process.GlobalTag, GLOBAL_TAG, '') # using realistic Phase 2 geom
0060 print("Using global tag:", process.GlobalTag.globaltag.value())
0061 
0062 ###################################################################
0063 # This uses the object from the tag and applies the misalignment scenario on top of that object
0064 ###################################################################
0065 process.load("Alignment.CommonAlignmentProducer.AlignmentProducer_cff")
0066 process.AlignmentProducer.doMisalignmentScenario=True
0067 process.AlignmentProducer.applyDbAlignment=True
0068 process.AlignmentProducer.checkDbAlignmentValidity=False #otherwise error thrown for IOV dependent GTs
0069 import Alignment.TrackerAlignment.Scenarios_cff as scenarios
0070 
0071 if hasattr(scenarios, options.myScenario):
0072     print("Using scenario:", options.myScenario)
0073     print("    with sigma:", options.mySigma)
0074     print()
0075     process.AlignmentProducer.MisalignmentScenario = getattr(scenarios, options.myScenario)
0076 else:
0077     print("----- Begin Fatal Exception -----------------------------------------------")
0078     print("Unrecognized",options.myScenario,"misalignment scenario !!!!")
0079     print("Aborting cmsRun now, please check your input")
0080     print("----- End Fatal Exception -------------------------------------------------")
0081     sys.exit(1)
0082 
0083 sigma = options.mySigma
0084 if sigma > 0:
0085     process.AlignmentProducer.MisalignmentScenario.scale = cms.double(0.0001*sigma) # shifts are in cm
0086 
0087 # if options.inputDB is not None:
0088 #     print("EXTENDING THE GLOBAL TAG!!!!")
0089 #     process.GlobalTag.toGet.extend([
0090 #             cms.PSet(
0091 #                 connect = cms.string("sqlite_file:"+options.inputDB),
0092 #                 record = cms.string("TrackerAlignmentRcd"),
0093 #                 tag = cms.string("Alignments")
0094 #                 ),
0095 #             cms.PSet(
0096 #                 connect = cms.string("sqlite_file:"+options.inputDB),
0097 #                 record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0098 #                 tag = cms.string("AlignmentErrorsExtended")
0099 #                 )
0100 #             ])
0101 
0102 process.AlignmentProducer.saveToDB=True
0103 process.AlignmentProducer.saveApeToDB=True
0104 
0105 ###################################################################
0106 # Output name
0107 ###################################################################
0108 outputfilename = None
0109 scenariolabel = str(options.myScenario)
0110 if sigma > 0:
0111     scenariolabel = scenariolabel+str(sigma)
0112 outputfilename = "geometry_"+str(scenariolabel)+"__from_"
0113 if options.inputDB is None:
0114     outputfilename += process.GlobalTag.globaltag.value()+".db"
0115 else:
0116     outputfilename += options.inputDB
0117 
0118 ###################################################################
0119 # Source
0120 ###################################################################
0121 process.source = cms.Source("EmptySource")
0122 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
0123 
0124 ###################################################################
0125 # Database output service
0126 ###################################################################
0127 from CondCore.CondDB.CondDB_cfi import *
0128 process.PoolDBOutputService = cms.Service(
0129     "PoolDBOutputService",
0130     CondDB,
0131     timetype = cms.untracked.string("runnumber"),
0132     toPut = cms.VPSet(
0133         cms.PSet(
0134             record = cms.string("TrackerAlignmentRcd"),
0135             tag = cms.string("Alignments")
0136             ),
0137         cms.PSet(
0138             record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0139             tag = cms.string("AlignmentErrorsExtended")
0140             ),
0141         )
0142     )
0143 process.PoolDBOutputService.connect = "sqlite_file:"+outputfilename
0144 process.PoolDBOutputService.DBParameters.messageLevel = 2