Beispiel #1
0
    def parse(self):

        if self.parsed:
            return

        self.options.parseArguments()
        if self.options.processIdMap != "":
            self.readProcessIdMap(self.options.processIdMap)

        if self.useAAA:
            self.filePrepend = "root://xrootd-cms.infn.it/"
        elif self.useEOS:
            self.filePrepend = "root://eoscms//eos/cms"

        dataset = None
        if self.dataset != "":
            print "Reading dataset (%s) %s" % (self.campaign, self.dataset)
            if self.dryRun and self.getMaxJobs:
                dataset = SamplesManager(
                    "$CMSSW_BASE/src/%s/MetaData/data/%s/datasets.json" %
                    (self.metaDataSrc, self.campaign),
                    self.crossSections,
                ).getDatasetMetaData(self.maxEvents,
                                     self.dataset,
                                     jobId=-1,
                                     nJobs=self.nJobs)
            else:
                dataset = SamplesManager(
                    "$CMSSW_BASE/src/%s/MetaData/data/%s/datasets.json" %
                    (self.metaDataSrc, self.campaign),
                    self.crossSections,
                ).getDatasetMetaData(self.maxEvents,
                                     self.dataset,
                                     jobId=self.jobId,
                                     nJobs=self.nJobs)
            if not dataset:
                print "Could not find dataset %s in campaing %s/%s" % (
                    self.dataset, self.metaDataSrc, self.campaing)
                sys.exit(-1)

        self.dataset = dataset
        # auto-detect data from xsec = 0
        if self.dataset:
            name, xsec, totEvents, files, maxEvents = self.dataset
            if type(xsec) != dict or type(xsec.get("xs", None)) != float:
                print "Warning: you are running on a dataset for which you specified no cross section: \n %s " % name
            else:
                if self.processType == "" and xsec["xs"] == 0.:
                    self.processType = "data"

            self.processId = self.getProcessId(name)

        outputFile = self.outputFile
        if self.jobId != -1:
            outputFile = "%s_%d.root" % (outputFile.replace(".root",
                                                            ""), self.jobId)
        self.setType("outputFile", VarParsing.VarParsing.varType.string)
        self.outputFile = outputFile

        self.parsed = True
Beispiel #2
0
    def parse(self):

        if self.parsed:
            return

        self.options.parseArguments()
        if self.options.processIdMap != "":
            self.readProcessIdMap(self.options.processIdMap)

        if self.useAAA:
            self.filePrepend = "root://xrootd-cms.infn.it/"
        elif self.useEOS:
            self.filePrepend = "root://eoscms//eos/cms"

        dataset = None
        if self.dataset != "":
            print "JOBCONFIG", self.dataset
            print "Reading dataset (%s) %s" % (self.campaign, self.dataset)
            #MATTEO
            if self.dryRun and self.getMaxJobs:
                dataset = SamplesManager(
                    "$CMSSW_BASE/src/%s/MetaData/data/%s/datasets.json" %
                    (self.metaDataSrc, self.campaign),
                    self.crossSections,
                ).getDatasetMetaData(self.maxEvents,
                                     self.dataset,
                                     jobId=-1,
                                     nJobs=self.nJobs)
            else:
                dataset = SamplesManager(
                    "$CMSSW_BASE/src/%s/MetaData/data/%s/datasets.json" %
                    (self.metaDataSrc, self.campaign),
                    self.crossSections,
                ).getDatasetMetaData(self.maxEvents,
                                     self.dataset,
                                     jobId=self.jobId,
                                     nJobs=self.nJobs)
        self.dataset = dataset

        outputFile = self.outputFile
        if self.jobId != -1:
            outputFile = "%s_%d.root" % (outputFile.replace(".root",
                                                            ""), self.jobId)
        self.setType("outputFile", VarParsing.VarParsing.varType.string)
        self.outputFile = outputFile
Beispiel #3
0
    def checkCrossSections(self):
        # checks if all cross sections (apart from data)
        # were specified

        import re
        from flashgg.MetaData.samples_utils import SamplesManager
        from flashgg.MetaData.JobConfig import JobConfig

        # ignore any escaping etc.
        kwargs = {}
        for part in re.split('\s+', self.options.cmdLine):
            key, value = part.split('=', 1)
            kwargs[key] = value

        if not kwargs.has_key('campaign'):
            print >> sys.stderr, "WARNING: campaign not set"

        # automatically get metadata locations right for both high-mass and SM Higgs
        try:
            from diphotons.MetaData.JobConfig import customize
        except ImportError:
            from flashgg.MetaData.JobConfig import customize
        if not kwargs.has_key("metaDataSrc"):
            kwargs["metaDataSrc"] = customize.metaDataSrc
        if not kwargs.has_key("crossSections"):
            kwargs["crossSections"] = customize.crossSections

        # TODO: the following line is duplicated from
        #       JobConfig(..) but we can't make JobConfig.options.parseArguments()
        #       to parse anything other than sys.argv without modifying sys.argv temporarily...
        campaign = kwargs.get('campaign', "")

        jobConfig = JobConfig(**kwargs)

        sm = SamplesManager(
            "$CMSSW_BASE/src/%s/MetaData/data/%s/datasets.json" %
            (jobConfig.metaDataSrc, campaign),
            jobConfig.crossSections,
        )

        hasProblem = False

        # loop over all types of processes (data, signal, background)
        for dsList in self.options.processes.values():
            for idsName in dsList:
                #if args were provided for this dataset, then it is a list...
                if isinstance(idsName, list):
                    dsName = idsName[0]
                #... or just a string
                else:
                    dsName = idsName

                # check if this datasets was selected
                if not self.isSelectedDataset(dsName):
                    # skip this dataset
                    continue

                #----------
                try:
                    name, xsec, totEvents, files, maxEvents = sm.getDatasetMetaData(
                        jobConfig.maxEvents,
                        dsName,
                        jobId=-1,
                        nJobs=jobConfig.nJobs)

                    if xsec == None:
                        print >> sys.stderr, "cross section for", dsName, "not found in", jobConfig.crossSections
                        hasProblem = True

                except Exception, ex:
                    if type(ex) == Exception and (
                            ex.message.startswith(
                                'No dataset matched the request:')
                            or ex.message.startswith(
                                'More then one dataset matched the request:')):
                        print >> sys.stderr, ex.message
                    else:
                        raise