# # import sys from DBSAPI.dbsApi import DbsApi from DBSAPI.dbsException import * from DBSAPI.dbsApiException import * from DBSAPI.dbsOptions import DbsOptionParser optManager = DbsOptionParser() (opts,args) = optManager.getOpt() api = DbsApi(opts.__dict__) try : # A PATH +ve case print "Trying Good PATH" for afile in api.listDatasetFiles(datasetPath="/RelVal131QCD_pt600_800/CMSSW_1_3_1-1176201507/GEN-SIM-DIGI-RECO"): print "PATH %s" % afile['LogicalFileName'] except DbsApiException, ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() ) if ex.getErrorCode() not in (None, ""): print "DBS Exception Error Code: ", ex.getErrorCode() try : print "Trying Good ADS" # An ADS +ve case for afile in api.listDatasetFiles(datasetPath="/RelVal131QCD_pt600_800/CMSSW_1_3_1-1176201507/GEN-SIM-DIGI-RECO/ALLFILES"): print "ADS %s" % afile['LogicalFileName'] except DbsApiException, ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() )
#process.dqmSaver.referenceHandling = 'all' process.load('HLTriggerOffline/HeavyFlavor/heavyFlavorValidationHarvestingSequence_cff') process.edmtome_step = cms.Path(process.EDMtoME) process.validationHarvesting = cms.Path(process.heavyFlavorValidationHarvestingSequence) process.dqmsave_step = cms.Path(process.DQMSaver) process.schedule = cms.Schedule(process.edmtome_step,process.validationHarvesting,process.dqmsave_step) import sys from DBSAPI.dbsApi import DbsApi from DBSAPI.dbsException import * from DBSAPI.dbsApiException import * from DBSAPI.dbsOptions import DbsOptionParser optManager = DbsOptionParser() (opts,args) = optManager.getOpt() api = DbsApi(opts.__dict__) try : print("Files to process:") for afile in api.listDatasetFiles(datasetPath=sampleName): process.source.fileNames.append(afile['LogicalFileName']) print(afile['LogicalFileName']) except DbsApiException as ex: print("Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() )) if ex.getErrorCode() not in (None, ""): print("DBS Exception Error Code: ", ex.getErrorCode())
#process.dqmSaver.referenceHandling = 'all' process.load('HLTriggerOffline/HeavyFlavor/heavyFlavorValidationHarvestingSequence_cff') process.edmtome_step = cms.Path(process.EDMtoME) process.validationHarvesting = cms.Path(process.heavyFlavorValidationHarvestingSequence) process.dqmsave_step = cms.Path(process.DQMSaver) process.schedule = cms.Schedule(process.edmtome_step,process.validationHarvesting,process.dqmsave_step) import sys from DBSAPI.dbsApi import DbsApi from DBSAPI.dbsException import * from DBSAPI.dbsApiException import * from DBSAPI.dbsOptions import DbsOptionParser optManager = DbsOptionParser() (opts,args) = optManager.getOpt() api = DbsApi(opts.__dict__) try : print "Files to process:" for afile in api.listDatasetFiles(datasetPath=sampleName): process.source.fileNames.append(afile['LogicalFileName']) print afile['LogicalFileName'] except DbsApiException as ex: print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() ) if ex.getErrorCode() not in (None, ""): print "DBS Exception Error Code: ", ex.getErrorCode()
def process(dataset, how_to_list="file"): # command,python,file dpmPath = "rfio:///dpm/particles.ipm.ac.ir/home/cms/" dbsUrl = "http://cmsdbsprod.cern.ch/cms_dbs_ph_analysis_02/servlet/DBSServlet" list = [] # Initialize file list # Check if cache file exists and if we should use it cacheFile = "." + dataset.replace("/", "_").replace("?", "_") allmyfiles = [] if how_to_list == "file" and os.path.isfile(cacheFile): print "Reading from cached file" f = open(cacheFile) showMessage("Reading files pertaining to " + dataset + "from cache file " + cacheFile) allmyfiles = f.readlines() f.close() elif how_to_list == "python": print "Trying Good PATH" api = DbsApi({"url": dbsUrl}) for afile in api.listDatasetFiles(datasetPath=dataset): allmyfiles.append(afile["LogicalFileName"] + " ") print afile["LogicalFileName"] f = open(cacheFile, "w") f.write("".join(allmyfiles)) else: # If not: rebuild the list showMessage("Going to fetch list of files pertaining to " + str(dataset)) command = 'dbs search --query="find file where dataset=' + dataset + '" --noheader --url=' + dbsUrl print command theList = os.popen(command) list = theList.readlines() for li in list: allmyfiles.append(li) f = open(cacheFile, "w") f.write("".join(allmyfiles)) numberOfFiles = len(allmyfiles) correctList = [] for fileName in allmyfiles: auxiliar = dpmPath + fileName auxiliar = auxiliar[0 : len(auxiliar) - 1] correctList.append(auxiliar) root_logon() N = 0 NEntriesTotal = 0 f2 = open(cacheFile + "_summary.csv", "w") for fileName in correctList: file = TFile.Open(fileName) t = file.Get("Events") N = N + 1 NEntriesTotal = NEntriesTotal + t.GetEntries() print str(N) + " " + fileName + ", NEntries:" + str(t.GetEntries()) + ", NTotal:" + str(NEntriesTotal) print >> f2, "%(N)d,%(filename)s,%(NEntries)d,%(NTotal)d" % { "N": N, "filename": fileName, "NEntries": t.GetEntries(), "NTotal": NEntriesTotal, } # f2.flush() file.Close()