Exemple #1
0
 def _getFolder(self):
     f = coolDbConn.GetDBConn(schema=self.schema,
                              db=Selector.condDB()).getFolder(self.folder)
     if f.versioningMode() == 0: self.tagname = ""
     if self.tagname not in ["HEAD", ""]:
         self.tagname = f.resolveTag(self.tagname)
     return f
    def _getFolder(self):
        from CoolRunQuery.AtlRunQueryRun import RunData
        RunData.DQLogic = self.channelNames
        RunData.DQKeys = self.channelNamesFlat

        f = coolDbConn.GetDBConn(schema=self.schema,
                                 db=Selector.condDB()).getFolder(self.folder)
        if self.useVirtualFlags:
            f = self.VirtualFlagFolder(f)
        else:
            if f.versioningMode() == 0: self.tagname = ""
            if self.tagname not in ["HEAD", ""]:
                self.tagname = f.resolveTag(self.tagname)
        return f
    def GetVirtualFlagLogic(self, db, schema):
        if self.useVirtualFlags: return self.vfl
        try:  # import
            from VirtualFlags import VirtualFlagLogicFolder, VirtualFlagFolder
        except ImportError:
            print "Can't import virtual flags"
            import traceback
            traceback.print_exc()

        self.VirtualFlagFolder = VirtualFlagFolder
        self.vfl = VirtualFlagLogicFolder(
            coolDbConn.GetDBConn(schema=schema, db=db))
        self.logics = self.vfl.get_logic_list()
        self.useVirtualFlags = True
        return self.vfl
Exemple #4
0
    def select(self):
        start = time()
        runlist = []
        folder = coolDbConn.GetDBConn(
            schema="COOLONL_TRIGGER",
            db=Selector.condDB()).getFolder('/TRIGGER/LUMI/LBTIME')
        print('SELOUT Checking for runs in time range "%s"' % self.timelist,
              end='')
        sys.stdout.flush()
        ranges = GetRanges(self.timelist, maxval=long(time() * 1E09))
        currentRun = None
        for rr in ranges:
            objs = folder.browseObjects(rr[0], rr[1] + 86400000000000,
                                        cool.ChannelSelection(0))
            while objs.goToNext():
                obj = objs.currentRef()
                payload = obj.payload()
                runNr = int(payload['Run'])
                if runNr == 0: continue  # mistakenly runnr=0 was stored

                if runNr > 1 << 30:
                    # there is a problem with runs between
                    # usetimes 2009-04-14:00:00:00 2009-04-16:13:00:00
                    # there the runnumbers are off the chart (> 1<<30)
                    continue

                if not currentRun or runNr != currentRun.runNr:
                    if currentRun:
                        currentRun.eor = currentEOR
                        runlist.append(currentRun)
                    currentRun = Run(runNr)
                    currentRun.sor = obj.since()
                lbNr = int(payload['LumiBlock'])
                currentRun.lbtimes.extend([(0, 0)] *
                                          (lbNr - len(currentRun.lbtimes)))
                currentRun.lbtimes[lbNr - 1] = (obj.since(), obj.until())
                currentRun.lastlb = lbNr
                currentEOR = obj.until()
        if currentRun:
            currentRun.eor = currentEOR
            runlist.append(currentRun)

        runlist.sort()
        duration = time() - start
        print(" ==> %i runs selected (%g sec)" % (len(runlist), duration))
        return runlist
Exemple #5
0
    def select(self):

        if len(self.runranges) == 0:  # no run specified
            return []

        runlist = []
        firstRun = self.runranges[0][0]
        start = time()
        folder = coolDbConn.GetDBConn(
            schema="COOLONL_TRIGGER",
            db=Selector.condDB(firstRun)).getFolder('/TRIGGER/LUMI/LBLB')
        print(self, end='')
        sys.stdout.flush()
        currentRun = None
        for rr in self.runranges:
            objs = folder.browseObjects(rr[0] << 32, ((rr[1] + 1) << 32) - 1,
                                        cool.ChannelSelection(0))
            while objs.goToNext():
                obj = objs.currentRef()
                payload = obj.payload()
                runNr, lbNr = RunTimeSelector.runlb(obj.since())
                if lbNr == 0:
                    lbNr = 1  # this is an aweful hack to make MC work (there only one LB exists in LBLB and it is nr 0) need to rethink this
                if not currentRun or runNr > currentRun.runNr:
                    if currentRun:
                        currentRun.eor = currentEOR
                        runlist.append(currentRun)
                    currentRun = Run(runNr)
                    currentRun.sor = payload['StartTime']
                currentRun.lbtimes.extend([(0, 0)] *
                                          (lbNr - len(currentRun.lbtimes)))
                currentRun.lbtimes[lbNr - 1] = (payload['StartTime'],
                                                payload['EndTime'])
                currentRun.lastlb = lbNr
                currentEOR = payload['EndTime']
        if currentRun:
            currentRun.eor = currentEOR
            runlist.append(currentRun)
        runlist.sort()

        duration = time() - start
        print(" ==> %i runs found (%.2f sec)" % (len(runlist), duration))
        return runlist
Exemple #6
0
    def select(self, runlist):
        print (self, end='')
        sys.stdout.flush()
        start = time()
        newrunlist = []
        f = coolDbConn.GetDBConn(schema=self.schema, db=Selector.condDB()).getFolder(self.folder)
        
        sortedChannel = sorted( list( set( self.CoolChannels() ) ) )
        chansel = None
        for ch in sortedChannel:
            if chansel==None: chansel = cool.ChannelSelection(ch,ch,cool.ChannelSelection.sinceBeforeChannel)
            else:             chansel.addChannel(ch)

        runranges = SmartRangeCalulator(runlist,True)
        condData = defaultdict(list)

            
        # access COOL
        for rr in runranges:
            firstrun = runlist[runlist.index(rr[0])]
            lastrun = runlist[runlist.index(rr[1])]
            iovmin=firstrun.sor
            iovmax=lastrun.eor

            objs = f.browseObjects( iovmin, iovmax, chansel)
            while objs.goToNext():
                obj= objs.currentRef()
                ch = obj.channelId()
                for chKey in self.ChannelKeys():
                    (channelNumber, resultKey, payloadKey) = chKey
                    if channelNumber != ch: continue
                    isBlob = (resultKey == 'olc:bcidmask')

                    if isBlob:
                        payloadvalue = obj.payload()[chKey[2]].read()
                    else:
                        payloadvalue = obj.payloadValue(chKey[2])

                    condData[resultKey].append( (IOVRange(obj=obj, timebased=True), payloadvalue) )


        # for each key sort the data by IOV start time
        for k in self.ResultKey(): condData[k].sort()
        
        condDataDict = {}
        for k in self.ResultKey():
            condDataDict[k] = self.getSortedAndCompletedPayloadDict(condData[k],runlist,k)

        for run in runlist:

            rejectSomething = False
            for k in self.ResultKey():

                if not run.runNr in condDataDict[k]:
                    run.addResult(k, "n.a.")
                    continue

                datavec = condDataDict[k][run.runNr]

                if not datavec or len(datavec)==0:
                    run.addResult(k, "n.a.")
                    continue

                if 'n.a.' in datavec: run.showDataIncomplete=True

                anyDataSelected = False
                for iov, data in datavec:
                    self.selDataMissing = False
                    if self.ApplySelection(k) and not self.passes(data,k):
                        run.addResult(k, self.prettyValue(data,k), iov, reject=True)
                        rejectSomething = True
                        continue

                    run.addResult(k, self.prettyValue(data,k), iov)

                    if self.selDataMissing: run.selDataIncomplete = True

            if not (rejectSomething and self.rejectRun(run)):
                newrunlist += [run.runNr]


        runlist = [r for r in runlist if r.runNr in newrunlist]

        duration = time() - start

        if self.applySelection: print (" ==> %i runs found (%.2f sec)" % (len(runlist),duration))
        else:                   print (" ==> Done (%g sec)" % duration)

        return runlist
 def _getFolder(self):
     from CoolRunQuery.AtlRunQueryRun import RunData
     RunData.DefectSelector = self._pass
     self.__db = coolDbConn.GetDBConn('DEFECTS', self.tagname)
     return self.__db  # return the DB, not the folder
    def select(self, runlist):
        start = time()
        print self,
        sys.stdout.flush()

        fL1R = coolDbConn.GetDBConn(
            self.schema, db=Selector.condDB()).getFolder(self.folder)

        for r in runlist:
            menu = r.result['TriggerMenu']

            namelookup = 256 * ['']
            channellist = []
            #print menu
            for tr in menu:
                if not tr.name.startswith("L1_"): continue
                ch = tr.counter
                namelookup[ch] = tr.name
                channellist.append(ch)

            if len(channellist) > 50:
                r.addResult(
                    self.ResultKey()[0],
                    "Too many L1 triggers requested (%i), maximum is 50" %
                    len(channellist))
                continue

            if len(channellist) == 0:
                r.addResult(self.ResultKey()[0], "No match")
                continue

            channellist.sort()
            ch = channellist[0]
            chanselL1 = cool.ChannelSelection(
                ch, ch, cool.ChannelSelection.sinceBeforeChannel)
            for ch in channellist[1:]:
                chanselL1.addChannel(ch)

            iovmin = (r.runNr << 32) + 0
            iovmax = ((r.runNr + 1) << 32) - 1

            countsholder = defaultdict(list)

            # the hlt part
            objs = fL1R.browseObjects(iovmin, iovmax, chanselL1)
            while objs.goToNext():
                obj = objs.currentRef()
                ch = obj.channelId()
                countsholder[namelookup[ch]].append(
                    (obj.since() & 0xFFFFFFFF,
                     obj.payloadValue('BeforePrescale'),
                     obj.payloadValue('AfterPrescale'),
                     obj.payloadValue('L1Accept')))

            r.addResult(self.ResultKey()[0], countsholder)

        duration = time() - start

        if self.applySelection:
            print " ==> %i runs found (%.2f sec)" % (len(runlist), duration)
        else:
            print " ==> Done (%g sec)" % duration

        return runlist