Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:29

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