Go to the documentation of this file.00001 import os
00002 import sys
00003
00004 if len(sys.argv) != 2:
00005 print "Error: please, specify the configuration file"
00006 sys.exit()
00007 else:
00008 configFile = sys.argv[1]
00009
00010 if os.path.isfile(configFile):
00011 print "Using configuration file:", configFile
00012 else:
00013 print "Error: configuration file", configFile, "not found"
00014 sys.exit()
00015
00016
00017 import HDQMDatabaseProducerConfiguration
00018 config = HDQMDatabaseProducerConfiguration.HDQMDatabaseProducerConfiguration(configFile)
00019
00020
00021 import DiscoverDQMFiles
00022 discoverDQMFiles = DiscoverDQMFiles.DiscoverDQMFiles()
00023
00024 import PopulateDB
00025 populateDB = PopulateDB.PopulateDB()
00026
00027 import ProducePlots
00028 producePlots = ProducePlots.ProducePlots()
00029
00030
00031
00032 if len(config.RecoTypes) == 0:
00033 fullList = discoverDQMFiles.filesList(config.SourceDir)
00034 keys = {}
00035 for file in fullList:
00036
00037 keys[file.split("__")[2]] = 1
00038 print "Found the following reco types:", keys.keys()
00039 config.RecoTypes = keys.keys()
00040
00041
00042 recoTypesFile = open('recoTypesFile.txt', 'w')
00043
00044
00045
00046
00047 for recoType in config.RecoTypes:
00048
00049 fullList = discoverDQMFiles.filesList(config.SourceDir, recoType)
00050 for subDetAndTag in config.SubDetsAndTags:
00051 FullTagName = config.TagName+"_"+subDetAndTag.SubDet+"_"+subDetAndTag.Tag
00052
00053 import DiscoverProcessedRuns
00054 discoverProcessedRuns = DiscoverProcessedRuns.DiscoverProcessedRuns()
00055
00056 discoverProcessedRuns.Database = config.Database
00057 discoverProcessedRuns.AuthenticationPath = config.AuthenticationPath
00058 discoverProcessedRuns.CMSSW_Version = config.CMSSW_Version
00059 discoverProcessedRuns.TagName = FullTagName
00060
00061 processedRuns = discoverProcessedRuns.runsList()
00062
00063
00064 filteredList = list(fullList)
00065 for run in processedRuns:
00066 for file in fullList:
00067 if( file.find(run) != -1 ):
00068
00069 try:
00070 filteredList.remove(file)
00071 except Exception:
00072 print "Error, trying to remove file:", file, "twice!"
00073 pass
00074
00075
00076 filteredList = sorted(filteredList, key=lambda run: run.split("R0")[1].split("__")[0])
00077 runsToSkip = int(config.RunsToSkip)
00078 if( runsToSkip > 0 ):
00079 for lastRun in range(runsToSkip):
00080 filteredList.pop()
00081
00082
00083 tempDir = config.BaseDir+"/"+subDetAndTag.SubDet+"_"+config.RunType+"/"
00084 if not os.path.isdir(tempDir):
00085 os.mkdir(tempDir)
00086
00087 for file in filteredList:
00088 runNumber = int(file.split("R0")[1].split("__")[0])
00089
00090 populateDB.RunNumber = str(runNumber)
00091 populateDB.AuthenticationPath = config.AuthenticationPath
00092 populateDB.Database = config.Database
00093 populateDB.TagName = FullTagName
00094 populateDB.FileName = file
00095 populateDB.TemplatesDir = config.TemplatesDir
00096 populateDB.DetName = subDetAndTag.SubDet
00097 populateDB.Dir = config.BaseDir+"/"+subDetAndTag.SubDet+"_"+config.RunType+"/"
00098 populateDB.CMSSW_Version = config.CMSSW_Version
00099
00100 populateDB.run()
00101
00102
00103 if len(filteredList) == 0:
00104 print "Creating plots"
00105
00106 producePlots.Dir = config.BaseDir+"/"
00107 producePlots.TagName = FullTagName
00108 producePlots.DetName = subDetAndTag.SubDet
00109 producePlots.StorageDir = config.StorageDir
00110 producePlots.BaseDir = config.BaseDir
00111 producePlots.FirstRun = str(config.FirstRun)
00112 producePlots.CMSSW_Version = config.CMSSW_Version
00113 producePlots.Database = config.Database
00114 producePlots.Password = PASSWORD
00115 producePlots.RunType = config.RunType
00116 producePlots.Group = config.Group
00117 producePlots.QualityFlag = subDetAndTag.QualityFlag
00118
00119 producePlots.makePlots()
00120
00121
00122 recoTypesFile.write(recoType+"\n")
00123
00124 recoTypesFile.close()