コード例 #1
0
 def listBadAdcs(self, rosBeg=0, modBeg=0, rosEnd=5, modEnd=64):
     """
     Print a formatted list of all ADCs with problems.
     """
     self.log().info(
         "==============================================================")
     self.log().info(
         "                 Current list of affected ADCs               ")
     self.log().info(
         "==============================================================")
     for ros in range(rosBeg, rosEnd):
         for mod in range(modBeg,
                          min(modEnd, TileCalibUtils.getMaxDrawer(ros))):
             modName = TileCalibUtils.getDrawerString(ros, mod)
             for chn in range(TileCalibUtils.max_chan()):
                 chnName = "channel %2i" % chn
                 for adc in range(TileCalibUtils.max_gain()):
                     gainName = "LG:"
                     if adc:
                         gainName = "HG:"
                     prbs = self.getAdcProblems(ros, mod, chn, adc)
                     for prbCode in sorted(prbs.keys()):
                         prbDesc = prbs[prbCode]
                         msg = "%s %s %s %2i (%s)" % (
                             modName, chnName, gainName, prbCode, prbDesc)
                         self.log().info(msg)
                         modName = " " * 5
                         chnName = " " * 10
                         gainName = " " * 3
     self.log().info(
         "==============================================================")
コード例 #2
0
def getModuleLabels(partition):
    '''
    This function returns list of Tile module names for given partition.

    Arguments:
        partition -- Tile partition name (LBA, LBC, EBA, EBC)
    '''

    if partition == 'AllPart':
        labels = [str(module) for module in range(1, Tile.MAX_DRAWER + 1)]
    else:
        ros = {'LBA': 1, 'LBC': 2, 'EBA': 3, 'EBC': 4}
        labels = [
            Tile.getDrawerString(ros[partition], module)
            for module in range(0, Tile.MAX_DRAWER)
        ]

    return labels
コード例 #3
0
def TileJetMonitoringConfig(flags, **kwargs):
    ''' Function to configure TileJetMonitorAlgorithm algorithm in the monitoring system.'''

    # Define one top-level monitoring algorithm. The new configuration
    # framework uses a component accumulator.
    from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
    result = ComponentAccumulator()

    from TileGeoModel.TileGMConfig import TileGMCfg
    result.merge(TileGMCfg(flags))

    from LArGeoAlgsNV.LArGMConfig import LArGMCfg
    result.merge(LArGMCfg(flags))

    from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
    result.merge(TileCablingSvcCfg(flags))

    from TileConditions.TileBadChannelsConfig import TileBadChanToolCfg
    badChanTool = result.popToolsAndMerge(TileBadChanToolCfg(flags))

    # The following class will make a sequence, configure algorithms, and link
    # them to GenericMonitoringTools
    from AthenaMonitoring import AthMonitorCfgHelper
    helper = AthMonitorCfgHelper(flags, 'TileMonitoring')

    # Adding an TileJetMonitorAlgorithm algorithm to the helper
    from AthenaConfiguration.ComponentFactory import CompFactory
    tileJetMonAlg = helper.addAlgorithm(CompFactory.TileJetMonitorAlgorithm,
                                        'TileJetMonAlg')

    tileJetMonAlg.TileBadChanTool = badChanTool
    tileJetMonAlg.TriggerChain = ''

    for k, v in kwargs.items():
        setattr(tileJetMonAlg, k, v)

    DoEnergyProfiles = kwargs.get(
        'DoEnergyProfiles',
        tileJetMonAlg._descriptors['DoEnergyProfiles'].default)

    Do1DHistograms = kwargs.get(
        'Do1DHistograms', tileJetMonAlg._descriptors['Do1DHistograms'].default)
    DoEnergyDiffHistograms = kwargs.get(
        'DoEnergyDiffHistograms',
        tileJetMonAlg._descriptors['DoEnergyDiffHistograms'].default)

    if flags.DQ.DataType not in ('heavyioncollisions', 'cosmics'):

        jvtTool = CompFactory.JetVertexTaggerTool()
        jetContainer = kwargs.get(
            'JetContainer', tileJetMonAlg._descriptors['JetContainer'].default)
        jvtTool.JetContainer = jetContainer
        tileJetMonAlg.JVT = jvtTool

        jetCleaningTool = CompFactory.JetCleaningTool()
        jetCleaningTool.CutLevel = "LooseBad"
        jetCleaningTool.DoUgly = False

        tileJetMonAlg.JetCleaningTool = jetCleaningTool
        result.addPublicTool(jetCleaningTool)

        jetPtMin = 20000
        jetTrackingEtaLimit = 2.4
        eventCleaningTool = CompFactory.ECUtils.EventCleaningTool()
        eventCleaningTool.JetCleaningTool = jetCleaningTool
        eventCleaningTool.PtCut = jetPtMin
        eventCleaningTool.EtaCut = jetTrackingEtaLimit
        eventCleaningTool.JvtDecorator = "passJvt"
        eventCleaningTool.OrDecorator = "passOR"
        eventCleaningTool.CleaningLevel = jetCleaningTool.CutLevel

        tileJetMonAlg.EventCleaningTool = eventCleaningTool
        tileJetMonAlg.JetTrackingEtaLimit = jetTrackingEtaLimit
        tileJetMonAlg.JetPtMin = jetPtMin

        tileJetMonAlg.DoEventCleaning = True
        tileJetMonAlg.DoJetCleaning = True

    else:

        tileJetMonAlg.DoEventCleaning = False
        tileJetMonAlg.DoJetCleaning = False

    # 1) Configure histogram with TileJetMonAlg algorithm execution time
    executeTimeGroup = helper.addGroup(tileJetMonAlg, 'TileJetMonExecuteTime',
                                       'Tile/')
    executeTimeGroup.defineHistogram(
        'TIME_execute',
        path='Jet',
        type='TH1F',
        title='Time for execute TileJetMonAlg algorithm;time [#mus]',
        xbins=300,
        xmin=0,
        xmax=300000)

    from TileMonitoring.TileMonitoringCfgHelper import addValueVsModuleAndChannelMaps, getPartitionName
    runNumber = flags.Input.RunNumber[0]

    # 2) Configure 2D histograms (profiles/maps) with Tile channel time vs module and channel per partion (DQ summary)
    channelTimeDQGroup = helper.addGroup(tileJetMonAlg, 'TileJetChanTimeDQ',
                                         'Tile/Jet/')
    addValueVsModuleAndChannelMaps(channelTimeDQGroup,
                                   name='tileJetChanTime',
                                   title='Average time with jets',
                                   path='DQ',
                                   type='TProfile2D',
                                   value='time',
                                   run=str(runNumber))

    gains = ['LG', 'HG']
    partitions = ['LBA', 'LBC', 'EBA', 'EBC']

    # 3a) Configure 1D histograms with Tile channel time per partition
    channelTimeGroup = helper.addGroup(tileJetMonAlg, 'TileJetChanTime',
                                       'Tile/Jet/ChanTime/')
    for partition in partitions:
        title = 'Partition ' + partition + ': Tile Channel Time;time [ns];N'
        name = 'channelTime' + partition
        path = partition
        channelTimeGroup.defineHistogram(name,
                                         title=title,
                                         path=path,
                                         type='TH1F',
                                         xbins=600,
                                         xmin=-30.0,
                                         xmax=30.0)

    # 3b) Configure 1D histograms with Tile channel time per partition for extended barrels without scintillators
    for partition in ['EBA', 'EBC']:
        title = 'Partition ' + partition + ': Tile Channel Time (without scintillators);time [ns];N'
        name = 'channelTime' + partition + '_NoScint'
        path = partition
        channelTimeGroup.defineHistogram(name,
                                         title=title,
                                         path=path,
                                         type='TH1F',
                                         xbins=600,
                                         xmin=-30.0,
                                         xmax=30.0)

    # Energy upper limits of the cell-time histograms
    energiesHG = [
        500, 1000, 2000, 4000, 6000, 8000, 10000, 13000, 16000, 20000
    ]
    energiesLG = [25000, 30000, 40000, 50000, 65000, 80000]
    energiesALL = {'LG': energiesLG, 'HG': energiesHG}
    tileJetMonAlg.CellEnergyUpperLimitsHG = energiesHG
    tileJetMonAlg.CellEnergyUpperLimitsLG = energiesLG

    # 4) Configure histograms with Tile cell time in energy slices per partition and gain
    cellTimeGroup = helper.addGroup(tileJetMonAlg, 'TileJetCellTime',
                                    'Tile/Jet/CellTime/')
    for partition in partitions:
        for gain in gains:
            index = 0
            energies = energiesALL[gain]
            for index in range(0, len(energies) + 1):
                toEnergy = energies[index] if index < len(energies) else None
                fromEnergy = energies[index - 1] if index > 0 else None
                name = 'Cell_time_' + partition + '_' + gain + '_slice_' + str(
                    index)
                title = 'Partition ' + partition + ': ' + gain + ' Tile Cell time in energy range'
                if not toEnergy:
                    title += ' > ' + str(fromEnergy) + ' MeV; time [ns]'
                elif not fromEnergy:
                    title += ' < ' + str(toEnergy) + ' MeV; time [ns]'
                else:
                    title += ' [' + str(fromEnergy) + ' .. ' + str(
                        toEnergy) + ') MeV; time [ns]'
                cellTimeGroup.defineHistogram(name,
                                              title=title,
                                              path=partition,
                                              type='TH1F',
                                              xbins=600,
                                              xmin=-30.0,
                                              xmax=30.0)

    if DoEnergyProfiles:

        # 5) Configure 1D histograms (profiles) with Tile cell energy profile in energy slices per partition and gain
        cellEnergyProfileGroup = helper.addGroup(tileJetMonAlg,
                                                 'TileJetCellEnergyProfile',
                                                 'Tile/Jet/CellTime/')
        for partition in partitions:
            for gain in gains:
                name = 'index_' + partition + '_' + gain
                name += ',energy_' + partition + '_' + gain
                name += ';Cell_ene_' + partition + '_' + gain + '_prof'
                title = 'Partition ' + partition + ': ' + gain + ' Tile Cell energy profile;Slice;Energy [MeV]'
                xmax = len(energiesALL[gain]) + 0.5
                nbins = len(energiesALL[gain]) + 1
                cellEnergyProfileGroup.defineHistogram(name,
                                                       title=title,
                                                       path=partition,
                                                       type='TProfile',
                                                       xbins=nbins,
                                                       xmin=-0.5,
                                                       xmax=xmax)

    else:

        # 6) Configure 1D histograms with Tile cell energy in energy slices per partition, gain and slice
        cellEnergyGroup = helper.addGroup(tileJetMonAlg, 'TileJetCellEnergy',
                                          'Tile/Jet/CellTime/')
        for partition in partitions:
            for gain in gains:
                energies = energiesALL[gain]
                for index in range(0, len(energies) + 1):
                    toEnergy = energies[index] if index < len(
                        energies) else 2 * energies[index - 1]
                    fromEnergy = energies[index - 1] if index > 0 else -1000
                    name = 'Cell_ene_' + partition + '_' + gain + '_slice_' + str(
                        index)
                    title = 'Partition ' + partition + ': ' + gain + ' Tile Cell Energy'
                    title += ' in energy range [' + str(
                        fromEnergy) + ' .. ' + str(
                            toEnergy) + ') MeV;Energy [MeV]'
                    cellEnergyGroup.defineHistogram(name,
                                                    title=title,
                                                    path=partition,
                                                    type='TH1F',
                                                    xbins=100,
                                                    xmin=fromEnergy,
                                                    xmax=toEnergy)

    from TileCalibBlobObjs.Classes import TileCalibUtils as Tile

    if Do1DHistograms:

        # 7) Configure 1D histograms with Tile channel time per channel
        channelTime1DGroup = helper.addGroup(tileJetMonAlg,
                                             'TileJetChanTime1D',
                                             'Tile/Jet/ChanTime/')

        for ros in range(1, Tile.MAX_ROS):
            for module in range(0, Tile.MAX_DRAWER):
                for channel in range(0, Tile.MAX_CHAN):
                    moduleName = Tile.getDrawerString(ros, module)
                    title = 'Time in ' + moduleName + ' channel ' + str(
                        channel) + ';time [ns];N'
                    name = moduleName + '_ch_' + str(channel) + '_1d'
                    path = getPartitionName(ros) + '/' + moduleName
                    channelTime1DGroup.defineHistogram(name,
                                                       title=title,
                                                       path=path,
                                                       type='TH1F',
                                                       xbins=600,
                                                       xmin=-30.0,
                                                       xmax=30.0)

    if DoEnergyDiffHistograms:

        # 7) Configure 1D histograms with Tile cell relative energy difference between two channels per even channel
        energyDiffGroup = helper.addGroup(tileJetMonAlg, 'TileJetEnergyDiff',
                                          'Tile/Jet/EnergyDiff/')

        for ros in range(1, Tile.MAX_ROS):
            for module in range(0, Tile.MAX_DRAWER):
                for channel in range(0, Tile.MAX_CHAN):
                    if not channel % 2:
                        for gain in gains:
                            moduleName = Tile.getDrawerString(ros, module)
                            title = 'Tile Cell Energy difference in ' + moduleName + ' channel ' + str(
                                channel) + ' ' + gain
                            title += ';#frac{ene1 - ene2}{ene1 + ene2}'
                            name = moduleName + '_enediff_' + gain + '_ch1_' + str(
                                channel)
                            path = getPartitionName(ros) + '/' + moduleName
                            energyDiffGroup.defineHistogram(name,
                                                            title=title,
                                                            path=path,
                                                            type='TH1F',
                                                            xbins=100,
                                                            xmin=-1.0,
                                                            xmax=1.0)

    accumalator = helper.result()
    result.merge(accumalator)
    return result
コード例 #4
0
log.info("Initializing folder %s with tag %s", folderPath, folderTag)

iovAll = []
iovList = []
iovUntil = []
iovListMOD = []
iovListCMT = []
iovUntilCMT = []
blobReader = TileCalibTools.TileBlobReader(dbr, folderPath, folderTag)
if iov:
    #=== filling the iovList
    log.info("Looking for IOVs")
    if moduleList != ['CMT']:
        for ros in range(rosmin, 5):
            for mod in range(min(64, TileCalibUtils.getMaxDrawer(ros))):
                modName = TileCalibUtils.getDrawerString(ros, mod)
                if len(
                        moduleList
                ) > 0 and modName not in moduleList and 'ALL' not in moduleList:
                    iovAll += [[]]
                else:
                    iovMod = blobReader.getIOVsWithinRange(ros, mod)
                    iovAll += [iovMod]
                    iovList += iovMod
        if 'ALL' in moduleList:
            moduleList.remove('ALL')
    else:
        for ros in range(rosmin, 5):
            iovAll += [[]] * min(64, TileCalibUtils.getMaxDrawer(ros))
    if 'CMT' in moduleList:
        iovListMOD = iovList
コード例 #5
0
def TileRawChannelNoiseMonitoringConfig(flags, **kwargs):
    ''' Function to configure TileRawChannelNoiseMonitorAlgorithm algorithm in the monitoring system.'''

    # Define one top-level monitoring algorithm. The new configuration
    # framework uses a component accumulator.
    from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
    result = ComponentAccumulator()

    from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
    result.merge(TileDQstatusAlgCfg(flags))

    from TileGeoModel.TileGMConfig import TileGMCfg
    result.merge(TileGMCfg(flags))

    from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
    result.merge(TileCablingSvcCfg(flags))

    from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
    result.merge(TileBadChannelsCondAlgCfg(flags, **kwargs))

    if 'TileCondToolEmscale' not in kwargs:
        from TileConditions.TileEMScaleConfig import TileCondToolEmscaleCfg
        emScaleTool = result.popToolsAndMerge(TileCondToolEmscaleCfg(flags))
        kwargs['TileCondToolEmscale'] = emScaleTool

    kwargs.setdefault('CheckDCS', flags.Tile.useDCS)
    if kwargs['CheckDCS']:
        from TileConditions.TileDCSConfig import TileDCSCondAlgCfg
        result.merge(TileDCSCondAlgCfg(flags))

    #kwargs.setdefault('TriggerChain', 'HLT_noalg_cosmiccalo_L1RD1_EMPTY') #FIXME
    kwargs.setdefault('TriggerTypes', [0x82])
    kwargs.setdefault('Gain', 1)
    kwargs.setdefault('TileRawChannelContainer',
                      flags.Tile.RawChannelContainer)

    # The following class will make a sequence, configure algorithms, and link
    # them to GenericMonitoringTools
    from AthenaMonitoring import AthMonitorCfgHelper
    helper = AthMonitorCfgHelper(flags, 'TileRawChanNoiseMonitoring')

    # Adding an TileCellMonitorAlgorithm algorithm to the helper
    from AthenaConfiguration.ComponentFactory import CompFactory
    TileRawChannelNoiseMonitorAlgorithm = CompFactory.TileRawChannelNoiseMonitorAlgorithm
    tileRawChanNoiseMonAlg = helper.addAlgorithm(
        TileRawChannelNoiseMonitorAlgorithm, 'TileRawChanNoiseMonAlg')

    for k, v in kwargs.items():
        setattr(tileRawChanNoiseMonAlg, k, v)

    run = str(flags.Input.RunNumber[0])

    # 1) Configure histogram with TileRawChanNoiseMonAlg algorithm execution time
    executeTimeGroup = helper.addGroup(tileRawChanNoiseMonAlg,
                                       'TileRawChanNoiseMonExecuteTime',
                                       'Tile/')
    executeTimeGroup.defineHistogram(
        'TIME_execute',
        path='RawChannelNoise',
        type='TH1F',
        title='Time for execute TileRawChanNoiseMonAlg algorithm;time [#mus]',
        xbins=100,
        xmin=0,
        xmax=100000)

    from TileCalibBlobObjs.Classes import TileCalibUtils as Tile

    from TileMonitoring.TileMonitoringCfgHelper import getPartitionName, getCellName, getGainName

    # 2) Configure histograms with Tile raw channel amplitude per channel
    gainName = getGainName(kwargs['Gain'])
    dimensions = [
        int(Tile.MAX_ROS) - 1,
        int(Tile.MAX_DRAWER),
        int(Tile.MAX_CHAN)
    ]
    chanAmpArray = helper.addArray(dimensions,
                                   tileRawChanNoiseMonAlg,
                                   'TileRawChannelNoise',
                                   topPath='Tile/RawChannelNoise')
    for postfix, tool in chanAmpArray.Tools.items():
        ros, module, channel = [int(x) for x in postfix.split('_')[1:]]

        partition = getPartitionName(ros + 1)
        moduleName = Tile.getDrawerString(ros + 1, module)
        cellName = getCellName(partition, channel)

        title = 'Run %s %s: Tile cell %s / channel %s amplitude (%s);Amplitude [ADC]'
        title = title % (run, moduleName, cellName, str(channel), gainName)
        name = 'amplitude;TileRawChannelNoise_%s_%s_ch_%s_%s' % (
            moduleName, cellName, str(channel), gainName)

        tool.defineHistogram(name,
                             title=title,
                             path=partition,
                             type='TH1F',
                             xbins=81,
                             xmin=-20.25,
                             xmax=20.25)

    accumalator = helper.result()
    result.merge(accumalator)
    return result
コード例 #6
0
    def commitToDb(self,
                   db,
                   folderPath,
                   tag,
                   bitPatVer,
                   author,
                   comment,
                   since,
                   until=(MAXRUN, MAXLBK),
                   untilCmt=None,
                   moduleList=[]):
        """
        Commits the differences compared to the set of bad channels read in with the
        initialze function to the provided database.
        - author  : author name (string)
        - comment : a comment (string)
        - sinceRun, sinceLbk : start of IOV for which bad channels are valid
        - untilRun, untilLbk : end   of IOV for which bad channels are valid
        """
        #=== check db status
        try:
            if not db.isOpen():
                raise Exception("DB not open: ", db.databaseId())
        except Exception as e:
            raise (e)

        multiVersion = self.__multiVersion
        writer = TileCalibTools.TileBlobWriter(db, folderPath, 'Bch',
                                               multiVersion)
        if len(comment) or isinstance(author, tuple):
            writer.setComment(author, comment)
        nUpdates = 0
        goodComment = True
        #=== get latest state from db
        if moduleList != ['CMT']:
            if since != (MINRUN, MINLBK):
                justBefore = list(since)
                if justBefore[1] > MINLBK:
                    justBefore[1] = justBefore[1] - 1
                else:
                    justBefore[0] = justBefore[0] - 1
                    justBefore[1] = MAXLBK
                justBefore = tuple(justBefore)
                if self.__mode != 2:
                    self.log().info(
                        "Reading db state just before %s, i.e. at %s", since,
                        justBefore)
                    self.__updateFromDb(db, folderPath, tag, justBefore, 0)
                else:
                    self.log().info(
                        "Using previous bad channel list from input DB")
                self.log().info(
                    "And comparing it with new list of bad channels")
            else:
                if self.__mode != 2:
                    reader = TileCalibTools.TileBlobReader(db, folderPath, tag)
                    multiVersion = reader.folderIsMultiVersion()
                self.log().info(
                    "Filling db from %s, resetting old status cache",
                    list(since))
                self.__oldStat = len(self.__oldStat) * [TileBchStatus()]

            #=== print status information
            self.log().info("Committing changes to DB \'%s\'", db.databaseId())
            self.log().info(
                "... using tag \'%s\' and [run,lumi] range: [%i,%i] - [%i,%i]",
                tag, since[0], since[1], until[0], until[1])
            if isinstance(author, tuple) and len(author) == 3:
                self.log().info("... author : \'%s\'", author[0])
                self.log().info("... comment: \'%s\'", author[1])
            else:
                self.log().info("... author : \'%s\'", author)
                self.log().info("... comment: \'%s\'", comment)

            #=== default for drawer initialization
            loGainDefVec = cppyy.gbl.std.vector('unsigned int')()
            loGainDefVec.push_back(0)
            hiGainDefVec = cppyy.gbl.std.vector('unsigned int')()
            hiGainDefVec.push_back(0)
            comChnDefVec = cppyy.gbl.std.vector('unsigned int')()
            comChnDefVec.push_back(0)
            cppyy.makeClass('std::vector<unsigned int>')
            defVec = cppyy.gbl.std.vector('std::vector<unsigned int>')()
            defVec.push_back(loGainDefVec)
            defVec.push_back(hiGainDefVec)
            defVec.push_back(comChnDefVec)

            #=== loop over the whole detector
            bchDecoder = TileBchDecoder(bitPatVer)
            for ros in range(0, TileCalibUtils.max_ros()):
                for mod in range(TileCalibUtils.getMaxDrawer(ros)):
                    modName = TileCalibUtils.getDrawerString(ros, mod)
                    nChange = self.checkModuleForChanges(ros, mod)
                    if nChange == 0 and (len(moduleList) == 0
                                         or modName not in moduleList
                                         or 'ALL' not in moduleList):
                        #=== do nothing if nothing changed
                        continue
                    if nChange == -1:
                        nUpdates += 1
                        self.log().info("Drawer %s reset to GOOD", modName)
                        if modName not in comment and not (
                                "ONL" not in folderPath
                                or "syncALL" not in comment):
                            goodComment = False
                            self.log().error(
                                "Comment string - '%s' - doesn't contain drawer %s",
                                comment, modName)
                        writer.zeroBlob(ros, mod)
                    else:
                        nUpdates += 1
                        self.log().info("Applying %2i changes to drawer %s",
                                        nChange, modName)
                        if modName not in comment and ("ONL" not in folderPath
                                                       or "syncALL"
                                                       not in comment):
                            goodComment = False
                            self.log().error(
                                "Comment string - '%s' - doesn't contain drawer %s",
                                comment, modName)
                        drawer = writer.getDrawer(ros, mod)
                        drawer.init(defVec, TileCalibUtils.max_chan(),
                                    bitPatVer)
                        for chn in range(TileCalibUtils.max_chan()):
                            #=== get low gain bit words
                            wordsLo = bchDecoder.encode(
                                self.getAdcStatus(ros, mod, chn, 0))
                            chBits = wordsLo[0]
                            loBits = wordsLo[1]
                            #=== get high gain bit words
                            wordsHi = bchDecoder.encode(
                                self.getAdcStatus(ros, mod, chn, 1))
                            chBits = wordsHi[0] | chBits
                            hiBits = wordsHi[1]
                            #=== set low, high and common channel word in calibDrawer
                            drawer.setData(chn, 0, 0, loBits)
                            drawer.setData(chn, 1, 0, hiBits)
                            drawer.setData(chn, 2, 0, chBits)
                            #=== synchronizing channel status in low and high gain
                            if wordsLo[0] != chBits:
                                self.log().info(
                                    "Drawer %s ch %2d - sync LG status with HG ",
                                    modName, chn)
                                status = TileBchStatus(
                                    bchDecoder.decode(chBits, loBits))
                                self.setAdcStatus(ros, mod, chn, 0, status)
                            if wordsHi[0] != chBits:
                                self.log().info(
                                    "Drawer %s ch %2d - sync HG status with LG ",
                                    modName, chn)
                                status = TileBchStatus(
                                    bchDecoder.decode(chBits, hiBits))
                                self.setAdcStatus(ros, mod, chn, 1, status)

        #=== register
        if nUpdates > 0 or moduleList == ['CMT']:
            if goodComment:
                self.log().info(
                    "Attempting to register %i modified drawers...", nUpdates)
                if untilCmt is not None and untilCmt != until:
                    if moduleList != ['CMT'] and until > since:
                        writer.register(since, until, tag, 1)
                    if untilCmt > since:
                        writer.register(since, untilCmt, tag, -1)
                else:
                    writer.register(since, until, tag)
            else:
                self.log().error(
                    "Aborting update due to errors in comment string")
        else:
            self.log().warning(
                "No drawer modifications detected, ignoring commit request")
コード例 #7
0
def TileRawChannelTimeMonitoringConfig(flags, **kwargs):
    ''' Function to configure TileRawChannelTimeMonitorAlgorithm algorithm in the monitoring system.'''

    # Define one top-level monitoring algorithm. The new configuration
    # framework uses a component accumulator.
    from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
    result = ComponentAccumulator()

    from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
    result.merge(TileDQstatusAlgCfg(flags))

    from TileGeoModel.TileGMConfig import TileGMCfg
    result.merge(TileGMCfg(flags))

    from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
    result.merge(TileCablingSvcCfg(flags))

    from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
    result.merge(TileBadChannelsCondAlgCfg(flags, **kwargs))

    kwargs.setdefault('CheckDCS', flags.Tile.useDCS)
    if kwargs['CheckDCS']:
        from TileConditions.TileDCSConfig import TileDCSCondAlgCfg
        result.merge(TileDCSCondAlgCfg(flags))

    kwargs.setdefault('TriggerChain', '')

    # Partition pairs to monitor average time difference between partitions (ROS - 1)
    partitionPairs = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]
    kwargs.setdefault('PartitionTimeDiffferncePairs', partitionPairs)

    # The following class will make a sequence, configure algorithms, and link
    # them to GenericMonitoringTools
    from AthenaMonitoring import AthMonitorCfgHelper
    helper = AthMonitorCfgHelper(flags, 'TileRawChannelTimeMonitoring')

    # Adding an TileCellMonitorAlgorithm algorithm to the helper
    from AthenaConfiguration.ComponentFactory import CompFactory
    TileRawChannelTimeMonitorAlgorithm = CompFactory.TileRawChannelTimeMonitorAlgorithm
    tileRawChanTimeMonAlg = helper.addAlgorithm(
        TileRawChannelTimeMonitorAlgorithm, 'TileRawChanTimeMonAlg')

    for k, v in kwargs.items():
        setattr(tileRawChanTimeMonAlg, k, v)

    run = str(flags.Input.RunNumber[0])

    # 1) Configure histogram with TileRawChannelTimeMonAlg algorithm execution time
    executeTimeGroup = helper.addGroup(tileRawChanTimeMonAlg,
                                       'TileRawChanTimeMonExecuteTime',
                                       'Tile/')
    executeTimeGroup.defineHistogram(
        'TIME_execute',
        path='RawChannelTime',
        type='TH1F',
        title='Time for execute TileRawChanTimeMonAlg algorithm;time [#mus]',
        xbins=100,
        xmin=0,
        xmax=100000)

    from TileMonitoring.TileMonitoringCfgHelper import addTileModuleChannelMapsArray

    # 2) Configure histograms with status of Tile channel time per partition
    addTileModuleChannelMapsArray(helper,
                                  tileRawChanTimeMonAlg,
                                  name='TileAverageTime',
                                  title='Tile average time',
                                  path='Tile/RawChannelTime/Summary',
                                  type='TProfile2D',
                                  value='time',
                                  run=run)

    from TileMonitoring.TileMonitoringCfgHelper import addTile2DHistogramsArray

    # 3) Configure histograms with Tile partition average time vs luminosity block per partition
    addTile2DHistogramsArray(
        helper,
        tileRawChanTimeMonAlg,
        name='TileAverageTimeLB',
        xvalue='lumiBlock',
        yvalue='time',
        type='TH2D',
        title='Tile Average time vs LumiBlock;LumiBlock;t [ns]',
        path='Tile/RawChannelTime/Summary',
        run=run,
        perPartition=True,
        xbins=3000,
        xmin=-0.5,
        xmax=2999.5,
        ybins=149,
        ymin=-74.5,
        ymax=74.5)

    from TileMonitoring.TileMonitoringCfgHelper import getPartitionName

    # 4) Configure histograms with Tile partition average time difference vs luminosity block
    partitionPairs = kwargs['PartitionTimeDiffferncePairs']
    partTimeDiffVsLBArray = helper.addArray([len(partitionPairs)],
                                            tileRawChanTimeMonAlg,
                                            'TileAverageTimeDifferenceLB',
                                            topPath='Tile/RawChannelTime')
    for postfix, tool in partTimeDiffVsLBArray.Tools.items():
        pairIdx = int(postfix.split('_').pop())
        partitionName1, partitionName2 = [
            getPartitionName(ros + 1) for ros in partitionPairs[pairIdx]
        ]

        title = 'Run %s: Average time between %s and %s' % (
            run, partitionName1, partitionName2)
        title += ' vs luminosity block;LumiBlock;t [ns]'
        name = 'lumiBlock,time;TileAverageTimeDifferenceLB_%s-%s' % (
            partitionName1, partitionName2)

        tool.defineHistogram(name,
                             title=title,
                             path='Summary',
                             type='TProfile',
                             xbins=1000,
                             xmin=-0.5,
                             xmax=999.5,
                             opt='kAddBinsDynamically')

    from TileCalibBlobObjs.Classes import TileCalibUtils as Tile

    # 5) Configure histograms with Tile digitizer time vs luminosity block per digitizer
    maxDigitizer = 8
    digiTimeVsLBArray = helper.addArray(
        [int(Tile.MAX_ROS - 1),
         int(Tile.MAX_DRAWER), maxDigitizer],
        tileRawChanTimeMonAlg,
        'TileDigitizerTimeLB',
        topPath='Tile/RawChannelTime')
    for postfix, tool in digiTimeVsLBArray.Tools.items():
        ros, module, digitizer = [int(x) for x in postfix.split('_')[1:]]

        moduleName = Tile.getDrawerString(ros + 1, module)
        title = 'Run ' + run + ' ' + moduleName + ' Digitizer ' + str(
            digitizer)
        title += ': Time vs luminosity block;LumiBlock;t [ns]'
        name = 'lumiBlock,time;TileDigitizerTimeLB_' + moduleName + '_DIGI_' + str(
            digitizer)
        path = getPartitionName(ros + 1) + '/' + moduleName

        tool.defineHistogram(name,
                             title=title,
                             path=path,
                             type='TProfile',
                             xbins=1000,
                             xmin=-0.5,
                             xmax=999.5,
                             opt='kAddBinsDynamically')

    accumalator = helper.result()
    result.merge(accumalator)
    return result
コード例 #8
0
folder1 = "/TILE/ONL01/NOISE/SAMPLE"
folder2 = "/TILE/ONL01/NOISE/OFNI"
if 'COMP200' in schema:
    folder1 = "/TILE/OFL01/NOISE/SAMPLE"
log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,
         drawer, run, lumi)
for folderPath in [folder1, folder2]:

    folderTag = TileCalibTools.getFolderTag(db, folderPath, tag)
    log.info("Initializing folder %s with tag %s", folderPath, folderTag)
    blobReader = TileCalibTools.TileBlobReader(db, folderPath, folderTag)
    log.info("... %s", blobReader.getComment((run, lumi)))
    blob = blobReader.getDrawer(ros, drawer, (run, lumi))

    if folderPath.find("SAMPLE") != -1:
        ped = blob.getData(channel, adc, 0)
        hfn = blob.getData(channel, adc, 1)
        lfn = blob.getData(channel, adc, 2)
    else:
        rms = blob.getData(channel, adc, 0)
        plp = blob.getData(channel, adc, 1)

log.info("\n")
print(
    "%s ch %i gn %i :  PED = %f  HFN = %f  LFN = %f    OF_RMS = %f  PILEUP = %f"
    % (TileCalibUtils.getDrawerString(
        ros, drawer), channel, adc, ped, hfn, lfn, rms, plp))

#=== close DB
db.closeDatabase()
コード例 #9
0
#=== get drawer with status at given run
log.info("Initializing ros %d, drawer %d for run %d, lumiblock %d", ros,
         drawer, run, lumi)
log.info("... %s", blobReader.getComment((run, lumi)))
ofc = blobReader.getDrawer(ros, drawer, (run, lumi))

#=== get other OFC parameters
nchann = ofc.getNChans()
nfields = ofc.getNFields()
nsamples = ofc.getNSamples()
nphases = ofc.getNPhases()
log.info("")
log.info("nchann   = %d", nchann)
log.info("nfields  = %d", nfields)
log.info("nphases  = %d", nphases)
log.info("nsamples = %d", nsamples)
log.info("")
log.info("OFC for %s channel %d adc %d field %d\n",
         TileCalibUtils.getDrawerString(ros, drawer), channel, adc, field)

#=== get OFC field for given adc, sample and phase
for iphase in range(abs(nphases)):
    phase = ofc.getPhase(channel, adc, iphase)
    msg = "phase %6.1f ns :" % phase
    for smp in range(0, nsamples):
        msg += " %f" % ofc.getOfc(field, channel, adc, phase, smp)
    print(msg)

#=== close DB
db.closeDatabase()
コード例 #10
0
comment = blobReader.getComment(pointInTime)
print("Comment: \"%s\"" % comment)

#=== Loop over the whole detector
#--- including default drawers with ros = [0,...,19]
for ros in range(TileCalibUtils.max_ros()):
    for mod in range(TileCalibUtils.getMaxDrawer(ros)):

        #=== get the TileCalibDrawerFlt correcponding to module
        drawer = blobReader.getDrawer(ros, mod, pointInTime)

        #=== loop over all the channels
        for chn in range(TileCalibUtils.max_chan()):
            for adc in range(TileCalibUtils.max_gain()):

                ped = drawer.getData(chn, adc, 0)
                hfn = drawer.getData(chn, adc, 1)

                #=== currently lfn is not filled, but should be in the future
                lfn = 0.
                if drawer.getObjSizeUint32() > 2:
                    lfn = drawer.getData(chn, adc, 2)

                print(
                    "%s, channel=%2i, gain=%i  -> ped=%5.4f\thfn=%5.4f\tlfn=%5.4f"
                    % (TileCalibUtils.getDrawerString(
                        ros, mod), chn, adc, ped, hfn, lfn))

#=== close the database connection
db.closeDatabase()