Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-24 22:51:42

0001 # documentation: https://twiki.cern.ch/twiki/bin/view/CMS/AlCaDBPCL#Drop_box_metadata_management
0002 
0003 import FWCore.ParameterSet.Config as cms
0004 
0005 process = cms.Process("myprocess")
0006 
0007 process.load("CondCore.CondDB.CondDB_cfi")
0008 process.load("FWCore.MessageService.MessageLogger_cfi")
0009 
0010 process.CondDB.connect = 'sqlite_file:DropBoxMetadata.db' 
0011 
0012 process.maxEvents = cms.untracked.PSet(
0013     input = cms.untracked.int32(1)
0014 )
0015 process.source = cms.Source("EmptySource",
0016                             firstRun = cms.untracked.uint32(300000)
0017                             )
0018 
0019 # process.PoolDBOutputService.DBParameters.messageLevel = 3
0020 import json
0021 
0022 def encodeJsonInString(filename):
0023     """This function open the json file and encodes it in a string replacing probelamtic characters"""
0024     thefile = open("../data/"+filename)
0025     thejson = json.load(thefile)
0026     thefile.close()
0027     return json.JSONEncoder().encode(thejson).replace('"',""")
0028 
0029 # beamspot by run
0030 BeamSpotObjectsRcdByRun_prod_str = encodeJsonInString("BeamSpotObjectsRcdByRun_prod.json")
0031 BeamSpotObjectsRcdByRun_prep_str = encodeJsonInString("BeamSpotObjectsRcdByRun_prep.json")
0032 
0033 # beamspot by lumi
0034 BeamSpotObjectsRcdByLumi_prod_str = encodeJsonInString("BeamSpotObjectsRcdByLumi_prod.json")
0035 BeamSpotObjectsRcdByLumi_prep_str = encodeJsonInString("BeamSpotObjectsRcdByLumi_prep.json")
0036 
0037 # beamspot High Perf by lumi
0038 BeamSpotObjectsRcdHPByLumi_prod_str = encodeJsonInString("BeamSpotObjectsRcdHPbyLumi_prod.json")
0039 BeamSpotObjectsRcdHPByLumi_prep_str = encodeJsonInString("BeamSpotObjectsRcdHPbyLumi_prep.json")
0040 
0041 # beamspot High Perf by run
0042 BeamSpotObjectsRcdHPByRun_prod_str = encodeJsonInString("BeamSpotObjectsRcdHPbyRun_prod.json")
0043 BeamSpotObjectsRcdHPByRun_prep_str = encodeJsonInString("BeamSpotObjectsRcdHPbyRun_prep.json")
0044 
0045 #SiStripBadStripRcd
0046 SiStripBadStripRcd_prod_str = encodeJsonInString("SiStripBadStripRcd_prod.json")
0047 SiStripBadStripRcd_prep_str = encodeJsonInString("SiStripBadStripRcd_prep.json")
0048 
0049 #SiStripBadStripRcd from Hit Efficiency
0050 SiStripBadStripRcdHitEff_prod_str = encodeJsonInString("SiStripBadStripFromHitEffRcd_prod.json")
0051 SiStripBadStripRcdHitEff_prep_str = encodeJsonInString("SiStripBadStripFromHitEffRcd_prep.json")
0052 
0053 #SiStripApvGainRcd
0054 SiStripApvGainRcd_prod_str = encodeJsonInString("SiStripApvGainRcd_prod.json")
0055 SiStripApvGainRcd_multirun_prod_str = encodeJsonInString("SiStripApvGainRcd_multirun_prod.json") 
0056 SiStripApvGainRcdAfterAbortGap_prod_str = encodeJsonInString("SiStripApvGainRcdAfterAbortGap_prod.json") # can be removed, once 92x deployed
0057 SiStripApvGainRcdAAG_prod_str = encodeJsonInString("SiStripApvGainRcdAAG_prod.json") # will take over
0058 SiStripApvGainRcdAAG_multirun_prod_str = encodeJsonInString("SiStripApvGainRcdAAG_multirun_prod.json")
0059 
0060 SiStripApvGainRcd_prep_str = encodeJsonInString("SiStripApvGainRcd_prep.json")
0061 SiStripApvGainRcd_multirun_prep_str = encodeJsonInString("SiStripApvGainRcd_multirun_prep.json")
0062 SiStripApvGainRcdAfterAbortGap_prep_str = encodeJsonInString("SiStripApvGainRcdAfterAbortGap_prep.json") # can be removed, once 92x deployed
0063 SiStripApvGainRcdAAG_prep_str = encodeJsonInString("SiStripApvGainRcdAAG_prep.json") # will take over
0064 SiStripApvGainRcdAAG_multirun_prep_str = encodeJsonInString("SiStripApvGainRcdAAG_multirun_prep.json")
0065 
0066 #SiPixelAli
0067 SiPixelAliRcd_prod_str = encodeJsonInString("SiPixelAliRcd_prod.json")
0068 SiPixelAliRcd_prep_str = encodeJsonInString("SiPixelAliRcd_prep.json")
0069 
0070 #SiPixelAliHG
0071 SiPixelAliHGRcd_prod_str = encodeJsonInString("SiPixelAliHGRcd_prod.json")
0072 SiPixelAliHGRcd_prep_str = encodeJsonInString("SiPixelAliHGRcd_prep.json")
0073 
0074 #EcalPedestalsRcd
0075 EcalPedestalsRcd_prod_str = encodeJsonInString("EcalPedestal_prod.json")
0076 EcalPedestalsRcd_prep_str = encodeJsonInString("EcalPedestal_prep.json")
0077 
0078 #LumiCorrectionsRcd
0079 LumiCorrectionsRcd_prod_str = encodeJsonInString("LumiCorrections_prod.json")
0080 LumiCorrectionsRcd_prep_str = encodeJsonInString("LumiCorrections_prep.json")
0081 
0082 #SiPixelQuality
0083 SiPixelQualityFromDbRcd_prompt_prod_str = encodeJsonInString("SiPixelQualityFromDbRcd_prompt_prod.json")
0084 SiPixelQualityFromDbRcd_prompt_prep_str = encodeJsonInString("SiPixelQualityFromDbRcd_prompt_prep.json")
0085 SiPixelQualityFromDbRcd_stuckTBM_prod_str = encodeJsonInString("SiPixelQualityFromDbRcd_stuckTBM_prod.json")
0086 SiPixelQualityFromDbRcd_stuckTBM_prep_str = encodeJsonInString("SiPixelQualityFromDbRcd_stuckTBM_prep.json")
0087 SiPixelQualityFromDbRcd_other_prod_str = encodeJsonInString("SiPixelQualityFromDbRcd_other_prod.json")
0088 SiPixelQualityFromDbRcd_other_prep_str = encodeJsonInString("SiPixelQualityFromDbRcd_other_prep.json")
0089 
0090 #SiPixelLorenzAngle
0091 SiPixelLorentzAngleRcd_prod_str =  encodeJsonInString("SiPixelLorentzAngleRcd_prod.json")
0092 SiPixelLorentzAngleRcd_multirun_prod_str =  encodeJsonInString("SiPixelLorentzAngleRcd_multirun_prod.json")
0093 SiPixelLorentzAngleRcd_prep_str = encodeJsonInString("SiPixelLorentzAngleRcd_prep.json")
0094 SiPixelLorentzAngleRcd_multirun_prep_str = encodeJsonInString("SiPixelLorentzAngleRcd_multirun_prep.json")
0095 
0096 #CT-PPS alignment and timing
0097 CTPPSRPAlignmentCorrectionsDataRcd_prod_str =  encodeJsonInString("CTPPSRPAlignmentCorrectionsDataRcd_prod.json")
0098 CTPPSRPAlignmentCorrectionsDataRcd_prep_str = encodeJsonInString("CTPPSRPAlignmentCorrectionsDataRcd_prep.json")
0099 PPSTimingCalibrationRcd_prod_str = encodeJsonInString("PPSTimingCalibrationRcd_prod.json")
0100 PPSTimingCalibrationRcd_prep_str = encodeJsonInString("PPSTimingCalibrationRcd_prep.json")
0101 PPSTimingCalibrationRcd_Sampic_prod_str = encodeJsonInString("PPSTimingCalibrationRcd_Sampic_prod.json")
0102 PPSTimingCalibrationRcd_Sampic_prep_str = encodeJsonInString("PPSTimingCalibrationRcd_Sampic_prep.json")
0103 
0104 
0105 # given a set of .json files in the current dir, ProduceDropBoxMetadata produces a sqlite containign the payload with the prod/and/prep metadata
0106 process.mywriter = cms.EDAnalyzer("ProduceDropBoxMetadata",
0107                                   # set to True if you want to write out a sqlite.db translating the json's into a payload
0108                                   write = cms.untracked.bool(True),
0109 
0110                                   # toWrite holds a list of Pset's, one for each workflow you want to produce DropBoxMetadata for;
0111                                   # you need to have 2 .json files for each PSet
0112                                   toWrite = cms.VPSet(cms.PSet(record              = cms.untracked.string("BeamSpotObjectsRcdByRun"), 
0113                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0114                                                                FileClass           = cms.untracked.string("ALCA"),
0115                                                                prodMetaData        = cms.untracked.string(BeamSpotObjectsRcdByRun_prod_str),
0116                                                                prepMetaData        = cms.untracked.string(BeamSpotObjectsRcdByRun_prep_str),
0117                                                                ),
0118                                                       cms.PSet(record              = cms.untracked.string('BeamSpotObjectsRcdByLumi'),
0119                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0120                                                                FileClass           = cms.untracked.string("ALCA"),
0121                                                                prodMetaData        = cms.untracked.string(BeamSpotObjectsRcdByLumi_prod_str),
0122                                                                prepMetaData        = cms.untracked.string(BeamSpotObjectsRcdByLumi_prep_str),
0123                                                                ),
0124                                                       cms.PSet(record              = cms.untracked.string('BeamSpotObjectsRcdHPByLumi'),
0125                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0126                                                                FileClass           = cms.untracked.string("ALCA"),
0127                                                                prodMetaData        = cms.untracked.string(BeamSpotObjectsRcdHPByLumi_prod_str),
0128                                                                prepMetaData        = cms.untracked.string(BeamSpotObjectsRcdHPByLumi_prep_str),
0129                                                                ),
0130                                                       cms.PSet(record              = cms.untracked.string('BeamSpotObjectsRcdHPByRun'),
0131                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0132                                                                FileClass           = cms.untracked.string("ALCA"),
0133                                                                prodMetaData        = cms.untracked.string(BeamSpotObjectsRcdHPByRun_prod_str),
0134                                                                prepMetaData        = cms.untracked.string(BeamSpotObjectsRcdHPByRun_prep_str),
0135                                                                ),
0136                                                       cms.PSet(record              = cms.untracked.string('SiStripBadStripRcd'),
0137                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0138                                                                FileClass           = cms.untracked.string("ALCA"),
0139                                                                prodMetaData        = cms.untracked.string(SiStripBadStripRcd_prod_str),
0140                                                                prepMetaData        = cms.untracked.string(SiStripBadStripRcd_prep_str),
0141                                                                ),
0142                                                       cms.PSet(record              = cms.untracked.string('SiStripBadStripFromHitEffRcd'),
0143                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0144                                                                FileClass           = cms.untracked.string("ALCA"),
0145                                                                prodMetaData        = cms.untracked.string(SiStripBadStripRcdHitEff_prod_str),
0146                                                                prepMetaData        = cms.untracked.string(SiStripBadStripRcdHitEff_prep_str),
0147                                                                ),
0148                                                       cms.PSet(record              = cms.untracked.string('SiStripApvGainRcd'),
0149                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0150                                                                FileClass           = cms.untracked.string("ALCA"),
0151                                                                prodMetaData        = cms.untracked.string(SiStripApvGainRcd_prod_str),
0152                                                                prodMetaDataMultiRun = cms.untracked.string(SiStripApvGainRcd_multirun_prod_str),
0153                                                                prepMetaData        = cms.untracked.string(SiStripApvGainRcd_prep_str),
0154                                                                prepMetaDataMultiRun = cms.untracked.string(SiStripApvGainRcd_multirun_prep_str),
0155                                                                ),
0156                                                       cms.PSet(record              = cms.untracked.string('TrackerAlignmentRcd'),
0157                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0158                                                                FileClass           = cms.untracked.string("ALCA"),
0159                                                                prodMetaData        = cms.untracked.string(SiPixelAliRcd_prod_str),
0160                                                                prepMetaData        = cms.untracked.string(SiPixelAliRcd_prep_str),
0161                                                                ),
0162                                                       cms.PSet(record              = cms.untracked.string('TrackerAlignmentHGRcd'),
0163                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0164                                                                FileClass           = cms.untracked.string("ALCA"),
0165                                                                prodMetaData        = cms.untracked.string(SiPixelAliHGRcd_prod_str),
0166                                                                prepMetaData        = cms.untracked.string(SiPixelAliHGRcd_prep_str),
0167                                                                ),
0168                                                       cms.PSet(record              = cms.untracked.string('SiStripApvGainRcdAfterAbortGap'), # can be removed, once 92x deployed...
0169                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0170                                                                FileClass           = cms.untracked.string("ALCA"),
0171                                                                prodMetaData        = cms.untracked.string(SiStripApvGainRcdAfterAbortGap_prod_str),
0172                                                                prepMetaData        = cms.untracked.string(SiStripApvGainRcdAfterAbortGap_prep_str),
0173                                                                ),
0174                                                       cms.PSet(record              = cms.untracked.string('SiStripApvGainRcdAAG'), # ... will take over
0175                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0176                                                                FileClass           = cms.untracked.string("ALCA"),
0177                                                                prodMetaData        = cms.untracked.string(SiStripApvGainRcdAAG_prod_str),
0178                                                                prodMetaDataMultiRun = cms.untracked.string(SiStripApvGainRcdAAG_multirun_prod_str),
0179                                                                prepMetaData        = cms.untracked.string(SiStripApvGainRcdAAG_prep_str),
0180                                                                prepMetaDataMultiRun = cms.untracked.string(SiStripApvGainRcdAAG_multirun_prep_str)
0181                                                                ),
0182                                                       cms.PSet(record              = cms.untracked.string('EcalPedestalsRcd'),
0183                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0184                                                                FileClass           = cms.untracked.string("ALCA"),
0185                                                                prodMetaData        = cms.untracked.string(EcalPedestalsRcd_prod_str),
0186                                                                prepMetaData        = cms.untracked.string(EcalPedestalsRcd_prep_str),
0187                                                                ),
0188                                                       cms.PSet(record              = cms.untracked.string('LumiCorrectionsRcd'),
0189                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0190                                                                FileClass           = cms.untracked.string("ALCA"),
0191                                                                prodMetaData        = cms.untracked.string(LumiCorrectionsRcd_prod_str),
0192                                                                prepMetaData        = cms.untracked.string(LumiCorrectionsRcd_prep_str),
0193                                                                ),
0194                                                       cms.PSet(record              = cms.untracked.string('SiPixelQualityFromDbRcd_prompt'),
0195                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0196                                                                FileClass           = cms.untracked.string("ALCA"),
0197                                                                prodMetaData        = cms.untracked.string(SiPixelQualityFromDbRcd_prompt_prod_str),
0198                                                                prepMetaData        = cms.untracked.string(SiPixelQualityFromDbRcd_prompt_prep_str),
0199                                                                ),
0200                                                       cms.PSet(record              = cms.untracked.string('SiPixelQualityFromDbRcd_stuckTBM'),
0201                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0202                                                                FileClass           = cms.untracked.string("ALCA"),
0203                                                                prodMetaData        = cms.untracked.string(SiPixelQualityFromDbRcd_stuckTBM_prod_str),
0204                                                                prepMetaData        = cms.untracked.string(SiPixelQualityFromDbRcd_stuckTBM_prep_str),
0205                                                                ),
0206                                                       cms.PSet(record              = cms.untracked.string('SiPixelQualityFromDbRcd_other'),
0207                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0208                                                                FileClass           = cms.untracked.string("ALCA"),
0209                                                                prodMetaData        = cms.untracked.string(SiPixelQualityFromDbRcd_other_prod_str),
0210                                                                prepMetaData        = cms.untracked.string(SiPixelQualityFromDbRcd_other_prep_str),
0211                                                                ),
0212                                                       cms.PSet(record              = cms.untracked.string('SiPixelLorentzAngleRcd'),
0213                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0214                                                                FileClass           = cms.untracked.string("ALCA"),
0215                                                                prodMetaData        = cms.untracked.string(SiPixelLorentzAngleRcd_prod_str),
0216                                                                prodMetaDataMultiRun = cms.untracked.string(SiPixelLorentzAngleRcd_multirun_prod_str),
0217                                                                prepMetaData        = cms.untracked.string(SiPixelLorentzAngleRcd_prep_str),
0218                                                                prepMetaDataMultiRun = cms.untracked.string(SiPixelLorentzAngleRcd_multirun_prep_str),
0219                                                                ),
0220                                                       cms.PSet(record              = cms.untracked.string('CTPPSRPAlignmentCorrectionsDataRcd'),
0221                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0222                                                                FileClass           = cms.untracked.string("ALCA"),
0223                                                                prodMetaData        = cms.untracked.string(CTPPSRPAlignmentCorrectionsDataRcd_prod_str),
0224                                                                prepMetaData        = cms.untracked.string(CTPPSRPAlignmentCorrectionsDataRcd_prep_str),
0225                                                                ),
0226                                                       cms.PSet(record              = cms.untracked.string('PPSTimingCalibrationRcd'),
0227                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0228                                                                FileClass           = cms.untracked.string("ALCA"),
0229                                                                prodMetaData        = cms.untracked.string(PPSTimingCalibrationRcd_prod_str),
0230                                                                prepMetaData        = cms.untracked.string(PPSTimingCalibrationRcd_prep_str),
0231                                                                ),
0232                                                       cms.PSet(record              = cms.untracked.string('PPSTimingCalibrationRcd_Sampic'),
0233                                                                Source              = cms.untracked.string("AlcaHarvesting"),
0234                                                                FileClass           = cms.untracked.string("ALCA"),
0235                                                                prodMetaData        = cms.untracked.string(PPSTimingCalibrationRcd_Sampic_prod_str),
0236                                                                prepMetaData        = cms.untracked.string(PPSTimingCalibrationRcd_Sampic_prep_str),
0237                                                                ),
0238                                                       ),
0239                                   # this boolean will read the content of whichever payload is available and print its content to stoutput
0240                                   # set this to false if you write out a sqlite.db translating the json's into a payload
0241                                   read = cms.untracked.bool(False),
0242                                   toRead = cms.untracked.vstring() 
0243                                   )
0244 
0245 process.p = cms.Path(process.mywriter)
0246 
0247 if process.mywriter.write:
0248 
0249     from CondCore.CondDB.CondDB_cfi import CondDB
0250     CondDB.connect = "sqlite_file:DropBoxMetadata.db"
0251 
0252     process.PoolDBOutputService = cms.Service("PoolDBOutputService",
0253                                               CondDB,
0254                                               toPut = cms.VPSet(cms.PSet(record = cms.string('DropBoxMetadataRcd'),
0255                                                                          tag = cms.string('DropBoxMetadata'),
0256                                                                          timetype   = cms.untracked.string('runnumber')
0257                                                                          )
0258                                                                 ),
0259                                               loadBlobStreamer = cms.untracked.bool(False),
0260                                               #    timetype   = cms.untracked.string('lumiid')
0261                                               #    timetype   = cms.untracked.string('runnumber')
0262                                               )
0263     
0264 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0265 process.GlobalTag.globaltag = '124X_dataRun3_Express_Queue'