Exemple #1
0
    def checkInput(self):
        self.checkFileMetaData()

        log = logging.getLogger( "TriggerConfigGetter.py" )
        if "ReadPool" in self._environment or "WritePool" in self._environment:
            log.info("Flags are ignored, since 'ReadPool' or  'WritePool' is specified")
            return True

        if rec.readESD() or rec.readAOD(): # and globalflags.DataSource()=='data':  # need this for MC as well
            protectedInclude("TriggerJobOpts/TriggerConfigCheckMetadata.py")

        if rec.readRDO() and globalflags.InputFormat()=='bytestream' and globalflags.DataSource()=='data' and TriggerFlags.configForStartup()!='HLToffline':
            protectedInclude("TriggerJobOpts/TriggerConfigCheckHLTpsk.py")

        log.info("The following flags are set:")
        log.info("globalflags.InputFormat             : %s", globalflags.InputFormat())
        log.info("rec.read.*                          : RDO: %s, ESD: %s, AOD: %s, TAG: %s", rec.readRDO(), rec.readESD(), rec.readAOD(), rec.readTAG())
        log.info("rec.doWrite.*                       : ESD: %s, AOD: %s, TAG: %s", rec.doWriteESD(), rec.doWriteAOD(), rec.doWriteTAG())
        log.info("globalflags.DataSource              : %s", globalflags.DataSource())
        log.info("TriggerFlags.configForStartup       : %s", TriggerFlags.configForStartup())
        log.info("TriggerFlags.dataTakingConditions   : %s", TriggerFlags.dataTakingConditions())
        log.info("TriggerFlags.configurationSourceList: %s", TriggerFlags.configurationSourceList())

        count = len([1 for x in [rec.readRDO(),rec.readESD(),rec.readAOD()] if x ]) #readTAG is only set with another input
        if count == 0:
            log.warning("Don't know what the input format is.")
            return False
        if count >= 2:
            log.warning("More than one input format specified, please set only the appropriate one.")
            return False
        return True
Exemple #2
0
def inputFileNames():
    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags

    if athenaCommonFlags.FilesInput() != []:
        return athenaCommonFlags.FilesInput()
    from RecExConfig.RecFlags import rec
    inFiles = None

    # highest flag have precedence
    if rec.readTAG():
        inFiles = athenaCommonFlags.PoolTAGInput()
    elif rec.readAOD():
        inFiles = athenaCommonFlags.PoolAODInput()
    elif rec.readESD():
        inFiles = athenaCommonFlags.PoolESDInput()
    elif rec.readRDO():
        from AthenaCommon.GlobalFlags import globalflags
        if globalflags.InputFormat == 'bytestream':
            inFiles = athenaCommonFlags.BSRDOInput()
        else:
            inFiles = athenaCommonFlags.PoolRDOInput()
    else:
        raise RutimeError("Unable to determine input file")

    return inFiles
def _fixJetTiming(c, **kw):
    # Check version number of the input data.
    # If no version is found, assume old.
    rlist = release_version()
    if rlist:
        if rlist[0] >= 16: return
        if rlist[0] == 15 and rlist[1] >= 7: return
        if rlist[0] == 15 and rlist[1] == 6 and rlist[2] >= 8: return

    sgkey_in = c.Getter.SGKey
    sgkey_in = resolveSGKey('JetCollection', sgkey_in)
    sgkey_out = sgkey_in + '_timing'

    seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName())
    if not hasattr(seq, sgkey_out):
        tools = []
        caloqual_kw = {
            'doCellBasedVariables': True,
            'doConstituentBasedVariables': True,
            'doSamplingBasedVariables': True,
            'cutOnTile': 254,
            'cutOnLAr': 4000,
            'doTileQuality': True,
            'doLArQuality': True
        }

        if hasattr(JetRecToolsConf, 'JetTimeQualityTool'):
            # rel 15 setup
            tool1 = JetRecToolsConf.JetTimeQualityTool(sgkey_out + 'TimeTool',
                                                       DoTime=False,
                                                       DoQuality=False,
                                                       UseCells=False)
            if rec.readESD() or rec.readRDO():
                tool1.DoTime = True
                tool1.DoQuality = True
                tool1.UseCells = True
            if rec.readAOD() and (sgkey_in.find('H1Topo') >= 0
                                  or sgkey_in.find('LCTopo') >= 0):
                tool1.DoTime = True
            tools.append(tool1)
        else:
            # rel 16
            caloqual_kw['doTiming'] = True

        tool2 = JetCaloQualityTool(sgkey_out + 'QualTool', **caloqual_kw)
        tools.append(tool2)

        alg = JetD3PDMaker.JetFixupAlg(sgkey_out,
                                       InputKey=sgkey_in,
                                       OutputKey=sgkey_out,
                                       Tools=tools)
        for t in tools:
            alg += t

        seq += alg

    c.Getter.SGKey = sgkey_out
    return
Exemple #4
0
def egammaBuilderAvailable():
    " Return true if egammaBuilder is available."
    flag = False
    if rec.readRDO() or rec.readESD() and not rec.readAOD():
        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        if hasattr(topSequence, 'egamma'):
            flag = True
    return flag
Exemple #5
0
def getMetaData():
    '''
   Try to determine from the meta data whether the decoration has been performed already.
   '''
    from RecExConfig.RecFlags import rec
    if not rec.readRDO():
        from PyUtils.MetaReaderPeekerFull import metadata
    try:
        return metadata['/TagInfo'][metaDataKey()]
    except Exception:
        pass
    return ''
Exemple #6
0
    def __init__(self, name='TrigDataAccess'):
        super(TrigDataAccess, self).__init__(name)

        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        from TriggerJobOpts.TriggerFlags import TriggerFlags
        from AthenaCommon.GlobalFlags import globalflags
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        from AthenaCommon.Logging import logging
        log = logging.getLogger(name)

        self.loadFullCollections = (TriggerFlags.doEF()
                                    or TriggerFlags.doHLT())
        self.loadAllSamplings = (TriggerFlags.doLVL2() or TriggerFlags.doHLT())

        if (globalflags.DatabaseInstance == "COMP200"
                and TriggerFlags.doCaloOffsetCorrection()):
            self.ApplyOffsetCorrection = False
            log.warning(
                "Not possible to run BCID offset correction with COMP200")
        else:
            if TriggerFlags.doCaloOffsetCorrection():
                log.info('Enable HLT calo offset correction')
                if globalflags.DataSource(
                ) == 'data' and athenaCommonFlags.isOnline():
                    from IOVDbSvc.CondDB import conddb
                    conddb.addFolder("LAR_ONL", "/LAR/ElecCalibFlat/OFC")
                    from LArRecUtils.LArRecUtilsConf import LArFlatConditionSvc
                    svcMgr += LArFlatConditionSvc()
                    svcMgr.LArFlatConditionSvc.OFCInput = "/LAR/ElecCalibFlat/OFC"
                    svcMgr.ProxyProviderSvc.ProviderNames += [
                        "LArFlatConditionSvc"
                    ]

                from CaloTools.CaloLumiBCIDToolDefault import CaloLumiBCIDToolDefault
                theCaloLumiBCIDTool = CaloLumiBCIDToolDefault()
                svcMgr.ToolSvc += theCaloLumiBCIDTool
                self.CaloLumiBCIDTool = theCaloLumiBCIDTool
                self.ApplyOffsetCorrection = True
            else:
                log.info('Disable HLT calo offset correction')
                self.ApplyOffsetCorrection = False

        from RecExConfig.RecFlags import rec
        transientBS = (rec.readRDO()
                       and not globalflags.InputFormat() == 'bytestream')
        if (transientBS or TriggerFlags.writeBS()):
            if (not hasattr(svcMgr.ToolSvc, 'LArRawDataContByteStreamTool')):
                from LArByteStream.LArByteStreamConfig import LArRawDataContByteStreamToolConfig
                svcMgr.ToolSvc += LArRawDataContByteStreamToolConfig()
            svcMgr.ToolSvc.LArRawDataContByteStreamTool.DSPRunMode = 4
            svcMgr.ToolSvc.LArRawDataContByteStreamTool.RodBlockVersion = 10

        return
Exemple #7
0
def getMetaData():
    '''
   Try to determine from the meta data whether the decoration has been performed already.  
   '''
    from RecExConfig.RecFlags import rec
    if not rec.readRDO():
        from RecExConfig.InputFilePeeker import inputFileSummary
        try:
            # print 'DEBUG InDetPhysValMonitoring getMetaData %s' % inputFileSummary['metadata']
            return inputFileSummary['tag_info'][metaDataKey()]
        except Exception:
            pass
    return ''
Exemple #8
0
def sync_Trigger2Reco():
    from AthenaCommon.Include import include
    from RecExConfig.RecAlgsFlags import recAlgs
    from AthenaCommon.GlobalFlags import globalflags
    from RecExConfig.RecFlags import rec

    if recAlgs.doTrigger() and rec.readRDO(
    ) and not globalflags.InputFormat() == 'bytestream':
        include("TriggerJobOpts/TransientBS_DetFlags.py")

    if globalflags.InputFormat() == 'bytestream':
        TriggerFlags.readBS = True
        TriggerFlags.doLVL1 = False
        TriggerFlags.doLVL2 = False
        TriggerFlags.doEF = False

    if rec.doWriteBS():
        TriggerFlags.writeBS = True
Exemple #9
0
def GetDefaultTagRefStream(streams):
    # spot the most downstream target : this will be the default
    # except if one readXYZ is locked
    from RecExConfig.RecFlags import rec

    if rec.readRDO.is_locked() and rec.readRDO():
        if 'Stream1_ref' in streams:
            return 'Stream1_ref'
        if 'StreamRDO_ref' in streams:
            return 'StreamRDO_ref'
        elif 'StreamRAW_ref' in streams:
            return 'StreamRAW_ref'
        else:
            raise RuntimeError(
                " readRDO locked True and no Stream1 nor StreamRDO nor StreamRAW !"
            )
    if rec.readESD.is_locked() and rec.readESD():
        if 'StreamESD_ref' in streams:
            return 'StreamESD_ref'
        else:
            raise RuntimeError(" readESD locked True and no StreamESD !")

    if rec.readAOD.is_locked() and rec.readAOD():
        if 'StreamAOD_ref' in streams:
            return 'StreamAOD_ref'
        else:
            raise RuntimeError(" readAOD locked True and no StreamAOD !")

    # now deal with default case
    if 'StreamAOD_ref' in streams:
        return 'StreamAOD_ref'
    elif 'StreamESD_ref' in streams:
        return 'StreamESD_ref'
    elif 'Stream1_ref' in streams:
        return 'Stream1_ref'
    elif 'StreamRDO_ref' in streams:
        return 'StreamRDO_ref'
    elif 'StreamRAW_ref' in streams:
        return 'StreamRAW_ref'
    else:
        raise RuntimeError(" no known streams !")

    return None
Exemple #10
0
def setMetaData():
    '''
   Write the input source on which the InDet decoration algorithm was running to the meta data
   '''

    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    if metaDataKey() in svcMgr.TagInfoMgr.ExtraTagValuePairs:
        return

    from RecExConfig.RecFlags import rec
    str = ''
    if rec.readRDO():
        str = 'fromRDO'
    elif rec.readESD():
        str = 'fromESD'
    elif rec.readAOD():
        str = 'fromAOD'

    if metaDataKey() not in svcMgr.TagInfoMgr.ExtraTagValuePairs:
        svcMgr.TagInfoMgr.ExtraTagValuePairs[metaDataKey()] = str
Exemple #11
0
 def checkFileMetaData(self):
     log = logging.getLogger("TriggerConfigGetter.py")
     from RecExConfig.InputFilePeeker import inputFileSummary
     self.hasLBwiseHLTPrescalesAndL1ItemDef = True
     if rec.readESD() or rec.readAOD() or "ReadPool" in self._environment:
         self.hasLBwiseHLTPrescalesAndL1ItemDef = inputFileSummary[
             'metadata'].has_key(
                 '/TRIGGER/HLT/Prescales'
             )  # they were all added at the same time (Repro with 15.6.3.2 Prod)
     # protection against early runs
     if inputFileSummary.has_key(
             'run_number'
     ) and self._environment == "" and globalflags.DataSource(
     ) == 'data' and rec.readRDO() and any(
         [run < 134230 for run in inputFileSummary['run_number']]):
         self.hasLBwiseHLTPrescalesAndL1ItemDef = False
     if self.hasLBwiseHLTPrescalesAndL1ItemDef:
         log.info("Using LB-wise HLT prescales")
     else:
         log.info("Using run-wise HLT prescales")
Exemple #12
0
def OutputFileName(suffix=""):
    from RecExConfig.RecFlags import rec
    OutFileName = ""
    if rec.OutputFileNameForRecoStep() == "":
        if rec.readRDO():
            if globalflags.InputFormat() == "bytestream":
                OutFileName = "bs"
            else:
                OutFileName = "rdo"
        elif rec.readESD():
            OutFileName = "esd"
        elif rec.readAOD():
            OutFileName = "aod"
        else:
            OutFileName = "in"

        OutFileName = OutFileName + "to"
        if rec.doWriteBS():
            OutFileName = OutFileName + "bs"
        elif rec.doWriteRDO():
            OutFileName = OutFileName + "rdo"

        if rec.doESD():
            OutFileName = OutFileName + "esd"
        if rec.doAOD():
            OutFileName = OutFileName + "aod"
        if rec.doDPD():
            OutFileName = OutFileName + "dpd"
        if rec.doWriteTAG():
            OutFileName = OutFileName + "tag"

        if suffix != "":
            OutFileName = OutFileName + "_" + suffix
        print("Generated OutFileName", OutFileName)
    else:
        OutFileName = rec.OutputFileNameForRecoStep()
        print("User defined OutFileName", OutFileName)
    return OutFileName
Exemple #13
0
    def __init__(self, name='TrigDataAccess'):
        super(TrigDataAccess, self).__init__(name)

        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        from TriggerJobOpts.TriggerFlags import TriggerFlags
        from AthenaCommon.GlobalFlags import globalflags
        from AthenaCommon.Logging import logging
        log = logging.getLogger(name)
     
        self.loadFullCollections = ( TriggerFlags.doEF() or TriggerFlags.doHLT() )
        self.loadAllSamplings    = ( TriggerFlags.doLVL2() or TriggerFlags.doHLT() )
        log.info('Not possible anymore to enable HLT calo offset correction, tools deprecated')

        from RecExConfig.RecFlags import rec
        transientBS = (rec.readRDO() and not globalflags.InputFormat()=='bytestream')
        if ( transientBS or TriggerFlags.doTransientByteStream() ):
            if ( not hasattr(svcMgr.ToolSvc,'LArRawDataContByteStreamTool') ):
                from LArByteStream.LArByteStreamConfig import LArRawDataContByteStreamToolConfig
                svcMgr.ToolSvc += LArRawDataContByteStreamToolConfig()
            svcMgr.ToolSvc.LArRawDataContByteStreamTool.DSPRunMode=4
            svcMgr.ToolSvc.LArRawDataContByteStreamTool.RodBlockVersion=10

        return
def CaloAffectedToolDefault(name='CaloAffectedToolDefault'):

    # check if tool already exists
    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    if hasattr(svcMgr.ToolSvc, name):
        # re-use previously configured (public) tool
        return getattr(svcMgr.ToolSvc, name)

    mlog = logging.getLogger( 'CaloAffectedToolDefault' )

    from CaloTools.CaloToolsConf import CaloAffectedTool


    theTool = CaloAffectedTool(name)

    from RecExConfig.RecFlags import rec
    if rec.readRDO():
       theTool.readRaw = True
    else:
       theTool.readRaw = False
       from IOVDbSvc.CondDB import conddb
       conddb.addFolder ('', '/LAR/LArAffectedRegionInfo<metaOnly/>')

    return theTool
Exemple #15
0
def InputFileNames():
    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
    if athenaCommonFlags.FilesInput() != []:
        return athenaCommonFlags.FilesInput()
    from RecExConfig.RecFlags import rec
    inFiles = None

    ## FIXME
    ##     if (not athenaCommonFlags.PoolTAGInput.isDefault() or rec.readTAG() ):
    ##         inFiles=athenaCommonFlags.PoolTAGInput()
    ##     elif (not athenaCommonFlags.PoolAODInput.isDefault() or rec.readAOD() ):
    ##         inFiles=athenaCommonFlags.PoolAODInput()
    ##     elif (not athenaCommonFlags.PoolESDInput.isDefault() or rec.readESD() ):
    ##         inFiles=athenaCommonFlags.PoolESDInput()
    ##     elif not athenaCommonFlags.BSRDOInput.isDefault():
    ##         inFiles=athenaCommonFlags.BSRDOInput()
    ##     elif not athenaCommonFlags.PoolRDOInput.isDefault():
    ##         inFiles=athenaCommonFlags.PoolRDOInput()

    if rec.readTAG():
        inFiles = athenaCommonFlags.PoolTAGInput()
    elif rec.readAOD():
        inFiles = athenaCommonFlags.PoolAODInput()
    elif rec.readESD():
        inFiles = athenaCommonFlags.PoolESDInput()

    elif rec.readRDO():
        from AthenaCommon.GlobalFlags import globalflags
        if globalflags.InputFormat == 'bytestream':
            inFiles = athenaCommonFlags.BSRDOInput()
        else:
            inFiles = athenaCommonFlags.PoolRDOInput()
    else:
        raise RuntimeError("Unable to determine input file")

    return inFiles
Exemple #16
0
from AthenaCommon.GlobalFlags import globalflags

from RecExConfig.RecFlags import rec

if globalflags.InputFormat=='bytestream' or (not  TriggerFlags.doLVL1()):
    CBNT_AthenaAware.Members += ["LVL1::CBNTAA_LVL1CaloESD/CBNT_LVL1calo"]
elif (rec.readESD() or rec.readAOD()):
    CBNT_AthenaAware.Members += ["LVL1::CBNTAA_LVL1CaloESD/CBNT_LVL1calo"]
elif (rec.readRDO() and TriggerFlags.doLVL1()):
    CBNT_AthenaAware.Members += [ "LVL1::CBNTAA_LVL1calo/CBNT_LVL1calo" ]
elif ( jobproperties.CaloCellFlags.doFastCaloSim() and TriggerFlags.doLVL1()):
    CBNT_AthenaAware.Members += [ "LVL1::CBNTAA_LVL1calo/CBNT_LVL1calo" ]
       
CBNT_AthenaAware.Members += [ "CBNTAA_ReadRoIBResult/CBNT_ReadRoIBResult" ]

#CBNTAthenaAware=True
include( "CBNT_Athena/CBNT_AthenaAware_jobOptions.py" )
include( "CBNT_Athena/CBNT_EventInfo_jobOptions.py" )
if rec.Commissioning:
    from AthenaMonitoring.DQMonFlags import DQMonFlags
    if DQMonFlags.doCTPMon():
        include ("TrigT1CTMonitoring/NtupleFragment.py")
    if DQMonFlags.doLVL1CaloMon(): 
        include( "TrigT1CaloCalibTools/CBNT_L1Calo_jobOptions.py" ) 
else:
    doL1CaloCBNT_JEM = False
    doL1CaloCBNT_CPM = False
    doL1CaloCBNT_RODHeader = False
    include( "TrigT1CaloCalibTools/CBNT_L1Calo_jobOptions.py" ) 

    include("TrigNtInDet/jobOfragment_TrigNtInDet.py")
Exemple #17
0
def ConfigureInputType():
    from PyUtils.MetaReaderPeeker import metadata

    from AthenaCommon.GlobalFlags import globalflags
    streamsName = []

    if metadata['file_type'] == 'BS':
        #byte stream
        logAutoConfiguration.info("Input BS detected")
        globalflags.InputFormat = 'bytestream'
        rec.readRDO = True
        rec.readESD = False
        rec.readAOD = False
        rec.doAOD = False
        rec.doESD = True
        rec.doWriteAOD = False
        logAutoConfiguration.info(
            "BS format: setting globalflags.InputFormat=%s " %
            globalflags.InputFormat())
        logAutoConfiguration.info("BS format: setting rec.readRDO=%s " %
                                  rec.readRDO())
        logAutoConfiguration.info("BS format: setting rec.doAOD=%s " %
                                  rec.doAOD())
        logAutoConfiguration.info("BS format: setting rec.doESD=%s " %
                                  rec.doESD())
        logAutoConfiguration.info("BS format: setting rec.doWriteAOD=%s " %
                                  rec.doWriteAOD())
    else:
        globalflags.InputFormat = 'pool'
        #Get streamsName
        streamsName = []
        if 'processingTags' in metadata:
            streamsName = metadata['processingTags']
        if streamsName == None:
            streamsName = []
        logAutoConfiguration.info("Extracted streams %s from input file " %
                                  streamsName)

        if len(streamsName) == 0:
            logAutoConfiguration.warning(
                "ConfigureInputType: no stream in input file.")
        elif len(streamsName) > 1:
            logAutoConfiguration.warning(
                "ConfigureInputType: more than one stream: %s in input file. Default action. Consider the highest one."
            )
        else:
            rec.mergingStreamName = streamsName[0]

    from RecExConfig.RecoFunctions import OverlapLists
    try:
        from PrimaryDPDMaker.PrimaryDPDFlags import listRAWtoDPD, listESDtoDPD, listAODtoDPD
    except:
        logAutoConfiguration.warning(
            "Unable to import PrimaryDPDFlags. OK for ATN tests below AtlasAnalysis, otherwise suspicious."
        )
        listRAWtoDPD = []
        listESDtoDPD = []
        listAODtoDPD = []

    ## these lines have been added to guarantee the backward compatibility for the old DPD naming convention cosmics
    try:
        from PrimaryDPDMaker.PrimaryDPDFlags import listBackwardCompatibleAODtoDPD, listBackwardCompatibleESDtoDPD
        listESDtoDPD.extend(listBackwardCompatibleESDtoDPD)
        listAODtoDPD.extend(listBackwardCompatibleAODtoDPD)
    except:
        logAutoConfiguration.warning(
            "Primary DPDMake does not support the old naming convention!!")

    if 'TagStreamsRef' in metadata and metadata['TagStreamsRef'] != None:
        logAutoConfiguration.info("Input TAG detected")
        rec.readTAG = True
        logAutoConfiguration.info("Auto configured rec.readTAG=%s " %
                                  rec.readTAG())

    from RecExConfig.RecoFunctions import ItemInListStartsWith
    if ItemInListStartsWith("StreamAOD", streamsName) or ItemInListStartsWith(
            'StreamDAOD', streamsName) or ItemInListStartsWith(
                'StreamD2AOD', streamsName) or OverlapLists(
                    streamsName, listAODtoDPD) or ItemInListStartsWith(
                        'DAOD', streamsName) or ItemInListStartsWith(
                            'D2AOD', streamsName):
        logAutoConfiguration.info("Input AOD detected")
        rec.readRDO = False
        rec.readESD = False
        rec.readAOD = True
        rec.doAOD = False
        rec.doESD = False
        logAutoConfiguration.info("setting rec.readAOD=%s " % rec.readAOD())
    elif ItemInListStartsWith(
            "StreamESD", streamsName) or ItemInListStartsWith(
                'StreamDESD', streamsName) or ItemInListStartsWith(
                    'StreamD2ESD', streamsName) or OverlapLists(
                        streamsName, listESDtoDPD) or ItemInListStartsWith(
                            'DESD', streamsName) or ItemInListStartsWith(
                                'D2ESD', streamsName):
        logAutoConfiguration.info("Input ESD detected")
        rec.readRDO = False
        rec.readESD = True
        rec.readAOD = False
        rec.doAOD = True
        rec.doESD = False
        logAutoConfiguration.info("setting rec.readESD=%s " % rec.readESD())
        logAutoConfiguration.info("setting rec.doAOD=%s " % rec.doAOD())
    elif ItemInListStartsWith("Stream1", streamsName) or ItemInListStartsWith(
            "StreamRDO", streamsName) or ItemInListStartsWith(
                "OutputStreamRDO", streamsName) or OverlapLists(
                    streamsName, listRAWtoDPD):
        logAutoConfiguration.info("Input RDO detected")
        rec.readRDO = True
        rec.readESD = False
        rec.readAOD = False
        rec.doAOD = False
        rec.doESD = True
        logAutoConfiguration.info("setting rec.readRDO=%s " % rec.readRDO())
        logAutoConfiguration.info("setting rec.doESD=%s " % rec.doESD())
    elif ItemInListStartsWith("StreamEVGEN", streamsName):
        logAutoConfiguration.info("Input EVGEN detected")
        rec.readRDO = False
        rec.readESD = False
        rec.readAOD = False
        rec.doAOD = False
        rec.doESD = False
        logAutoConfiguration.info(
            "setting all unlocked rec.readXXX and rec.doXXX to False")
    elif ItemInListStartsWith("StreamHITS", streamsName):
        logAutoConfiguration.info("Input StreamEVGEN detected")

    elif metadata['file_type'] != 'BS':
        raise RuntimeError("ConfigureInputType cannot handle streamsName==%s" %
                           streamsName)
    return
Exemple #18
0
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration

from MuonCombinedRecExample.MuonCombinedKeys import MuonCombinedKeys as MuonCbKeys
from MuonCombinedRecExample.MuonCombinedRecFlags import muonCombinedRecFlags
from RecExConfig.RecFlags import rec
from RecExConfig.ObjKeyStore import cfgKeyStore

if (not rec.readRDO()
        or muonCombinedRecFlags.doAOD()) and not muonCombinedRecFlags.doxAOD():

    from RecExConfig.ObjKeyStore import cfgKeyStore

    #SA
    if not cfgKeyStore.isInInput('xAOD::TrackParticleContainer',
                                 MuonCbKeys.ExtrapolatedMSParticles()):
        from xAODTrackingCnv.xAODTrackingCnvConf import xAODMaker__TrackParticleCnvAlg
        alg1 = xAODMaker__TrackParticleCnvAlg(
            "TrackParticleCnvAlg_ExtrapolatedMS")
        alg1.AODContainerName = 'ExtrapolatedMuonSpectrometerParticles'  #ExtrapolatedMuonSpectrometerParticles
        alg1.xAODContainerName = MuonCbKeys.ExtrapolatedMSParticles()
        topSequence += alg1
        print "Added convertor for ", MuonCbKeys.ExtrapolatedMSParticles()

    # StatCombined
    if not cfgKeyStore.isInInput('xAOD::TrackParticleContainer',
                                 MuonCbKeys.StatCombinedParticles()):
        from xAODTrackingCnv.xAODTrackingCnvConf import xAODMaker__TrackParticleCnvAlg
        alg3 = xAODMaker__TrackParticleCnvAlg(
            "TrackParticleCnvAlg_StatCombined")
        alg3.AODContainerName = 'StatCombinedMuonParticles'  #xStatCombinedMuonParticles
        alg3.xAODContainerName = MuonCbKeys.StatCombinedParticles()
Exemple #19
0
def AODFix_Init():
    ''' This function is called to correctly setup AODFix.'''

    global _aodFixInstance

    from RecExConfig.RecFlags import rec

    ##################
    # exit if locked to false
    ##################
    if rec.doApplyAODFix.is_locked() and rec.doApplyAODFix.get_Value(
    ) == False:
        logAODFix.info(
            "doApplyAODFix is locked to False; not applying anything")
        return

    ##################
    # deterimine in what release we are running (and fill some rec variables
    ##################

    import os
    curRelease = os.getenv("AtlasVersion") or ''

    logAODFix.debug("curRelease set to " + curRelease)

    ##################
    # determine athena with which input file was created and previous AODFix
    ##################

    # RDO doesn't have MetaData
    prevAODFix = ''
    prevRelease = ''
    isMC = False
    isHI = rec.doHeavyIon()
    isHIP = rec.doHIP()

    # is it better to do this or to look at GlobalFlags?
    from RecExConfig.InputFilePeeker import inputFileSummary
    try:
        isMC = (inputFileSummary['evt_type'][0] == "IS_SIMULATION")
    except Exception:
        logAODFix.warning(
            "Could not tell if the input file is data or MC; setting to data")
        isMC = False

    if not rec.readRDO():

        try:
            AtlasReleaseVersionString = inputFileSummary['metadata'][
                '/TagInfo']['AtlasRelease']
            rv = AtlasReleaseVersionString.split('-')
            if len(rv) > 1:
                prevRelease = rv[1]
        except Exception:
            logAODFix.warning(
                "no AthenRelease found in input file, setting to <none> !!")
            prevRelease = ''

        ##################
        # determine which is the previous verion of the AODFix
        ##################
        try:
            prevAODFix = inputFileSummary['tag_info']['AODFixVersion']
            if prevAODFix.startswith("AODFix_"):
                prevAODFix = prevAODFix[7:]
                prevAODFix = prevAODFix.split("_")[0]
        except Exception:
            logAODFix.debug(
                "no AODFixVersion found in input file, setting to <none>.")
            prevAODFix = ''

    logAODFix.info("Summary of MetaData for AODFix:")
    if isMC:
        logAODFix.info(" Input file is MC")
    else:
        logAODFix.info(" Input file is DATA")
    logAODFix.info(" Input file produced with Athena version <%s>." %
                   prevRelease)
    logAODFix.info(" AODFix version <%s> was previously applied." % prevAODFix)
    if rec.doApplyAODFix.is_locked():
        logAODFix.info(" AODFix is forced to run!")

    ##################
    # determine which AODFix to run (if actually running--to be determined later)
    ##################

    doAODFix = False
    if rec.readAOD():  # change in policy: no AODFix if reading ESD.
        doAODFix = True
        # check to see if it's a DAOD; do not run by default in DAODs
        from RecExConfig.InputFilePeeker import inputFileSummary
        try:
            streamNames = inputFileSummary['stream_names']
            if any(map(lambda x: "StreamDAOD" in x,
                       streamNames)) and not rec.doApplyAODFix.is_locked():
                logAODFix.info("Running on a DAOD, so not scheduling AODFix")
                doAODFix = False
        except Exception:
            logAODFix.warning("Could not determine the stream name")

    elif rec.readESD() and rec.doApplyAODFix.is_locked():
        # only run on ESDs if forcing
        doAODFix = True

    #exit if not doing AODFix
    if not doAODFix:
        return

    curReleaseSplit = curRelease.split('.')
    prevReleaseSplit = prevRelease.split('.')
    if len(curReleaseSplit) >= 2 and (rec.doApplyAODFix.is_locked()
                                      or len(prevReleaseSplit) >= 2):
        ### If adding an AODFix for a release family that does not have it,
        ### please add it to the if-elif... statement below
        # if (curReleaseSplit[0] == '21' and (curReleaseSplit[1] == '0' or curReleaseSplit[1] == '2') and
        #       (rec.doApplyAODFix.is_locked() or
        #        (prevReleaseSplit[0] == '21' and (prevReleaseSplit[1] == '0' or prevReleaseSplit[1] == '2')))):
        #     _aodFixInstance = AODFix_r210(prevAODFix, isMC, rec.doApplyAODFix.is_locked(), isHI, isHIP)
        # else:
        #     logAODFix.info("No AODFix scheduled for this release.")
        logAODFix.info("AODFix disabled.")

    else:
        logAODFix.info("Current release is of strange form: %s" % curRelease)
Exemple #20
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
Exemple #21
0
        "invalid jobproperties.Beam.beamType(): %s, using default (%s)",
        jobproperties.Beam.beamType(), DQMonFlags.monManDataType)

# First, test to see if this is being run online
if athenaCommonFlags.isOnline:
    DQMonFlags.monManEnvironment = 'online'

# Running offline; set the monMan environment based on monType
elif DQMonFlags.monType == 'BSonly':
    DQMonFlags.monManEnvironment = 'tier0Raw'
    if rec.readESD():
        DQMonFlags.doMonitoring = False

elif DQMonFlags.monType == 'ESDonly':
    DQMonFlags.monManEnvironment = 'tier0ESD'
    if rec.readRDO():
        DQMonFlags.doMonitoring = False

elif (DQMonFlags.monType == 'BS_ESD'):
    if rec.readRDO():
        DQMonFlags.monManEnvironment = 'tier0Raw'
    if rec.readESD():
        DQMonFlags.monManEnvironment = 'tier0ESD'
    if rec.readAOD():
        DQMonFlags.monManEnvironment = 'AOD'

elif DQMonFlags.monType == 'BSall':
    DQMonFlags.monManEnvironment = 'tier0'
    if rec.readESD():
        DQMonFlags.doMonitoring = False
else:
                        jobproperties.Beam.beamType(), DQMonFlags.monManDataType)


# First, test to see if this is being run online
if athenaCommonFlags.isOnline:
   DQMonFlags.monManEnvironment='online'

# Running offline; set the monMan environment based on monType
elif DQMonFlags.monType=='BSonly':
   DQMonFlags.monManEnvironment='tier0Raw'
   if rec.readESD(): 
      DQMonFlags.doMonitoring=False

elif DQMonFlags.monType=='ESDonly':  
   DQMonFlags.monManEnvironment='tier0ESD' 
   if rec.readRDO(): 
      DQMonFlags.doMonitoring=False

elif (DQMonFlags.monType=='BS_ESD'):
   if rec.readRDO():
      DQMonFlags.monManEnvironment='tier0Raw'
   if rec.readESD(): 
      DQMonFlags.monManEnvironment='tier0ESD'
   if rec.readAOD():
      DQMonFlags.monManEnvironment='AOD'

elif DQMonFlags.monType=='BSall':
   DQMonFlags.monManEnvironment='tier0'
   if rec.readESD(): 
      DQMonFlags.doMonitoring=False
else:
    "LAR", "/LAR/BadChannels/MissingFEBs",
    "/LAR/BadChannelsOfl/MissingFEBs" + forceRN + rekeyMF)
# and the same for Known Noisy and MNB FEBs
if (rec.doESD() or rec.doRDOTrigger()) and ('COMP200'
                                            not in conddb.GetInstance()):
    rekeyBADF = "<key>/LAR/BadChannels/KnownBADFEBs</key>"
    rekeyMNBF = "<key>/LAR/BadChannels/KnownMNBFEBs</key>"
    conddb.addFolderSplitOnline(
        "LAR", "/LAR/BadChannels/KnownBADFEBs",
        "/LAR/BadChannelsOfl/KnownBADFEBs" + forceRN + rekeyBADF)
    conddb.addFolderSplitOnline(
        "LAR", "/LAR/BadChannels/KnownMNBFEBs",
        "/LAR/BadChannelsOfl/KnownMNBFEBs" + forceRN + rekeyMNBF)

if not larCondFlags.LoadElecCalib.is_locked():
    larCondFlags.LoadElecCalib.set_Value(rec.readRDO())

#For run 2 we use cool-inline storage in online database COOLONL_LAR/CONDBR2:
haveElecCalibInline = (conddb.dbdata == "CONDBR2")

if (haveElecCalibInline):
    # Run 2 case:
    #This service creates a objects in the DetectorStore that wrap the AttributeListCollections
    #with the inline representation of the electronic calibration and makes them accessible through the
    #ILArRamp, ILArOFC, etc. abstract interfaces
    from LArRecUtils.LArRecUtilsConf import LArFlatConditionSvc
    theLArCondSvc = LArFlatConditionSvc()
    svcMgr += theLArCondSvc
    svcMgr.ProxyProviderSvc.ProviderNames += ["LArFlatConditionSvc"]

#Load HVScaleCorr. For run 2,these constants are also used by the CaloNoiseToolDB
Exemple #24
0
def RecoFix_Init():
    ''' This function is called to correctly setup RecoFix.'''

    global _recoFixInstance

    from RecExConfig.RecFlags import rec

    ##################
    # deterimine in what release we are running (and fill some rec variables
    ##################

    import os
    curRelease = os.getenv("AtlasVersion") or ''

    logRecoFix.debug("curRelease set to " + curRelease)

    ##################
    # determine athena with which input file was created and previous RecoFix
    ##################

    # RDO doesn't have MetaData
    prevAODFix = ''
    if not rec.readRDO():

        ##################
        # determine which is the previous verion of the AODFix
        ##################
        # is it better to do this or to look at GlobalFlags?
        from RecExConfig.InputFilePeeker import inputFileSummary
        try:
            prevAODFix = inputFileSummary['tag_info']['AODFixVersion']
            if prevAODFix.startswith("AODFix_"):
                prevAODFix = prevAODFix[7:]
                prevAODFix = prevAODFix.split("_")[0]
        except Exception:
            logRecoFix.debug(
                "no AODFixVersion found in input file, setting to <none>.")
            prevAODFix = ''

    logRecoFix.info("Summary of MetaData for RecoFix:")
    logRecoFix.info(" AODFix version <%s> was previously applied." %
                    prevAODFix)

    ##################
    # determine which RecoFix to run (if actually running--to be determined later)
    ##################

    doRecoFix = False
    if rec.doESD():
        # running from RAW or ESD, set recofix metadata
        logRecoFix.debug("detected doESD=True, applying RecoFix metadata")
        doRecoFix = True

    #exit if not doing RecoFix
    if not doRecoFix:
        return

    curReleaseSplit = curRelease.split('.')
    if len(curReleaseSplit) >= 2:
        ### If adding an RecoFix for a release family that does not have it,
        ### please add it to the if-elif... statement below
        if (curReleaseSplit[0] == '21'
                and (curReleaseSplit[1] == '0' or curReleaseSplit[1] == '2')):
            _recoFixInstance = RecoFix_r210()
        else:
            logRecoFix.info("No RecoFix scheduled for this release.")

    else:
        logRecoFix.info("Current release is of strange form: %s" % curRelease)
Exemple #25
0
    def sync_DetFlags(self,technologies="MDT,RPC,CSC,TGC,sTGC,Micromegas"):
        self.setDefaults()
        global rec
        from AthenaCommon.DetFlags import DetFlags
        # if Muons off, then do nothing
        if not DetFlags.Muon_on() or not rec.doMuon(): return

        flagsOn = []
        flagsOff = [ 'readRIOBS' ] # we don't store RIO (=PRD) on bytestream ???
        # Reading RDO
        if rec.readRDO():
            if muonRecFlags.makePRDs():
                flagsOn.append( 'makeRIO' )
            else:
                flagsOff.append( 'makeRIO' )
            if globalflags.InputFormat == 'pool'      :
                flagsOn.append( 'readRDOPool' )
                flagsOff.append( 'readRDOBS' )
            elif globalflags.InputFormat == 'bytestream':
                flagsOn.append( 'readRDOBS'   )
                flagsOff.append( 'readRDOPool' )
        else: # not reading RDO

            flagsOff.append( 'makeRIO' )

        # Reading ESD
        if rec.readESD():
            flagsOn.append( 'readRIOPool' )
        else:
            flagsOff.append( 'readRIOPool' )

        # Writing RDO Pool
        if rec.doWriteRDO():
            flagsOn.append( 'writeRDOPool' )
        else:
            flagsOff.append( 'writeRDOPool' )

        # Writing RDO bystream
        if rec.doWriteBS() :
            flagsOn.append( 'writeBS' )
        else:
            flagsOff.append( 'writeBS' )

        # Writing ESD
        if rec.doWriteESD():
            flagsOn.append( 'writeRIOPool' )
        else:
            flagsOff.append( 'writeRIOPool' )

        # Digitization on-the-fly
        if self.doDigitization():
            flagsOn.append( 'digitize' )
            try:
                flagsOn.remove( 'readRDOPool' )
            except ValueError: # not in list
                pass
            try:
                flagsOn.remove( 'readRDOBS' )
            except ValueError: # not in list
                pass
            flagsOff.append( 'readRDOPool' )
            flagsOff.append( 'readRDOBS'   )
            # very special case for normal Rome production (inspired by RecExCommon_DetFlags.py)
            if 'readRIOPool' not in flagsOn:
                flagsOn.append( 'readRIOPool' )
                try:
                    flagsOff.remove( 'readRIOPool' )
                except ValueError: # not in list
                    pass
            if not rec.doWriteRDO() and 'makeRIO' not in flagsOn:
                flagsOn.append( 'makeRIO' )
                try:
                    flagsOff.remove( 'makeRIO' )
                except ValueError: #not in list
                    pass
                    
        else:
            flagsOff.append( 'digitize')


        # do sync per technology for selected flags
        MDT_on = self.doMDTs()
        RPC_on = self.doRPCs()
        CSC_on = self.doCSCs()
        TGC_on = self.doTGCs()
        sTGC_on = self.dosTGCs()
        Micromegas_on = self.doMicromegas()
        techList = technologies.split(',')
        for f in flagsOn:
            for tech in techList:
                setOn = eval(tech+'_on')
                isOn = eval("DetFlags.%s.%s_on()" % (f,tech))
                if setOn:
                    if not isOn:
                        cmd = "DetFlags.%s.%s_setOn()" % (f,tech)
                        logMuon.info(cmd)
                        exec(cmd)
                else: # set off
                    if isOn:
                        cmd = "DetFlags.%s.%s_setOff()" % (f,tech)
                        logMuon.info(cmd)
                        exec(cmd)

        # Turn off Muon flags (row in DetFlags printout)
        for f in flagsOff:
            isOn = eval("DetFlags.%s.Muon_on()" % f)
            if isOn:
                cmd = "DetFlags.%s.Muon_setOff()" % f
                logMuon.info(cmd)
                exec(cmd)
Exemple #26
0
def EDMDecodingVersion():

    log = logging.getLogger("EDMDecodingVersion")

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

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

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

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

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

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

        boundary_run12 = 230000
        boundary_run23 = 368000

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

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

        TriggerFlags.doMergedHLTResult = True
        if cfgKeyStore.isInInputFile("HLT::HLTResult", "HLTResult_EF"):
            TriggerFlags.EDMDecodingVersion = 1
            TriggerFlags.doMergedHLTResult = False
            log.info(
                "Decoding version set to 1, because HLTResult_EF found in POOL file"
            )
        elif cfgKeyStore.isInInputFile("xAOD::TrigNavigation",
                                       "TrigNavigation"):
            TriggerFlags.EDMDecodingVersion = 2
            log.info(
                "Decoding version set to 2, because TrigNavigation found in POOL file"
            )
        elif cfgKeyStore.isInInputFile("xAOD::TrigCompositeContainer",
                                       "HLTNav_Summary"):
            TriggerFlags.EDMDecodingVersion = 3
            log.info(
                "Decoding version set to 3, because HLTNav_Summary found in POOL file"
            )
        elif rec.readRDO():
            # If running Trigger on RDO input (without previous trigger result), choose Run-2 or Run-3 based on doMT
            if TriggerFlags.doMT():
                TriggerFlags.EDMDecodingVersion = 3
                log.info(
                    "Decoding version set to 3, because running Trigger with doMT=True"
                )
            else:
                TriggerFlags.EDMDecodingVersion = 2
                log.info(
                    "Decoding version set to 2, because running Trigger with doMT=False"
                )
        else:
            log.warning(
                "Cannot recognise HLT EDM format, leaving default TriggerFlags.EDMDecodingVersion=%d",
                TriggerFlags.EDMDecodingVersion())
Exemple #27
0
    def configure(self):

        log = logging.getLogger("HLTTriggerResultGetter.py")
        from RecExConfig.ObjKeyStore import objKeyStore

        # set EDMDecodingVersion
        EDMDecodingVersion()

        # Set AODFULL for data unless it was set explicitly already
        if TriggerFlags.AODEDMSet.isDefault() and globalflags.DataSource(
        ) == 'data':
            TriggerFlags.AODEDMSet = 'AODFULL'

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()
        log.info("BS unpacking (TF.readBS): %d", TriggerFlags.readBS())
        if TriggerFlags.readBS():
            if TriggerFlags.EDMDecodingVersion() <= 2:
                bs = ByteStreamUnpackGetterRun2()  # noqa: F841
            else:
                bs = ByteStreamUnpackGetter()  # noqa: F841

        xAODContainers = {}
        #        if not recAlgs.doTrigger():      #only convert when running on old data
        if TriggerFlags.EDMDecodingVersion() == 1:
            xaodcnvrt = xAODConversionGetter()
            xAODContainers = xaodcnvrt.xaodlist

        if recAlgs.doTrigger() or TriggerFlags.doTriggerConfigOnly():
            if TriggerFlags.EDMDecodingVersion() <= 2:
                tdt = TrigDecisionGetterRun2()  # noqa: F841
            else:
                tdt = TrigDecisionGetter()  # noqa: F841

        # Temporary hack to add Run-3 navigation to ESD and AOD
        if (rec.doESD()
                or rec.doAOD()) and TriggerFlags.EDMDecodingVersion() == 3:
            # The hack with wildcards is needed for BS->ESD because we don't know the exact keys
            # of HLT navigation containers before unpacking them from the BS event.
            objKeyStore._store['streamESD'].allowWildCard(True)
            objKeyStore._store['streamAOD'].allowWildCard(True)
            objKeyStore.addManyTypesStreamESD([
                'xAOD::TrigCompositeContainer#HLTNav*',
                'xAOD::TrigCompositeAuxContainer#HLTNav*'
            ])
            objKeyStore.addManyTypesStreamAOD([
                'xAOD::TrigCompositeContainer#HLTNav*',
                'xAOD::TrigCompositeAuxContainer#HLTNav*'
            ])

        # TrigJetRec additions
        if rec.doWriteESD():
            objKeyStore.addStreamESD("JetKeyDescriptor", "JetKeyMap")
            objKeyStore.addStreamESD("JetMomentMap", "TrigJetRecMomentMap")

        if rec.doWriteAOD():
            objKeyStore.addStreamAOD("JetKeyDescriptor", "JetKeyMap")
            objKeyStore.addStreamAOD("JetMomentMap", "TrigJetRecMomentMap")

        # ID truth
        if not rec.readESD() and (not rec.readAOD()) and TriggerFlags.doID() \
                and rec.doTruth():
            try:
                from TrigInDetTruthAlgs.TrigInDetTruthAlgsConfig import \
                    TrigIDTruthMaker
                topSequence += TrigIDTruthMaker()
            except Exception:
                log.warning("Couldn't set up the trigger ID truth maker")
                pass

        if rec.doESD() or rec.doAOD():
            from TrigEDMConfig.TriggerEDM import getTrigIDTruthList
            objKeyStore.addManyTypesStreamESD(
                getTrigIDTruthList(TriggerFlags.ESDEDMSet()))
            objKeyStore.addManyTypesStreamAOD(
                getTrigIDTruthList(TriggerFlags.AODEDMSet()))

        if (rec.doESD() or rec.doAOD()) and TriggerFlags.writeL1TopoValData():
            objKeyStore.addManyTypesStreamESD([
                'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'
            ])
            objKeyStore.addManyTypesStreamAOD([
                'xAOD::TrigCompositeContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValData',
                'xAOD::TrigCompositeAuxContainer#HLT_xAOD__TrigCompositeContainer_L1TopoValDataAux.'
            ])
            log.debug(
                "HLT_xAOD__TrigCompositeContainer_L1TopoValData(Aux.) for L1Topo validation added to the data."
            )

        if rec.doAOD() or rec.doWriteAOD():
            # schedule the RoiDescriptorStore conversion
            # log.warning( "HLTTriggerResultGetter - setting up RoiWriter" )
            roiWriter = RoiWriter()
            # Add fictional input to ensure data dependency in AthenaMT
            roiWriter.ExtraInputs += [("TrigBSExtractionOutput",
                                       "StoreGateSvc+TrigBSExtractionOutput")]
            topSequence += roiWriter
            # write out the RoiDescriptorStores
            from TrigEDMConfig.TriggerEDMRun2 import TriggerRoiList
            objKeyStore.addManyTypesStreamAOD(TriggerRoiList)

        #Are we adding operational info objects in ESD?
        added = self._AddOPIToESD()
        if added:
            log.debug(
                "Operational Info object HLT_EXPRESS_OPI_HLT with extra information about express stream prescaling added to the data."
            )

        # ESD objects definitions
        _TriggerESDList = {}

        from TrigEDMConfig.TriggerEDM import getTriggerEDMList
        # we have to store xAOD containers in the root file, NOT AOD,
        # if the xAOD container list is not empty
        if (xAODContainers):
            _TriggerESDList.update(xAODContainers)
        else:
            _TriggerESDList.update(
                getTriggerEDMList(TriggerFlags.ESDEDMSet(),
                                  TriggerFlags.EDMDecodingVersion()))

        log.info(
            "ESD content set according to the ESDEDMSet flag: %s and EDM version %d",
            TriggerFlags.ESDEDMSet(), TriggerFlags.EDMDecodingVersion())

        # AOD objects choice
        _TriggerAODList = {}

        #from TrigEDMConfig.TriggerEDM import getAODList
        _TriggerAODList.update(
            getTriggerEDMList(TriggerFlags.AODEDMSet(),
                              TriggerFlags.EDMDecodingVersion()))

        log.info(
            "AOD content set according to the AODEDMSet flag: %s and EDM version %d",
            TriggerFlags.AODEDMSet(), TriggerFlags.EDMDecodingVersion())

        log.debug("ESD EDM list: %s", _TriggerESDList)
        log.debug("AOD EDM list: %s", _TriggerAODList)

        # Highlight what is in AOD list but not in ESD list, as this can cause
        # the "different number of entries in branch" problem, when it is in the
        # AOD list but the empty container per event is not created
        # Just compares keys of dicts, which are the class names, not their string keys in StoreGate
        not_in = [
            element for element in _TriggerAODList
            if element not in _TriggerESDList
        ]
        if (len(not_in) > 0):
            log.warning("In AOD list but not in ESD list: ")
            log.warning(not_in)
        else:
            log.info("AOD list is subset of ESD list - good.")

        def _addSlimming(stream, edm):
            from TrigNavTools.TrigNavToolsConfig import navigationThinningSvc

            edmlist = list(y.split('-')[0] for x in edm.values()
                           for y in x)  #flatten names

            svc = navigationThinningSvc({
                'name': 'HLTNav_%s' % stream,
                'mode': 'cleanup',
                'result': 'HLTResult_HLT',
                'features': edmlist
            })

            from OutputStreamAthenaPool.CreateOutputStreams import registerTrigNavThinningSvc
            registerTrigNavThinningSvc(stream, svc)

            log.info("Configured slimming of HLT for %s", stream)
            print(svc)  # noqa: ATL901
            del edmlist

        if TriggerFlags.doNavigationSlimming() and rec.readRDO(
        ) and rec.doWriteAOD():
            _addSlimming('StreamAOD',
                         _TriggerESDList)  #Use ESD item list also for AOD!
            log.info("configured navigation slimming for AOD output")

        if TriggerFlags.doNavigationSlimming() and rec.readRDO(
        ) and rec.doWriteESD():
            _addSlimming('StreamESD', _TriggerESDList)
            log.info("configured navigation slimming for ESD output")

        objKeyStore.addManyTypesStreamESD(_TriggerESDList)
        objKeyStore.addManyTypesStreamAOD(_TriggerAODList)

        return True
Exemple #28
0
#specify beam type (default is "collisions", other values "cosmics" "singlebeam"
# pick the correct one
jobproperties.Beam.beamType = 'cosmics'
# singlebeam not tested recently
#jobproperties.Beam.beamType = 'singlebeam'

# input configuration (lock to prevent override)
# note that if reading from TAG, the input file spec is ignored,
#   however the flag settings should still be consistent
if Input == 'data':
    if rec.readTAG():
        # read TAG, navigate to ESD
        athenaCommonFlags.PoolTAGInput = ['../cosm/myTAGCOMM.root']
        athenaCommonFlags.PoolInputQuery.set_Value_and_Lock("TRTTracks>0")
    if rec.readRDO():
        if jobproperties.Beam.beamType() == 'cosmics':
            if RTTdata:
                # this is ignored if TAG are read
                athenaCommonFlags.BSRDOInput.set_Value_and_Lock([
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-1._0001.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-1._0002.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-1._0003.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-2._0001.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-2._0002.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-2._0003.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-3._0001.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-3._0002.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-3._0003.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-4._0001.data',
                    '/castor/cern.ch/grid/atlas/DAQ/2008/91900/physics_IDCosmic/daq.ATLAS.0091900.physics.IDCosmic.LB0001.SFO-4._0002.data',
Exemple #29
0
# now synchronise other flags

if rec.doWriteRDO():
    logRecExCommon_flags.info("write RDO, do not make ESD AOD TAG CBNT")
    # switch off all algorithms
    rec.doESD = False
    rec.doAOD = False
    rec.doWriteESD = False
    rec.doWriteAOD = False
    rec.doWriteTAG = False
    rec.doCBNT = False
    if rec.readESD or rec.readAOD:
        raise RuntimeError, "Cannot have readESD or readAOD if doWriteRDO"

    if rec.readRDO() and globalflags.InputFormat() != 'bytestream':
        # this is a RDO to RDO copy, do not put detector status
        rec.doDetStatus = False

# in case several read specified, favour the highest one
if rec.readAOD():
    logRecExCommon_flags.info("read AOD : all algs switched off ")

    # switch off all algorithms
    rec.doESD = False
    rec.doAOD = False
    rec.doWriteESD = False
    rec.doWriteAOD = False
    if rec.readRDO:
        logRecExCommon_flags.info("readAOD : switch readRDO off ")
        rec.readRDO = False
from AthenaCommon.AppMgr import ServiceMgr
from AthenaCommon.GlobalFlags import globalflags
from AthenaCommon.DetFlags import DetFlags
from AthenaCommon import CfgMgr
from RecExConfig.RecFlags import rec
from RecExConfig.RecAlgsFlags import recAlgs
from MuonRecExample.MuonAlignFlags import muonAlignFlags

muonRecFlags.setDefaults()

topSequence = AlgSequence()

if muonRecFlags.doDigitization():
    include("MuonRecExample/MuonDigitization_jobOptions.py")

if rec.readRDO():
    if globalflags.InputFormat == 'bytestream':
        include("MuonCnvExample/MuonReadBS_jobOptions.py")
    else:
        include("MuonCnvExample/MuonReadRDO_jobOptions.py")
    if DetFlags.makeRIO.Muon_on():
        include("MuonRecExample/MuonRDO_to_PRD_jobOptions.py")

### add PRD -> xAOD
if (rec.readRDO() or rec.readESD()) and muonRecFlags.prdToxAOD():
    from AthenaCommon import CfgMgr
    topSequence += CfgMgr.MDT_PrepDataToxAOD()
    topSequence += CfgMgr.RPC_PrepDataToxAOD()
    topSequence += CfgMgr.TGC_PrepDataToxAOD()
    topSequence += CfgMgr.CSC_PrepDataToxAOD()
Exemple #31
0
    def setDefaults(self):
        global globalflags

        from MuonRecExample.MuonRecUtils import setJobPropertyDefault as setDefault

        # as long as rec.Commissioning is alive, sync the default to it
        # in case of BS->RDO, RDO->RDO, RDO->BS, BS->BS: don't run RIO (i.e RDO->PRD)
        setDefault(self.makePRDs, rec.readRDO() and not rec.doWriteRDO() and not rec.doWriteBS())
        setDefault(self.doStandalone,True)
        setDefault(self.doDigitization,False)
        setDefault(self.doCalib,False)
        setDefault(self.applyResilience,athenaCommonFlags.AllowIgnoreConfigError())
        setDefault(self.doSegmentsOnly,False)
        setDefault(self.doMDTs,True)
        setDefault(self.doRPCs,True)
        setDefault(self.doTGCs,True)
        setDefault(self.doCSCs,True)
        setDefault(self.dosTGCs,True)
        setDefault(self.doMicromegas,True)
        setDefault(self.doMSVertex,True)
        setDefault(self.useWireSagCorrections,False)
        setDefault(self.enableErrorTuning,True)
        setDefault(self.useLooseErrorTuning,False)
        setDefault(self.useAlignmentCorrections,DetFlags.detdescr.Muon_on() and rec.doMuon())
        setDefault(self.writeSDOs, rec.doWriteESD() and globalflags.DataSource != 'data')
        setDefault(self.useTGCPriorNextBC,True)
        setDefault(self.doMuonIso,True)

        if beamFlags.beamType == 'cosmics' or beamFlags.beamType == 'singlebeam':
            setDefault(self.doSegmentT0Fit,True)
        else:
            setDefault(self.doSegmentT0Fit,False)
            
        setDefault(self.doPrdSelect,False)

        # Default for MuonCalibration ntuple
        setDefault(self.calibMuonStandalone, muonRecFlags.doStandalone() or rec.readESD() )
        try:
            from MuonCnvExample.MuonCalibFlags import muonCalibFlags
        except ImportError:
            from AthenaCommon.Resilience import treatException
            treatException("Could not load MuonCalibFlags. Switching off calibration ntuple")
            self.doCalib = False
            self.doCalibNtuple = False
        else:
               
            doTracks = self.calibMuonStandalone()
            # chose a default
            if not muonCalibFlags.Mode.statusOn:
                if doTracks:
                    muonCalibFlags.Mode = 'trackNtuple'
                else:
                    muonCalibFlags.Mode = 'ntuple'

            if muonCalibFlags.Mode == 'trackNtuple' and doTracks:
                setDefault(self.doCalibNtuple,self.doCalib())
                setDefault(self.calibNtupleSegments,True)
                setDefault(self.calibNtupleTracks,True)
                if rec.doTrigger: setDefault(self.calibNtupleTrigger,True)
                else: setDefault(self.calibNtupleTrigger,False)
            elif muonCalibFlags.Mode == 'ntuple' or (muonCalibFlags.Mode == 'trackNtuple' and not doTracks):
                setDefault(self.doCalibNtuple,self.doCalib())
                setDefault(self.calibNtupleSegments,True)
                setDefault(self.calibNtupleTracks,False)
                if rec.doTrigger: setDefault(self.calibNtupleTrigger,True)
                else: setDefault(self.calibNtupleTrigger,False)
            else:
                setDefault(self.doCalibNtuple,False)
                setDefault(self.calibNtupleSegments,False)
                setDefault(self.calibNtupleTracks,False)
                setDefault(self.calibNtupleTrigger,False)