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) 36 import commands, re, time
40 from BeamSpotObj
import BeamSpot
41 from IOVObj
import IOV
42 from CommonMethods
import *
48 import simplejson
as json
50 error =
"Please set a crab environment in order to get the proper JSON lib" 58 listIOVCommand =
"cmscond_list_iov -c " + destDB +
" -P /afs/cern.ch/cms/DB/conddb -t " + tagName
59 dbError = commands.getstatusoutput( listIOVCommand )
61 if dbError[1].
find(
"metadata entry \"" + tagName +
"\" does not exist") != -1:
62 print "Creating a new tag because I got the following error contacting the DB" 67 exit(
"ERROR: Can\'t connect to db because:\n" + dbError[1])
70 aCommand = listIOVCommand +
" | grep DB= | tail -1 | awk \'{print $1}\'" 71 output = commands.getstatusoutput( aCommand )
75 exit(
"ERROR: The tag " + tagName +
" exists but I can't get the value of the last IOV")
77 return long(output[1])
81 queryCommand =
"dbs --search --query \"find file where dataset=" + dataSet
83 queryCommand = queryCommand +
" and run > " +
str(lastRun)
84 queryCommand = queryCommand +
"\" | grep .root" 86 output = commands.getstatusoutput( queryCommand )
87 return output[1].
split(
'\n')
91 queryCommand =
"dbs --search --query \"find file where dataset=" + dataSet +
" and run = " +
str(run) +
"\" | grep .root" 93 output = commands.getstatusoutput( queryCommand )
97 return len(output[1].
split(
'\n'))
101 datasetList = dataSet.split(
',')
103 for data
in datasetList:
104 queryCommand =
"dbs --search --query \"find run,lumi where dataset=" + data
106 queryCommand = queryCommand +
" and run > " +
str(lastRun)
108 print " >> " + queryCommand
111 output = commands.getstatusoutput( queryCommand )
112 if output[0] == 0
and not (output[1].
find(
"ERROR") != -1
or output[1].
find(
"Error") != -1) :
115 exit(
"ERROR: I can't contact DBS for the following reason:\n" + output[1])
117 tmpList = output[1].
split(
'\n')
119 outputList.append(file)
121 for out
in outputList:
122 regExp = re.search(
'(\d+)\s+(\d+)',out)
124 run = long(regExp.group(1))
125 lumi = long(regExp.group(2))
126 if not run
in runsAndLumis:
127 runsAndLumis[run] = []
128 runsAndLumis[run].
append(lumi)
136 file = open(fileName);
137 jsonFile = file.read();
139 jsonList=json.loads(jsonFile);
142 for element
in jsonList:
143 selected_dcs[long(element)]=jsonList[element]
148 RunReg =
"http://pccmsdqm04.cern.ch/runregistry" 151 Group =
"Collisions10" 154 FULLADDRESS=RunReg +
"/xmlrpc" 156 server = xmlrpclib.ServerProxy(FULLADDRESS)
158 sel_runtable=
"{groupName} ='" + Group +
"' and {runNumber} > " +
str(firstRun)
163 while tries<maxAttempts:
165 run_data = server.DataExporter.export(
'RUN' ,
'GLOBAL',
'csv_runs', sel_runtable)
169 print "Something wrong in accessing runregistry, retrying in 2s....", tries,
"/", maxAttempts
172 if tries==maxAttempts:
173 error =
"Run registry unaccessible.....exiting now" 178 for line
in run_data.split(
"\n"):
179 run=line.split(
',')[0]
181 listOfRuns.append(run)
184 firstRun = listOfRuns[len(listOfRuns)-1];
185 lastRun = listOfRuns[0];
186 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" 189 while tries<maxAttempts:
192 dcs_data = server.DataExporter.export(
'RUNLUMISECTION',
'GLOBAL',
'json' , sel_dcstable)
195 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
198 if tries==maxAttempts:
199 error =
"Run registry unaccessible.....exiting now" 203 jsonList=json.loads(dcs_data)
206 for element
in listOfRuns:
208 if element
in jsonList:
209 selected_dcs[long(element)]=jsonList[element]
211 print "WARNING: Run " + element +
" is a collision10 run with 0 lumis in Run Registry!" 212 selected_dcs[long(element)]= [[]]
219 for file
in DBSListOfFiles:
221 if runs.count(runNumber) == 0:
222 runs.append(runNumber)
228 return long(runs[len(runs)-2])
233 regExp = re.search(
'(\D+)_(\d+)_(\d+)_',fileName)
236 return long(regExp.group(3))
240 regExp = re.search(
'(\D+)/(\d+)/(\d+)/(\d+)/(\D+)',fileName)
243 return long(regExp.group(3)+regExp.group(4))
248 listOfFiles =
ls(fromDir,
".txt")
250 for fileName
in listOfFiles:
252 if runNumber > lastUploadedIOV:
253 newRunList.append(fileName)
257 def selectFilesToProcess(listOfRunsAndLumiFromDBS,listOfRunsAndLumiFromRR,newRunList,runListDir,dataSet,mailList,dbsTolerance,dbsTolerancePercent,rrTolerance,missingFilesTolerance,missingLumisTimeout):
258 runsAndLumisProcessed = {}
260 for fileName
in newRunList:
261 file = open(runListDir+fileName)
263 if line.find(
"Runnumber") != -1:
264 run = long(line.replace(
'\n',
'').
split(
' ')[1])
265 elif line.find(
"LumiRange") != -1:
266 lumiLine = line.replace(
'\n',
'').
split(
' ')
267 begLumi = long(lumiLine[1])
268 endLumi = long(lumiLine[3])
269 if begLumi != endLumi:
270 error =
"The lumi range is greater than 1 for run " +
str(run) +
" " + line +
" in file: " + runListDir + fileName
273 if not run
in runsAndLumisProcessed:
274 runsAndLumisProcessed[run] = []
275 if begLumi
in runsAndLumisProcessed[run]:
276 print "Lumi " +
str(begLumi) +
" in event " +
str(run) +
" already exist. This MUST not happen but right now I will ignore this lumi!" 278 runsAndLumisProcessed[run].
append(begLumi)
279 if not run
in runsAndFiles:
280 runsAndFiles[run] = []
281 runsAndFiles[run].
append(fileName)
284 rrKeys = sorted(listOfRunsAndLumiFromRR.keys())
285 dbsKeys = listOfRunsAndLumiFromDBS.keys()
288 lastUnclosedRun = dbsKeys.pop()
290 procKeys = runsAndLumisProcessed.keys()
302 for lumiRange
in listOfRunsAndLumiFromRR[run]:
304 for l
in range(lumiRange[0],lumiRange[1]+1):
305 RRList.append(long(l))
306 if run
in procKeys
and run < lastUnclosedRun:
308 if not run
in dbsKeys
and run != lastUnclosedRun:
309 error =
"Impossible but run " +
str(run) +
" has been processed and it is also in the run registry but it is not in DBS!" 311 print "Working on run " +
str(run)
313 for data
in dataSet.split(
','):
317 if len(runsAndFiles[run]) < nFiles:
318 print "I haven't processed all files yet : " +
str(len(runsAndFiles[run])) +
" out of " +
str(nFiles) +
" for run: " +
str(run)
319 if nFiles - len(runsAndFiles[run]) <= missingFilesTolerance:
323 print "WARNING: I previously set a timeout that expired...I'll continue with the script even if I didn't process all the lumis!" 325 if timeoutType == -1:
326 print "WARNING: Setting the DBS_MISMATCH_Run" +
str(run) +
" timeout because I haven't processed all files!" 328 print "WARNING: Timeout DBS_MISMATCH_Run" +
str(run) +
" is in progress." 329 return filesToProcess
331 timeoutType =
timeoutManager(
"DBS_VERY_BIG_MISMATCH_Run"+
str(run),missingLumisTimeout)
333 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) +
")" 335 return filesToProcess
338 if timeoutType == -1:
339 print "WARNING: Setting the DBS_VERY_BIG_MISMATCH_Run" +
str(run) +
" timeout because I haven't processed all files!" 341 print "WARNING: Timeout DBS_VERY_BIG_MISMATCH_Run" +
str(run) +
" is in progress." 342 return filesToProcess
347 print "I have processed " +
str(len(runsAndFiles[run])) +
" out of " +
str(nFiles) +
" files that are in DBS. So I should have all the lumis!" 355 badDBSProcessed,badDBS =
compareLumiLists(runsAndLumisProcessed[run],listOfRunsAndLumiFromDBS[run],errors)
356 for i
in range(0,len(errors)):
357 errors[i] = errors[i].
replace(
"listA",
"the processed lumis")
358 errors[i] = errors[i].
replace(
"listB",
"DBS")
364 print "This is weird because I processed more lumis than the ones that are in DBS!" 365 if len(badDBSProcessed) != 0
and run
in rrKeys:
366 lastError = len(errors)
369 badRRProcessed,badRR =
compareLumiLists(runsAndLumisProcessed[run],RRList,errors)
370 for i
in range(0,len(errors)):
371 errors[i] = errors[i].
replace(
"listA",
"the processed lumis")
372 errors[i] = errors[i].
replace(
"listB",
"Run Registry")
377 if len(badRRProcessed) != 0:
378 print "I have not processed some of the lumis that are in the run registry for run: " +
str(run)
379 for lumi
in badDBSProcessed:
380 if lumi
in badRRProcessed:
381 badProcessed.append(lumi)
382 lenA = len(badProcessed)
384 if 100.*lenA/lenB <= dbsTolerancePercent:
385 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" 388 elif lenA <= dbsTolerance:
389 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" 393 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!" 396 return filesToProcess
399 elif len(errors) != 0:
400 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!" 404 if len(badProcessed) == 0:
405 for file
in runsAndFiles[run]:
406 filesToProcess.append(file)
409 print "This should never happen because if I have errors I return or exit! Run: " +
str(run)
411 error =
"Run " +
str(run) +
" is in the run registry but it has not been processed yet!" 413 timeoutType =
timeoutManager(
"MISSING_RUNREGRUN_Run"+
str(run),missingLumisTimeout)
415 if len(RRList) <= rrTolerance:
416 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... " 421 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" 423 return filesToProcess
426 if timeoutType == -1:
427 print "WARNING: Setting the MISSING_RUNREGRUN_Run" +
str(run) +
" timeout because I haven't processed a run!" 429 print "WARNING: Timeout MISSING_RUNREGRUN_Run" +
str(run) +
" is in progress." 430 return filesToProcess
432 return filesToProcess
437 if lenA < lenB-(lenB*
float(tolerance)/100):
438 errors.append(
"ERROR: The number of lumi sections is different: listA(" +
str(lenA) +
")!=(" +
str(lenB) +
")listB")
459 if not lumi
in listB:
460 errors.append(
"Lumi (" +
str(lumi) +
") is in listA but not in listB")
465 if not lumi
in listA:
466 errors.append(
"Lumi (" +
str(lumi) +
") is in listB but not in listA")
475 for fileName
in newRunList:
477 if not run
in processedRuns:
478 processedRuns[run] = 0
479 processedRuns[run] += 1
481 for run
in processedRuns.keys():
483 if processedRuns[run] < nFiles:
484 print "I haven't processed all files yet : " +
str(processedRuns[run]) +
" out of " +
str(nFiles) +
" for run: " +
str(run)
486 print "All files have been processed for run: " +
str(run) +
" (" +
str(processedRuns[run]) +
" out of " +
str(nFiles) +
")" 493 for file
in listOfFilesToProcess:
496 if run
not in runsToProcess:
497 runsToProcess[run] = 1
499 runsToProcess[run] = runsToProcess[run] + 1
501 for file
in newRunList:
504 if run
not in processedRuns:
505 processedRuns[run] = 1
507 processedRuns[run] = processedRuns[run] + 1
513 processedRunsKeys = sorted(processedRuns.keys())
515 for run
in processedRunsKeys:
516 if run <= lastClosedRun :
517 print "For run " +
str(run) +
" I have processed " +
str(processedRuns[run]) +
" files and in DBS there are " +
str(runsToProcess[run]) +
" files!" 518 if not run
in runsToProcess:
519 exit(
"ERROR: I have a result file for run " +
str(run) +
" but it doesn't exist in DBS. Impossible but it happened!")
520 lumiList = getDBSLumiListForRun(run)
521 if processedRuns[run] == runsToProcess[run]:
522 for file
in newRunList:
524 selectedFiles.append(file)
526 exit(
"ERROR: For run " +
str(run) +
" I have processed " +
str(processedRuns[run]) +
" files but in DBS there are " +
str(runsToProcess[run]) +
" files!")
532 option,args =
parse(__doc__)
538 print "There is already a megascript runnning...exiting" 544 destDB =
'oracle://cms_orcon_prod/CMS_COND_31X_BEAMSPOT' 546 destDB =
'oracle://cms_orcoff_prep/CMS_COND_BEAMSPOT' 549 cfgFile =
"BeamSpotWorkflow.cfg" 552 configurationFile = os.getenv(
"CMSSW_BASE") +
"/src/RecoVertex/BeamSpotProducer/scripts/" + cfgFile
553 configuration = ConfigParser.ConfigParser()
554 print 'Reading configuration from ', configurationFile
555 configuration.read(configurationFile)
557 sourceDir = configuration.get(
'Common',
'SOURCE_DIR')
558 archiveDir = configuration.get(
'Common',
'ARCHIVE_DIR')
559 workingDir = configuration.get(
'Common',
'WORKING_DIR')
560 databaseTag = configuration.get(
'Common',
'DBTAG')
561 dataSet = configuration.get(
'Common',
'DATASET')
562 fileIOVBase = configuration.get(
'Common',
'FILE_IOV_BASE')
563 dbIOVBase = configuration.get(
'Common',
'DB_IOV_BASE')
564 dbsTolerance =
float(configuration.get(
'Common',
'DBS_TOLERANCE'))
565 dbsTolerancePercent =
float(configuration.get(
'Common',
'DBS_TOLERANCE_PERCENT'))
566 rrTolerance =
float(configuration.get(
'Common',
'RR_TOLERANCE'))
567 missingFilesTolerance =
float(configuration.get(
'Common',
'MISSING_FILES_TOLERANCE'))
568 missingLumisTimeout =
float(configuration.get(
'Common',
'MISSING_LUMIS_TIMEOUT'))
569 jsonFileName = configuration.get(
'Common',
'JSON_FILE')
570 mailList = configuration.get(
'Common',
'EMAIL')
573 if sourceDir[len(sourceDir)-1] !=
'/':
574 sourceDir = sourceDir +
'/' 576 error =
"ERROR: The source directory " + sourceDir +
" doesn't exist!" 580 if archiveDir[len(archiveDir)-1] !=
'/':
581 archiveDir = archiveDir +
'/' 582 if not os.path.isdir(archiveDir):
585 if workingDir[len(workingDir)-1] !=
'/':
586 workingDir = workingDir +
'/' 587 if not os.path.isdir(workingDir):
590 os.system(
"rm -f "+ workingDir +
"*")
593 print "Getting last IOV for tag: " + databaseTag
595 if destDB ==
"oracle://cms_orcon_prod/CMS_COND_31X_BEAMSPOT":
602 if dbIOVBase ==
"lumiid":
606 print "Getting list of files processed after IOV " +
str(lastUploadedIOV)
607 newProcessedRunList =
getNewRunList(sourceDir,lastUploadedIOV)
608 if len(newProcessedRunList) == 0:
609 exit(
"There are no new runs after " +
str(lastUploadedIOV))
612 print "Copying files to archive directory" 615 copiedFiles =
cp(sourceDir,archiveDir,newProcessedRunList)
616 if len(copiedFiles) == len(newProcessedRunList):
618 if len(copiedFiles) != len(newProcessedRunList):
619 error =
"ERROR: I can't copy more than " +
str(len(copiedFiles)) +
" files out of " +
str(len(newProcessedRunList))
626 print "Getting list of files from DBS" 628 if len(listOfRunsAndLumiFromDBS) == 0:
629 exit(
"There are no files in DBS to process")
630 print "Getting list of files from RR" 632 if(
not listOfRunsAndLumiFromRR):
633 print "Looks like I can't get anything from the run registry so I'll get the data from the json file " + jsonFileName
641 print "Getting list of files to process" 642 selectedFilesToProcess =
selectFilesToProcess(listOfRunsAndLumiFromDBS,listOfRunsAndLumiFromRR,copiedFiles,archiveDir,dataSet,mailList,dbsTolerance,dbsTolerancePercent,rrTolerance,missingFilesTolerance,missingLumisTimeout)
643 if len(selectedFilesToProcess) == 0:
644 exit(
"There are no files to process")
648 print "Copying files from archive to working directory" 651 copiedFiles =
cp(archiveDir,workingDir,selectedFilesToProcess)
652 if len(copiedFiles) == len(selectedFilesToProcess):
655 commands.getstatusoutput(
"rm -rf " + workingDir)
656 if len(copiedFiles) != len(selectedFilesToProcess):
657 error =
"ERROR: I can't copy more than " +
str(len(copiedFiles)) +
" files out of " +
str(len(selectedFilesToProcess)) +
" from " + archiveDir +
" to " + workingDir
661 print "Sorting and cleaning beamlist" 663 for fileName
in copiedFiles:
668 if len(beamSpotObjList) == 0:
669 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." 672 payloadFileName =
"PayloadFile.txt" 675 if dbIOVBase ==
"runnumber":
679 if len(payloadList) == 0:
680 error =
"WARNING: I wasn't able to create any payload even if I have some BeamSpot objects." 684 tmpPayloadFileName = workingDir +
"SingleTmpPayloadFile.txt" 685 tmpSqliteFileName = workingDir +
"SingleTmpSqliteFile.db" 687 writeDBTemplate = os.getenv(
"CMSSW_BASE") +
"/src/RecoVertex/BeamSpotProducer/test/write2DB_template.py" 688 readDBTemplate = os.getenv(
"CMSSW_BASE") +
"/src/RecoVertex/BeamSpotProducer/test/readDB_template.py" 694 uuid = commands.getstatusoutput(
'uuidgen -t')[1]
695 final_sqlite_file_name = databaseTag +
'@' + uuid
696 sqlite_file = workingDir + final_sqlite_file_name +
".db" 697 metadata_file = workingDir + final_sqlite_file_name +
".txt" 699 for payload
in payloadList:
703 payload.sigmaZerr = 2.5e-05
704 tmpFile =
file(tmpPayloadFileName,
'w')
707 if not writeSqliteFile(tmpSqliteFileName,databaseTag,dbIOVBase,tmpPayloadFileName,writeDBTemplate,workingDir):
708 error =
"An error occurred while writing the sqlite file: " + tmpSqliteFileName
710 readSqliteFile(tmpSqliteFileName,databaseTag,readDBTemplate,workingDir)
714 if dbIOVBase ==
"runnumber":
715 iov_since =
str(payload.Run)
717 elif dbIOVBase ==
"lumiid":
718 iov_since =
str(
pack(
int(payload.Run),
int(payload.IOVfirst)) )
719 iov_till =
str(
pack(
int(payload.Run),
int(payload.IOVlast)) )
720 elif dbIOVBase ==
"timestamp":
721 error =
"ERROR: IOV " + dbIOVBase +
" still not implemented." 724 error =
"ERROR: IOV " + dbIOVBase +
" unrecognized!" 727 if payloadNumber == 0:
728 iovSinceFirst = iov_since
729 if payloadNumber == len(payloadList)-1:
730 iovTillLast = iov_till
732 appendSqliteFile(final_sqlite_file_name +
".db", tmpSqliteFileName, databaseTag, iov_since, iov_till ,workingDir)
733 os.system(
"rm -f " + tmpPayloadFileName +
" " + tmpSqliteFileName)
738 print " create MERGED payload card for dropbox ..." 740 dfile = open(metadata_file,
'w')
742 dfile.write(
'destDB ' + destDB +
'\n')
743 dfile.write(
'tag ' + databaseTag +
'\n')
744 dfile.write(
'inputtag' +
'\n')
745 dfile.write(
'since ' + iovSinceFirst +
'\n')
747 dfile.write(
'Timetype '+ dbIOVBase +
'\n')
751 print "WARNING TAG TYPE forced to be just offline" 754 if tagType ==
"express":
756 dfile.write(
'IOVCheck ' + checkType +
'\n')
757 dfile.write(
'usertext Beam spot position\n')
764 print " scp files to offline Drop Box" 767 dropbox =
"/DropBox_test" 768 print "UPLOADING TO TEST DB" 771 archive_sqlite_file_name =
"Payloads_" + iovSinceFirst +
"_" + iovTillLast +
"_" + final_sqlite_file_name
772 archive_results_file_name =
"Payloads_" + iovSinceFirst +
"_" + iovTillLast +
"_" + databaseTag +
".txt" 773 if not os.path.isdir(archiveDir +
'payloads'):
774 os.mkdir(archiveDir +
'payloads')
775 commands.getstatusoutput(
'mv ' + sqlite_file +
' ' + archiveDir +
'payloads/' + archive_sqlite_file_name +
'.db')
776 commands.getstatusoutput(
'mv ' + metadata_file +
' ' + archiveDir +
'payloads/' + archive_sqlite_file_name +
'.txt')
777 commands.getstatusoutput(
'cp ' + workingDir + payloadFileName +
' ' + archiveDir +
'payloads/' + archive_results_file_name)
779 print archiveDir +
"payloads/" + archive_sqlite_file_name +
'.db' 780 print archiveDir +
"payloads/" + archive_sqlite_file_name +
'.txt' 784 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/")
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)