Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-05-05 02:46:37

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                  "MisalignmentScenario10MuPixelPhase2", # 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.GeometryExtended2026D88Reco_cff')
0050 process.trackerGeometry.applyAlignment = True
0051 
0052 ###################################################################
0053 # Just state the Global Tag (and pick some run)
0054 ###################################################################
0055 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0056 from Configuration.AlCa.GlobalTag import GlobalTag
0057 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T21', '') # using realistic Phase 2 geom
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 #     print("EXTENDING THE GLOBAL TAG!!!!")
0087 #     process.GlobalTag.toGet.extend([
0088 #             cms.PSet(
0089 #                 connect = cms.string("sqlite_file:"+options.inputDB),
0090 #                 record = cms.string("TrackerAlignmentRcd"),
0091 #                 tag = cms.string("Alignments")
0092 #                 ),
0093 #             cms.PSet(
0094 #                 connect = cms.string("sqlite_file:"+options.inputDB),
0095 #                 record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0096 #                 tag = cms.string("AlignmentErrorsExtended")
0097 #                 )
0098 #             ])
0099 
0100 process.AlignmentProducer.saveToDB=True
0101 process.AlignmentProducer.saveApeToDB=True
0102 
0103 ###################################################################
0104 # Output name
0105 ###################################################################
0106 outputfilename = None
0107 scenariolabel = str(options.myScenario)
0108 if sigma > 0:
0109     scenariolabel = scenariolabel+str(sigma)
0110 outputfilename = "geometry_"+str(scenariolabel)+"__from_"
0111 if options.inputDB is None:
0112     outputfilename += process.GlobalTag.globaltag.value()+".db"
0113 else:
0114     outputfilename += options.inputDB
0115 
0116 ###################################################################
0117 # Source
0118 ###################################################################
0119 process.source = cms.Source("EmptySource")
0120 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
0121 
0122 ###################################################################
0123 # Database output service
0124 ###################################################################
0125 from CondCore.CondDB.CondDB_cfi import *
0126 process.PoolDBOutputService = cms.Service(
0127     "PoolDBOutputService",
0128     CondDB,
0129     timetype = cms.untracked.string("runnumber"),
0130     toPut = cms.VPSet(
0131         cms.PSet(
0132             record = cms.string("TrackerAlignmentRcd"),
0133             tag = cms.string("Alignments")
0134             ),
0135         cms.PSet(
0136             record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0137             tag = cms.string("AlignmentErrorsExtended")
0138             ),
0139         )
0140     )
0141 process.PoolDBOutputService.connect = "sqlite_file:"+outputfilename
0142 process.PoolDBOutputService.DBParameters.messageLevel = 2