Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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