From 7a2d2ab3e54f6c1163b640d0ffc3853b98bc0a91 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 17 Aug 2022 13:09:48 +0200 Subject: [PATCH] fix run-by-run PV Validation submission script in case of extra conditions --- .../scripts/submitPVValidationJobs.py | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/Alignment/OfflineValidation/scripts/submitPVValidationJobs.py b/Alignment/OfflineValidation/scripts/submitPVValidationJobs.py index 6a567211d2884..62538355662fd 100755 --- a/Alignment/OfflineValidation/scripts/submitPVValidationJobs.py +++ b/Alignment/OfflineValidation/scripts/submitPVValidationJobs.py @@ -444,12 +444,10 @@ def createTheCfgFile(self,lfn): fout=open(os.path.join(self.cfg_dir,self.outputCfgName),'w') template_cfg_file = os.path.join(self.the_dir,"PVValidation_T_cfg.py") - - fin = open(template_cfg_file) + file = open(template_cfg_file,'r') config_txt = '\n\n' + CopyRights + '\n\n' - config_txt += fin.read() - + config_txt += file.read() config_txt=config_txt.replace("ISDATEMPLATE",self.isDA) config_txt=config_txt.replace("ISMCTEMPLATE",self.isMC) config_txt=config_txt.replace("APPLYBOWSTEMPLATE",self.applyBOWS) @@ -477,27 +475,36 @@ def createTheCfgFile(self,lfn): config_txt=config_txt.replace("FILESOURCETEMPLATE","["+",".join(lfn_with_quotes)+"]") config_txt=config_txt.replace("OUTFILETEMPLATE",self.output_full_name+".root") + ### now for the extra conditions + textToWrite='' + for element in self.extraCondVect : + if("Rcd" in element): + params = self.extraCondVect[element].split(',') + text = '''\n + process.conditionsIn{record} = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone( + connect = cms.string('{database}'), + toGet = cms.VPSet(cms.PSet(record = cms.string('{record}'), + tag = cms.string('{tag}'), + label = cms.untracked.string('{label}') + ) + ) + ) + process.prefer_conditionsIn{record} = cms.ESPrefer("PoolDBESSource", "conditionsIn{record}") + '''.format(record = element, database = params[0], tag = params[1], label = (params[2] if len(params)>2 else '')) + textToWrite+=text + + if(self.applyEXTRACOND=="True"): + if not self.extraCondVect: + raise Exception('Requested extra conditions, but none provided') + + config_txt=config_txt.replace("END OF EXTRA CONDITIONS",textToWrite) + else: + print("INFO: Will not apply any extra conditions") + pass + fout.write(config_txt) - for line in fin.readlines(): - - if 'END OF EXTRA CONDITIONS' in line: - for element in self.extraCondVect : - if("Rcd" in element): - params = self.extraCondVect[element].split(',') - - fout.write(" \n") - fout.write(" process.conditionsIn"+element+"= CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone( \n") - fout.write(" connect = cms.string('"+params[0]+"'), \n") - fout.write(" toGet = cms.VPSet(cms.PSet(record = cms.string('"+element+"'), \n") - fout.write(" tag = cms.string('"+params[1]+"'), \n") - if (len(params)>2): - fout.write(" label = cms.untracked.string('"+params[2]+"') \n") - fout.write(" ) \n") - fout.write(" ) \n") - fout.write(" ) \n") - fout.write(" process.prefer_conditionsIn"+element+" = cms.ESPrefer(\"PoolDBESSource\", \"conditionsIn"+element[0]+"\") \n \n") - fout.write(line) + file.close() fout.close() def createTheLSFFile(self):