Esempio n. 1
0
def getMuonCalibAlg(eventTag):
    global topSequence, beamFlags
    try:
        return topSequence.MuonCalibAlg
    except AttributeError:
        from MuonCalibAlgs.MuonCalibAlgsConf import MuonCalib__MuonCalibAlg
        MuonCalibAlg = MuonCalib__MuonCalibAlg(
            "MuonCalibAlg",
            doMDTs=muonRecFlags.doMDTs(),
            doCSCs=muonRecFlags.doCSCs(),
            doRPCs=muonRecFlags.doRPCs(),
            doTGCs=(muonRecFlags.doTGCs()
                    and muonRecFlags.calibNtupleRawTGC()),
            doTGCCoinData=(muonRecFlags.doTGCs()
                           and muonRecFlags.calibNtupleRawTGC()),
            doTruth=rec.doTruth(),
            DoPrdSelect=muonRecFlags.doPrdSelect(
            ),  # optional cutting away of PRD hits to simulate dead channels
            NtupleName=muonRecFlags.calibNtupleOutput(
            ),  # set the name of the output calibration ntuple
            EventTag=eventTag)

        if beamFlags.beamType == 'singlebeam' or beamFlags.beamType == 'cosmics':
            MuonCalibAlg.addTriggerTag = False
        else:
            MuonCalibAlg.addTriggerTag = rec.doTrigger()
        MuonCalibAlg.doTruth = rec.doTruth()
        topSequence += MuonCalibAlg
        return topSequence.MuonCalibAlg
Esempio n. 2
0
def BunchCrossingConfProvider(type=""):

    # Get ourselves a logger:
    from AthenaCommon.Logging import logging
    __logger = logging.getLogger("BunchCrossingConfProvider")

    # If the user requested some instance directly:
    if type != "":
        if type == "TrigConf":
            __logger.info("Forcing the usage of TrigConfBunchCrossingTool")
            from TrigBunchCrossingTool.BunchCrossingTool import TrigConfBunchCrossingTool
            return TrigConfBunchCrossingTool()
        elif type == "LHC":
            __logger.info("Forcing the usage of LHCBunchCrossingTool")
            from TrigBunchCrossingTool.BunchCrossingTool import LHCBunchCrossingTool
            return LHCBunchCrossingTool()
        elif type == "MC":
            from TrigBunchCrossingTool.BunchCrossingTool import MCBunchCrossingTool
            __logger.info("Forcing the usage of MCBunchCrossingTool")
            return MCBunchCrossingTool()
        else:
            __logger.warning("Type = " + type + " not recognized")
            __logger.warning("Will select tool type based on global flags")

    # Decide which tool to use based on the global flags:
    from AthenaCommon.GlobalFlags import globalflags
    if globalflags.isOverlay():
        __logger.info("Selecting LHCBunchCrossingTool for overlay job")
        from TrigBunchCrossingTool.BunchCrossingTool import LHCBunchCrossingTool
        return LHCBunchCrossingTool()
    if globalflags.DataSource() == "data":
        from RecExConfig.RecFlags import rec
        from RecExConfig.RecAlgsFlags import recAlgs
        from TriggerJobOpts.TriggerFlags import TriggerFlags
        if rec.doTrigger() or TriggerFlags.doTriggerConfigOnly(
        ) or recAlgs.doTrigger():
            from TrigBunchCrossingTool.BunchCrossingTool import TrigConfBunchCrossingTool
            __logger.info("Selecting TrigConfBunchCrossingTool for this job")
            return TrigConfBunchCrossingTool()
        else:
            __logger.info(
                "Trigger turned off, selecting LHCBunchCrossingTool for this job"
            )
            from TrigBunchCrossingTool.BunchCrossingTool import LHCBunchCrossingTool
            return LHCBunchCrossingTool()
    else:
        __logger.info("Selecting MCBunchCrossingTool for this job")
        from TrigBunchCrossingTool.BunchCrossingTool import MCBunchCrossingTool
        return MCBunchCrossingTool()
def BunchCrossingConfProvider( type = "" ):

    # Get ourselves a logger:
    from AthenaCommon.Logging import logging
    __logger = logging.getLogger( "BunchCrossingConfProvider" )

    # If the user requested some instance directly:
    if type != "":
        if type == "TrigConf":
            __logger.info( "Forcing the usage of TrigConfBunchCrossingTool" )
            from TrigBunchCrossingTool.BunchCrossingTool import TrigConfBunchCrossingTool
            return TrigConfBunchCrossingTool()
        elif type == "LHC":
            __logger.info( "Forcing the usage of LHCBunchCrossingTool" )
            from TrigBunchCrossingTool.BunchCrossingTool import LHCBunchCrossingTool
            return LHCBunchCrossingTool()
        elif type == "MC":
            from TrigBunchCrossingTool.BunchCrossingTool import MCBunchCrossingTool
            __logger.info( "Forcing the usage of MCBunchCrossingTool" )
            return MCBunchCrossingTool()
        else:
            __logger.warning( "Type = " + type + " not recognized" )
            __logger.warning( "Will select tool type based on global flags" )

    # Decide which tool to use based on the global flags:
    from AthenaCommon.GlobalFlags import globalflags
    if globalflags.isOverlay():
        __logger.info( "Selecting LHCBunchCrossingTool for overlay job" )
        from TrigBunchCrossingTool.BunchCrossingTool import LHCBunchCrossingTool
        return LHCBunchCrossingTool()
    if globalflags.DataSource() == "data":
        from RecExConfig.RecFlags import rec
        from RecExConfig.RecAlgsFlags import recAlgs
        from TriggerJobOpts.TriggerFlags import TriggerFlags
        if rec.doTrigger() or TriggerFlags.doTriggerConfigOnly() or recAlgs.doTrigger():
            from TrigBunchCrossingTool.BunchCrossingTool import TrigConfBunchCrossingTool
            __logger.info( "Selecting TrigConfBunchCrossingTool for this job" )
            return TrigConfBunchCrossingTool()
        else:
            __logger.info( "Trigger turned off, selecting LHCBunchCrossingTool for this job" )
            from TrigBunchCrossingTool.BunchCrossingTool import LHCBunchCrossingTool
            return LHCBunchCrossingTool()
    else:
        __logger.info( "Selecting MCBunchCrossingTool for this job" )
        from TrigBunchCrossingTool.BunchCrossingTool import MCBunchCrossingTool
        return MCBunchCrossingTool()
Esempio n. 4
0
# Offline AthenaMonitoring configuration
# set DQMonFlags; defaults are in DataQualityTools/python/DQMonFlags.py
########################################################################

local_logger = logging.getLogger('DQMonFlagsConfig_jobOptions')

if not 'DQMonFlags' in dir():
    local_logger.debug("DQMonFlags not yet imported - I import them now")
    from AthenaMonitoring.DQMonFlags import DQMonFlags

if not 'rec' in dir():
    from RecExConfig.RecFlags import rec

from RecExConfig.RecAlgsFlags import recAlgs

if rec.doTrigger() == False:
    DQMonFlags.useTrigger = False  # steers trigger-awareness
    DQMonFlags.doLVL1CaloMon = False
    DQMonFlags.doCTPMon = False
    DQMonFlags.doHLTMon = False

# Set the data type based on beamType/HI flag
if globalflags.DataSource.get_Value() == 'geant4':
    DQMonFlags.monManDataType = 'monteCarlo'
elif rec.doHeavyIon():
    DQMonFlags.monManDataType = 'heavyioncollisions'
    DQMonFlags.doHIMon = True
elif jobproperties.Beam.beamType() == 'cosmics':
    DQMonFlags.monManDataType = 'cosmics'
elif jobproperties.Beam.beamType() == 'collisions':
    DQMonFlags.monManDataType = 'collisions'
    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
Esempio n. 6
0
    raise RuntimeError, " one and only one of readRDO (%s)  readESD (%s) readAOD (%s) should be on !!!" % (
        rec.readRDO(), rec.readESD(), rec.readAOD())

#now read input file to set up some flags accordingly if possible
# load an OKS with the input data file
from AthenaCommon.Include import excludeTracePattern

excludeTracePattern.append("*/PyUtils/*")

# if autoconfig not used, switched of doTruth for data
if globalflags.DataSource == 'data' and not 'DoTruth' in rec.AutoConfiguration(
):
    rec.doTruth = False

try:
    if rec.doTrigger():
        from TriggerJobOpts.TriggerFlags import TriggerFlags, sync_Trigger2Reco
except Exception:
    logRecExCommon_flags.info(
        "Could not load TriggerFlags. OK only if AtlasReconstruction. Switching of rec.doTrigger"
    )
    rec.doTrigger = False

#load commissioning flags here (major cleanup needed)
if rec.Commissioning():
    #--------------------------------------------------------------
    # Common flags with RecExCommon
    #--------------------------------------------------------------
    #if rec.readRDO:
    #   include( "RecExCommission/RecExCommissionCommonFlags_jobOptions.py" )
Esempio n. 7
0

   
#now read input file to set up some flags accordingly if possible
# load an OKS with the input data file
from AthenaCommon.Include import excludeTracePattern
excludeTracePattern.append("*/PyUtils/*")


# if autoconfig not used, switched of doTruth for data
if globalflags.DataSource=='data' and not 'DoTruth' in rec.AutoConfiguration():
   rec.doTruth=False


try:
   if rec.doTrigger():
      from TriggerJobOpts.TriggerFlags import TriggerFlags, sync_Trigger2Reco
except Exception:
   logRecExCommon_flags.info("Could not load TriggerFlags. OK only if AtlasReconstruction. Switching of rec.doTrigger")
   rec.doTrigger=False


#load commissioning flags here (major cleanup needed)
if rec.Commissioning():
   #--------------------------------------------------------------
   # Common flags with RecExCommon
   #--------------------------------------------------------------
   #if rec.readRDO:
   #   include( "RecExCommission/RecExCommissionCommonFlags_jobOptions.py" )

Esempio n. 8
0
def backgroundD3PD(alg=None,
                   level=10,
                   file='background.root',
                   tuplename='background',
                   flags=BackgroundD3PDMakerFlags,
                   **kw):

    preseq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())
    if (not hasattr(topSequence, 'BeamBackgroundFiller')
            and not hasattr(preseq, 'BeamBackgroundFiller')):
        if cfgKeyStore.isInInput("Trk::SegmentCollection",
                                 "ConvertedMBoySegments"):
            from RecBackgroundAlgs import RecBackgroundAlgsConf
            preseq += RecBackgroundAlgsConf.BeamBackgroundFiller()

    if (not hasattr(topSequence, 'BeamBackgroundFillerMoore')
            and not hasattr(preseq, 'BeamBackgroundFillerMoore')):
        if cfgKeyStore.isInInput("Trk::SegmentCollection", "MooreSegments"):
            from RecBackgroundAlgs.RecBackgroundAlgsConf import BeamBackgroundFiller
            BeamBackgroundFillerMoore = BeamBackgroundFiller(
                'BeamBackgroundFillerMoore',
                muonSegmentContainerKey='MooreSegments',
                BeamBackgroundKey='BeamBackgroundDataMoore')
            preseq += BeamBackgroundFillerMoore

    # The core algorithm
    if not alg:
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        alg = MSMgr.NewRootStream(tuplename, file)

    #Event level info
    alg += EventInfoD3PDObject(**_args(1, 'EventInfo', kw))
    if globalflags.DataSource == "data":
        alg += LBLengthD3PDObject(**_args(0, 'LBLength', kw))

    if rec.doTruth():
        from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject
        alg += GenEventD3PDObject(**_args(0, 'GenEvent', kw))

    if rec.doTrigger():
        alg += TrigDecisionD3PDObject(**_args(2, 'TrigDecision', kw))
        addTrigConfMetadata(alg)

        bcToolType = ""
        if globalflags.DataSource == "data":
            bcToolType = "LHC"
        addBunchStructureMetadata(alg, bcToolType)

        alg += BGCodeD3PDObject(**_args(2, 'BGCode', kw))

        if flags.AddTriggerBits():
            alg += getBkgdTriggerBitsD3PDObject([])

    alg += BackgroundWordD3PDObject(**_args(0, 'BkgWord', kw))
    if flags.doLUCID():
        alg += Lucid_RawDataD3PDObject(**_args(0, 'Lucid', kw))
    alg += RawInfoSummaryForTagD3PDObject(**_args(0, 'SumForTag', kw))

    alg += MBTSD3PDObject(**_args(0, 'MBTS', kw))
    alg += LArCollisionTimeD3PDObject(**_args(0, 'LArTimeDiff', kw))

    if flags.doMet():
        alg += MissingETD3PDObject(**_args(1,
                                           'MET_RefFinal',
                                           kw,
                                           sgkey='MET_RefFinal',
                                           prefix='MET_RefFinal',
                                           allowMissing=True))

    alg += MuonD3PDObject(
        **_args(0,
                'Muon',
                kw,
                sgkey='MuonCollection',
                prefix='mu_',
                include=[
                    "Isolation", "Quality", "MuonTimingFillerTool",
                    "MuonTileTimeTool", "ChamberT0"
                ],
                allowMissing=True))
    alg += MuonD3PDObject(
        **_args(0,
                'MuidMuon',
                kw,
                sgkey='MuidMuonCollection',
                prefix='mu_muid_',
                include=[
                    "Isolation", "Quality", "MuonTimingFillerTool",
                    "MuonTileTimeTool", "ChamberT0"
                ],
                allowMissing=True))
    alg += MuonD3PDObject(
        **_args(0,
                'StacoMuon',
                kw,
                sgkey='StacoMuonCollection',
                prefix='mu_staco_',
                include=[
                    "Isolation", "Quality", "MuonTimingFillerTool",
                    "MuonTileTimeTool", "ChamberT0"
                ],
                allowMissing=True))
    if flags.doCaloMuon():
        alg += MuonD3PDObject(
            **_args(0,
                    'CaloMuon',
                    kw,
                    sgkey='CaloMuonCollection',
                    prefix='mu_calo_',
                    include=[
                        "Isolation", "Quality", "MuonTimingFillerTool",
                        "MuonTileTimeTool", "ChamberT0"
                    ],
                    allowMissing=True))

    alg += MuonSegmentD3PDObject(**_args(
        1,
        'MuonSeg',
        kw,
        sgkey='MuonSegments',
        prefix='museg_',
        # MooreSegmentT0 takes the default time
        # MuonboySegmentT0 recalculates time (see MuonSegmentD3PDObject.py and MuonSegmentT0FillerTool.cxx)
        include=['MooreSegmentT0'],
        exclude=['MuonboySegmentT0'],
        allowMissing=True))
    alg += MuonSegmentD3PDObject(**_args(1,
                                         'MooreSeg',
                                         kw,
                                         sgkey='MooreSegments',
                                         prefix='mooreseg_',
                                         include=['MooreSegmentT0'],
                                         exclude=['MuonboySegmentT0'],
                                         allowMissing=True))
    alg += MuonSegmentD3PDObject(**_args(1,
                                         'MboySeg',
                                         kw,
                                         sgkey='ConvertedMBoySegments',
                                         prefix='mboyseg_',
                                         include=['MuonboySegmentT0'],
                                         exclude=['MooreSegmentT0'],
                                         allowMissing=True))
    if flags.doMuGirlSeg():
        alg += MuonSegmentD3PDObject(**_args(1,
                                             'MuGirlSeg',
                                             kw,
                                             sgkey='MuGirlSegments',
                                             prefix='mgseg_',
                                             include=['MooreSegmentT0'],
                                             exclude=['MuonboySegmentT0'],
                                             allowMissing=True))

    if flags.doTrk():
        alg += xAODTrackParticleD3PDObject(
            **_args(0, 'TrackParticle', kw, prefix='trk_'))

    if flags.doMuonHits():
        alg += MdtPrepDataD3PDObject(0)
        alg += RpcPrepDataD3PDObject(0)
        alg += CscPrepDataD3PDObject(0)
        alg += TgcPrepDataD3PDObject(0)

        alg += TgcPrepDataD3PDObject(**_args(0,
                                             'TGC_MeasurementsPriorBC',
                                             kw,
                                             sgkey='TGC_MeasurementsPriorBC',
                                             prefix='tgcPriorBC_',
                                             label='TgcPrepDataPriorBC'))
        alg += TgcPrepDataD3PDObject(**_args(0,
                                             'TGC_MeasurementsNextBC',
                                             kw,
                                             sgkey='TGC_MeasurementsNextBC',
                                             prefix='tgcNextBC_',
                                             label='TgcPrepDataNextBC'))

    if flags.doCaloJet():
        #alg += JetD3PDObject (**_args(4,'AntiKt4TopoEMJets', kw,  sgkey='AntiKt4TopoEMJets',   prefix='AntiKt4TopoEM_', include='BeamBackground' ))
        if cfgKeyStore.isInInput("Trk::SegmentCollection",
                                 "ConvertedMBoySegments"):
            alg += JetD3PDObject(
                **_args(4,
                        'AntiKt4TopoEMJets',
                        kw,
                        sgkey='AntiKt4TopoEMJets',
                        prefix='AntiKt4TopoEM_',
                        include=['BeamBackground'],
                        exclude=[
                            'JetVertexFraction', 'JVtx', 'ActiveArea',
                            'TruthMF', 'TracksMoments'
                        ],
                        BeamBackground_BeamBackgroundKey='BeamBackgroundData'))
        else:
            alg += JetD3PDObject(
                **_args(4,
                        'AntiKt4TopoEMJets',
                        kw,
                        sgkey='AntiKt4TopoEMJets',
                        prefix='AntiKt4TopoEM_',
                        exclude=[
                            'JetVertexFraction', 'JVtx', 'ActiveArea',
                            'TruthMF', 'TracksMoments'
                        ]))
    else:
        alg += JetD3PDObject(
            **_args(4,
                    'AntiKt4TrackJets',
                    kw,
                    sgkey='AntiKt4TrackJets',
                    prefix='AntiKt4Track_',
                    exclude=[
                        'JetVertexFraction', 'JVtx', 'ActiveArea', 'TruthMF',
                        'TracksMoments'
                    ]))

    alg += PrimaryxAODVertexD3PDObject(0)

    if flags.doBeamBkgd():
        #alg += BeamBackgroundD3PDObject(1)
        if cfgKeyStore.isInInput("Trk::SegmentCollection",
                                 "ConvertedMBoySegments"):
            alg += BeamBackgroundD3PDObject(
                **_args(1,
                        'BeamBackgroundData',
                        kw,
                        sgkey='BeamBackgroundData',
                        prefix='bb_',
                        bbJetIndex_Target='AntiKt4TopoEM_',
                        bbClusterIndex_Target='cl_'))
        if cfgKeyStore.isInInput("Trk::SegmentCollection", "MooreSegments"):
            alg += BeamBackgroundD3PDObject(
                **_args(1,
                        'BeamBackgroundData',
                        kw,
                        sgkey='BeamBackgroundDataMoore',
                        prefix='bbMoore_',
                        bbJetIndex_Target='AntiKt4TopoEM_',
                        bbClusterIndex_Target='cl_'))

    if flags.doBCM():
        alg += BcmRdoFlatD3PDObject(**_args(0, 'BCMRdo', kw))

    if flags.doZDC():
        if globalflags.DataSource == "data": alg += ZdcD3PDObject(10)

    if flags.doPixelClus():
        from InDetD3PDMaker.PixelClusterD3PDObject import PixelClusterD3PDObject
        alg += PixelClusterD3PDObject(0)

    if flags.doCaloClus():
        from CaloSysD3PDMaker.ClusterD3PDObject import ClusterD3PDObject
        alg += ClusterD3PDObject(1)

    return alg
Esempio n. 9
0
            cleaning.CutLevel = "LooseBad"
            cleaning.DoUgly = False
            ToolSvc += cleaning
            ToolSvc.TileJetMonTool.do_jet_cleaning   = True
            ToolSvc.TileJetMonTool.useJVTTool        = jvt
            ToolSvc.TileJetMonTool.useJetCleaning    = cleaning

        if DQMonFlags.monManDataType == 'heavyioncollisions':
            if not rec.doHIP(): 
                ToolSvc.TileJetMonTool.jetCollectionName = 'AntiKt4HIJets'
            ToolSvc.TileJetMonTool.do_event_cleaning = False
            ToolSvc.TileJetMonTool.do_jet_cleaning   = False
        
        ManagedAthenaTileMon.AthenaMonTools += [ ToolSvc.TileJetMonTool ]

    if (not 'doTileTMDBRawChannelMon' in dir() or doTileTMDBRawChannelMon)  and (DQMonFlags.useTrigger() and rec.doTrigger()):
        from TileConditions.TileCondToolConf import getTileCondToolTMDB
        tileCondToolTMDB = getTileCondToolTMDB('COOL')
        if tileCondToolTMDB:
            ToolSvc += tileCondToolTMDB
            ToolSvc += CfgMgr.TileTMDBRawChannelMonTool(name            = 'TileTMDBRawChannelDspMon'
                                                        , OutputLevel   = INFO
                                                        , NotDSP        = False
                                                        , Efficiency    = True
                                                        , TileRawChannelContainer = "MuRcvRawChCnt"
                                                        , TileCondToolTMDB = tileCondToolTMDB
                                                        , histoPathBase = "/Tile/TMDBRawChannel/Dsp")
            ManagedAthenaTileMon.AthenaMonTools += [ ToolSvc.TileTMDBRawChannelDspMon ];


Esempio n. 10
0
include.block ("EventTagUtils/RegistrationStreamTrig_jobOptions.py")

from EventTagUtils.EventTagUtilsConf import RegistrationStreamTrig as ConfiguredRegistrationStreamTrig
from RecExConfig.RecFlags import rec
topSequence += ConfiguredRegistrationStreamTrig(GetTriggerConf = rec.doTrigger())
if not rec.doTrigger() :
   print "RegistrationStreamTrig_jobOptions.py::WARNING: No Trigger keys in metadata if rec.doTrigger()=false"

print topSequence
Esempio n. 11
0
def configure(config):
    """Configure the calibration input and output.
    If both segmentsKey and segmentCombisKey are defined, segmentsKey has priority."""
    global topSequence, ToolSvc, MdtCalibTool, MuonSegmentToCalibSegment, MuonCalibAlg, MuonCalibTool, MuonCalibExtraTreeAlg, muonRecFlags
    log.info("Configuring with %s", config)

    calibMode = muonCalibFlags.Mode()
    #
    # Configure MuonSegmentToCalibSegment
    #
    try:
        MuonSegmentToCalibSegment = topSequence.MuonSegmentToCalibSegment
    except AttributeError:
        from MuonCalibPatRec.MuonCalibPatRecConf import MuonCalib__MuonSegmentToCalibSegment
        MuonSegmentToCalibSegment = MuonCalib__MuonSegmentToCalibSegment(
            "MuonSegmentToCalibSegment")
        topSequence += MuonSegmentToCalibSegment
    MuonSegmentToCalibSegment.UseCscSegments = muonRecFlags.doCSCs()

    # segmentsKey
    try:
        segmentsKey = config.segmentsKey
    except AttributeError:
        MuonSegmentToCalibSegment.ReadSegments = False
    else:
        MuonSegmentToCalibSegment.SegmentLocation = segmentsKey
        MuonSegmentToCalibSegment.ReadSegments = True
    # segmentCombisKey
    try:
        segmentCombisKey = config.segmentCombisKey
    except AttributeError:
        pass
    else:
        MuonSegmentToCalibSegment.SegmentCombiLocation = segmentCombisKey

    #
    # MuonCalibAlg
    #
    try:
        MuonCalibAlg = topSequence.MuonCalibAlg
    except AttributeError:
        from MuonCalibAlgs.MuonCalibAlgsConf import MuonCalib__MuonCalibAlg
        MuonCalibAlg = MuonCalib__MuonCalibAlg("MuonCalibAlg")
        topSequence += MuonCalibAlg
    if beamFlags.beamType() == 'singlebeam' or beamFlags.beamType(
    ) == 'cosmics':
        MuonCalibAlg.addTriggerTag = False
    else:
        MuonCalibAlg.addTriggerTag = recFlags.doTrigger()
    MuonCalibAlg.doMDTs = muonRecFlags.doMDTs()
    MuonCalibAlg.doCSCs = muonRecFlags.doCSCs()
    MuonCalibAlg.doRPCs = muonRecFlags.doRPCs()
    MuonCalibAlg.doTGCs = muonRecFlags.doTGCs()
    try:
        eventTag = config.eventTag
    except AttributeError:
        pass
    else:
        MuonCalibAlg.EventTag = eventTag

    MuonCalibAlg.doTruth = recFlags.doTruth()

    if calibMode == 'ntuple' or calibMode == 'trackNtuple':
        from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker
        MuonCalibTool = MuonCalib__PatternNtupleMaker()
        if calibMode == 'trackNtuple':
            if muonRecFlags.doSegmentsOnly():
                log.warning(
                    "Making ntuple instead of trackNtuple because making segments only"
                )
                muonCalibFlags.Mode = 'ntuple'
            else:
                MuonCalibTool.DelayFinish = True
                try:
                    MuonCalibExtraTreeAlg = topSequence.MuonCalibExtraTreeAlg
                except AttributeError:
                    from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg
                    MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg(
                        "MuonCalibExtraTreeAlg")
                    MuonCalibExtraTreeAlg.NtupleName = "PatternNtupleMaker"
                    topSequence += MuonCalibExtraTreeAlg

                # doPhi
                try:
                    doPhi = config.doPhi
                except AttributeError:
                    doPhi = False
                MuonCalibExtraTreeAlg.doPhi = doPhi
                # doTracks
                try:
                    doTracks = config.doTracks
                except AttributeError:
                    doTracks = False
                MuonCalibExtraTreeAlg.doTracks = doTracks
                # patternsKey
                try:
                    patternsKey = config.patternsKey
                except AttributeError:
                    pass
                else:
                    MuonCalibExtraTreeAlg.PatternLocation = patternsKey
                # tracksKey
                try:
                    tracksKey = config.tracksKey
                except AttributeError:
                    pass
                else:
                    MuonCalibExtraTreeAlg.TrackLocation = tracksKey

    else:  # other calib modes
        from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool
        MuonCalibTool = MuonCalib__MdtCalibTool()
        if calibMode == 'regionNtuple':
            from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool
            MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool()
        else:
            raise RuntimeError("Unknown Muon Calibration Mode: %r" % calibMode)

        ToolSvc += MdtCalibTool
        MuonCalibTool.MdtCalibTool = MdtCalibTool

    ToolSvc += MuonCalibTool
    MuonCalibAlg.MuonCalibTool = MuonCalibTool
Esempio n. 12
0
########################################################################
# Conditions access
# These lines were previously in SCT_Monitoring_ConditionsAccess.py
########################################################################

from SCT_Monitoring.SCT_MonitoringConf import SCTHitsNoiseMonTool
InDetSCTHitsTool = SCTHitsNoiseMonTool ( name                         = "InDetSCTHitsNoiseMonTool",
                                         OutputLevel                  = 4,
                                         doHitmapHistos               = False,
                                         CheckRate                    = 1000,
                                         doPositiveEndcap             = True,
                                         doNegativeEndcap             = True,
                                         doTrigger = globalflags.DataSource == "data")

from RecExConfig.RecFlags import rec
if not rec.doTrigger():
  InDetSCTHitsTool.doTrigger=False
	
InDetSCTHitsTool.tracksName = InDetKeys.SCTTracks() if  InDetFlags.doTrackSegmentsSCT() else InDetKeys.UnslimmedTracks()

ToolSvc += InDetSCTHitsTool
if (InDetFlags.doPrintConfigurables()):
  print InDetSCTHitsTool

from SCT_Monitoring.SCT_MonitoringConf import SCTTracksMonTool
InDetSCTTracksMonTool = SCTTracksMonTool ( name             = "InDetSCTTracksMonTool",
                                           OutputLevel      = 4,
                                           CheckRate        = 1000,
                                           doPositiveEndcap = True,
                                           doNegativeEndcap = True,
                                           doUnbiasedCalc   = True,
Esempio n. 13
0
            ecTool.PtCut = jetPtMin
            ecTool.EtaCut = jet_tracking_eta_limit
            ecTool.JvtDecorator = "passJvt"
            ecTool.OrDecorator = "passOR"
            ecTool.CleaningLevel = cleaning.CutLevel
            ToolSvc += ecTool
            TileJetMonTool.useJVTTool = jvt
            TileJetMonTool.useJetCleaning = cleaning
            TileJetMonTool.useEventCleaning = ecTool
            TileJetMonTool.jet_tracking_eta_limit = jet_tracking_eta_limit

        ManagedAthenaTileMon.AthenaMonTools += [TileJetMonTool]

    if (not 'doTileTMDBRawChannelMon' in dir()
            or doTileTMDBRawChannelMon) and (DQMonFlags.useTrigger()
                                             and rec.doTrigger()):
        from TileConditions.TileCondToolConf import getTileCondToolTMDB
        tileCondToolTMDB = getTileCondToolTMDB('COOL')
        if tileCondToolTMDB:
            ToolSvc += tileCondToolTMDB
            TileTMDBRawChannelDspMon = CfgMgr.TileTMDBRawChannelMonTool(
                name='TileTMDBRawChannelDspMon',
                OutputLevel=INFO,
                NotDSP=False,
                Efficiency=True,
                TileRawChannelContainer="MuRcvRawChCnt",
                TileCondToolTMDB=tileCondToolTMDB,
                histoPathBase="/Tile/TMDBRawChannel/Dsp")
            ManagedAthenaTileMon.AthenaMonTools += [TileTMDBRawChannelDspMon]

if tileRawMon:
Esempio n. 14
0
globalflags.InputFormat = 'pool'
globalflags.Luminosity = 'zero'

#--------------------------------------------------------------
# --- switch on only Muon Detector
#--------------------------------------------------------------
DetFlags.ID_setOff()
DetFlags.detdescr.ID_setOn()
DetFlags.Calo_setOff()
DetFlags.detdescr.Calo_setOn()
DetFlags.Muon_setOn()

# no digitization
DetFlags.digitize.all_setOff()

if not recFlags.doTrigger():
    DetFlags.LVL1_setOff()

#--------------------------------------------------------------
# switch on writing of Full Calibration ntuple by default
#--------------------------------------------------------------
muonRecFlags.doCalibNtuple = False
muonRecFlags.calibNtupleSegments = False
muonRecFlags.calibNtupleTracks = False
muonRecFlags.calibNtupleTrigger = False

#--------------------------------------------------------------
# select Standalone reconstruction
#--------------------------------------------------------------
muonRecFlags.doStandalone = True
# Offline AthenaMonitoring configuration
# set DQMonFlags; defaults are in DataQualityTools/python/DQMonFlags.py
########################################################################

local_logger = logging.getLogger('DQMonFlagsConfig_jobOptions')

if not 'DQMonFlags' in dir():
   local_logger.debug("DQMonFlags not yet imported - I import them now")
   from AthenaMonitoring.DQMonFlags import DQMonFlags

if not 'rec' in dir():
   from RecExConfig.RecFlags import rec

from RecExConfig.RecAlgsFlags import recAlgs

if rec.doTrigger() == False:
   DQMonFlags.useTrigger=False     # steers trigger-awareness
   DQMonFlags.doLVL1CaloMon=False
   DQMonFlags.doCTPMon=False
   DQMonFlags.doHLTMon=False

# Set the data type based on beamType/HI flag
if globalflags.DataSource.get_Value() == 'geant4':
   DQMonFlags.monManDataType = 'monteCarlo'
elif rec.doHeavyIon():
   DQMonFlags.monManDataType = 'heavyioncollisions'
   DQMonFlags.doHIMon = True
elif jobproperties.Beam.beamType()   == 'cosmics':
   DQMonFlags.monManDataType = 'cosmics'
elif jobproperties.Beam.beamType() == 'collisions':
   DQMonFlags.monManDataType = 'collisions'
Esempio n. 16
0
    #ManagedAthenaGlobalMon.AthenaMonTools += [ DQTGlobalWFinderTool ];

    # Import BackgroundMon tool

    if DQMonFlags.useTrigger():

        from DataQualityTools.DataQualityToolsConf import DQTBackgroundMon
        DQTBackgroundMon = DQTBackgroundMon(
            name='DQTBackgroundMon',
            histoPathBase="/GLOBAL/DQTBackgroundMon",
            doOfflineHists=isOffline,
            doOnlineHists=isOnline,
            doRunCosmics=isCosmics,
            doRunBeam=isBeam,
            doMuons=rec.doMuon(),
            doTrigger=rec.doTrigger())

        ToolSvc += DQTBackgroundMon
        ManagedAthenaGlobalMon.AthenaMonTools += [DQTBackgroundMon]

    # Default values
    MinSCTHits = 5
    MinPtCut = 4000

    #For now, to increase statistics in cosmics data taking
    if athenaCommonFlags.isOnline == True:
        MinSCTHits = 0
        MinPtCut = 500

    # Import MuonID tool
    #from DataQualityTools.DataQualityToolsConf import DQTMuonIDTrackTool
Esempio n. 17
0
##         svcMgr.ByteStreamAddressProviderSvc.TypeNames += ["LArRawChannelContainer/LArRawChannels"]

if DetFlags.readRDOBS.Tile_on():
    svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
        "TileRawChannelContainer/TileRawChannelCnt",
        "TileL2Container/TileL2Cnt"
    ]

if DetFlags.readRDOBS.LVL1_on():
    svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
        "ROIB::RoIBResult/RoIBResult", "MuCTPI_RDO/MUCTPI_RDO",
        "CTP_RDO/CTP_RDO", "L1TopoRDOCollection/L1TopoRDOCollection"
    ]

#if ATLASCosmicFlags.doLVL1Calo:
if rec.doTrigger():
    include("TrigT1CaloByteStream/ReadLVL1CaloBS_jobOptions.py")

if rec.doTrigger():
    if DetFlags.readRIOBS.Tile_on():
        svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
            "TileCellIDC/TileCellIDC",
        ]

    if DetFlags.readRIOBS.pixel_on():
        svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
            "Trk::PixelClusterContainer/PixelOnlineClusters",
        ]

    if DetFlags.readRIOBS.SCT_on():
        svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
Esempio n. 18
0
if DetFlags.readRIOBS.RPC_on():
    svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
        "RpcDigitContainer/RPC_DIGITS",
        "Muon::RpcPrepDataContainer/RPC_Measurements",
    ]

if DetFlags.readRIOBS.TGC_on():
    svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
        "TgcDigitContainer/TGC_DIGITS",
        "Muon::TgcPrepDataContainer/TGC_Measurements",
    ]

if DetFlags.readRIOBS.CSC_on():
    svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
        "CscDigitContainer/CSC_DIGITS",
        "Muon::CscPrepDataContainer/CSC_Clusters",
    ]

if DetFlags.readRIOBS.LVL1_on():
    svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
        "ROIB::RecRoIBResult/RecRoIBResult", "MuCTPI_RIO/MUCTPI_RIO",
        "CTP_RIO/CTP_RIO"
    ]

from RecExConfig.RecFlags import rec
if rec.doTrigger():
    svcMgr.ByteStreamAddressProviderSvc.TypeNames += [
        "HLT::HLTResult/HLTResult_L2", "HLT::HLTResult/HLTResult_EF"
    ]
Esempio n. 19
0
    def configure(self):

        if self._done:
            log.info("configuration already done, who is calling it again?")
            return True
        self._done = True

        # start with print some information what this will do
        log.info(
            "Basic configuration flags RecAlgsFlag.doTrigger: %d   RecFlags.doTrigger: %d TriggerFlags.doTriggerConfigOnly %d",
            recAlgs.doTrigger(), rec.doTrigger(), TF.doTriggerConfigOnly())
        log.info(
            "TriggerFlags: doL1Topo: %s, doLVL1: %s, doLVL2: %s, doEF: %s, doHLT: %s, doMT: %s",
            TF.doL1Topo(), TF.doLVL1(), TF.doLVL2(), TF.doEF(), TF.doHLT(),
            TF.doMT())

        # RDOtoRDOTrigger MT temporarily coded in the transform skeleton, so skip here
        if TF.doMT() and rec.readRDO() and rec.doWriteRDO():
            log.info("Nothing happens in TriggerGetter for RDOtoRDOTrigger MT")
            return True
        else:  #GenerateMenu imports slice flags, which are Menu/MenuMT dependent
            from TriggerMenu.menu.GenerateMenu import GenerateMenu

        willGenerateMenu = recAlgs.doTrigger() and (
            TF.doLVL1() or TF.doLVL2() or TF.doEF()
            or TF.doHLT()) and not TF.doTriggerConfigOnly()
        willRunTriggerConfigGetter = recAlgs.doTrigger() or rec.doTrigger(
        ) or TF.doTriggerConfigOnly()
        willRunLVL1SimulationGetter = recAlgs.doTrigger(
        ) and not TF.doTriggerConfigOnly()
        willRunHLTSimulationGetter = willRunLVL1SimulationGetter and (
            TF.doLVL2() or TF.doEF() or TF.doHLT())

        log.info(
            "Will run: %s%s%s%s", "GenerateMenu " if willGenerateMenu else "",
            "TriggerConfigGetter " if willRunTriggerConfigGetter else "",
            "LVL1SimulationGetter " if willRunLVL1SimulationGetter else "",
            "HLTSimulationGetter " if willRunHLTSimulationGetter else "")

        log.info(
            "Will not run: %s%s%s%s",
            "GenerateMenu " if not willGenerateMenu else "",
            "TriggerConfigGetter " if not willRunTriggerConfigGetter else "",
            "LVL1SimulationGetter " if not willRunLVL1SimulationGetter else "",
            "HLTSimulationGetter " if not willRunHLTSimulationGetter else "")
        if recAlgs.doTrigger():

            if ((TF.doLVL1() or TF.doLVL2() or TF.doEF() or TF.doHLT())
                    and not TF.doTriggerConfigOnly()):
                log.info("generating menu")
                # trigger menu files generation
                g = GenerateMenu()
                g.generate()

                # after the menu xml file has been created or the TriggerDB access is configured,
                # the COOL/SQlite db can be written
                # TB this needs to be optimized -- we do not need ti always but only when AOD or ESD are created

        if recAlgs.doTrigger() or rec.doTrigger() or TF.doTriggerConfigOnly():
            # setup configuration services
            from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
            cfg = TriggerConfigGetter()  # noqa: F841

            from TrigConfigSvc.TrigConf2COOL import theConfCOOLWriter
            theConfCOOLWriter.writeConf2COOL()

        # preconfigure TrigDecisionTool
        from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
        from AthenaCommon.AppMgr import ToolSvc
        ToolSvc += Trig__TrigDecisionTool("TrigDecisionTool")
        from PyUtils.MetaReaderPeekerFull import metadata
        if "metadata_items" in metadata and any(
            ('TriggerMenu' in key)
                for key in metadata["metadata_items"].keys()):
            # Use xAOD configuration.
            from AthenaCommon.AppMgr import ServiceMgr as svcMgr
            if not hasattr(svcMgr, 'xAODConfigSvc'):
                from TrigConfxAOD.TrigConfxAODConf import TrigConf__xAODConfigSvc
                svcMgr += TrigConf__xAODConfigSvc('xAODConfigSvc')
            ToolSvc += Trig__TrigDecisionTool("TrigDecisionTool")
            ToolSvc.TrigDecisionTool.TrigConfigSvc = svcMgr.xAODConfigSvc
        else:
            # Use TrigConfigSvc
            ToolSvc.TrigDecisionTool.TrigConfigSvc = "TrigConf::TrigConfigSvc/TrigConfigSvc"

        from TrigEDMConfig.TriggerEDM import EDMLibraries
        ToolSvc.TrigDecisionTool.Navigation.Dlls = [
            e for e in EDMLibraries if 'TPCnv' not in e
        ]

        # actuall trigger simulation running
        if recAlgs.doTrigger() and not TF.doTriggerConfigOnly():
            # setup Lvl1
            # initialize LVL1ConfigSvc
            log.info("configuring lvl1")
            from TriggerJobOpts.Lvl1TriggerGetter import Lvl1SimulationGetter
            lvl1 = Lvl1SimulationGetter()  # noqa: F841

            if TF.doTransientByteStream() or (
                    jobproperties.Global.InputFormat() != 'bytestream' and
                (TF.doLVL2() or TF.doEF() or TF.doHLT())):
                # Transient BS construction and intialization
                from ByteStreamCnvSvc import WriteByteStream
                StreamBS = WriteByteStream.getStream("Transient", "StreamBS")
                StreamBS.ItemList += [
                    "DataVector<LVL1::TriggerTower>#TriggerTowers"
                ]
                StreamBS.ItemList += ["TRT_RDO_Container#TRT_RDOs"]
                StreamBS.ItemList += ["SCT_RDO_Container#SCT_RDOs"]
                StreamBS.ItemList += ["PixelRDO_Container#PixelRDOs"]
                # StreamBS.ItemList +=["LArRawChannelContainer#*"]
                StreamBS.ItemList += ["2721#*"]
                # StreamBS.ItemList +=["TileRawChannelContainer#*"]
                StreamBS.ItemList += ["2927#*"]
                StreamBS.ItemList += [
                    "2934#*"
                ]  # added on request from: Arantxa Ruiz Martinez for TileRODMu

                # don't need Muons in transient BS
                # StreamBS.ItemList +=["MdtCsmContainer#*"]
                # StreamBS.ItemList +=["RpcPadContainer#*"]
                # StreamBS.ItemList +=["TgcRdoContainer#*"]
                # StreamBS.ItemList +=["CscRawDataContainer#*"]

                from AthenaCommon.Include import include
                # setup trans BS for the ID
                include("InDetRecExample/InDetRecCabling.py")

            # setup HLT
            # initialize HLT config svc
            log.info("TriggerFlags: doLVL2 %r", TF.doLVL2())
            log.info("TriggerFlags: doEF   %r", TF.doEF())
            log.info("TriggerFlags: doHLT  %r", TF.doHLT())
            if TF.doLVL2() or TF.doEF() or TF.doHLT():
                log.info("configuring hlt")
                from TriggerJobOpts.HLTTriggerGetter import HLTSimulationGetter
                hlt = HLTSimulationGetter(g)  # noqa: F841
            else:
                from RegionSelector.RegSelSvcDefault import RegSelSvcDefault
                from AthenaCommon.AppMgr import ServiceMgr
                ServiceMgr += RegSelSvcDefault()
                ServiceMgr.RegSelSvc.enablePixel = False
                ServiceMgr.RegSelSvc.enableSCT = False

        # prepare result making of L1
        from TriggerJobOpts.Lvl1ResultBuilderGetter import Lvl1ResultBuilderGetter
        hltouput = Lvl1ResultBuilderGetter()

        # prepare result making of HLT
        if TF.doLVL2() or TF.doEF() or TF.doHLT() or (recAlgs.doTrigger()
                                                      and TF.readBS()):
            from TriggerJobOpts.HLTTriggerResultGetter import HLTTriggerResultGetter
            hltouput = HLTTriggerResultGetter()  # noqa: F841

        return True
Esempio n. 20
0
    def configure(self):
        from AthenaCommon.Logging import logging
        mlog = logging.getLogger('CaloCellGetter_DigiHSTruth::configure:')
        mlog.info('entering')

        doStandardCellReconstruction = True
        from CaloRec.CaloCellFlags import jobproperties

        # get handle to upstream object
        # handle tile

        if doStandardCellReconstruction:
            from LArROD.LArRODFlags import larRODFlags

        # 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 Exception:
            mlog.error("could not import CaloRec.CaloCellMaker")
            print(traceback.format_exc())
            return False

        theCaloCellMaker = CaloCellMaker("CaloCellMaker_DigiHSTruth")
        self._CaloCellMakerHandle = theCaloCellMaker

        from AthenaCommon.AppMgr import ToolSvc

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

            if rec.doLArg():
                from LArCabling.LArCablingAccess import LArOnOffIdMapping
                LArOnOffIdMapping()

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

                if jobproperties.CaloCellFlags.doLArCreateMissingCells():
                    theLArCellBuilder.addDeadOTX = True

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

            if rec.doTile():
                try:
                    from TileRecUtils.TileRecUtilsConf import TileCellBuilder
                    theTileCellBuilder = TileCellBuilder(
                        "TileCellBuilder_DigiHSTruth")
                    theTileCellBuilder.TileRawChannelContainer = "TileRawChannelCnt_DigiHSTruth"
                    theTileCellBuilder.E4prContainer = "E4prContainer2_DigiHSTruth"
                    theTileCellBuilder.MBTSContainer = "MBTSContainer2_DigiHSTruth"
                    theTileCellBuilder.TileDSPRawChannelContainer = "TileRawChannelCnt_DigiHSTruth"

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

        #
        # CaloCellContainerFinalizerTool : closing container and setting up iterators
        #

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

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

        doLArMerge = False
        if doLArMerge:
            try:
                from LArCellRec.LArCellRecConf import LArCellMerger
                theLArCellMerger = LArCellMerger()
            except Exception:
                mlog.error("could not get handle to LArCellMerge Quit")
                print(traceback.format_exc())
                return False
            theLArCellMerger.RawChannelsName = larRODFlags.RawChannelFromDigitsContainerName(
            )
            theCaloCellMaker += 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 Exception:
                mlog.error(
                    "could not get handle to LArCellNoiseMaskingTool Quit")
                print(traceback.format_exc())
                return False

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

            if doNoiseMask:
                try:
                    from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelMasker
                    theLArNoiseMasker = LArBadChannelMasker("LArNoiseMasker")
                except Exception:
                    mlog.error("could not access bad channel tool Quit")
                    print(traceback.format_exc())
                    return False
                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
            theCaloCellMaker += theLArCellNoiseMaskingTool
            theCaloCellMaker.CaloCellMakerToolNames += [
                theLArCellNoiseMaskingTool
            ]

        #
        #  masking of Feb problems
        #
        doBadFebMasking = False
        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 Exception:
                mlog.error("could not get handle to LArBadFebMaskingTool Quit")
                print(traceback.format_exc())
                return False
            theCaloCellMaker += theLArBadFebMaskingTool

            theCaloCellMaker.CaloCellMakerToolNames += [
                theLArBadFebMaskingTool
            ]

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

        if doGainPathology:
            try:
                from LArCellRec.LArCellRecConf import LArCellGainPathology
                theLArCellGainPathology = LArCellGainPathology()
            except Exception:
                mlog.error("could not get handle to LArCellGainPatholog< Quit")
                print(traceback.format_exc())
                return False
            theCaloCellMaker += 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
            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 Exception:
                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 Exception:
                mlog.error("could not get handle to MisCalibTool Quit")
                print(traceback.format_exc())
                return False

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

        #
        # Pedestal shift correction
        #
        doPedestalCorr = False
        if jobproperties.CaloCellFlags.doPedestalCorr.statusOn:
            if jobproperties.CaloCellFlags.doPedestalCorr() and (
                    jobproperties.CaloCellFlags.doPileupOffsetBCIDCorr):
                doPedestalCorr = True
                mlog.info("Apply cell level pedestal shift correction")

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

        #
        # Correction for MinBias energy shift for MC pileup reco
        #
        doMinBiasAverage = False
        if jobproperties.CaloCellFlags.doMinBiasAverage.statusOn:
            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 Exception:
                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 Exception:
                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 Exception:
                mlog.error(
                    "could not get handle to CaloCellContainerCorrectorTool/MBAverageTool Quit"
                )
                print(traceback.format_exc())
                return False

            theCaloCellMaker += 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 Exception:
                mlog.error(
                    "could not get handle to  CaloCellNeighborsAverageCorr  Quit"
                )
                print(traceback.format_exc())
                return False
            theCaloCellMaker += 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 Exception:
                mlog.error("could not get handle to LArCellDeadOTXCorr Quit")
                print(traceback.format_exc())

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

        # 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

        theCaloCellMaker += 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())

        # Also note that we produce it as a transient output.
        objKeyStore.addTransient(self.outputType(), self.outputKey())

        from TileRecUtils.TileDQstatusAlgDefault import TileDQstatusAlgDefault
        TileDQstatusAlgDefault()

        # 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
Esempio n. 21
0
    def configure(self):

        if self._done:
            log.info("configuration already done, who is calling it again?")
            return True
        self._done = True

        # start with print some information what this will do
        log.info(
            "Basic configuration flags RecAlgsFlag.doTrigger: %d   RecFlags.doTrigger: %d TriggerFlags.doTriggerConfigOnly %d"
            % (recAlgs.doTrigger(), rec.doTrigger(), TF.doTriggerConfigOnly()))
        log.info(
            "TriggerFlags: doL1Topo: %s, doLVL1: %s, doLVL2: %s, doEF: %s, doHLT: %s"
            % (TF.doL1Topo(), TF.doLVL1(), TF.doLVL2(), TF.doEF(), TF.doHLT()))

        willGenerateMenu = recAlgs.doTrigger() and (
            TF.doLVL1() or TF.doLVL2() or TF.doEF()
            or TF.doHLT()) and not TF.doTriggerConfigOnly()
        willRunTriggerConfigGetter = recAlgs.doTrigger() or rec.doTrigger(
        ) or TF.doTriggerConfigOnly()
        willRunLVL1SimulationGetter = recAlgs.doTrigger(
        ) and not TF.doTriggerConfigOnly()
        willRunHLTSimulationGetter = willRunLVL1SimulationGetter and (
            TF.doLVL2() or TF.doEF() or TF.doHLT())

        log.info("Will run: %s%s%s%s" % (
            "GenerateMenu " if willGenerateMenu else "",
            "TriggerConfigGetter " if willRunTriggerConfigGetter else "",
            "LVL1SimulationGetter " if willRunLVL1SimulationGetter else "",
            "HLTSimulationGetter " if willRunHLTSimulationGetter else "",
        ))
        log.info("Will not run: %s%s%s%s" % (
            "GenerateMenu " if not willGenerateMenu else "",
            "TriggerConfigGetter " if not willRunTriggerConfigGetter else "",
            "LVL1SimulationGetter " if not willRunLVL1SimulationGetter else "",
            "HLTSimulationGetter " if not willRunHLTSimulationGetter else "",
        ))

        if recAlgs.doTrigger():

            # setup the trigger from the DB
            if TF.readConfigFromTriggerDb():
                return self.configureTriggerFromDB()

            if ((TF.doLVL1() == True or TF.doLVL2() == True
                 or TF.doEF() == True or TF.doHLT() == True)
                    and TF.doTriggerConfigOnly() == False):
                log.info("generating menu")
                # trigger menu files generation
                g = GenerateMenu()
                g.generate()

                # after the menu xml file has been created or the TriggerDB access is configured,
                # the COOL/SQlite db can be written
                # TB this needs to be optimized -- we do not need ti always but only when AOD or ESD are created

        if recAlgs.doTrigger() or rec.doTrigger() or TF.doTriggerConfigOnly():
            # setup configuration services
            from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
            cfg = TriggerConfigGetter()

            from TrigConfigSvc.TrigConf2COOL import theConfCOOLWriter
            theConfCOOLWriter.writeConf2COOL()

        # preconfigure TrigDecisionTool
        from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
        from AthenaCommon.AppMgr import ToolSvc
        ToolSvc += Trig__TrigDecisionTool("TrigDecisionTool")
        # tell tdt to use TrigConfigSvc (Since TrigDecisionTool-00-03-40, defaults to not use it)
        ToolSvc.TrigDecisionTool.TrigConfigSvc = "Trig::TrigConfigSvc/TrigConfigSvc"

        from TrigEDMConfig.TriggerEDM import EDMLibraries
        ToolSvc.TrigDecisionTool.Navigation.Dlls = [
            e for e in EDMLibraries if 'TPCnv' not in e
        ]

        # actuall trigger simulation running
        if recAlgs.doTrigger() and not TF.doTriggerConfigOnly():
            # setup Lvl1
            # initialize LVL1ConfigSvc
            log.info("configuring lvl1")
            from TriggerJobOpts.Lvl1TriggerGetter import Lvl1SimulationGetter
            lvl1 = Lvl1SimulationGetter()

            if jobproperties.Global.InputFormat() != 'bytestream' and (
                    TF.doLVL2 == True or TF.doEF == True or TF.doHLT == True):
                # Transient BS construction and intialization
                from ByteStreamCnvSvc import WriteByteStream
                StreamBS = WriteByteStream.getStream("Transient", "StreamBS")
                StreamBS.ForceRead = True
                StreamBS.ItemList += [
                    "DataVector<LVL1::TriggerTower>#TriggerTowers"
                ]
                StreamBS.ItemList += ["TRT_RDO_Container#TRT_RDOs"]
                StreamBS.ItemList += ["SCT_RDO_Container#SCT_RDOs"]
                StreamBS.ItemList += ["PixelRDO_Container#PixelRDOs"]
                # StreamBS.ItemList +=["LArRawChannelContainer#*"]
                StreamBS.ItemList += ["2721#*"]
                # StreamBS.ItemList +=["TileRawChannelContainer#*"]
                StreamBS.ItemList += ["2927#*"]
                StreamBS.ItemList += [
                    "2934#*"
                ]  # added on request from: Arantxa Ruiz Martinez for TileRODMu

                # don't need Muons in transient BS
                # StreamBS.ItemList +=["MdtCsmContainer#*"]
                # StreamBS.ItemList +=["RpcPadContainer#*"]
                # StreamBS.ItemList +=["TgcRdoContainer#*"]
                # StreamBS.ItemList +=["CscRawDataContainer#*"]

                from AthenaCommon.Include import include
                # setup trans BS for the ID
                include("InDetRecExample/InDetRecCabling.py")

            # setup HLT
            # initialize HLT config svc
            log.info("TriggerFlags: doLVL2 %r" % TF.doLVL2())
            log.info("TriggerFlags: doEF   %r" % TF.doEF())
            log.info("TriggerFlags: doHLT  %r" % TF.doHLT())
            if TF.doLVL2() == True or TF.doEF() == True or TF.doHLT() == True:
                log.info("configuring hlt")
                from TriggerJobOpts.HLTTriggerGetter import HLTSimulationGetter
                hlt = HLTSimulationGetter(g)
            else:
                from RegionSelector.RegSelSvcDefault import RegSelSvcDefault
                from AthenaCommon.AppMgr import ServiceMgr
                ServiceMgr += RegSelSvcDefault()
                ServiceMgr.RegSelSvc.enablePixel = False
                ServiceMgr.RegSelSvc.enableSCT = False

        # prepare result making of L1
        from TriggerJobOpts.Lvl1ResultBuilderGetter import Lvl1ResultBuilderGetter
        hltouput = Lvl1ResultBuilderGetter()

        # prepare result making of HLT
        if TF.doLVL2() == True or TF.doEF() == True or TF.doHLT() or (
                recAlgs.doTrigger() and TF.readBS()):
            from TriggerJobOpts.HLTTriggerResultGetter import HLTTriggerResultGetter
            hltouput = HLTTriggerResultGetter()

        return True
Esempio n. 22
0
if jobproperties.CaloRecFlags.doCaloTopoTower() and DetFlags.haveRIO.Calo_on():
    try:
        include("CaloRec/CaloTopoTower_jobOptions.py")
    except Exception:
        treatException("Problem with CaloTopoTower. Switched off.")
        jobproperties.CaloRecFlags.doCaloTopoTower = False
else:
    jobproperties.CaloRecFlags.doCaloTopoTower = False

#
# functionality : muon candidates in Tile
#
if DetFlags.haveRDO.Tile_on() and DetFlags.detdescr.Tile_on():
    # this part is needed if we are reading Geant4 RDO created before 14.5.0
    # but it's also safe to include this jobOptions even for new Geant4 RDO
    if globalflags.DataSource() == 'geant4' and rec.doTrigger():
        try:
            include("TileL2Algs/TileL2Algs_jobOptions.py")
        except Exception:
            treatException("Could not set up TileMuId at ROD")

if jobproperties.CaloRecFlags.doTileMuId():

    if DetFlags.haveRIO.Tile_on():
        from AthenaCommon.BeamFlags import jobproperties
        try:
            # will merge these 2 jobOptions eventually
            if jobproperties.Beam.beamType(
            ) == 'cosmics' or jobproperties.Beam.beamType() == 'singlebeam':
                include("TileMuId/TileMuId_cosmics_jobOptions.py")
            else:
Esempio n. 23
0
TriggerD3PDStream_msg = logging.getLogger('TriggerD3PD_prodJobOFragment')

# Check if the configuration makes sense:
if prodFlags.WriteTriggerD3PD.isVirtual:
    TriggerD3PDStream_msg.error("The Trigger D3PD stream can't be virtual! " +
                                "It's a configuration error!")
    raise NameError("Trigger D3PD set to be a virtual stream")

# Construct the stream and file names for the Trigger D3PD:
streamName = prodFlags.WriteTriggerD3PD.StreamName
fileName = buildFileName(prodFlags.WriteTriggerD3PD)
TriggerD3PDStream_msg.info( "Configuring Trigger D3PD with streamName '%s' and " \
                            "fileName '%s'" % ( streamName, fileName ) )

# Check if we will get trigger information:
triggerAvailable = (rec.doTrigger() and (not rec.noESDTrigger()))

# Print a warning if the trigger is not used:
if not triggerAvailable:
    TriggerD3PDStream_msg.warning(
        "Running without trigger information on the input. "
        "Most information will not be available/saved.")
    pass

# Set global D3PDMaker flags:
from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
D3PDMakerFlags.DoPAU = False
D3PDMakerFlags.DoTrigger = True
#FPP: patch to run D3PD with the merged L2EF (must add new flags in D3PDMakerConfig/python/D3PDMakerFlags.py)
D3PDMakerFlags.ElectronEFTrigPattern = "EF_[0-9]?e[0-9]+.*|HLT_[0-9]?e[0-9]+.*"
D3PDMakerFlags.ElectronL2TrigPattern = "L2_[0-9]?e[0-9]+.*"
Esempio n. 24
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