18 A very complicate script to upload the results into the DB 20 usage: %prog -d <data file/directory> -t <tag name> 21 -c, --cfg = CFGFILE : Use a different configuration file than the default 22 -l, --lock = LOCK : Create a lock file to have just one script running 23 -o, --overwrite : Overwrite results files when copying. 24 -T, --Test : Upload files to Test dropbox for data validation. 25 -u, --upload : Upload files to offline drop box via scp. 26 -z, --zlarge : Enlarge sigmaZ to 10 +/- 0.005 cm. 28 Francisco Yumiceva (yumiceva@fnal.gov) 29 Lorenzo Uplegger (send an email to Francisco) 33 from __future__
import print_function
37 import commands, re, time
41 from BeamSpotObj
import BeamSpot
42 from IOVObj
import IOV
43 from CommonMethods
import *
49 import simplejson
as json
51 error =
"Please set a crab environment in order to get the proper JSON lib" 59 listIOVCommand =
"cmscond_list_iov -c " + destDB +
" -P /afs/cern.ch/cms/DB/conddb -t " + tagName
60 dbError = commands.getstatusoutput( listIOVCommand )
62 if dbError[1].
find(
"metadata entry \"" + tagName +
"\" does not exist") != -1:
63 print(
"Creating a new tag because I got the following error contacting the DB")
68 exit(
"ERROR: Can\'t connect to db because:\n" + dbError[1])
71 aCommand = listIOVCommand +
" | grep DB= | tail -1 | awk \'{print $1}\'" 72 output = commands.getstatusoutput( aCommand )
76 exit(
"ERROR: The tag " + tagName +
" exists but I can't get the value of the last IOV")
78 return long(output[1])
82 queryCommand =
"dbs --search --query \"find file where dataset=" + dataSet
84 queryCommand = queryCommand +
" and run > " +
str(lastRun)
85 queryCommand = queryCommand +
"\" | grep .root" 87 output = commands.getstatusoutput( queryCommand )
88 return output[1].
split(
'\n')
92 queryCommand =
"dbs --search --query \"find file where dataset=" + dataSet +
" and run = " +
str(run) +
"\" | grep .root" 94 output = commands.getstatusoutput( queryCommand )
98 return len(output[1].
split(
'\n'))
102 datasetList = dataSet.split(
',')
104 for data
in datasetList:
105 queryCommand =
"dbs --search --query \"find run,lumi where dataset=" + data
107 queryCommand = queryCommand +
" and run > " +
str(lastRun)
109 print(
" >> " + queryCommand)
112 output = commands.getstatusoutput( queryCommand )
113 if output[0] == 0
and not (output[1].
find(
"ERROR") != -1
or output[1].
find(
"Error") != -1) :
116 exit(
"ERROR: I can't contact DBS for the following reason:\n" + output[1])
118 tmpList = output[1].
split(
'\n')
120 outputList.append(file)
122 for out
in outputList:
123 regExp = re.search(
'(\d+)\s+(\d+)',out)
125 run = long(regExp.group(1))
126 lumi = long(regExp.group(2))
127 if not run
in runsAndLumis:
128 runsAndLumis[run] = []
129 runsAndLumis[run].
append(lumi)
137 file = open(fileName);
138 jsonFile = file.read();
140 jsonList=json.loads(jsonFile);
143 for element
in jsonList:
144 selected_dcs[long(element)]=jsonList[element]
149 RunReg =
"http://pccmsdqm04.cern.ch/runregistry" 152 Group =
"Collisions10" 155 FULLADDRESS=RunReg +
"/xmlrpc" 157 server = xmlrpclib.ServerProxy(FULLADDRESS)
159 sel_runtable=
"{groupName} ='" + Group +
"' and {runNumber} > " +
str(firstRun)
164 while tries<maxAttempts:
166 run_data = server.DataExporter.export(
'RUN' ,
'GLOBAL',
'csv_runs', sel_runtable)
170 print(
"Something wrong in accessing runregistry, retrying in 2s....", tries,
"/", maxAttempts)
173 if tries==maxAttempts:
174 error =
"Run registry unaccessible.....exiting now" 179 for line
in run_data.split(
"\n"):
180 run=line.split(
',')[0]
182 listOfRuns.append(run)
185 firstRun = listOfRuns[len(listOfRuns)-1];
186 lastRun = listOfRuns[0];
187 sel_dcstable=
"{groupName} ='" + Group +
"' and {runNumber} >= " +
str(firstRun) +
" and {runNumber} <= " +
str(lastRun) +
" and {parDcsBpix} = 1 and {parDcsFpix} = 1 and {parDcsTibtid} = 1 and {parDcsTecM} = 1 and {parDcsTecP} = 1 and {parDcsTob} = 1 and {parDcsEbminus} = 1 and {parDcsEbplus} = 1 and {parDcsEeMinus} = 1 and {parDcsEePlus} = 1 and {parDcsEsMinus} = 1 and {parDcsEsPlus} = 1 and {parDcsHbheA} = 1 and {parDcsHbheB} = 1 and {parDcsHbheC} = 1 and {parDcsH0} = 1 and {parDcsHf} = 1" 190 while tries<maxAttempts:
193 dcs_data = server.DataExporter.export(
'RUNLUMISECTION',
'GLOBAL',
'json' , sel_dcstable)
196 print(
"I was able to get the list of runs and now I am trying to access the detector status, retrying in 2s....", tries,
"/", maxAttempts)
199 if tries==maxAttempts:
200 error =
"Run registry unaccessible.....exiting now" 204 jsonList=json.loads(dcs_data)
207 for element
in listOfRuns:
209 if element
in jsonList:
210 selected_dcs[long(element)]=jsonList[element]
212 print(
"WARNING: Run " + element +
" is a collision10 run with 0 lumis in Run Registry!")
213 selected_dcs[long(element)]= [[]]
220 for file
in DBSListOfFiles:
222 if runs.count(runNumber) == 0:
223 runs.append(runNumber)
229 return long(runs[len(runs)-2])
234 regExp = re.search(
'(\D+)_(\d+)_(\d+)_',fileName)
237 return long(regExp.group(3))
241 regExp = re.search(
'(\D+)/(\d+)/(\d+)/(\d+)/(\D+)',fileName)
244 return long(regExp.group(3)+regExp.group(4))
249 listOfFiles =
ls(fromDir,
".txt")
251 for fileName
in listOfFiles:
253 if runNumber > lastUploadedIOV:
254 newRunList.append(fileName)
258 def selectFilesToProcess(listOfRunsAndLumiFromDBS,listOfRunsAndLumiFromRR,newRunList,runListDir,dataSet,mailList,dbsTolerance,dbsTolerancePercent,rrTolerance,missingFilesTolerance,missingLumisTimeout):
259 runsAndLumisProcessed = {}
261 for fileName
in newRunList:
262 file = open(runListDir+fileName)
264 if line.find(
"Runnumber") != -1:
265 run = long(line.replace(
'\n',
'').
split(
' ')[1])
266 elif line.find(
"LumiRange") != -1:
267 lumiLine = line.replace(
'\n',
'').
split(
' ')
268 begLumi = long(lumiLine[1])
269 endLumi = long(lumiLine[3])
270 if begLumi != endLumi:
271 error =
"The lumi range is greater than 1 for run " +
str(run) +
" " + line +
" in file: " + runListDir + fileName
274 if not run
in runsAndLumisProcessed:
275 runsAndLumisProcessed[run] = []
276 if begLumi
in runsAndLumisProcessed[run]:
277 print(
"Lumi " +
str(begLumi) +
" in event " +
str(run) +
" already exist. This MUST not happen but right now I will ignore this lumi!")
279 runsAndLumisProcessed[run].
append(begLumi)
280 if not run
in runsAndFiles:
281 runsAndFiles[run] = []
282 runsAndFiles[run].
append(fileName)
285 rrKeys = sorted(listOfRunsAndLumiFromRR.keys())
286 dbsKeys = listOfRunsAndLumiFromDBS.keys()
289 lastUnclosedRun = dbsKeys.pop()
291 procKeys = runsAndLumisProcessed.keys()
303 for lumiRange
in listOfRunsAndLumiFromRR[run]:
305 for l
in range(lumiRange[0],lumiRange[1]+1):
306 RRList.append(long(l))
307 if run
in procKeys
and run < lastUnclosedRun:
309 if not run
in dbsKeys
and run != lastUnclosedRun:
310 error =
"Impossible but run " +
str(run) +
" has been processed and it is also in the run registry but it is not in DBS!" 314 for data
in dataSet.split(
','):
318 if len(runsAndFiles[run]) < nFiles:
319 print(
"I haven't processed all files yet : " +
str(len(runsAndFiles[run])) +
" out of " +
str(nFiles) +
" for run: " +
str(run))
320 if nFiles - len(runsAndFiles[run]) <= missingFilesTolerance:
324 print(
"WARNING: I previously set a timeout that expired...I'll continue with the script even if I didn't process all the lumis!")
326 if timeoutType == -1:
327 print(
"WARNING: Setting the DBS_MISMATCH_Run" +
str(run) +
" timeout because I haven't processed all files!")
329 print(
"WARNING: Timeout DBS_MISMATCH_Run" +
str(run) +
" is in progress.")
330 return filesToProcess
332 timeoutType =
timeoutManager(
"DBS_VERY_BIG_MISMATCH_Run"+
str(run),missingLumisTimeout)
334 error =
"ERROR: I previously set a timeout that expired...I can't continue with the script because there are too many (" +
str(nFiles - len(runsAndFiles[run])) +
" files missing) and for too long " +
str(missingLumisTimeout/3600) +
" hours! I will process anyway the runs before this one (" +
str(run) +
")" 336 return filesToProcess
339 if timeoutType == -1:
340 print(
"WARNING: Setting the DBS_VERY_BIG_MISMATCH_Run" +
str(run) +
" timeout because I haven't processed all files!")
342 print(
"WARNING: Timeout DBS_VERY_BIG_MISMATCH_Run" +
str(run) +
" is in progress.")
343 return filesToProcess
348 print(
"I have processed " +
str(len(runsAndFiles[run])) +
" out of " +
str(nFiles) +
" files that are in DBS. So I should have all the lumis!")
356 badDBSProcessed,badDBS =
compareLumiLists(runsAndLumisProcessed[run],listOfRunsAndLumiFromDBS[run],errors)
357 for i
in range(0,len(errors)):
358 errors[i] = errors[i].
replace(
"listA",
"the processed lumis")
359 errors[i] = errors[i].
replace(
"listB",
"DBS")
365 print(
"This is weird because I processed more lumis than the ones that are in DBS!")
366 if len(badDBSProcessed) != 0
and run
in rrKeys:
367 lastError = len(errors)
370 badRRProcessed,badRR =
compareLumiLists(runsAndLumisProcessed[run],RRList,errors)
371 for i
in range(0,len(errors)):
372 errors[i] = errors[i].
replace(
"listA",
"the processed lumis")
373 errors[i] = errors[i].
replace(
"listB",
"Run Registry")
378 if len(badRRProcessed) != 0:
379 print(
"I have not processed some of the lumis that are in the run registry for run: " +
str(run))
380 for lumi
in badDBSProcessed:
381 if lumi
in badRRProcessed:
382 badProcessed.append(lumi)
383 lenA = len(badProcessed)
385 if 100.*lenA/lenB <= dbsTolerancePercent:
386 print(
"WARNING: I didn't process " +
str(100.*lenA/lenB) +
"% of the lumis but I am within the " +
str(dbsTolerancePercent) +
"% set in the configuration. Which corrispond to " +
str(lenA) +
" out of " +
str(lenB) +
" lumis")
389 elif lenA <= dbsTolerance:
390 print(
"WARNING: I didn't process " +
str(lenA) +
" lumis but I am within the " +
str(dbsTolerance) +
" lumis set in the configuration. Which corrispond to " +
str(lenA) +
" out of " +
str(lenB) +
" lumis")
394 error =
"ERROR: For run " +
str(run) +
" I didn't process " +
str(100.*lenA/lenB) +
"% of the lumis and I am not within the " +
str(dbsTolerancePercent) +
"% set in the configuration. The number of lumis that I didn't process (" +
str(lenA) +
" out of " +
str(lenB) +
") is greater also than the " +
str(dbsTolerance) +
" lumis that I can tolerate. I can't process runs >= " +
str(run) +
" but I'll process the runs before!" 397 return filesToProcess
400 elif len(errors) != 0:
401 print(
"The number of lumi sections processed didn't match the one in DBS but they cover all the ones in the Run Registry, so it is ok!")
405 if len(badProcessed) == 0:
406 for file
in runsAndFiles[run]:
407 filesToProcess.append(file)
410 print(
"This should never happen because if I have errors I return or exit! Run: " +
str(run))
412 error =
"Run " +
str(run) +
" is in the run registry but it has not been processed yet!" 414 timeoutType =
timeoutManager(
"MISSING_RUNREGRUN_Run"+
str(run),missingLumisTimeout)
416 if len(RRList) <= rrTolerance:
417 error =
"WARNING: I previously set the MISSING_RUNREGRUN_Run" +
str(run) +
" timeout that expired...I am missing run " +
str(run) +
" but it only had " +
str(len(RRList)) +
" <= " +
str(rrTolerance) +
" lumis. So I will continue and ignore it... " 422 error =
"ERROR: I previously set the MISSING_RUNREGRUN_Run" +
str(run) +
" timeout that expired...I am missing run " +
str(run) +
" which has " +
str(len(RRList)) +
" > " +
str(rrTolerance) +
" lumis. I can't continue but I'll process the runs before this one" 424 return filesToProcess
427 if timeoutType == -1:
428 print(
"WARNING: Setting the MISSING_RUNREGRUN_Run" +
str(run) +
" timeout because I haven't processed a run!")
430 print(
"WARNING: Timeout MISSING_RUNREGRUN_Run" +
str(run) +
" is in progress.")
431 return filesToProcess
433 return filesToProcess
438 if lenA < lenB-(lenB*
float(tolerance)/100):
439 errors.append(
"ERROR: The number of lumi sections is different: listA(" +
str(lenA) +
")!=(" +
str(lenB) +
")listB")
460 if not lumi
in listB:
461 errors.append(
"Lumi (" +
str(lumi) +
") is in listA but not in listB")
466 if not lumi
in listA:
467 errors.append(
"Lumi (" +
str(lumi) +
") is in listB but not in listA")
476 for fileName
in newRunList:
478 if not run
in processedRuns:
479 processedRuns[run] = 0
480 processedRuns[run] += 1
482 for run
in processedRuns.keys():
484 if processedRuns[run] < nFiles:
485 print(
"I haven't processed all files yet : " +
str(processedRuns[run]) +
" out of " +
str(nFiles) +
" for run: " +
str(run))
487 print(
"All files have been processed for run: " +
str(run) +
" (" +
str(processedRuns[run]) +
" out of " +
str(nFiles) +
")")
494 for file
in listOfFilesToProcess:
497 if run
not in runsToProcess:
498 runsToProcess[run] = 1
500 runsToProcess[run] = runsToProcess[run] + 1
502 for file
in newRunList:
505 if run
not in processedRuns:
506 processedRuns[run] = 1
508 processedRuns[run] = processedRuns[run] + 1
514 processedRunsKeys = sorted(processedRuns.keys())
516 for run
in processedRunsKeys:
517 if run <= lastClosedRun :
518 print(
"For run " +
str(run) +
" I have processed " +
str(processedRuns[run]) +
" files and in DBS there are " +
str(runsToProcess[run]) +
" files!")
519 if not run
in runsToProcess:
520 exit(
"ERROR: I have a result file for run " +
str(run) +
" but it doesn't exist in DBS. Impossible but it happened!")
521 lumiList = getDBSLumiListForRun(run)
522 if processedRuns[run] == runsToProcess[run]:
523 for file
in newRunList:
525 selectedFiles.append(file)
527 exit(
"ERROR: For run " +
str(run) +
" I have processed " +
str(processedRuns[run]) +
" files but in DBS there are " +
str(runsToProcess[run]) +
" files!")
533 option,args =
parse(__doc__)
539 print(
"There is already a megascript runnning...exiting")
545 destDB =
'oracle://cms_orcon_prod/CMS_COND_31X_BEAMSPOT' 547 destDB =
'oracle://cms_orcoff_prep/CMS_COND_BEAMSPOT' 550 cfgFile =
"BeamSpotWorkflow.cfg" 553 configurationFile = os.getenv(
"CMSSW_BASE") +
"/src/RecoVertex/BeamSpotProducer/scripts/" + cfgFile
554 configuration = ConfigParser.ConfigParser()
555 print(
'Reading configuration from ', configurationFile)
556 configuration.read(configurationFile)
558 sourceDir = configuration.get(
'Common',
'SOURCE_DIR')
559 archiveDir = configuration.get(
'Common',
'ARCHIVE_DIR')
560 workingDir = configuration.get(
'Common',
'WORKING_DIR')
561 databaseTag = configuration.get(
'Common',
'DBTAG')
562 dataSet = configuration.get(
'Common',
'DATASET')
563 fileIOVBase = configuration.get(
'Common',
'FILE_IOV_BASE')
564 dbIOVBase = configuration.get(
'Common',
'DB_IOV_BASE')
565 dbsTolerance =
float(configuration.get(
'Common',
'DBS_TOLERANCE'))
566 dbsTolerancePercent =
float(configuration.get(
'Common',
'DBS_TOLERANCE_PERCENT'))
567 rrTolerance =
float(configuration.get(
'Common',
'RR_TOLERANCE'))
568 missingFilesTolerance =
float(configuration.get(
'Common',
'MISSING_FILES_TOLERANCE'))
569 missingLumisTimeout =
float(configuration.get(
'Common',
'MISSING_LUMIS_TIMEOUT'))
570 jsonFileName = configuration.get(
'Common',
'JSON_FILE')
571 mailList = configuration.get(
'Common',
'EMAIL')
574 if sourceDir[len(sourceDir)-1] !=
'/':
575 sourceDir = sourceDir +
'/' 577 error =
"ERROR: The source directory " + sourceDir +
" doesn't exist!" 581 if archiveDir[len(archiveDir)-1] !=
'/':
582 archiveDir = archiveDir +
'/' 583 if not os.path.isdir(archiveDir):
586 if workingDir[len(workingDir)-1] !=
'/':
587 workingDir = workingDir +
'/' 588 if not os.path.isdir(workingDir):
591 os.system(
"rm -f "+ workingDir +
"*")
594 print(
"Getting last IOV for tag: " + databaseTag)
596 if destDB ==
"oracle://cms_orcon_prod/CMS_COND_31X_BEAMSPOT":
603 if dbIOVBase ==
"lumiid":
607 print(
"Getting list of files processed after IOV " +
str(lastUploadedIOV))
608 newProcessedRunList =
getNewRunList(sourceDir,lastUploadedIOV)
609 if len(newProcessedRunList) == 0:
610 exit(
"There are no new runs after " +
str(lastUploadedIOV))
613 print(
"Copying files to archive directory")
616 copiedFiles =
cp(sourceDir,archiveDir,newProcessedRunList)
617 if len(copiedFiles) == len(newProcessedRunList):
619 if len(copiedFiles) != len(newProcessedRunList):
620 error =
"ERROR: I can't copy more than " +
str(len(copiedFiles)) +
" files out of " +
str(len(newProcessedRunList))
627 print(
"Getting list of files from DBS")
629 if len(listOfRunsAndLumiFromDBS) == 0:
630 exit(
"There are no files in DBS to process")
631 print(
"Getting list of files from RR")
633 if(
not listOfRunsAndLumiFromRR):
634 print(
"Looks like I can't get anything from the run registry so I'll get the data from the json file " + jsonFileName)
642 print(
"Getting list of files to process")
643 selectedFilesToProcess =
selectFilesToProcess(listOfRunsAndLumiFromDBS,listOfRunsAndLumiFromRR,copiedFiles,archiveDir,dataSet,mailList,dbsTolerance,dbsTolerancePercent,rrTolerance,missingFilesTolerance,missingLumisTimeout)
644 if len(selectedFilesToProcess) == 0:
645 exit(
"There are no files to process")
649 print(
"Copying files from archive to working directory")
652 copiedFiles =
cp(archiveDir,workingDir,selectedFilesToProcess)
653 if len(copiedFiles) == len(selectedFilesToProcess):
656 commands.getstatusoutput(
"rm -rf " + workingDir)
657 if len(copiedFiles) != len(selectedFilesToProcess):
658 error =
"ERROR: I can't copy more than " +
str(len(copiedFiles)) +
" files out of " +
str(len(selectedFilesToProcess)) +
" from " + archiveDir +
" to " + workingDir
662 print(
"Sorting and cleaning beamlist")
664 for fileName
in copiedFiles:
669 if len(beamSpotObjList) == 0:
670 error =
"WARNING: None of the processed and copied payloads has a valid fit so there are no results. This shouldn't happen since we are filtering using the run register, so there should be at least one good run." 673 payloadFileName =
"PayloadFile.txt" 676 if dbIOVBase ==
"runnumber":
680 if len(payloadList) == 0:
681 error =
"WARNING: I wasn't able to create any payload even if I have some BeamSpot objects." 685 tmpPayloadFileName = workingDir +
"SingleTmpPayloadFile.txt" 686 tmpSqliteFileName = workingDir +
"SingleTmpSqliteFile.db" 688 writeDBTemplate = os.getenv(
"CMSSW_BASE") +
"/src/RecoVertex/BeamSpotProducer/test/write2DB_template.py" 689 readDBTemplate = os.getenv(
"CMSSW_BASE") +
"/src/RecoVertex/BeamSpotProducer/test/readDB_template.py" 695 uuid = commands.getstatusoutput(
'uuidgen -t')[1]
696 final_sqlite_file_name = databaseTag +
'@' + uuid
697 sqlite_file = workingDir + final_sqlite_file_name +
".db" 698 metadata_file = workingDir + final_sqlite_file_name +
".txt" 700 for payload
in payloadList:
704 payload.sigmaZerr = 2.5e-05
705 tmpFile =
file(tmpPayloadFileName,
'w')
708 if not writeSqliteFile(tmpSqliteFileName,databaseTag,dbIOVBase,tmpPayloadFileName,writeDBTemplate,workingDir):
709 error =
"An error occurred while writing the sqlite file: " + tmpSqliteFileName
711 readSqliteFile(tmpSqliteFileName,databaseTag,readDBTemplate,workingDir)
715 if dbIOVBase ==
"runnumber":
716 iov_since =
str(payload.Run)
718 elif dbIOVBase ==
"lumiid":
719 iov_since =
str(
pack(
int(payload.Run),
int(payload.IOVfirst)) )
720 iov_till =
str(
pack(
int(payload.Run),
int(payload.IOVlast)) )
721 elif dbIOVBase ==
"timestamp":
722 error =
"ERROR: IOV " + dbIOVBase +
" still not implemented." 725 error =
"ERROR: IOV " + dbIOVBase +
" unrecognized!" 728 if payloadNumber == 0:
729 iovSinceFirst = iov_since
730 if payloadNumber == len(payloadList)-1:
731 iovTillLast = iov_till
733 appendSqliteFile(final_sqlite_file_name +
".db", tmpSqliteFileName, databaseTag, iov_since, iov_till ,workingDir)
734 os.system(
"rm -f " + tmpPayloadFileName +
" " + tmpSqliteFileName)
739 print(
" create MERGED payload card for dropbox ...")
741 dfile = open(metadata_file,
'w')
743 dfile.write(
'destDB ' + destDB +
'\n')
744 dfile.write(
'tag ' + databaseTag +
'\n')
745 dfile.write(
'inputtag' +
'\n')
746 dfile.write(
'since ' + iovSinceFirst +
'\n')
748 dfile.write(
'Timetype '+ dbIOVBase +
'\n')
752 print(
"WARNING TAG TYPE forced to be just offline")
755 if tagType ==
"express":
757 dfile.write(
'IOVCheck ' + checkType +
'\n')
758 dfile.write(
'usertext Beam spot position\n')
765 print(
" scp files to offline Drop Box")
768 dropbox =
"/DropBox_test" 769 print(
"UPLOADING TO TEST DB")
772 archive_sqlite_file_name =
"Payloads_" + iovSinceFirst +
"_" + iovTillLast +
"_" + final_sqlite_file_name
773 archive_results_file_name =
"Payloads_" + iovSinceFirst +
"_" + iovTillLast +
"_" + databaseTag +
".txt" 774 if not os.path.isdir(archiveDir +
'payloads'):
775 os.mkdir(archiveDir +
'payloads')
776 commands.getstatusoutput(
'mv ' + sqlite_file +
' ' + archiveDir +
'payloads/' + archive_sqlite_file_name +
'.db')
777 commands.getstatusoutput(
'mv ' + metadata_file +
' ' + archiveDir +
'payloads/' + archive_sqlite_file_name +
'.txt')
778 commands.getstatusoutput(
'cp ' + workingDir + payloadFileName +
' ' + archiveDir +
'payloads/' + archive_results_file_name)
780 print(archiveDir +
"payloads/" + archive_sqlite_file_name +
'.db')
781 print(archiveDir +
"payloads/" + archive_sqlite_file_name +
'.txt')
785 if __name__ ==
'__main__':
def readBeamSpotFile(fileName, listbeam=[], IOVbase="runbase", firstRun='1', lastRun='4999999999')
def dumpValues(beam, file)
def getRunNumberFromFileName(fileName)
def getLastClosedRun(DBSListOfFiles)
def replace(string, replacements)
def appendSqliteFile(combinedSqliteFileName, sqliteFileName, tagName, IOVSince, IOVTill, tmpDir="/tmp/")
S & print(S &os, JobReport::InputFile const &f)
def createWeightedPayloads(fileName, listbeam=[], weighted=True)
CREATE FILE FOR PAYLOADS.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def uploadSqliteFile(sqliteFileDirName, sqliteFileName, dropbox="/DropBox")
def getLastUploadedIOV(tagName, destDB="oracle://cms_orcoff_prod/CMS_COND_31X_BEAMSPOT")
General functions.
def getListOfRunsAndLumiFromFile(firstRun=-1, fileName="")
def compareLumiLists(listA, listB, errors=[], tolerance=0)
def sortAndCleanBeamList(listbeam=[], IOVbase="lumibase")
Sort and clean list of data for consecutive duplicates and bad fits.
def getNewRunList(fromDir, lastUploadedIOV)
def readSqliteFile(sqliteFileName, tagName, sqliteTemplateFile, tmpDir="/tmp/")
def getNumberOfFilesToProcessForRun(dataSet, run)
def getRunNumberFromDBSName(fileName)
def removeUncompleteRuns(newRunList, dataSet)
def getListOfFilesToProcess(dataSet, lastRun=-1)
def aselectFilesToProcess(listOfFilesToProcess, newRunList)
def getListOfRunsAndLumiFromDBS(dataSet, lastRun=-1)
def selectFilesToProcess(listOfRunsAndLumiFromDBS, listOfRunsAndLumiFromRR, newRunList, runListDir, dataSet, mailList, dbsTolerance, dbsTolerancePercent, rrTolerance, missingFilesTolerance, missingLumisTimeout)
def timeoutManager(type, timeout=-1, fileName=".timeout")
def writeSqliteFile(sqliteFileName, tagName, timeType, beamSpotFile, sqliteTemplateFile, tmpDir="/tmp/")
def sendEmail(mailList, error)
General utilities.
def getListOfRunsAndLumiFromRR(firstRun=-1)