Example #1
0
    def __init__(self, options) :
        self.__batch   = options.batch
        self.__loop    = int(options.loop)   if options.loop!=None else None
        self.__nSlices = int(options.slices) if options.slices!=None else 1
        self.__profile = options.profile
        self.__jobId   = options.jobId
        self.__tag     = options.tag
        self.__sample  = options.sample
        self.__site    = options.site if options.site!=None else configuration.sitePrefix()
        self.__tags    = options.tags.split(',') if type(options.tags)==str else options.tags
        self.__samples = options.samples.split(',') if type(options.samples)==str else options.samples
        self.__omit    = options.omit.split(',')
        self.__nocheck = options.nocheck

        self.localStem  = "%s/%s"%(configuration.siteInfo(site = self.__site, key = "localOutputDir" ), self.name)
        self.globalStem = "%s/%s"%(configuration.siteInfo(site = self.__site, key = "globalOutputDir"), self.name)
    
        self.sampleDict = samples.SampleHolder()
        map(self.sampleDict.update,self.listOfSampleDictionaries())

        if self.__tags is True or self.__samples is True :
            for conf in self.configurations :
                print conf['tag']
                if self.__samples is True :
                    print '\n'.join('  '+sample.weightedName for sample in self.filteredSamples(conf))
            sys.exit(0)
                
        if self.__loop!=None :
            os.system("mkdir -p %s"%self.localStem)
            if self.__jobId==None :
                os.system("mkdir -p %s"%self.globalStem)
                self.makeInputFileLists()

        for conf in self.configurations :
            self.listsOfLoopers[conf['tag']] = self.sampleLoopers(conf)
            if self.__jobId==None and self.__loop!=None :
                for looper in self.listsOfLoopers[conf['tag']] :
                    utils.writePickle( self.jobsFile(conf['tag'],looper.name), self.__nSlices )
Example #2
0
#!/usr/bin/env python

import sys,os,tempfile,utils
import configuration
sys.path.extend([configuration.siteInfo(key="CMSSW_lumi")])

try:
    from RecoLuminosity.LumiDB import lumiQueryAPI,inputFilesetParser
except: pass

def jsonToIFP(json) :
    with tempfile.NamedTemporaryFile() as file :
        print >> file, str(json).replace("'",'"')
        file.flush()
        return inputFilesetParser.inputFilesetParser(file.name)

def recordedInvMicrobarns(json) :
    pars = lumiQueryAPI.ParametersObject()
    pars.noWarnings  = True
    pars.norm        = 1.0
    pars.lumiversion = '0001'
    pars.beammode    = 'STABLE BEAMS'

    session,svc =  lumiQueryAPI.setupSession( connectString = 'frontier://LumiCalc/CMS_LUMI_PROD',
                                              parameters = pars, siteconfpath = None, debug = False)
    lumidata =  lumiQueryAPI.recordedLumiForRange (session, pars, jsonToIFP(json))    
    return sum(lumiQueryAPI.calculateTotalRecorded(dataperRun[2]) for dataperRun in lumidata if dataperRun[1])

def recordedInvMicrobarnsShotgun(jsons, cores = 2, cacheDir = './' ) :
    pickles = ["%s/%d.pickle"%(cacheDir,hash(str(sorted([(key,val) for key,val in json.iteritems()])))) for json in jsons]
    def worker(pickle, json) :