Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:23

0001 from __future__ import print_function
0002 ########################################################################################
0003 ###
0004 ###  Read and write APEs to and from database and ASCII files
0005 ###
0006 ###  The ASCII file contains one row per module, where the first column
0007 ###  lists the module id and the following 21 columns the diagonal and
0008 ###  lower elements x11,x21,x22,x31,x32,x33,0... of the 6x6 covariance
0009 ###  matrix, where the upper 3x3 sub-matrix contains the position APEs.
0010 ###  The elements are stored in units of cm^2.
0011 ###
0012 ########################################################################################
0013 
0014 
0015 
0016 ###### Steering parameters #############################################################
0017 
0018 ### specify the input APE
0019 #
0020 GT = "auto:phase1_2017_design"
0021 #
0022 # read the APE from database or from ASCII
0023 # True  : from database
0024 # False : from ASCII
0025 readAPEFromDB = False
0026 
0027 ### specify APE input from database (only relevant if 'readAPEFromDB=True')
0028 #
0029 # specify run (to get proper IOV in IOV dependent databases)
0030 # for data payload only, "1" for MC
0031 readDBRun = 1
0032 #
0033 # False : APE from GT,
0034 # True  : APE from es_prefer statement
0035 readDBOverwriteGT = False
0036 #
0037 # info for es_prefer to overwrite APE info in GT
0038 # (only relevant if 'readDBOverwriteGT=True')
0039 readDBConnect = "frontier://FrontierProd/CMS_CONDITIONS"
0040 readDBTag     = "TrackerAlignmentErrorsExtended_Upgrade2017_design_v0"
0041 
0042 ### specify APE input from ASCII (only relevant if 'readAPEFromDB=False')
0043 #
0044 # file name (relative to $CMSSW_BASE/src)
0045 readASCIIFile = "Alignment/APEEstimation/macros/ape.txt"
0046 #
0047 
0048 ### specify APE output to ASCII file
0049 #
0050 saveAPEtoASCII = True
0051 saveASCIIFile = "apeDump.txt"
0052 
0053 ### specify APE output to database file
0054 #
0055 saveAPEtoDB = True
0056 saveAPEFile = "APE_BPX-L1-Scenario_v0.db"
0057 saveAPETag  = "APEs"
0058 
0059 
0060 
0061 ###### Main script #####################################################################
0062 
0063 import FWCore.ParameterSet.Config as cms
0064 process = cms.Process("APEtoASCIIDump")
0065 
0066 # Load the conditions
0067 process.load('Configuration.Geometry.GeometryRecoDB_cff')
0068 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0069 from Configuration.AlCa.GlobalTag import GlobalTag
0070 process.GlobalTag = GlobalTag(process.GlobalTag,GT)
0071 print("Using Global Tag:", process.GlobalTag.globaltag._value)
0072 if readAPEFromDB and readDBOverwriteGT:
0073     print("Overwriting APE payload with "+readDBTag)
0074     process.GlobalTag.toGet.append(
0075         cms.PSet(
0076             record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0077             tag = cms.string(readDBTag)
0078             )
0079         )
0080 
0081 
0082 ### setup the alignmnet producer to read the APEs and dump them
0083 process.load("Alignment.CommonAlignmentProducer.AlignmentProducer_cff")
0084 from Alignment.CommonAlignmentAlgorithm.ApeSettingAlgorithm_cfi import ApeSettingAlgorithm
0085 #
0086 # general settings
0087 process.AlignmentProducer.algoConfig = ApeSettingAlgorithm.clone()
0088 process.AlignmentProducer.algoConfig.setComposites       = False
0089 process.AlignmentProducer.algoConfig.saveComposites      = False
0090 process.AlignmentProducer.algoConfig.readLocalNotGlobal  = False
0091 process.AlignmentProducer.algoConfig.readFullLocalMatrix = True
0092 process.AlignmentProducer.algoConfig.saveLocalNotGlobal  = False
0093 #
0094 # define how APEs are read: either from DB or from ASCII
0095 process.AlignmentProducer.applyDbAlignment            = readAPEFromDB
0096 process.AlignmentProducer.checkDbAlignmentValidity    = False # enable reading from tags with several IOVs
0097 process.AlignmentProducer.algoConfig.readApeFromASCII = not readAPEFromDB
0098 process.AlignmentProducer.algoConfig.apeASCIIReadFile = cms.FileInPath(readASCIIFile)
0099 #
0100 # define how APEs are written
0101 process.AlignmentProducer.saveApeToDB                 = saveAPEtoDB
0102 process.AlignmentProducer.algoConfig.saveApeToASCII   = saveAPEtoASCII
0103 process.AlignmentProducer.algoConfig.apeASCIISaveFile = saveASCIIFile
0104 
0105 
0106 ### specify the output database file
0107 from CondCore.CondDB.CondDB_cfi import CondDB
0108 process.PoolDBOutputService = cms.Service(
0109     "PoolDBOutputService",
0110     CondDB.clone(connect = cms.string("sqlite_file:"+saveAPEFile)),
0111     timetype = cms.untracked.string("runnumber"),
0112     toPut = cms.VPSet(
0113         cms.PSet(
0114             record = cms.string("TrackerAlignmentErrorExtendedRcd"),
0115             tag = cms.string(saveAPETag)
0116             ),
0117         )
0118     )
0119 
0120      
0121 process.MessageLogger = cms.Service("MessageLogger",
0122     cerr = cms.untracked.PSet(
0123         enable = cms.untracked.bool(False)
0124     ),
0125     cout = cms.untracked.PSet(
0126         enable = cms.untracked.bool(True),
0127         enableStatistics = cms.untracked.bool(True),
0128         noLineBreaks = cms.untracked.bool(True),
0129         threshold = cms.untracked.string('DEBUG')
0130     ),
0131     files = cms.untracked.PSet(
0132         alignment = cms.untracked.PSet(
0133             Alignment = cms.untracked.PSet(
0134                 limit = cms.untracked.int32(-1)
0135             ),
0136             DEBUG = cms.untracked.PSet(
0137                 limit = cms.untracked.int32(-1)
0138             ),
0139             ERROR = cms.untracked.PSet(
0140                 limit = cms.untracked.int32(-1)
0141             ),
0142             INFO = cms.untracked.PSet(
0143                 limit = cms.untracked.int32(-1)
0144             ),
0145             WARNING = cms.untracked.PSet(
0146                 limit = cms.untracked.int32(-1)
0147             ),
0148             enableStatistics = cms.untracked.bool(True),
0149             noLineBreaks = cms.untracked.bool(True),
0150             threshold = cms.untracked.string('INFO')
0151         )
0152     )
0153 )
0154 
0155 
0156 ### speficy the source
0157 # 
0158 # process an empty source
0159 process.source = cms.Source(
0160     "EmptySource",
0161     firstRun = cms.untracked.uint32(readDBRun)
0162     )
0163 #
0164 # need to run over 1 event
0165 # NB: will print an "MSG-e" saying no events to process. This can be ignored.
0166 process.maxEvents = cms.untracked.PSet(
0167     input = cms.untracked.int32(1)
0168     )
0169 
0170 # We do not even need a path - producer is called anyway...