Ejemplo n.º 1
0
def _setup():
    rn = 0
    try:
        from RecExConfig.AutoConfiguration import GetRunNumber
        rn = GetRunNumber()
    except Exception, e:
        print " cannot find run number "
Ejemplo n.º 2
0
def _setup():
    rn = 0
    try:
        from RecExConfig.AutoConfiguration import GetRunNumber
        rn = GetRunNumber()
    except Exception:
        print(" cannot find run number ")
    if (rn is not None):
        from LArConditionsCommon.LArRunFormat import getLArFormatForRun
        larcool = getLArFormatForRun(rn)
    else:
        larcool = None
    return larcool
Ejemplo n.º 3
0
def _setup():
    from AthenaCommon.Logging import logging
    logGetCool = logging.getLogger('GetCool')
    logGetCool.debug("Getting CoolConvUtilities object...")

    from RecExConfig.AutoConfiguration import GetRunNumber
    from RecExConfig.AutoConfiguration import GetLBNumber
    rn = GetRunNumber()
    lb = GetLBNumber()

    from CoolConvUtilities.MagFieldUtils import getFieldForRun

    if lb == None:
        logGetCool.info(rn)
        cool = getFieldForRun(rn)
    else:
        # MagFieldDCSInfo
        cool = getFieldForRun(run=rn, lumiblock=lb)
    return cool
Ejemplo n.º 4
0
def TileMBTSMonitoringConfigOld(flags, **kwargs):
    ''' Function to configure TileMBTSMonitorAlgorithm algorithm in the old monitoring system.'''

    from AthenaMonitoring import AthMonitorCfgHelperOld
    from AthenaCommon.GlobalFlags import globalflags

    if globalflags.InputFormat().lower() == 'pool':
        kwargs.setdefault('TileDigitsContainer', 'TileDigitsFlt')

    helper = AthMonitorCfgHelperOld(flags, 'TileMBTSMonAlgCfg')

    from RecExConfig.AutoConfiguration import GetRunNumber
    runNumber = GetRunNumber()

    from TileMonitoring.TileMonitoringConf import TileMBTSMonitorAlgorithm
    _TileMBTSMonitoringConfigCore(helper, TileMBTSMonitorAlgorithm, runNumber,
                                  **kwargs)

    return helper.result()
Ejemplo n.º 5
0
# Bytestream to TrigT1Calo objects conversions
include.block(
    "TrigT1CaloCalibConditions/L1CaloCalibConditionsTier0_jobOptions.py")

from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
from AthenaCommon.GlobalFlags import globalflags
from RecExConfig.AutoConfiguration import GetRunNumber
# Need something better eventually
if athenaCommonFlags.isOnline:
    run = 2
elif globalflags.DataSource() == "data":
    run = 1 if (GetRunNumber() < 230000) else 2
else:  # MC
    run = 2

include(
    "TrigT1CaloCalibConditions/L1CaloCalibConditionsTier0Run%d_jobOptions.py" %
    run)
Ejemplo n.º 6
0
from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__JEMEnergySim
from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__RoIROD
from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__CPCMX
from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__JetCMX
from TrigT1CaloSim.TrigT1CaloSimConf import LVL1__EnergyCMX

# Get the algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()

# Get RunNumber from input file
_my_run_number = None
try:
    # first attempt RecExConfig ...
    from RecExConfig.AutoConfiguration import GetRunNumber
    _my_run_number = GetRunNumber()
    # sometime GetRunNumber doesn't raise an exception if something goes wrong ...
    if _my_run_number < 100000: raise ValueError('non-sensible RunNumber')
except BaseException, E:
    log.info('Exception retrieving RunNumber from RecExConfig.AutoConfiguration: %s' % E)
    #  let's see if we are lucky with AthFile directly ...
    try:
        import PyUtils.AthFile as athFile
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        af = athFile.fopen(athenaCommonFlags.BSRDOInput()[0])
        _my_run_number = af.run_number[0] # don't modify global state
    except BaseException, EE:
        log.info('Exception retrieving RunNumber from AthFile: %s' % EE)
        # one last shot ...
        try:
            global _run_number
Ejemplo n.º 7
0
    def configure(self):
        from AthenaCommon.Logging import logging
        mlog = logging.getLogger('CaloCellGetter::configure:')
        mlog.info('entering')

        doStandardCellReconstruction = True
        from CaloRec.CaloCellFlags import jobproperties

        if not jobproperties.CaloCellFlags.doFastCaloSim.statusOn:
            doFastCaloSim = False
            mlog.info("doFastCaloSim not set, so not using it")
        else:
            doFastCaloSim = jobproperties.CaloCellFlags.doFastCaloSim()
            if doFastCaloSim:
                mlog.info("doFastCaloSim requested")
                doStandardCellReconstruction = False
                if jobproperties.CaloCellFlags.doFastCaloSimAddCells():
                    doStandardCellReconstruction = True
                    mlog.info(
                        "doFastCaloSimAddCells requested: FastCaloSim is added to fullsim calorimeter"
                    )
                else:
                    mlog.info(
                        "doFastCaloSimAddCells not requested: Stand alone FastCaloSim is running"
                    )
            else:
                mlog.info("doFastCaloSim explicitly not requested")

        # get handle to upstream object
        # handle tile

        if doStandardCellReconstruction:
            # handle LAr
            import traceback
            try:
                from LArROD.LArRODFlags import larRODFlags
                from AthenaCommon.GlobalFlags import globalflags
                if larRODFlags.readDigits() and globalflags.DataSource(
                ) == 'data':
                    from AthenaCommon.KeyStore import CfgItemList
                    CfgItemList("KeyStore_inputFile").removeItem(
                        "LArRawChannelContainer#LArRawChannels")
                if (not larRODFlags.readDigits()
                    ) and globalflags.InputFormat() == 'bytestream':
                    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                    try:
                        if not "LArRawChannelContainer/LArRawChannels" in svcMgr.ByteStreamAddressProviderSvc.TypeNames:
                            svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
                                "LArRawChannelContainer/LArRawChannels"
                            ]
                    except:
                        mlog.warning(
                            "Cannot remove LArRawChannelContainer/LArRawChannels from bytestream list"
                        )
                from LArROD.LArRawChannelGetter import LArRawChannelGetter
                theLArRawChannelGetter = LArRawChannelGetter()
            except:
                mlog.error("could not get handle to LArRawChannel Quit")
                print traceback.format_exc()
                return False

            if not theLArRawChannelGetter.usable():
                if not self.ignoreConfigError():
                    mlog.error("LArRawChannelGetter unusable. Quit.")
                    return False
                else:
                    mlog.error(
                        "LArRawChannelGetter unusable. Continue nevertheless")

        # writing of thinned digits
        if jobproperties.CaloCellFlags.doLArThinnedDigits.statusOn and jobproperties.CaloCellFlags.doLArThinnedDigits(
        ):
            from AthenaCommon.GlobalFlags import globalflags
            if globalflags.DataSource() == 'data':
                try:
                    from LArROD.LArDigits import DefaultLArDigitThinner
                    LArDigitThinner = DefaultLArDigitThinner(
                        'LArDigitThinner'
                    )  # automatically added to topSequence
                    LArDigitThinner.InputContainerName = "FREE"
                    LArDigitThinner.OutputContainerName = "LArDigitContainer_Thinned"
                except Exception:
                    treatException("Problem with LArDigitThinner ")

        # now configure the algorithm, part of this could be done in a separate class
        # cannot have same name
        try:
            from CaloRec.CaloRecConf import CaloCellMaker
        except:
            mlog.error("could not import CaloRec.CaloCellMaker")
            print traceback.format_exc()
            return False

        theCaloCellMaker = CaloCellMaker()
        self._CaloCellMakerHandle = theCaloCellMaker

        from AthenaCommon.AppMgr import ToolSvc

        if doStandardCellReconstruction:
            # configure CaloCellMaker here
            # check LArCellMakerTool_jobOptions.py for full configurability
            # FIXME

            from RecExConfig.RecFlags import rec

            if rec.doLArg():
                try:
                    from LArCellRec.LArCellRecConf import LArCellBuilderFromLArRawChannelTool
                    theLArCellBuilder = LArCellBuilderFromLArRawChannelTool()
                except:
                    mlog.error(
                        "could not get handle to LArCellBuilderFromLArRawChannel Quit"
                    )
                    print traceback.format_exc()
                    return False

                if jobproperties.CaloCellFlags.doLArCreateMissingCells():
                    # bad channel tools
                    try:
                        from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
                        theLArBadChannelTool = LArBadChanTool()
                    except:
                        mlog.error("could not access bad channel tool Quit")
                        print traceback.format_exc()
                        return False
                    ToolSvc += theLArBadChannelTool
                    theLArCellBuilder.addDeadOTX = True
                    theLArCellBuilder.badChannelTool = theLArBadChannelTool

                # add the tool to list of tool ( should use ToolHandle eventually)
                ToolSvc += theLArCellBuilder
                theCaloCellMaker.CaloCellMakerToolNames += [theLArCellBuilder]

            if rec.doTile():

                from AthenaCommon.GlobalFlags import globalflags
                if globalflags.DataSource(
                ) == 'data' and globalflags.InputFormat() == 'bytestream':
                    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
                    try:
                        svcMgr.ByteStreamCnvSvc.ROD2ROBmap = ["-1"]
                        if not "TileDigitsContainer/TileDigitsCnt" in svcMgr.ByteStreamAddressProviderSvc.TypeNames:
                            svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
                                "TileBeamElemContainer/TileBeamElemCnt",
                                "TileDigitsContainer/TileDigitsCnt",
                                "TileL2Container/TileL2Cnt",
                                "TileLaserObject/TileLaserObj",
                                "TileMuonReceiverContainer/TileMuRcvCnt"
                            ]
                    except:
                        mlog.warning(
                            "Cannot add TileDigitsContainer/TileDigitsCnt et al. to bytestream list"
                        )

                    # set options for TileRawChannelMaker
                    from TileRecUtils.TileRecFlags import jobproperties
                    jobproperties.TileRecFlags.TileRunType = 1
                    # physics run type

                    # reading of digits can be disabled before calling CaloCellGetter
                    # if this is not done, but digits are not available in BS file
                    # reading of digits is automatically disabled at start of run
                    if jobproperties.TileRecFlags.readDigits()                \
                        and not (jobproperties.TileRecFlags.doTileFlat        \
                                 or jobproperties.TileRecFlags.doTileFit      \
                                 or jobproperties.TileRecFlags.doTileFitCool  \
                                 or jobproperties.TileRecFlags.doTileOpt      \
                                 or jobproperties.TileRecFlags.doTileOF1      \
                                 or jobproperties.TileRecFlags.doTileOpt2     \
                                 or jobproperties.TileRecFlags.doTileOptATLAS \
                                 or jobproperties.TileRecFlags.doTileMF):

                        from AthenaCommon.BeamFlags import jobproperties
                        # run Opt filter with iterations by default, both for cosmics and collisions before 2011
                        # run Opt filter without iterations for collisions in 2011 and later
                        if not 'doTileOpt2' in dir():
                            from RecExConfig.AutoConfiguration import GetRunNumber
                            rn = GetRunNumber()
                            if rn > 0 and rn < 171194:
                                doTileOpt2 = True
                            elif jobproperties.Beam.beamType() == 'collisions':
                                doTileOpt2 = False
                                # use OF without iterations for collisions
                            else:
                                doTileOpt2 = True
                                # always run OF with iterations for cosmics

                        # jobproperties.TileRecFlags.calibrateEnergy=True; # use pCb for RawChannels
                        # please, note that time correction and best phase are used only for collisions
                        if doTileOpt2:
                            jobproperties.TileRecFlags.doTileOpt2 = True
                            # run optimal filter with iterations
                            jobproperties.TileRecFlags.doTileOptATLAS = False
                            # disable optimal filter without iterations
                            jobproperties.TileRecFlags.correctAmplitude = False
                            # don't do parabolic correction
                            if jobproperties.Beam.beamType() == 'collisions':
                                jobproperties.TileRecFlags.correctTime = True
                                # apply time correction in physics runs
                                jobproperties.TileRecFlags.BestPhaseFromCOOL = False
                                # best phase is not needed for iterations
                        else:
                            jobproperties.TileRecFlags.doTileOpt2 = False
                            # disable optimal filter with iterations
                            jobproperties.TileRecFlags.doTileOptATLAS = True
                            # run optimal filter without iterations
                            jobproperties.TileRecFlags.correctAmplitude = True
                            # apply parabolic correction
                            if jobproperties.Beam.beamType() == 'collisions':
                                jobproperties.TileRecFlags.correctTime = False
                                # don't need time correction if best phase is used
                                jobproperties.TileRecFlags.BestPhaseFromCOOL = True
                                # use best phase stored in DB

                    try:
                        from TileRecUtils.TileRawChannelGetter import TileRawChannelGetter
                        theTileRawChannelGetter = TileRawChannelGetter()
                    except:
                        mlog.error("could not load TileRawChannelGetter Quit")
                        print traceback.format_exc()
                        return False

                    try:
                        from TileRecAlgs.TileRecAlgsConf import TileDigitsFilter
                        from AthenaCommon.AlgSequence import AlgSequence
                        topSequence = AlgSequence()
                        topSequence += TileDigitsFilter()
                    except:
                        mlog.error("Could not configure TileDigitsFilter")

                try:
                    from TileRecUtils.TileRecUtilsConf import TileCellBuilder
                    theTileCellBuilder = TileCellBuilder()
                    from TileRecUtils.TileRecFlags import jobproperties
                    theTileCellBuilder.TileRawChannelContainer = jobproperties.TileRecFlags.TileRawChannelContainer(
                    )

                    if not hasattr(ToolSvc, "TileBeamInfoProvider"):
                        from TileRecUtils.TileRecUtilsConf import TileBeamInfoProvider
                        ToolSvc += TileBeamInfoProvider()

                    if globalflags.DataSource(
                    ) == 'data' and globalflags.InputFormat() == 'bytestream':
                        if jobproperties.TileRecFlags.readDigits():
                            # everything is already corrected at RawChannel level
                            theTileCellBuilder.correctTime = False
                            theTileCellBuilder.correctAmplitude = False
                        else:
                            ToolSvc.TileBeamInfoProvider.TileRawChannelContainer = "TileRawChannelCnt"
                            # by default parameters are tuned for opt.filter without iterations
                            theTileCellBuilder.correctTime = jobproperties.TileRecFlags.correctTime(
                            )
                            theTileCellBuilder.correctAmplitude = jobproperties.TileRecFlags.correctAmplitude(
                            )
                            theTileCellBuilder.AmpMinForAmpCorrection = jobproperties.TileRecFlags.AmpMinForAmpCorrection(
                            )
                            if jobproperties.TileRecFlags.TimeMaxForAmpCorrection(
                            ) <= jobproperties.TileRecFlags.TimeMinForAmpCorrection(
                            ):
                                from AthenaCommon.BeamFlags import jobproperties
                                mlog.info(
                                    "adjusting min/max time of parabolic correction for %s"
                                    % jobproperties.Beam.bunchSpacing)
                                halfBS = jobproperties.Beam.bunchSpacing.get_Value(
                                ) / 2.
                                jobproperties.TileRecFlags.TimeMinForAmpCorrection = -halfBS
                                jobproperties.TileRecFlags.TimeMaxForAmpCorrection = halfBS
                            if jobproperties.TileRecFlags.TimeMaxForAmpCorrection(
                            ) > jobproperties.TileRecFlags.TimeMinForAmpCorrection(
                            ):
                                theTileCellBuilder.TimeMinForAmpCorrection = jobproperties.TileRecFlags.TimeMinForAmpCorrection(
                                )
                                theTileCellBuilder.TimeMaxForAmpCorrection = jobproperties.TileRecFlags.TimeMaxForAmpCorrection(
                                )

                    ToolSvc += theTileCellBuilder
                    theCaloCellMaker.CaloCellMakerToolNames += [
                        theTileCellBuilder
                    ]
                except:
                    mlog.error("could not get handle to TileCellBuilder Quit")
                    print traceback.format_exc()
                    return False

        if doFastCaloSim:
            mlog.info('configuring FastCaloSim here')

            try:
                from FastCaloSim.FastCaloSimConf import EmptyCellBuilderTool
                theEmptyCellBuilderTool = EmptyCellBuilderTool()
                ToolSvc += theEmptyCellBuilderTool
                theCaloCellMaker.CaloCellMakerToolNames += [
                    theEmptyCellBuilderTool
                ]

                print theEmptyCellBuilderTool
                mlog.info("configure EmptyCellBuilderTool worked")
            except:
                mlog.error("could not get handle to EmptyCellBuilderTool Quit")
                print traceback.format_exc()
                return False

            try:
                from FastCaloSim.FastCaloSimFactory import FastCaloSimFactory
                theFastShowerCellBuilderTool = FastCaloSimFactory()

                ToolSvc += theFastShowerCellBuilderTool
                theCaloCellMaker.CaloCellMakerToolNames += [
                    theFastShowerCellBuilderTool
                ]
                mlog.info("configure FastShowerCellBuilderTool worked")
            except:
                mlog.error(
                    "could not get handle to FastShowerCellBuilderTool Quit")
                print traceback.format_exc()
                return False

            doFastCaloSimNoise = jobproperties.CaloCellFlags.doFastCaloSimNoise(
            )
            if doFastCaloSimNoise:
                try:
                    from FastCaloSim.FastCaloSimConf import AddNoiseCellBuilderTool
                    theAddNoiseCellBuilderTool = AddNoiseCellBuilderTool()

                    from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault
                    theCaloNoiseTool = CaloNoiseToolDefault()
                    from AthenaCommon.AppMgr import ToolSvc
                    ToolSvc += theCaloNoiseTool

                    theAddNoiseCellBuilderTool.CaloNoiseTool = theCaloNoiseTool.getFullName(
                    )

                    print theAddNoiseCellBuilderTool

                    ToolSvc += theAddNoiseCellBuilderTool
                    theCaloCellMaker.CaloCellMakerToolNames += [
                        theAddNoiseCellBuilderTool
                    ]
                    mlog.info("configure AddNoiseCellBuilderTool worked")
                except:
                    mlog.error(
                        "could not get handle to AddNoiseCellBuilderTool Quit")
                    print traceback.format_exc()
                    return False

        #
        # CaloCellContainerFinalizerTool : closing container and setting up iterators
        #

        from CaloRec.CaloRecConf import CaloCellContainerFinalizerTool
        theCaloCellContainerFinalizerTool = CaloCellContainerFinalizerTool()
        ToolSvc += theCaloCellContainerFinalizerTool
        theCaloCellMaker.CaloCellMakerToolNames += [
            theCaloCellContainerFinalizerTool
        ]

        #
        # Mergeing of calo cellcontainer with sparse raw channel container with improved energies
        #

        doLArMerge = False
        if globalflags.DataSource(
        ) == 'data' and jobproperties.CaloCellFlags.doLArRawChannelMerge.statusOn and jobproperties.CaloCellFlags.doLArRawChannelMerge(
        ):
            from LArROD.LArRODFlags import larRODFlags
            if larRODFlags.readDigits() and larRODFlags.keepDSPRaw():
                doLArMerge = True
        if doLArMerge:
            try:
                from LArCellRec.LArCellRecConf import LArCellMerger
                theLArCellMerger = LArCellMerger()
            except:
                mlog.error("could not get handle to LArCellMerge Quit")
                print traceback.format_exc()
                return False
            theLArCellMerger.RawChannelsName = larRODFlags.RawChannelFromDigitsContainerName(
            )
            ToolSvc += theLArCellMerger
            theCaloCellMaker.CaloCellMakerToolNames += [theLArCellMerger]

        #
        # masking of noisy and sporadic noisy cells in LAr
        #

        doNoiseMask = False
        if jobproperties.CaloCellFlags.doLArNoiseMasking.statusOn and jobproperties.CaloCellFlags.doLArNoiseMasking(
        ):
            doNoiseMask = True
        doSporadicMask = False
        if jobproperties.CaloCellFlags.doLArSporadicMasking.statusOn and jobproperties.CaloCellFlags.doLArSporadicMasking(
        ):
            doSporadicMask = True

        if doNoiseMask or doSporadicMask:
            try:
                from LArCellRec.LArCellRecConf import LArCellNoiseMaskingTool
                theLArCellNoiseMaskingTool = LArCellNoiseMaskingTool()
            except:
                mlog.error(
                    "could not get handle to LArCellNoiseMaskingTool Quit")
                print traceback.format_exc()
                return False

            # bad channel tools
            try:
                from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
                theLArBadChannelTool = LArBadChanTool()
            except:
                mlog.error("could not access bad channel tool Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArBadChannelTool

            if doSporadicMask:
                try:
                    from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker
                    theLArSporadicNoiseMasker = LArBadChannelMasker(
                        "LArSporadicNoiseMasker")
                except:
                    mlog.error("could not access bad channel tool Quit")
                    print traceback.format_exc()
                    return False
                theLArSporadicNoiseMasker.TheLArBadChanTool = theLArBadChannelTool
                theLArSporadicNoiseMasker.DoMasking = True
                theLArSporadicNoiseMasker.ProblemsToMask = [
                    "sporadicBurstNoise"
                ]
                ToolSvc += theLArSporadicNoiseMasker
                theLArCellNoiseMaskingTool.MaskingSporadicTool = theLArSporadicNoiseMasker

            if doNoiseMask:
                try:
                    from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker
                    theLArNoiseMasker = LArBadChannelMasker("LArNoiseMasker")
                except:
                    mlog.error("could not access bad channel tool Quit")
                    print traceback.format_exc()
                    return False
                theLArNoiseMasker.TheLArBadChanTool = theLArBadChannelTool
                theLArNoiseMasker.DoMasking = True
                theLArNoiseMasker.ProblemsToMask = [
                    "highNoiseHG", "highNoiseMG", "highNoiseLG", "deadReadout",
                    "deadPhys"
                ]
                ToolSvc += theLArNoiseMasker
                theLArCellNoiseMaskingTool.MaskingTool = theLArNoiseMasker

            theLArCellNoiseMaskingTool.maskNoise = doNoiseMask
            theLArCellNoiseMaskingTool.maskSporadic = doSporadicMask
            # quality cut for sporadic noise masking
            theLArCellNoiseMaskingTool.qualityCut = 4000
            ToolSvc += theLArCellNoiseMaskingTool
            theCaloCellMaker.CaloCellMakerToolNames += [
                theLArCellNoiseMaskingTool
            ]

        #
        #  masking of Feb problems
        #
        doBadFebMasking = False
        if jobproperties.CaloCellFlags.doLArBadFebMasking.statusOn and jobproperties.CaloCellFlags.doLArBadFebMasking(
        ):
            from AthenaCommon.GlobalFlags import globalflags
            if globalflags.DataSource() == 'data':
                doBadFebMasking = True

        if doBadFebMasking:
            try:
                from LArCellRec.LArCellRecConf import LArBadFebMaskingTool
                theLArBadFebMaskingTool = LArBadFebMaskingTool()
                if (
                        rec.doExpressProcessing()
                        or athenaCommonFlags.isOnline()
                ):  # In online or express processing, EventInfo::LArError is triggered if >=4 FEB with data corrupted
                    theLArBadFebMaskingTool.minFebInError = 4
            except:
                mlog.error("could not get handle to LArBadFebMaskingTool Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArBadFebMaskingTool

            # bad channel tools
            try:
                from LArBadChannelTool.LArBadChannelToolConf import LArBadChanTool
                theLArBadChannelTool = LArBadChanTool()
            except:
                mlog.error("could not access bad channel tool Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArBadChannelTool

            theLArBadFebMaskingTool.badChannelTool = theLArBadChannelTool
            theCaloCellMaker.CaloCellMakerToolNames += [
                theLArBadFebMaskingTool
            ]

        #
        #  emulate gain pathologies on MC
        #
        doGainPathology = False
        if jobproperties.CaloCellFlags.doLArCellGainPathology.statusOn and jobproperties.CaloCellFlags.doLArCellGainPathology(
        ):
            from AthenaCommon.GlobalFlags import globalflags
            if globalflags.DataSource() == 'geant4':
                doGainPathology = True

        if doGainPathology:
            try:
                from LArCellRec.LArCellRecConf import LArCellGainPathology
                theLArCellGainPathology = LArCellGainPathology()
            except:
                mlog.error("could not get handle to LArCellGainPatholog< Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArCellGainPathology

            theCaloCellMaker.CaloCellMakerToolNames += [
                theLArCellGainPathology
            ]

        # lar miscalibration if MC only  (should be done after finalisation)

        if not jobproperties.CaloCellFlags.doLArCellEmMisCalib.statusOn:
            # the flag has not been set, so decide a reasonable default
            # this is the old global flags should use the new one as
            # soon as monitoring does
            from AthenaCommon.GlobalFlags import globalflags
            if globalflags.DataSource() == 'data':
                doLArCellEmMisCalib = False
                mlog.info(
                    "jobproperties.CaloCellFlags.doLArMisCalib not set and real data: do not apply LArCellEmMisCalibTool"
                )
            else:
                doLArCellEmMisCalib = True
                mlog.info(
                    "jobproperties.CaloCellFlags.doLArMisCalib not set and Monte Carlo: apply LArCellEmMisCalibTool"
                )
        else:
            doLArCellEmMisCalib = jobproperties.CaloCellFlags.doLArCellEmMisCalib(
            )
            if doLArCellEmMisCalib:
                mlog.info("LArCellEmMisCalibTool requested")
            else:
                mlog.info("LArCellEmMisCalibTool explicitly not requested")

        if doLArCellEmMisCalib:
            try:
                from LArCellRec.LArCellRecConf import LArCellEmMiscalib
                theLArCellEmMiscalib = LArCellEmMiscalib("LArCellEmMiscalib")
            except:
                mlog.error("could not get handle to LArCellEmMisCalib Quit")
                print traceback.format_exc()
                return False

            # examples on how to change miscalibration. Default values are 0.005 and 0.007
            #        theLArCellEmMiscalib.SigmaPerRegion = 0.005;
            #        theLArCellEmMiscalib.SigmaPerCell = 0.005;

            ToolSvc += theLArCellEmMiscalib

            try:
                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
                from CaloIdentifier import SUBCALO
                theMisCalibTool = CaloCellContainerCorrectorTool(
                    "MisCalibTool",
                    CaloNums=[SUBCALO.LAREM],
                    CellCorrectionToolNames=[theLArCellEmMiscalib])
            except:
                mlog.error("could not get handle to MisCalibTool Quit")
                print traceback.format_exc()
                return False

            ToolSvc += theMisCalibTool
            theCaloCellMaker.CaloCellMakerToolNames += [theMisCalibTool]

        #
        # Pedestal shift correction
        #
        doPedestalCorr = False
        if jobproperties.CaloCellFlags.doPedestalCorr.statusOn:
            from AthenaCommon.GlobalFlags import globalflags
            if jobproperties.CaloCellFlags.doPedestalCorr() and (
                    globalflags.DataSource() == 'data'
                    or jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr):
                doPedestalCorr = True
                mlog.info("Apply cell level pedestal shift correction")

        import os
        if doPedestalCorr:
            try:
                from CaloCellCorrection.CaloCellPedestalCorrDefault import CaloCellPedestalCorrDefault
                theCaloCellPedestalCorr = CaloCellPedestalCorrDefault()
                ToolSvc += theCaloCellPedestalCorr
                theCaloCellMaker.CaloCellMakerToolNames += [
                    theCaloCellPedestalCorr
                ]
            except:
                mlog.error("could not get handle to CaloCellPedestalCorr")
                print traceback.format_exc()

        #
        # HV correction for offline reprocessing, reading HV from Cool-DCS database
        #
        doHVCorr = False
        from AthenaCommon.DetFlags import DetFlags
        if DetFlags.dcs.LAr_on():
            if jobproperties.CaloCellFlags.doLArHVCorr.statusOn:
                from AthenaCommon.GlobalFlags import globalflags
                if jobproperties.CaloCellFlags.doLArHVCorr(
                ) and globalflags.DataSource() == 'data':
                    doHVCorr = True
                    mlog.info(
                        "Redoing HV correction at cell level from COOL/DCS database"
                    )

        if doHVCorr:
            from LArCellRec.LArCellHVCorrDefault import LArCellHVCorrDefault
            theLArCellHVCorr = LArCellHVCorrDefault()

            try:
                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
                from CaloIdentifier import SUBCALO
                theHVCorrTool = CaloCellContainerCorrectorTool(
                    "HVCorrTool",
                    CaloNums=[SUBCALO.LAREM, SUBCALO.LARHEC, SUBCALO.LARFCAL],
                    CellCorrectionToolNames=[theLArCellHVCorr])
            except:
                mlog.error("could not get handle to HVCorrTool Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theHVCorrTool
            theCaloCellMaker.CaloCellMakerToolNames += [theHVCorrTool]

        #
        # correction to undo online calibration and apply new LAr electronics calibration for ADC->MeV conversion
        #
        doLArRecalibration = False
        if jobproperties.CaloCellFlags.doLArRecalibration.statusOn:
            from AthenaCommon.GlobalFlags import globalflags
            from LArConditionsCommon.LArCondFlags import larCondFlags
            if jobproperties.CaloCellFlags.doLArRecalibration(
            ) and globalflags.DataSource() == 'data' and (
                    not larCondFlags.SingleVersion()):
                doLArRecalibration = True
                mlog.info("Redoing LAr electronics calibration for ADC->MeV")

        if doLArRecalibration:

            # get tool for cell recalibration
            try:
                from LArCellRec.LArCellRecConf import LArCellRecalibration
                theLArCellRecalibration = LArCellRecalibration(
                    "LArCellRecalibration")
            except:
                mlog.error("could not get handle to LArCellRecalibration Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArCellRecalibration

            # get new ADC2MeVTool
            try:
                from LArRecUtils.LArADC2MeVToolDefault import LArADC2MeVToolDefault
                theLArADC2MeVToolDefault = LArADC2MeVToolDefault()
            except:
                mlog.error(
                    "Could not get handle to LArADC2MeVToolDefault Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArADC2MeVToolDefault

            # get old  ADC2MeVTool
            try:
                from LArRecUtils.LArADC2MeVToolOnline import LArADC2MeVToolOnline
                theLArADC2MeVToolOnline = LArADC2MeVToolOnline()
            except:
                mlog.error("Could not get handle to LArADC2MeVToolOnline Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArADC2MeVToolOnline

            theLArCellRecalibration.adc2MeVTool = theLArADC2MeVToolDefault
            theLArCellRecalibration.adc2MeVToolOnline = theLArADC2MeVToolOnline

            try:
                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
                from CaloIdentifier import SUBCALO
                theLArRecalibrationTool = CaloCellContainerCorrectorTool(
                    "LArRecalibrationTool",
                    CaloNums=[SUBCALO.LAREM, SUBCALO.LARHEC, SUBCALO.LARFCAL],
                    CellCorrectionToolNames=[theLArCellRecalibration])
            except:
                mlog.error("could not get handle to HVCorrTool Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theLArRecalibrationTool
            theCaloCellMaker.CaloCellMakerToolNames += [
                theLArRecalibrationTool
            ]

        #
        # Correction for MinBias energy shift for MC pileup reco
        #
        doMinBiasAverage = False
        if jobproperties.CaloCellFlags.doMinBiasAverage.statusOn:
            from AthenaCommon.GlobalFlags import globalflags
            from AthenaCommon.BeamFlags import jobproperties
            if jobproperties.CaloCellFlags.doMinBiasAverage(
            ) and globalflags.DataSource() == 'geant4' and (
                    not jobproperties.Beam.zeroLuminosity()):
                doMinBiasAverage = True

        if doMinBiasAverage:

            try:
                from CaloTools.CaloMBAverageToolDefault import CaloMBAverageToolDefault
                theCaloMBAverageTool = CaloMBAverageToolDefault()
            except:
                mlog.error("could not get handle to CaloMBAverageTool  Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theCaloMBAverageTool

            try:
                from CaloCellCorrection.CaloCellCorrectionConf import CaloCellMBAverageCorr
                theCaloCellMBAverageCorr = CaloCellMBAverageCorr(
                    "CaloCellMBAverageCorr")
                theCaloCellMBAverageCorr.CaloMBAverageTool = theCaloMBAverageTool
            except:
                mlog.error(
                    "could not get handle to  CaloCellMBAverageCorr  Quit")
                print traceback.format_exc()
                return False
            ToolSvc += theCaloCellMBAverageCorr

            try:
                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
                from CaloIdentifier import SUBCALO
                theMBAverageTool = CaloCellContainerCorrectorTool(
                    "MBAverageTool",
                    CaloNums=[SUBCALO.NSUBCALO],
                    CellCorrectionToolNames=[theCaloCellMBAverageCorr])
            except:
                mlog.error(
                    "could not get handle to CaloCellContainerCorrectorTool/MBAverageTool Quit"
                )
                print traceback.format_exc()
                return False

            ToolSvc += theMBAverageTool
            theCaloCellMaker.CaloCellMakerToolNames += [theMBAverageTool]

        #
        # Correction for dead cells, where we average the energy density of neighbor cells
        #
        doNeighborsAverage = False
        if jobproperties.CaloCellFlags.doDeadCellCorr.statusOn:
            if jobproperties.CaloCellFlags.doDeadCellCorr():
                doNeighborsAverage = True

        if doNeighborsAverage:
            try:
                from CaloCellCorrection.CaloCellCorrectionConf import CaloCellNeighborsAverageCorr
                theCaloCellNeighborsAverageCorr = CaloCellNeighborsAverageCorr(
                    "CaloCellNeighborsAverageCorr")
                theCaloCellNeighborsAverageCorr.testMode = False
            except:
                mlog.error(
                    "could not get handle to  CaloCellNeighborsAverageCorr  Quit"
                )
                print traceback.format_exc()
                return False
            ToolSvc += theCaloCellNeighborsAverageCorr
            theCaloCellMaker.CaloCellMakerToolNames += [
                theCaloCellNeighborsAverageCorr
            ]

        #
        # correction for missing Febs based on L1 readout
        doLArDeadOTXCorr = False
        if jobproperties.CaloCellFlags.doLArDeadOTXCorr.statusOn and jobproperties.CaloCellFlags.doLArCreateMissingCells.statusOn:
            if jobproperties.CaloCellFlags.doLArDeadOTXCorr(
            ) and jobproperties.CaloCellFlags.doLArCreateMissingCells(
            ) and doStandardCellReconstruction:
                if rec.doTrigger():
                    doLArDeadOTXCorr = True
                else:
                    mlog.warning(
                        "Trigger is switched off. Can't run deadOTX correction."
                    )

        if doLArDeadOTXCorr:

            try:
                from LArCellRec.LArCellDeadOTXCorrToolDefault import LArCellDeadOTXCorrToolDefault
                theLArCellDeadOTXCorr = LArCellDeadOTXCorrToolDefault()
            except:
                mlog.error("could not get handle to LArCellDeadOTXCorr Quit")
                print traceback.format_exc()

            ToolSvc += theLArCellDeadOTXCorr
            theCaloCellMaker.CaloCellMakerToolNames += [theLArCellDeadOTXCorr]

        doCaloEnergyRescaler = False
        if jobproperties.CaloCellFlags.doCaloCellEnergyCorr(
        ) and globalflags.DataSource(
        ) == 'data' and not athenaCommonFlags.isOnline():

            try:
                from CaloCellCorrection.CaloCellCorrectionConf import CaloCellEnergyRescaler
                theCCERescalerTool = CaloCellEnergyRescaler()
                theCCERescalerTool.Folder = "/LAR/CellCorrOfl/EnergyCorr"
                ToolSvc += theCCERescalerTool
                from IOVDbSvc.CondDB import conddb
                # conddb.addFolder("","/LAR/CellCorrOfl/EnergyCorr<tag>EnergyScale-00</tag><db>sqlite://;schema=escale.db;dbname=COMP200</db>")
                conddb.addFolder("LAR_OFL", "/LAR/CellCorrOfl/EnergyCorr")
                ToolSvc += theCCERescalerTool
                theCaloCellMaker.CaloCellMakerToolNames += [theCCERescalerTool]
            except:
                mlog.error(
                    "could not get handle to CaloCellEnergyRescaler Quit")
                print traceback.format_exc()
                return False
            pass

        if jobproperties.CaloCellFlags.doCaloCellTimeCorr(
        ) and globalflags.DataSource(
        ) == 'data' and not athenaCommonFlags.isOnline():
            try:
                from CaloRec.CaloRecConf import CaloCellContainerCorrectorTool
                from CaloCellCorrection.CaloCellCorrectionConf import CaloCellTimeCorrTool
                theLArTimeCorr = CaloCellTimeCorrTool()
                theLArTimeCorr.Folder = "/LAR/TimeCorrectionOfl/CellTimeOffset"
                ToolSvc += theLArTimeCorr
                from IOVDbSvc.CondDB import conddb
                # conddb.addFolder("","/LAR/TimeCorrectionOfl/CellTimeOffset<tag>LARTimeCorrectionOflCellTimeOffset-empty</tag><db>sqlite://;schema=timecorr.db;dbname=COMP200</db>")
                conddb.addFolder("LAR_OFL",
                                 "/LAR/TimeCorrectionOfl/CellTimeOffset")
                theCaloTimeCorrTool = CaloCellContainerCorrectorTool(
                    "LArTimeCorrTool",
                    CellCorrectionToolNames=[theLArTimeCorr])
                ToolSvc += theCaloTimeCorrTool
                theCaloCellMaker.CaloCellMakerToolNames += [
                    theCaloTimeCorrTool
                ]

            except:
                mlog.error("could not get handle to CaloCellTimeCorrTool Quit")
                print traceback.format_exc()
                return False

            pass

        # make lots of checks (should not be necessary eventually)
        # to print the check add:

        from CaloRec.CaloRecConf import CaloCellContainerCheckerTool
        theCaloCellContainerCheckerTool = CaloCellContainerCheckerTool()
        # FIXME
        # theCaloCellContainerCheckerTool.OutputLevel=DEBUG

        ToolSvc += theCaloCellContainerCheckerTool
        theCaloCellMaker.CaloCellMakerToolNames += [
            theCaloCellContainerCheckerTool
        ]

        #

        # sets output key
        theCaloCellMaker.CaloCellsOutputName = self.outputKey()

        # register output in objKeyStore
        from RecExConfig.ObjKeyStore import objKeyStore

        objKeyStore.addStreamESD(self.outputType(), self.outputKey())

        # now add algorithm to topSequence
        # this should always come at the end

        mlog.info(" now adding CaloCellMaker to topSequence")

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        topSequence += theCaloCellMaker

        return True
Ejemplo n.º 8
0
            elif (geoFlags.isIBL() == False):
                IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping.dat"
            else:
                # Planar IBL
                if (geoFlags.IBLLayout() == "planar"):
                    if (geoFlags.isDBM() == True):
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_inclIBL_DBM.dat"
                    else:
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_inclIBL.dat"
                # Hybrid IBL plus DBM
                elif (geoFlags.IBLLayout() == "3D"):
                    IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_Run2.dat"

        elif (globalflags.DataSource == 'data'):
            from RecExConfig.AutoConfiguration import GetRunNumber
            runNum = GetRunNumber()
            if (runNum < 222222):
                useCablingConditions = False
                IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_May08.dat"
                rodIDForSingleLink40 = 1300000
            else:
                useCablingConditions = True
                rodIDForSingleLink40 = 1300000
                # Even though we are reading from COOL, set the correct fallback map.
                if (runNum >= 344494):
                    IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_344494.dat"
                elif (runNum >= 314940 and runNum < 344494):
                    IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_314940.dat"
                elif (runNum >= 289350 and runNum < 314940):  # 2016
                    IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_2016.dat"
                elif (runNum >= 222222 and runNum < 289350):  # 2015
Ejemplo n.º 9
0
    def configure(self):
        log = logging.getLogger("TriggerConfigGetter.py")

        # first check the input
        if "HIT2RDO" in self._environment:
            TriggerFlags.doLVL2 = False
            TriggerFlags.doEF = False
            log.info("For simulation jobs the following flags are set:")
            log.info("globalflags.InputFormat             : %s" %
                     globalflags.InputFormat())
            log.info("globalflags.DataSource              : %s" %
                     globalflags.DataSource())
            log.info("TriggerFlags.configForStartup       : %s" %
                     TriggerFlags.configForStartup())
            log.info("TriggerFlags.dataTakingConditions   : %s" %
                     TriggerFlags.dataTakingConditions())
            log.info("TriggerFlags.doLVL2                 : %s" %
                     TriggerFlags.doLVL2())
            log.info("TriggerFlags.doEF                   : %s" %
                     TriggerFlags.doEF())
        else:
            if not self.checkInput():
                log.error(
                    "Could not determine job input. Can't setup trigger configuration and will return!"
                )
                return

        self.readPool = globalflags.InputFormat() == 'pool'
        self.readRDO = rec.readRDO()
        self.writeESDAOD = rec.doWriteESD() or rec.doWriteAOD(
        ) or rec.doWriteDPD()
        self.ConfigSrcList = TriggerFlags.configurationSourceList()
        self.readMC = globalflags.DataSource(
        ) == 'geant3' or globalflags.DataSource() == 'geant4'
        self.readTriggerDB = TriggerFlags.readMenuFromTriggerDb(
        ) and self.readRDO
        self.isCommisioning = globalflags.DataSource(
        ) == 'data' and globalflags.DetGeo() == 'commis'
        self.l1Folders = TriggerFlags.dataTakingConditions(
        ) == 'FullTrigger' or TriggerFlags.dataTakingConditions() == 'Lvl1Only'
        self.hltFolders = TriggerFlags.dataTakingConditions(
        ) == 'FullTrigger' or TriggerFlags.dataTakingConditions() == 'HltOnly'
        self.isRun1Data = False
        if globalflags.DataSource() == 'data':
            from RecExConfig.AutoConfiguration import GetRunNumber
            runNumber = GetRunNumber()
            if runNumber > 0 and runNumber < 230000:
                self.isRun1Data = True
        self.isTriggerReprocessing = False

        # the TriggerFlags.readMenuFromTriggerDb() tells us that we read the trigger menu from the database
        # the connection itself is defined in TriggerFlags.triggerDbConnection()

        # reading from the TriggerDB can mean different things:

        # a) TriggerFlags doLVL2() and doEF() are both False:
        #    - create a tmp sqlite file with the conditions (menu)
        #    - use DSConfigSvc

        # b) TriggerFlags doLVL2() or doEF() is True:
        #    - use HLTConfigSvc
        if self.readTriggerDB and (TriggerFlags.doLVL2()
                                   or TriggerFlags.doEF()
                                   or TriggerFlags.doHLT()):

            self.ConfigSrcList = [
                'xml'
            ]  # to use L1/HLTConfigSvc and not DSConfigSvc, but only if we are running the HLT

        if self._environment:  # I don't think anyone calls TriggerConfigGetter with an argument
            self.readPool = False
            self.writeESDAOD = False
            self.readHits = False
            if "ReadPoolRDO" in self._environment:
                self.readPool = True
                self.readRDO = True
            elif "ReadPool" in self._environment:
                self.readPool = True
                self.readRDO = False
            if "WritePool" in self._environment:
                self.writeESDAOD = True
            if "HIT2RDO" in self._environment:
                self.readRDO = False
                self.readHits = True

        # define ConfigSvc
        if not self.ConfigSrcList:
            if (self.readPool and not self.readRDO) or (
                    self.readRDO
                    and not self.readPool):  # (ESD, AOD, DPD) or (RDO-BS)
                self.ConfigSrcList = ['ds']
            elif (self.readRDO and self.readPool
                  ) or rec.readTAG() or self.readHits:  # (RDO-MC) or TAG
                self.ConfigSrcList = ['xml']
            else:  # should not get here: should be found by checkInput
                log.fatal('no reading of BS, RDO, AOD, ESD, or TAG specified')

        # we need the temporary COOL database, if we read the configuration from XML and write ESD/AOD (or have 'ds' set for some reason)
        self.makeTempCool   = self.readRDO and \
                              ( self.writeESDAOD or 'ds' in self.ConfigSrcList ) and \
                              ( self.readMC \
                                or (self.isCommisioning and (TriggerFlags.readLVL1configFromXML() and TriggerFlags.readHLTconfigFromXML())) \
                                or TriggerFlags.readMenuFromTriggerDb() )

        log.info("Need to create temporary cool file? : %r" %
                 self.makeTempCool)

        log.info('Creating the Trigger Configuration Services')
        self.svc = SetupTrigConfigSvc()

        #set the merged system
        #self.svc.doMergedHLT = TriggerFlags.doHLT()

        if 'xml' in self.ConfigSrcList or self.makeTempCool:
            # sets them if plain XML reading is to be used
            self.svc.l1topoXmlFile = TriggerFlags.outputL1TopoConfigFile(
            )  # generated in python
            self.svc.l1XmlFile = TriggerFlags.outputLVL1configFile(
            )  # generated in python
            self.svc.hltXmlFile = TriggerFlags.outputHLTconfigFile(
            )  # generated in python
            if TriggerFlags.readL1TopoConfigFromXML():
                self.svc.l1topoXmlFile = TriggerFlags.inputL1TopoConfigFile(
                )  # given XML
            if TriggerFlags.readLVL1configFromXML():
                self.svc.l1XmlFile = TriggerFlags.inputLVL1configFile(
                )  # given XML
            if TriggerFlags.readHLTconfigFromXML():
                self.svc.hltXmlFile = TriggerFlags.inputHLTconfigFile(
                )  # given XML

        ### preparations are done!
        try:
            self.svc.SetStates(self.ConfigSrcList)
        except:
            log.error('Failed to set state of TrigConfigSvc to %r' %
                      self.ConfigSrcList)
        else:
            log.info('The following configuration services will be tried: %r' %
                     self.ConfigSrcList)

        try:
            self.svc.InitialiseSvc()
        except Exception, ex:
            log.error('Failed to activate TrigConfigSvc: %r' % ex)
Ejemplo n.º 10
0
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration

#-- set flags ------------------------------------------------------------------------------
log = logging.getLogger( "TrigHLTMonCommon_jobOptions.py" )

from AthenaCommon.GlobalFlags import globalflags
from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc)

from RecExConfig.RecFlags import rec
from RecExConfig.AutoConfiguration import GetProjectName,GetRunNumber,ConfigureTriggerStream,ConfigureSimulationOrRealData,ConfigureBeamType,ConfigureFieldAndGeo,ConfigureConditionsTag

from AthenaCommon.BeamFlags import jobproperties
runNb=GetRunNumber()
projectName=GetProjectName()
rec.projectName=projectName
ConfigureFieldAndGeo()
ConfigureTriggerStream()
ConfigureSimulationOrRealData()
ConfigureBeamType()
ConfigureConditionsTag()

data_type=globalflags.InputFormat.get_Value()
beam_type=jobproperties.Beam.beamType.get_Value()
#evt_type=inputFileSummary['evt_type']
log.info("Run Number %s",runNb)
log.info("Project name %s",projectName)
log.info("DetDescription %s", globalflags.DetDescrVersion())
log.info("File type %s",data_type)
log.info("Beam type %s",beam_type)
log.info("Trigger stream %s",rec.triggerStream())
#log.info("Event type %s",evt_type)
Ejemplo n.º 11
0
            % gbltg)
        TileUseCOOL = False
        TileFrameLength = 9

if (not 'TileCablingType' in dir()):
    if rn is None:
        try:
            from G4AtlasApps.SimFlags import simFlags
            if simFlags.RunNumber.statusOn:
                rn = simFlags.RunNumber()
        except:
            msg.info("No SimFlags available - looks like HLT job")
    if rn is None:
        try:
            from RecExConfig.AutoConfiguration import GetRunNumber
            rn = GetRunNumber()
        except:
            msg.info("No Run Number available - assume latest cabling")

    from AtlasGeoModel.CommonGMJobProperties import CommonGeometryFlags as geoFlags
    if geoFlags.Run() == "RUN1":
        if rn > 219651:  # choose RUN2 cabling for old geometry tags starting from 26-MAR-2013
            TileCablingType = 4
            msg.warning("Forcing RUN2 cabling for run %s with geometry %s" %
                        (rn, gbltg))
    elif geoFlags.Run() == "RUN2":
        if rn == None or (
                globalflags.DataSource() != 'data' and rn >= 310000
        ) or rn >= 343000 or rn < 1:  # choose RUN2a cabling for R2 geometry tags starting from 31-Jan-2018
            TileCablingType = 5
            msg.info(
Ejemplo n.º 12
0
#
#  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
#
'''
@file PixelAthMonitoringBase.py
@brief Helper functions for Run 3 Pixel monitoring algorithm configuration
'''
# hack to deal with global variables in this module
# check if we are in "old-" or "new-style" configuration
from AthenaConfiguration.AllConfigFlags import ConfigFlags
if ConfigFlags.DQ.isReallyOldStyle:
    from RecExConfig.AutoConfiguration import GetRunNumber
    runtext = ' (Run %d)' % GetRunNumber()
else:
    from AthenaConfiguration.AllConfigFlags import ConfigFlags
    runtext = ' (Run %d)' % ConfigFlags.Input.RunNumber[0]

NumLayersDisk = 3
NumLayersDBM = 3
NumStavesIBL = 14
NumStavesL0 = 22
NumStavesL1 = 38
NumStavesL2 = 52

NumModulesIBL = 32
NumModulesIBL2D = 12
NumModulesIBL3D = 8
NumModulesBarrel = 13
NumModulesDisk = 48
NumModulesDBM = 4
NumPP0sEC = 24
Ejemplo n.º 13
0
def  EDMDecodingVersion():

    log = logging.getLogger("EDMDecodingVersion.py")

    # change version only if not rerunning the trigger    
    TriggerFlags.EDMDecodingVersion = 2

    # run the AutoConfiguration
    from RecExConfig.AutoConfiguration import ConfigureInputType
    #ConfigureInputType()
    from RecExConfig.InputFilePeeker import inputFileSummary
    
    if globalflags.InputFormat.is_bytestream():
        # BYTESTREAM: decide Run1/Run2 based on Run number
        from RecExConfig.AutoConfiguration  import GetRunNumber
        runNumber = GetRunNumber()

        #Run1 data
        if runNumber > 0 and runNumber < 230000 :            
            TriggerFlags.EDMDecodingVersion = 1
            log.info("decoding version set to 1, because running on BS file from Run1")
            pass
    else:
        #Pool files
        from RecExConfig.ObjKeyStore import cfgKeyStore
        ItemDic=inputFileSummary.get("eventdata_itemsDic")
        ItemList=inputFileSummary.get('eventdata_itemsList')

        if cfgKeyStore.isInInputFile( "HLTResult", "HLTResult_EF" ):          
            TriggerFlags.EDMDecodingVersion = 1
            log.info("Decoding version set to 1, because HLTResult_EF found in pool file")
        elif cfgKeyStore.isInInputFile( "HLTResult", "HLTResult_HLT"):          
            TriggerFlags.EDMDecodingVersion = 2
        else:
            log.warning("No HLTResult found in pool file")
        pass
    pass
                




    ## if not (rec.readESD() or rec.readAOD()):
    ##     log.info("FPP Found rec.RunNumber=%s and autoConfiguration.RunNumber=%s"# and svcMgr.EventSelector.RunNumber=%s"
    ##              %(str(rec.RunNumber()),str(GetRunNumber())))#, str(svcMgr.EventSelector.RunNumber())))
            
         
                
        ## inputIsSimulation = False
        ## if inputFileSummary.has_key("evt_type"):
        ##     eventTypeList = inputFileSummary.get("evt_type")
        ##     if eventTypeList.__contains__("IS_SIMULATION") :
        ##         print "FPP Detected that the input file is a simulated dataset"
        ##         inputIsSimulation = True
        ##         pass
        ##     pass

            #from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamCnvSvc

            #    from AthenaCommon.GlobalFlags  import globalflags
            ## from RecExConfig.AutoConfiguration  import GetProjectName
            ## print "FPP projectName=%s"%str(GetProjectName())
        # Run1 data  

    # ESD/AOD files:
    

    log.info("EDMDecoding set to %s"%TriggerFlags.EDMDecodingVersion )
  
    return  True
Ejemplo n.º 14
0
        from TrigT1Muctpi.TrigT1MuctpiConfig import L1Muctpi_on_Data
        topSequence += L1Muctpi_on_Data()

        from TrigT1CTMonitoring.TrigT1CTMonitoringConf import TrigT1CTMonitoring__DeriveSimulationInputs as DeriveSimulationInputs
        topSequence += DeriveSimulationInputs(do_MuCTPI_input=True,
                                              do_L1Calo_sim=False)

        from TrigT1CTP.TrigT1CTPConfig import CTPSimulationOnData
        topSequence += CTPSimulationOnData("CTPSimulation")

        # configure simulation histogram output directory
        from AthenaMonitoring.DQMonFlags import DQMonFlags
        histbase = "/" + DQMonFlags.monManFileKey() + "/"
        if DQMonFlags.monManRun():
            from RecExConfig.AutoConfiguration import GetRunNumber
            histbase += "run_%i/L1" % GetRunNumber()
        else:
            histbase += "L1Simulation"
        try:
            topSequence.CTPSimulation.HistPath = histbase
        except AttributeError as ex:
            printfunc(ex, " ignore for now")
            import traceback
            traceback.print_exc()

    ## add an AthenaMonManager algorithm to the list of algorithms to be run
    monMan = AthenaMonManager(
        name="CTMonManager",
        FileKey=DQMonFlags.monManFileKey(),
        Environment=DQMonFlags.monManEnvironment(),
        ManualDataTypeSetup=DQMonFlags.monManManualDataTypeSetup(),
Ejemplo n.º 15
0
def EDMDecodingVersion():

    log = logging.getLogger("EDMDecodingVersion")

    # BYTESTREAM: decide Run3 or later based on ROD version, decide Run1/Run2 based on run number
    if globalflags.InputFormat.is_bytestream():

        # Check HLT ROD version in first event of first input file
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        inputFileName = athenaCommonFlags.FilesInput()[0]
        if not inputFileName and athenaCommonFlags.isOnline():
            log.info(
                "Online reconstruction mode, no input file available. Leaving default TriggerFlags.EDMDecodingVersion=%d",
                TriggerFlags.EDMDecodingVersion())
            return

        import eformat
        from libpyeformat_helper import SubDetector
        bs = eformat.istream(inputFileName)

        rodVersionM = -1
        rodVersionL = -1
        # Find the first HLT ROBFragment in the first event
        for robf in bs[0]:
            if robf.rob_source_id().subdetector_id() == SubDetector.TDAQ_HLT:
                rodVersionM = robf.rod_minor_version() >> 8
                rodVersionL = robf.rod_minor_version() & 0xFF
                log.debug("HLT ROD minor version from input file is %d.%d",
                          rodVersionM, rodVersionL)
                break

        if rodVersionM < 0 or rodVersionL < 0:
            log.warning(
                "Cannot determine HLT ROD version from input file, falling back to runNumber-based decision"
            )
        elif rodVersionM >= 1:
            TriggerFlags.EDMDecodingVersion = 3
            log.info(
                "Decoding version set to 3, because running on BS file with HLT ROD version %d.%d",
                rodVersionM, rodVersionL)
            return

        # Use run number to determine decoding version
        from RecExConfig.AutoConfiguration import GetRunNumber
        runNumber = GetRunNumber()

        boundary_run12 = 230000
        boundary_run23 = 368000

        if runNumber <= 0:
            log.error(
                "Cannot determine decoding version because run number %d is invalid. Leaving the default version %d",
                runNumber, TriggerFlags.EDMDecodingVersion())
        elif runNumber < boundary_run12:
            # Run-1 data
            TriggerFlags.EDMDecodingVersion = 1
            TriggerFlags.doMergedHLTResult = False
            log.info(
                "Decoding version set to 1 based on BS file run number (runNumber < %d)",
                boundary_run12)
        elif runNumber < boundary_run23:
            # Run-2 data
            TriggerFlags.EDMDecodingVersion = 2
            log.info(
                "Decoding version set to 2 based on BS file run number (%d < runNumber < %d)",
                boundary_run12, boundary_run23)
        else:
            # Run-3 data
            TriggerFlags.EDMDecodingVersion = 3
            log.info(
                "Decoding version set to 3 based on BS file run number (runNumber > %d)",
                boundary_run23)

    else:
        # POOL files: decide based on HLT output type present in file
        from RecExConfig.ObjKeyStore import cfgKeyStore
        from PyUtils.MetaReaderPeeker import convert_itemList
        cfgKeyStore.addManyTypesInputFile(convert_itemList(layout='#join'))

        TriggerFlags.doMergedHLTResult = True
        if cfgKeyStore.isInInputFile("HLT::HLTResult", "HLTResult_EF"):
            TriggerFlags.EDMDecodingVersion = 1
            TriggerFlags.doMergedHLTResult = False
            log.info(
                "Decoding version set to 1, because HLTResult_EF found in POOL file"
            )
        elif cfgKeyStore.isInInputFile("xAOD::TrigNavigation",
                                       "TrigNavigation"):
            TriggerFlags.EDMDecodingVersion = 2
            log.info(
                "Decoding version set to 2, because TrigNavigation found in POOL file"
            )
        elif cfgKeyStore.isInInputFile("xAOD::TrigCompositeContainer",
                                       "HLTNav_Summary"):
            TriggerFlags.EDMDecodingVersion = 3
            log.info(
                "Decoding version set to 3, because HLTNav_Summary found in POOL file"
            )
        elif rec.readRDO():
            # If running Trigger on RDO input (without previous trigger result), choose Run-2 or Run-3 based on doMT
            if TriggerFlags.doMT():
                TriggerFlags.EDMDecodingVersion = 3
                log.info(
                    "Decoding version set to 3, because running Trigger with doMT=True"
                )
            else:
                TriggerFlags.EDMDecodingVersion = 2
                log.info(
                    "Decoding version set to 2, because running Trigger with doMT=False"
                )
        else:
            log.warning(
                "Cannot recognise HLT EDM format, leaving default TriggerFlags.EDMDecodingVersion=%d",
                TriggerFlags.EDMDecodingVersion())
Ejemplo n.º 16
0
# configure writing of L1CaloRampData.pool.root
from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg
outputConditionsAlg = OutputConditionsAlg("outputConditionsAlg",
                                          "L1CaloRampData.pool.root")
outputConditionsAlg.ObjectList = ["L1CaloRampDataContainer"]
outputConditionsAlg.WriteIOV = False

# configure writing of calib database
EnergyScanResultOutput = OutputConditionsAlg("EnergyScanResultOutput",
                                             "dummy.root")
EnergyScanResultOutput.ObjectList = [
    "CondAttrListCollection#/TRIGGER/L1Calo/V1/Results/EnergyScanResults",
    "AthenaAttributeList#/TRIGGER/L1Calo/V1/Results/EnergyScanRunInfo"
]
EnergyScanResultOutput.WriteIOV = True
EnergyScanResultOutput.Run1 = GetRunNumber()
svcMgr.IOVDbSvc.dbConnection = "sqlite://;schema=energyscanresults.sqlite;dbname=L1CALO"

# configure writing of additional files for the calibration gui
topSequence += CfgMgr.L1CaloDumpRampData(RootStreamName="RAMPDATA")
#from TrigT1CaloCalibUtils.L1CaloDumpRampDataAlgorithm import L1CaloDumpRampDataAlgorithm
#topSequence += L1CaloDumpRampDataAlgorithm()

# run finetime
topSequence += CfgMgr.L1CaloPprMonitoring("L1CaloPprMonitoring",
                                          lumiBlockMax=2,
                                          ppmADCMinValue=80,
                                          ppmADCMaxValue=963,
                                          doFineTimePlots=True,
                                          doPedestalPlots=False,
                                          doEtCorrelationPlots=False,
Ejemplo n.º 17
0
    def createTool(self):
        from AthenaCommon.AppMgr import ToolSvc

        #############################
        # Setup Pixel Configuration #
        #############################
        from AthenaCommon.AlgSequence import AthSequencer
        condSeq = AthSequencer("AthCondSeq")

        from IOVDbSvc.CondDB import conddb
        from AthenaCommon.GlobalFlags import globalflags
        from AtlasGeoModel.CommonGMJobProperties import CommonGeometryFlags as commonGeoFlags
        from AtlasGeoModel.InDetGMJobProperties import InDetGeometryFlags as geoFlags

        useNewDeadmapFormat = False
        useNewChargeFormat = False

        if not useNewDeadmapFormat:
            if not (conddb.folderRequested("/PIXEL/PixMapOverlay")
                    or conddb.folderRequested("/PIXEL/Onl/PixMapOverlay")):
                conddb.addFolderSplitOnline("PIXEL",
                                            "/PIXEL/Onl/PixMapOverlay",
                                            "/PIXEL/PixMapOverlay",
                                            className='CondAttrListCollection')

        if not hasattr(condSeq, 'PixelConfigCondAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelConfigCondAlg

            useCablingConditions = False
            IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_2016.dat"
            rodIDForSingleLink40 = 0
            if (globalflags.DataSource() == 'geant4'):
                # ITk:
                if geoFlags.isSLHC():
                    IdMappingDat = "ITk_Atlas_IdMapping.dat"
                    if "BrlIncl4.0_ref" == commonGeoFlags.GeoType():
                        IdMappingDat = "ITk_Atlas_IdMapping_InclBrl4.dat"
                    elif "IBrlExt4.0ref" == commonGeoFlags.GeoType():
                        IdMappingDat = "ITk_Atlas_IdMapping_IExtBrl4.dat"
                    elif "BrlExt4.0_ref" == commonGeoFlags.GeoType():
                        IdMappingDat = "ITk_Atlas_IdMapping_ExtBrl4.dat"
                    elif "BrlExt3.2_ref" == commonGeoFlags.GeoType():
                        IdMappingDat = "ITk_Atlas_IdMapping_ExtBrl32.dat"
                elif (geoFlags.isIBL() == False):
                    IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping.dat"
                else:
                    # Planar IBL
                    if (geoFlags.IBLLayout() == "planar"):
                        if (geoFlags.isDBM() == True):
                            IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_inclIBL_DBM.dat"
                        else:
                            IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_inclIBL.dat"
                    # Hybrid IBL plus DBM
                    elif (geoFlags.IBLLayout() == "3D"):
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_Run2.dat"

            elif (globalflags.DataSource == 'data'):
                from RecExConfig.AutoConfiguration import GetRunNumber
                runNum = GetRunNumber()
                if (runNum < 222222):
                    useCablingConditions = False
                    IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_May08.dat"
                    rodIDForSingleLink40 = 1300000
                else:
                    useCablingConditions = True
                    rodIDForSingleLink40 = 1300000
                    # Even though we are reading from COOL, set the correct fallback map.
                    if (runNum >= 344494):
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_344494.dat"
                    elif (runNum >= 314940 and runNum < 344494):
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_314940.dat"
                    elif (runNum >= 289350 and runNum < 314940):  # 2016
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_2016.dat"
                    elif (runNum >= 222222 and runNum < 289350):  # 2015
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_Run2.dat"
                    else:
                        IdMappingDat = "PixelCabling/Pixels_Atlas_IdMapping_344494.dat"

            condSeq += PixelConfigCondAlg(
                name="PixelConfigCondAlg",
                UseDeadmapConditions=self.usePixMap,
                UseDCSStateConditions=self.useDCS,
                UseDCSStatusConditions=self.useDCS,
                UseTDAQConditions=self.
                useTDAQ,  # should be false. This is only valid in RUN-1.
                UseCalibConditions=True,
                UseCablingConditions=useCablingConditions,
                CablingMapFileName=IdMappingDat)

        #########################
        # Deadmap Setup (RUN-3) #
        #########################
        if useNewDeadmapFormat:
            if not conddb.folderRequested("/PIXEL/PixelModuleFeMask"):
                conddb.addFolder("PIXEL_OFL",
                                 "/PIXEL/PixelModuleFeMask",
                                 className="CondAttrListCollection")
            if not hasattr(condSeq, "PixelDeadMapCondAlg"):
                from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDeadMapCondAlg
                condSeq += PixelDeadMapCondAlg(name="PixelDeadMapCondAlg")

        ########################
        # DCS Conditions Setup #
        ########################
        PixelHVFolder = "/PIXEL/DCS/HV"
        PixelTempFolder = "/PIXEL/DCS/TEMPERATURE"
        PixelDBInstance = "DCS_OFL"

        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        if athenaCommonFlags.isOnline():
            PixelHVFolder = "/PIXEL/HLT/DCS/HV"
            PixelTempFolder = "/PIXEL/HLT/DCS/TEMPERATURE"
            PixelDBInstance = "PIXEL_ONL"

        if not conddb.folderRequested(PixelHVFolder):
            conddb.addFolder(PixelDBInstance,
                             PixelHVFolder,
                             className="CondAttrListCollection")
        if not conddb.folderRequested(PixelTempFolder):
            conddb.addFolder(PixelDBInstance,
                             PixelTempFolder,
                             className="CondAttrListCollection")

        if not self.onlineMode:  #this is only for testing in offline like setup
            if not conddb.folderRequested("/PIXEL/DCS/FSMSTATE"):
                conddb.addFolder("DCS_OFL",
                                 "/PIXEL/DCS/FSMSTATE",
                                 className="CondAttrListCollection")
            if not conddb.folderRequested("/PIXEL/DCS/FSMSTATUS"):
                conddb.addFolder("DCS_OFL",
                                 "/PIXEL/DCS/FSMSTATUS",
                                 className="CondAttrListCollection")

        if not hasattr(condSeq, 'PixelDCSCondStateAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDCSCondStateAlg
            condSeq += PixelDCSCondStateAlg(name="PixelDCSCondStateAlg")

        if not hasattr(condSeq, 'PixelDCSCondStatusAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDCSCondStatusAlg
            condSeq += PixelDCSCondStatusAlg(name="PixelDCSCondStatusAlg")

        if not hasattr(condSeq, 'PixelDCSCondHVAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDCSCondHVAlg
            condSeq += PixelDCSCondHVAlg(name="PixelDCSCondHVAlg",
                                         ReadKey=PixelHVFolder)

        if not hasattr(condSeq, 'PixelDCSCondTempAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDCSCondTempAlg
            condSeq += PixelDCSCondTempAlg(name="PixelDCSCondTempAlg",
                                           ReadKey=PixelTempFolder)

        #########################
        # TDAQ Conditions Setup #
        #########################
        if self.useTDAQ:
            PixelTDAQFolder = "/TDAQ/Resources/ATLAS/PIXEL/Modules"
            PixelTDAQInstance = "TDAQ_ONL"
            if not conddb.folderRequested(PixelTDAQFolder):
                conddb.addFolder(PixelTDAQInstance,
                                 PixelTDAQFolder,
                                 className="CondAttrListCollection")

            if not hasattr(condSeq, "PixelTDAQCondAlg"):
                from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelTDAQCondAlg
                condSeq += PixelTDAQCondAlg(name="PixelTDAQCondAlg",
                                            ReadKey=PixelTDAQFolder)

        ############################
        # Conditions Summary Setup #
        ############################
        # This is future replacement of the PixelConditionsSummaryTool...

        from PixelConditionsTools.PixelConditionsToolsConf import PixelConditionsSummaryTool
        TrigPixelConditionsSummaryTool = PixelConditionsSummaryTool(
            name=self.instanceName('PixelConditionsSummaryTool'),
            UseByteStream=self.useBS)

        if self.useDCS and not self.onlineMode:
            TrigPixelConditionsSummaryTool.IsActiveStates = ['READY', 'ON']
            TrigPixelConditionsSummaryTool.IsActiveStatus = ['OK', 'WARNING']

        self.summaryTool = TrigPixelConditionsSummaryTool

        if self._print: print(TrigPixelConditionsSummaryTool)

        #####################
        # Calibration Setup #
        #####################
        if not useNewChargeFormat:
            if not conddb.folderRequested("/PIXEL/PixCalib"):
                conddb.addFolderSplitOnline("PIXEL",
                                            "/PIXEL/Onl/PixCalib",
                                            "/PIXEL/PixCalib",
                                            className="CondAttrListCollection")
            if not hasattr(condSeq, 'PixelChargeCalibCondAlg'):
                from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeCalibCondAlg
                condSeq += PixelChargeCalibCondAlg(
                    name="PixelChargeCalibCondAlg", ReadKey="/PIXEL/PixCalib")
        else:
            if not conddb.folderRequested("/PIXEL/ChargeCalibration"):
                conddb.addFolder("PIXEL_OFL",
                                 "/PIXEL/ChargeCalibration",
                                 className="CondAttrListCollection")
            if not hasattr(condSeq, 'PixelChargeLUTCalibCondAlg'):
                from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelChargeLUTCalibCondAlg
                condSeq += PixelChargeLUTCalibCondAlg(
                    name="PixelChargeLUTCalibCondAlg",
                    ReadKey="/PIXEL/ChargeCalibration")

        #####################
        # Cabling map Setup #
        #####################
        if (conddb.dbdata == "CONDBR2" or
            (conddb.dbmc == "OFLP200" and geoFlags.isIBL()
             == True)) and not conddb.folderRequested("/PIXEL/HitDiscCnfg"):
            conddb.addFolderSplitMC("PIXEL",
                                    "/PIXEL/HitDiscCnfg",
                                    "/PIXEL/HitDiscCnfg",
                                    className="AthenaAttributeList")

        if not hasattr(condSeq, 'PixelHitDiscCnfgAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelHitDiscCnfgAlg
            condSeq += PixelHitDiscCnfgAlg(name="PixelHitDiscCnfgAlg")

        if not conddb.folderRequested("/PIXEL/ReadoutSpeed"):
            if not (globalflags.DataSource() == 'geant4'):
                conddb.addFolder("PIXEL",
                                 "/PIXEL/ReadoutSpeed",
                                 className="AthenaAttributeList")
            else:
                conddb.addFolderSplitMC("PIXEL",
                                        "/PIXEL/ReadoutSpeed",
                                        "/PIXEL/ReadoutSpeed",
                                        className="AthenaAttributeList")

        if not hasattr(condSeq, 'PixelReadoutSpeedAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelReadoutSpeedAlg
            condSeq += PixelReadoutSpeedAlg(name="PixelReadoutSpeedAlg")

        if (globalflags.DataSource == 'data'):
            if not conddb.folderRequested("/PIXEL/CablingMap"):
                conddb.addFolderSplitOnline("PIXEL",
                                            "/PIXEL/Onl/CablingMap",
                                            "/PIXEL/CablingMap",
                                            className="AthenaAttributeList")

        if not hasattr(condSeq, 'PixelCablingCondAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelCablingCondAlg
            condSeq += PixelCablingCondAlg(
                name="PixelCablingCondAlg",
                MappingFile=IdMappingDat,
                RodIDForSingleLink40=rodIDForSingleLink40)

        #############################
        # Offline calibration Setup #
        #############################
        if not conddb.folderRequested("/PIXEL/PixReco"):
            conddb.addFolderSplitOnline("PIXEL",
                                        "/PIXEL/Onl/PixReco",
                                        "/PIXEL/PixReco",
                                        className="DetCondCFloat")

        if not hasattr(condSeq, 'PixelOfflineCalibCondAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelOfflineCalibCondAlg
            condSeq += PixelOfflineCalibCondAlg(
                name="PixelOfflineCalibCondAlg", ReadKey="/PIXEL/PixReco")
            PixelOfflineCalibCondAlg.InputSource = 2

        if not conddb.folderRequested("/Indet/PixelDist"):
            conddb.addFolderSplitOnline("INDET",
                                        "/Indet/Onl/PixelDist",
                                        "/Indet/PixelDist",
                                        className="DetCondCFloat")

        if not hasattr(condSeq, 'PixelDistortionAlg'):
            from PixelConditionsAlgorithms.PixelConditionsAlgorithmsConf import PixelDistortionAlg
            condSeq += PixelDistortionAlg(name="PixelDistortionAlg",
                                          ReadKey="/Indet/PixelDist")

        ### configure the special pixel map service
        if not (conddb.folderRequested("/PIXEL/PixMapShort")
                or conddb.folderRequested("/PIXEL/Onl/PixMapShort")):
            conddb.addFolderSplitOnline("PIXEL",
                                        "/PIXEL/Onl/PixMapShort",
                                        "/PIXEL/PixMapShort",
                                        className='CondAttrListCollection')
        if not (conddb.folderRequested("/PIXEL/PixMapLong")
                or conddb.folderRequested("/PIXEL/Onl/PixMapLong")):
            conddb.addFolderSplitOnline("PIXEL",
                                        "/PIXEL/Onl/PixMapLong",
                                        "/PIXEL/PixMapLong",
                                        className='CondAttrListCollection')
        if not (conddb.folderRequested("/PIXEL/NoiseMapShort")
                or conddb.folderRequested("/PIXEL/Onl/NoiseMapShort")):
            conddb.addFolderSplitOnline("PIXEL",
                                        "/PIXEL/Onl/NoiseMapShort",
                                        "/PIXEL/NoiseMapShort",
                                        className='CondAttrListCollection')
        if not (conddb.folderRequested("/PIXEL/NoiseMapLong")
                or conddb.folderRequested("/PIXEL/Onl/NoiseMapLong")):
            conddb.addFolderSplitOnline("PIXEL",
                                        "/PIXEL/Onl/NoiseMapLong",
                                        "/PIXEL/NoiseMapLong",
                                        className='CondAttrListCollection')
        if not (conddb.folderRequested("/PIXEL/PixMapOverlay")
                or conddb.folderRequested("/PIXEL/Onl/PixMapOverlay")):
            conddb.addFolderSplitOnline("PIXEL",
                                        "/PIXEL/Onl/PixMapOverlay",
                                        "/PIXEL/PixMapOverlay",
                                        className='CondAttrListCollection')

        #######################
        # Lorentz Angle Setup #
        #######################
        if not hasattr(condSeq, 'PixelSiPropertiesCondAlg'):
            from SiPropertiesTool.SiPropertiesToolConf import PixelSiPropertiesCondAlg
            condSeq += PixelSiPropertiesCondAlg(
                name="PixelSiPropertiesCondAlg")

        from SiPropertiesTool.SiPropertiesToolConf import SiPropertiesTool
        TrigSiPropertiesTool = SiPropertiesTool(
            name="PixelSiPropertiesTool",
            DetectorName="Pixel",
            ReadKey="PixelSiliconPropertiesVector")

        ToolSvc += TrigSiPropertiesTool

        if not hasattr(condSeq, 'PixelSiLorentzAngleCondAlg'):
            from SiLorentzAngleTool.SiLorentzAngleToolConf import PixelSiLorentzAngleCondAlg
            condSeq += PixelSiLorentzAngleCondAlg(
                name="PixelSiLorentzAngleCondAlg",
                SiPropertiesTool=TrigSiPropertiesTool,
                UseMagFieldCache=True,
                UseMagFieldDcs=(not athenaCommonFlags.isOnline()))

        from SiLorentzAngleTool.SiLorentzAngleToolConf import SiLorentzAngleTool
        TrigPixelLorentzAngleTool = SiLorentzAngleTool(
            name=self.instanceName('PixelLorentzAngleTool'),
            DetectorName="Pixel",
            SiLorentzAngleCondData="PixelSiLorentzAngleCondData")

        ToolSvc += TrigPixelLorentzAngleTool
Ejemplo n.º 18
0
## @file TrigT1CaloMonitoring_forRecExCommission.py
#
# Standard monitoring jobOptions - runs on Tier0 (Reco_tf.py) or online.
#
# @authors Johanna Fleckner, Andrea Neusiedl, Peter Faulkner, Vasiliki Kouskoura
#
include.block(
    "TrigT1CaloMonitoring/TrigT1CaloMonitoring_forRecExCommission.py")

from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
from AthenaCommon.GlobalFlags import globalflags
from RecExConfig.AutoConfiguration import GetRunNumber

if athenaCommonFlags.isOnline:
    run1 = False
elif globalflags.DataSource() == "data":
    run1 = (GetRunNumber() < 230000)
else:  #MC
    run1 = False
if run1:
    include(
        "TrigT1CaloMonitoring/TrigT1CaloMonitoring_forRecExCommission_Run1.py")
else:
    include(
        "TrigT1CaloMonitoring/TrigT1CaloMonitoring_forRecExCommission_Run2.py")
Ejemplo n.º 19
0
    def configure(self):
        log = logging.getLogger( "TriggerConfigGetter.py" )
        from PyUtils.MetaReaderPeekerFull import metadata

        # first check the input
        if "HIT2RDO" in self._environment:
            TriggerFlags.doLVL2 = False
            TriggerFlags.doEF = False
            log.info("For simulation jobs the following flags are set:")
            log.info("globalflags.InputFormat             : %s", globalflags.InputFormat())
            log.info("globalflags.DataSource              : %s", globalflags.DataSource())
            log.info("TriggerFlags.configForStartup       : %s", TriggerFlags.configForStartup())
            log.info("TriggerFlags.dataTakingConditions   : %s", TriggerFlags.dataTakingConditions())
            log.info("TriggerFlags.doLVL2                 : %s", TriggerFlags.doLVL2())
            log.info("TriggerFlags.doEF                   : %s", TriggerFlags.doEF())
        else:
            if not self.checkInput():
                log.error("Could not determine job input. Can't setup trigger configuration and will return!")
                return
            # self.checkInput() may call TriggerConfigCheckMetadata, this can in turn set "rec.doTrigger.set_Value_and_Lock(False)"
            # but TriggerConfigGetter might have only been called in the first place due to this flag having been true, 
            # so re-check that we're still OK to be executing here
            if not (recAlgs.doTrigger() or rec.doTrigger() or TriggerFlags.doTriggerConfigOnly()):
                log.info("Aborting TriggerConfigGetter as the trigger flags were switched to false in checkInput()")
                return True

        self.readPool       = globalflags.InputFormat() == 'pool'
        self.readRDO        = rec.readRDO()
        self.writeESDAOD    = rec.doWriteESD() or rec.doWriteAOD() or rec.doWriteDPD()
        self.writeAOD       = rec.doWriteAOD() or rec.doWriteDPD()
        self.ConfigSrcList  = TriggerFlags.configurationSourceList()
        self.readMC         = globalflags.DataSource()=='geant3' or globalflags.DataSource()=='geant4'
        self.readTriggerDB  = TriggerFlags.readMenuFromTriggerDb() and self.readRDO
        self.isCommisioning = globalflags.DataSource()=='data' and globalflags.DetGeo()=='commis' 
        self.l1Folders      = TriggerFlags.dataTakingConditions()=='FullTrigger' or TriggerFlags.dataTakingConditions()=='Lvl1Only'
        self.hltFolders     = TriggerFlags.dataTakingConditions()=='FullTrigger' or TriggerFlags.dataTakingConditions()=='HltOnly'
        self.isRun1Data     = False 
        self.hasxAODMeta    = ("metadata_items" in metadata and any(('TriggerMenu' in key) for key in metadata["metadata_items"].keys()))
        if globalflags.DataSource()=='data':
            from RecExConfig.AutoConfiguration  import GetRunNumber
            runNumber = GetRunNumber()
            if runNumber is not None and runNumber > 0 and runNumber < 230000 :
                self.isRun1Data = True
        self.isTriggerReprocessing = False

        # the TriggerFlags.readMenuFromTriggerDb() tells us that we read the trigger menu from the database
        # the connection itself is defined in TriggerFlags.triggerDbConnection()

        # reading from the TriggerDB can mean different things:

        # a) TriggerFlags doLVL2() and doEF() are both False:
        #    - create a tmp sqlite file with the conditions (menu)
        #    - use DSConfigSvc


        # b) TriggerFlags doLVL2() or doEF() is True:
        #    - use HLTConfigSvc
        if self.readTriggerDB and (TriggerFlags.doLVL2() or TriggerFlags.doEF() or TriggerFlags.doHLT()):

            self.ConfigSrcList = ['xml'] # to use L1/HLTConfigSvc and not DSConfigSvc, but only if we are running the HLT


        if self._environment: # I don't think anyone calls TriggerConfigGetter with an argument
            self.readPool  = False
            self.writeESDAOD = False
            self.readHits = False
            if "ReadPoolRDO" in self._environment:
                self.readPool = True
                self.readRDO = True
            elif "ReadPool" in self._environment:
                self.readPool = True
                self.readRDO = False
            if "WritePool" in self._environment:
                self.writeESDAOD = True
            if "HIT2RDO" in self._environment:
                self.readRDO = False
                self.readHits = True


        # define ConfigSvc
        if not self.ConfigSrcList:
            if (self.readPool and not self.readRDO) or (self.readRDO and not self.readPool): # (ESD, AOD, DPD) or (RDO-BS)
                self.ConfigSrcList = ['ds']
            elif (self.readRDO and self.readPool) or rec.readTAG() or self.readHits:           # (RDO-MC) or TAG
                self.ConfigSrcList = ['xml']
            else: # should not get here: should be found by checkInput
                log.fatal('no reading of BS, RDO, AOD, ESD, or TAG specified')

        # we need the temporary COOL database, if we read the configuration from XML and write ESD/AOD (or have 'ds' set for some reason)
        self.makeTempCool   = self.readRDO and \
                              ( self.writeESDAOD or 'ds' in self.ConfigSrcList ) and \
                              ( self.readMC \
                                or (self.isCommisioning and (TriggerFlags.readLVL1configFromXML() and TriggerFlags.readHLTconfigFromXML())) \
                                or TriggerFlags.readMenuFromTriggerDb() )

        log.info("Need to create temporary cool file? : %r", self.makeTempCool)

        log.info('Creating the Trigger Configuration Services')

        from AthenaCommon.AppMgr import ServiceMgr as svcMgr

        ########################################################################
        # START OF TEMPORARY SOLUTION FOR RUN-3 TRIGGER DEVELOPMENT
        ########################################################################
        from TriggerJobOpts.HLTTriggerResultGetter import EDMDecodingVersion
        EDMDecodingVersion()  # In most use cases this needs to be called much earlier than in HLTTriggerResultGetter

        if TriggerFlags.EDMDecodingVersion() >= 3:
            if self.hasxAODMeta:
                if not hasattr(svcMgr, 'xAODConfigSvc'):
                    from TrigConfxAOD.TrigConfxAODConf import TrigConf__xAODConfigSvc
                    svcMgr += TrigConf__xAODConfigSvc('xAODConfigSvc')
            else: # Does not have xAODMeta
                # Run-3 Trigger Configuration Services
                from TrigConfigSvc.TrigConfigSvcCfg import getL1ConfigSvc, getHLTConfigSvc
                from AthenaConfiguration.AllConfigFlags import ConfigFlags
                svcMgr += getL1ConfigSvc(ConfigFlags)
                svcMgr += getHLTConfigSvc(ConfigFlags)

                # Needed for TrigConf::xAODMenuWriterMT
                from TrigConfigSvc.TrigConfigSvcConfig import TrigConfigSvc
                svcMgr += TrigConfigSvc("TrigConfigSvc")
                svcMgr.TrigConfigSvc.PriorityList = ["none", "ds", "xml"]

        else:
            # non-MT (Run-2) Trigger Configuration
            self.svc = SetupTrigConfigSvc()

            if 'xml' in self.ConfigSrcList or self.makeTempCool:
                # sets them if plain XML reading is to be used
                self.svc.l1topoXmlFile = TriggerFlags.outputL1TopoConfigFile()  # generated in python
                self.svc.l1XmlFile     = TriggerFlags.outputLVL1configFile()    # generated in python
                self.svc.hltXmlFile    = TriggerFlags.outputHLTconfigFile()     # generated in python
                if TriggerFlags.readL1TopoConfigFromXML():
                    self.svc.l1topoXmlFile  = TriggerFlags.inputL1TopoConfigFile() # given XML
                if TriggerFlags.readLVL1configFromXML():
                    self.svc.l1XmlFile  = TriggerFlags.inputLVL1configFile() # given XML
                if TriggerFlags.readHLTconfigFromXML():
                    self.svc.hltXmlFile  = TriggerFlags.inputHLTconfigFile()   # given XML

            try:
                self.svc.SetStates( self.ConfigSrcList )
            except Exception:
                log.error( 'Failed to set state of TrigConfigSvc to %r', self.ConfigSrcList )
            else:
                log.info('The following configuration services will be tried: %r', self.ConfigSrcList )

            try:
                self.svc.InitialiseSvc()
            except Exception as ex:
                log.error( 'Failed to activate TrigConfigSvc: %r', ex )
        ########################################################################
        # END OF TEMPORARY SOLUTION FOR RUN-3 TRIGGER DEVELOPMENT
        ########################################################################

        if self.readTriggerDB:
            log.info( "Using TriggerDB connection '%s'", TriggerFlags.triggerDbConnection() )
            self.trigDbConnectionParameters = interpretConnection(TriggerFlags.triggerDbConnection(), resolveAlias=False)
            self.setConfigSvcConnParams(self.trigDbConnectionParameters)

        log.info("TriggerFlags.triggerCoolDbConnection is '%s' [default: '']", TriggerFlags.triggerCoolDbConnection())
        TrigCoolDbConnection = TriggerFlags.triggerCoolDbConnection()

        if self.makeTempCool:
            TrigCoolDbConnection = self.setupTempCOOLWriting(TrigCoolDbConnection)

        if ('ds' in self.ConfigSrcList) and not self.hasxAODMeta:
            self.setupCOOLReading(TrigCoolDbConnection)

        if hasattr(svcMgr, 'DSConfigSvc'):
            db = 'TRIGGERDB'
            if self.isRun1Data:
                db = 'TRIGGERDB_RUN1'
            elif self.readMC:
                db = 'TRIGGERDBMC'
            elif self.isTriggerReprocessing:
                db = 'TRIGGERDBREPR'
            svcMgr.DSConfigSvc.ConfigSource = 'dblookup'
            svcMgr.DSConfigSvc.DBServer = db
            log.info("DSConfigSvc trigger database is '%s'", db)
        
        if not self.hasxAODMeta:
            self.setupxAODWriting()


        # all went fine we are configured
        return True