diff --git a/CMGTools/Production/python/eostools.py b/CMGTools/Production/python/eostools.py index d540429ee5fcf..9171aaed0c415 100644 --- a/CMGTools/Production/python/eostools.py +++ b/CMGTools/Production/python/eostools.py @@ -84,6 +84,8 @@ def lfnToPFN( path, tfcProt = 'rfio'): if path.startswith("/store/cmst3/"): path = path.replace("/store/cmst3/","root://eoscms.cern.ch//store/cmst3/") + if path.startswith("/pnfs/psi.ch/cms/trivcat/"): + path = path.replace("/pnfs/psi.ch/cms/trivcat/","root://t3se01.psi.ch//") #print "path to cmsFile():", path entity = cmsIO.cmsFile( path, tfcProt ) # tokens = cmsIO.splitPFN(entity.pfn) @@ -322,8 +324,7 @@ def listFiles(path, rec = False, full_info = False): if full_info: result.append( tokens) else: - result.append( tokens[4]) - # print result + result.append( tokens[4] ) return result def which(cmd): diff --git a/CMGTools/TTHAnalysis/python/samples/ComponentCreator.py b/CMGTools/TTHAnalysis/python/samples/ComponentCreator.py index 71c07be79b52a..08447a3fa65de 100644 --- a/CMGTools/TTHAnalysis/python/samples/ComponentCreator.py +++ b/CMGTools/TTHAnalysis/python/samples/ComponentCreator.py @@ -78,7 +78,28 @@ def makeMCComponentFromEOS(self,name,dataset,path,pattern=".*root",xSec=1): ) return component - + def getFilesFromPSI(self,name,dataset,path,pattern=".*root"): + from CMGTools.Production.dataset import getDatasetFromCache, writeDatasetToCache + if "%" in path: path = path % dataset; + try: + files = getDatasetFromCache('PSI%{path}%{pattern}.pck'.format(path = path.replace('/','_'), pattern = pattern)) + except IOError: + files = [ 'root://t3se01.psi.ch//'+x.replace("/pnfs/psi.ch/cms/trivcat/","") for x in eostools.listFiles('/pnfs/psi.ch/cms/trivcat/'+path) if re.match(pattern,x) ] + if len(files) == 0: + raise RuntimeError, "ERROR making component %s: no files found under %s matching '%s'" % (name,path,pattern) + writeDatasetToCache('PSI%{path}%{pattern}.pck'.format(path = path.replace('/','_'), pattern = pattern), files) + return files + def makeMCComponentFromPSI(self,name,dataset,path,pattern=".*root",xSec=1): + component = cfg.MCComponent( + dataset=dataset, + name = name, + files = self.getFilesFromPSI(name,dataset,path,pattern), + xSection = xSec, + nGenEvents = 1, + triggers = [], + effCorrFactor = 1, + ) + return component def makeDataComponent(self,name,datasets,user,pattern): files=[] @@ -97,7 +118,6 @@ def makeDataComponent(self,name,datasets,user,pattern): return component - def getFiles(self, dataset, user, pattern, useAAA=False): # print 'getting files for', dataset,user,pattern ds = datasetToSource( user, dataset, pattern, True )