Esempio n. 1
0
    def __init__(self, mainTree=None, otherTreesToKeepWhenSkimming=None,
                 leavesToBlackList=None, moveOutputFiles=None, localStem=None,
                 globalStem=None, subDir=None, steps=None, calculables=None,
                 inputFiles=None, name=None, nEventsMax=None, quietMode=None,
                 skip=None, nSlicesFixed=None, nEventsPerSlice=None, byEvents=None):

        for arg in ["mainTree", "otherTreesToKeepWhenSkimming",
                    "leavesToBlackList", "moveOutputFiles", "localStem",
                    "globalStem", "subDir", "steps", "calculables",
                    "inputFiles", "name", "nEventsMax", "quietMode",
                    "skip", "byEvents"]:
            setattr(self, arg, eval(arg))

        if nSlicesFixed is not None:
            assert nEventsPerSlice is None
            self.nSlices = nSlicesFixed
        if nEventsPerSlice is not None:
            assert nSlicesFixed is None
            self.byEvents = True  # until "by chunks" is implemented
            assert 1 <= nEventsPerSlice
            assert configuration.computeEntriesAtMakeFileList()
            num = self.nExpect + 0.0
            self.nSlices = int(math.ceil(num / nEventsPerSlice)) if num else 1
        assert hasattr(self, "nSlices")
        assert 1 <= self.nSlices

        self.trace = configuration.trace() and not any([step.requiresNoTrace() for step in self.steps])
        self.outputDir = self.globalDir #the value will be modified in self.prepareOutputDirectory()
        self.inputDir = self.globalDir 
        self.divisor = None
        self.remainder = None
        self.checkSteps()
Esempio n. 2
0
        def pickleJar(step):
            if step.name=='master' and configuration.computeEntriesAtMakeFileList():
                if self.byEvents:
                    nExpect = self.nExpect / self.nSlices
                    if iSlice < (self.nExpect % self.nSlices):
                        nExpect += 1
                else:
                    nExpect = self.nExpect

                msg = "iSlice: %d, Expect: %d, Actual: %d" % (iSlice, nExpect, step.nPass + step.nFail)
                assert abs(step.nPass + step.nFail - nExpect) < 1 , msg
            inter = set(step.varsToPickle()).intersection(set(['nPass','nFail','outputFileName']))
            assert not inter, "%s is trying to pickle %s, which %s reserved for use by analysisStep."%(step.name, str(inter), ["is","are"][len(inter)>1])
            return dict([ (item, getattr(step,item)) for item in step.varsToPickle()+['nPass','nFail']] +
                        [('outputFileName', getattr(step,'outputFileName').replace(self.outputDir, self.globalDir))])
Esempio n. 3
0
    def setupChains(self) :
        assert self.mainTree not in self.otherTreesToKeepWhenSkimming
        self.chains = dict( [(item,r.TChain("%s/%s"%item)) for item in [self.mainTree]+self.otherTreesToKeepWhenSkimming])
        for (dirName,treeName),chain in self.chains.iteritems() :
            for infile in self.inputFiles : chain.Add(infile[0])
            r.SetOwnership(chain, False)

        if self.inputFiles and not self.quietMode:
            nFiles = len(self.inputFiles)
            nEventsString = ( str(self.chains[self.mainTree].GetEntries()) if configuration.computeEntriesForReport() else
                              "%d (expected)"%self.nExpect if configuration.computeEntriesAtMakeFileList() else
                              "(number not computed)" )
            filesLines = ( '\n'.join(zip(*self.inputFiles)[0]) if len(self.inputFiles) < 5 else
                           '\n'.join(zip(*self.inputFiles[:2])[0]+("...",)[:len(self.inputFiles)-1]+zip(*self.inputFiles[2:][-2:])[0]) )
            plural = nFiles>1
            print utils.hyphens
            print "The %d \"%s\" input file%s:"%(nFiles, self.name, ['','s'][plural])
            print filesLines
            print "contain%s %s events."%(['s',''][plural], nEventsString)
            if self.skip :
                print "Skipping first %d events"%self.skip
            print utils.hyphens
Esempio n. 4
0
 def nEventsFile(fileName):
     if not configuration.computeEntriesAtMakeFileList(): return None
     return utils.nEventsFile(fileName,'/'.join(self.mainTree()))
Esempio n. 5
0
 def nExpect(self):
     if not configuration.computeEntriesAtMakeFileList(): return None
     if not len(self.inputFiles): return 0
     nExpect = sum(zip(*self.inputFiles)[1])
     return nExpect if self.nEventsMax==None else min(nExpect, self.nEventsMax)