Beispiel #1
0
def CreateBookkeeperTool(name="CutBookkeepers"):

    from AthenaCommon.AppMgr import ServiceMgr as svcMgr

    # Make sure MetaDataSvc is ready
    if not hasattr(svcMgr, 'MetaDataSvc'):
        from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import MetaDataSvc
        svcMgr += MetaDataSvc("MetaDataSvc")

    # Add BookkeeperTools
    from EventBookkeeperTools.EventBookkeeperToolsConf import BookkeeperTool

    # Standard event bookkeepers
    cutflowtool = BookkeeperTool(name, InputCollName=name, OutputCollName=name)
    svcMgr.ToolSvc += cutflowtool

    # Add tool to MetaDataSvc
    svcMgr.MetaDataSvc.MetaDataTools += [cutflowtool]

    return
#svcMgr.UserDataSvc.OutputStream=outStream

#======================================================================================
# L u m i B l o c k  j o b  o p t i o n s
#=========================================
# add LumiBlockMetaDataTool to ToolSvc and configure
from LumiBlockComps.LumiBlockCompsConf import LumiBlockMetaDataTool
ToolSvc += LumiBlockMetaDataTool("LumiBlockMetaDataTool")
LumiBlockMetaDataTool.calcLumi = False  # False by default
LumiBlockMetaDataTool.storeXMLFiles = True
LumiBlockMetaDataTool.applyDQCuts = True
LumiBlockMetaDataTool.OutputLevel = INFO

# add ToolSvc.LumiBlockMetaDataTool to MetaDataSvc
from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import MetaDataSvc
svcMgr += MetaDataSvc("MetaDataSvc")
svcMgr.MetaDataSvc.MetaDataTools += [ToolSvc.LumiBlockMetaDataTool]

# Configure the goodrunslist selector tool
from GoodRunsLists.GoodRunsListsConf import *
ToolSvc += GoodRunsListSelectorTool()
GoodRunsListSelectorTool.OutputLevel = INFO
GoodRunsListSelectorTool.GoodRunsListVec = [
    'data11_7TeV.periodAllYear_DetStatus-v36-pro10_CoolRunQuery-00-04-08_Susy.xml'
]
GoodRunsListSelectorTool.PassThrough = False

## This Athena job consists of algorithms that loop over events;
## here, the (default) top sequence is used:
from AthenaCommon.AlgSequence import AlgSequence, AthSequencer
job = AlgSequence()
Beispiel #3
0
def _setupConfig():
    rf = {}
    rf['readTAG'] = jp.Rec.readTAG()
    rf['readESD'] = jp.Rec.readESD()
    rf['readAOD'] = jp.Rec.readAOD()
    rf['readBS'] = jp.Rec.Trigger.readBS()
    rf['readRDO'] = jp.Rec.readRDO()
    rf['DataSource'] = jp.Global.DataSource()
    rf['readRDO'] = jp.Rec.readRDO()
    rf['doWriteESD'] = jp.Rec.doWriteESD()
    rf['doWriteAOD'] = jp.Rec.doWriteAOD()
    rf['doWriteTAG'] = jp.Rec.doWriteTAG()
    rf['TrigCoolSQLite'] = False

    global readRDO
    print "global readRDO=", readRDO
    varInit = globals().keys()
    print varInit
    print rf.keys()
    for o in [o for o in rf.keys() if o in varInit]:
        rf[o] = eval(o)

    #print "JJJJ DEBUG Print jobproperties"
    #jp.print_JobProperties('tree&value')
    #print "JJJJ DEBUG Print rec.jobproperties"
    #jp.Rec.print_JobProperties('tree&value')
    #print "JJJJ DEBUG Print rec.Trigger.jobproperties aka TriggerFlags"
    #jp.Rec.Trigger.print_JobProperties('tree&value')

    ## logging for this module
    msg = log.getLogger('TriggerConfig.py')

    ## the generic trigger configuration service needs to be set up
    from TrigConfigSvc.TrigConfigSvcConfig import SetupTrigConfigSvc
    msg.info('Creating the trigger configuration service wrapper')
    svc = SetupTrigConfigSvc()

    ## ================================================================================
    ## the service depends on the condition we are running in
    ##
    ##     environment       ConfigSvc      Data input   Config input   Flags
    ##     ---------------   ------------   ----------   ------------   -----
    ## (1) data taking       HLTConfigSvc   BS           TriggerDB      DataSource='data',...
    ##
    ## (2) MC simulation     HTLConfigSvc   BS, RDO      XML            DataSource='geant3/4' and (readBS=True or readRDO=True) and doFEX=True and doHypo=True
    ##                       (to be replaced by DSConfigSvc later)
    ##
    ## (3) data processing   DSConfigSvc    BS, RDO      COOL/Oracle    readBS=True or readRDO=True
    ##
    ## (4) AOD processing    DSConfigSvc    ESD/AOD      ESD/AOD(run)   (readESD=True or readAOD=True) and doFEX=False and doHypo=False
    ##                       AODConfigSvc                ESD/AOD(ev)
    ##
    ## (5) Trigger ESD/AOD   HLTConfigSvc   ESD/AOD      XML            (readESD or readAOD)=True and doFEX=True and doHypo=True
    ##
    ## (6) Trigger rerun     HLTConfigSvc   ESD/AOD      XML            (readBS or readRDO or readESD or readAOD)=True and doFEX=False and doHypo=True
    ##
    ## (7) TAG reading       HLTConfigSvc   TAG          XML            readTAG=True
    ##
    ##
    ## ================================================================================
    ## In cases (2), (3) and (5) the configuration information needs to be written
    ## into the header of the AOD file. This is completely independent of the configuration
    ## service, but will depend on the flags readESD, readAOD, doWriteESD, doWriteAOD, doWriteTAG
    ##
    ## ================================================================================
    ## two flags are steering the execution of the trigger, if neither
    ## is True, no trigger is used
    ##
    ## - doTrigger: if True, "TriggerRelease/jobOfragment_forRecExCommon.py"
    ## is included
    ##
    ## - doTriggerConfigOnly: if True, no TrigDecision is build/used
    ##
    ## ================================================================================
    ## flags that control the setup of the trigger are
    ##
    ## boolean:
    ## readBS,  readAOD,    readESD,    readRDO,    readTAG
    ## writeBS, doWriteAOD, doWriteESD, doWriteRDO, doWriteTAG
    ## readLVL1configFromXML, readHLTconfigFromXML
    ##
    ## string:
    ## inputHLTconfigFile, inputLVL1configFile, outputHLTconfigFile, outputLVL1configFile
    ##
    ## on/offline:
    ## DataSource: ['data','geant3','geant4']
    ## ================================================================================

    svc.hltXmlFile = lv1_menu_file_name = jp.Rec.Trigger.inputHLTconfigFile()
    svc.l1XmlFile = jp.Rec.Trigger.inputLVL1configFile()

    myList = []
    scenario = 0
    if len(jp.Rec.Trigger.configurationSourceList()) > 0:
        # take the user-defined list of trigger configuration sources:
        myList = jp.Rec.Trigger.configurationSourceList()

    else:
        print jp.Rec
        if rf['readTAG']:  # TAG
            myList = ['xml']

        elif rf['readESD'] or rf['readAOD']:  # AOD/ESD
            myList = ['ds', 'aod', 'xml']

        elif rf['readBS'] or rf['readRDO']:  # RDO/BS
            if rf['DataSource'] == 'data':
                myList = ['ds', 'xml']
            else:
                myList = ['xml']

        else:
            msg.fatal('no reading of BS, RDO, AOD, ESD, or TAG specified')

    message = 'setup the following services in order: '
    for s in myList:
        message += s + " "
    msg.info(message)

    try:
        svc.SetStates(myList)
    except:
        msg.error('failed to set state of TrigConfigSvc ...')

    try:
        svc.InitialiseSvc()
    except:
        msg.error('failed to activate TrigConfigSvc ...')

    if rf['doWriteESD'] or rf['doWriteAOD'] or rf['doWriteTAG'] or ('ds'
                                                                    in myList):

        ## setup the copying of configuration data from input to output metadatastore
        if rf['doWriteESD'] or rf['doWriteAOD'] or rf['doWriteTAG']:
            msg.info(
                'writing of ESD, AOD, or TAG requested, will setup IOVDbSvc to access configuration meta data'
            )
        else:
            msg.info(
                'DSConfigSvc enabled, will setup IOVDbSvc to access configuration meta data'
            )

        # first we need a new algorithm that triggers the copying
        from AthenaCommon.AlgSequence import AlgSequence
        from TrigConfigSvc.TrigConfigSvcConf import TrigConf__TrigConfDataIOVChanger as TrigConfDataIOVChanger
        topAlgs = AlgSequence()
        TrigConfDataIOVChanger = TrigConfDataIOVChanger(
            'TrigConfDataIOVChanger')
        topAlgs += TrigConfDataIOVChanger

        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        from AthenaCommon.AppMgr import ToolSvc

        if not hasattr(ToolSvc, 'IOVDbMetaDataTool'):
            from IOVDbMetaDataTools.IOVDbMetaDataToolsConf import IOVDbMetaDataTool
            ToolSvc += IOVDbMetaDataTool("IOVDbMetaDataTool")

        if not hasattr(svcMgr, 'MetaDataSvc'):
            from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import MetaDataSvc
            svcMgr += MetaDataSvc("MetaDataSvc")
            svcMgr.MetaDataSvc.MetaDataContainer = "MetaDataHdr"
            svcMgr.MetaDataSvc.MetaDataTools += ["IOVDbMetaDataTool"]

        # for debugging uncomment the following three lines
        from AthenaCommon.Constants import VERBOSE
        ToolSvc.IOVDbMetaDataTool.OutputLevel = VERBOSE
        svcMgr.MetaDataSvc.OutputLevel = VERBOSE

        dbConnection = "<dbConnection>impl=cool;techno=oracle;schema=ATLAS_COOLONL_READER;devdb10:COOLTEST:atlas_trig_stelzer</dbConnection>"

        ### when moving to configurable IOVDbSvc use the ### lines and remove those with ## at the end
        ### import IOVDbSvc.IOVDb
        ### IOVDbSvc = svcMgr.IOVDbSvc
        from AthenaCommon.Include import include  ##
        include("IOVDbSvc/IOVDbSvc_jobOptions.py")  ##
        IOVDbSvc = theApp.service("IOVDbSvc")  ##
        #from AthenaCommon.Constants import VERBOSE
        #IOVDbSvc.OutputLevel = VERBOSE

        ## if we process MC from an XML file the dbConnection needs to
        ## be set to a local SQlite file

        if (rf['readRDO'] or rf['readBS']) and (rf['DataSource'] == 'geant3'
                                                or rf['DataSource'] == 'geant4'
                                                or rf['TrigCoolSQLite']):
            from TrigConfigSvc.TrigConf2COOL import theConfCOOLWriter
            dbConnection = theConfCOOLWriter.dbConnection
            theConfCOOLWriter.isWritingNeeded = True
            TrigConfDataIOVChanger.AdjustIOV = True

        msg.info("COOL DBConnection: " + dbConnection)

        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/HLT/Menu <tag>HEAD</tag>"]
        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/HLT/HltConfigKeys <tag>HEAD</tag>"]
        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/LVL1/Lvl1ConfigKey <tag>HEAD</tag>"]
        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/LVL1/Menu <tag>HEAD</tag>"]
        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/LVL1/Prescales <tag>HEAD</tag>"]
        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/LVL1/ItemDef <tag>HEAD</tag>"]
        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/HLT/Prescales <tag>HEAD</tag>"]
        ### svcMgr.IOVDbSvc.Folders+=[dbConnection + "/TRIGGER/HLT/PrescaleKey <tag>HEAD</tag>"]

        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/HLT/Menu <tag>HEAD</tag>"
        ]  ##
        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/HLT/HltConfigKeys <tag>HEAD</tag>"
        ]  ##
        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/LVL1/Lvl1ConfigKey <tag>HEAD</tag>"
        ]  ##
        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/LVL1/Menu <tag>HEAD</tag>"
        ]  ##
        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/LVL1/Prescales <tag>HEAD</tag>"
        ]  ##
        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/LVL1/ItemDef <tag>HEAD</tag>"
        ]  ##
        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/HLT/Prescales <tag>HEAD</tag>"
        ]  ##
        IOVDbSvc.Folders += [
            dbConnection + "/TRIGGER/HLT/PrescaleKey <tag>HEAD</tag>"
        ]  ##

        # only in jobs that write AOD or ESD
        if rf['doWriteAOD'] or rf['doWriteESD']:
            msg.info(
                'writing of ESD or AOD enabled, will setup IOVDbSvc to write configuration meta data'
            )
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/HLT/Menu"]
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/HLT/HltConfigKeys"]
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/LVL1/Lvl1ConfigKey"]
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/LVL1/Menu"]
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/LVL1/Prescales"]
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/LVL1/ItemDef"]
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/HLT/Prescales"]
            ### svcMgr.IOVDbSvc.FoldersToMetaData+=["/TRIGGER/HLT/PrescaleKey"]

            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/HLT/Menu"]  ##
            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/HLT/HltConfigKeys"]  ##
            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/LVL1/Lvl1ConfigKey"]  ##
            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/LVL1/Menu"]  ##
            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/LVL1/Prescales"]  ##
            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/LVL1/ItemDef"]  ##
            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/HLT/Prescales"]  ##
            IOVDbSvc.FoldersToMetaData += ["/TRIGGER/HLT/PrescaleKey"]  ##
Beispiel #4
0
def CreateCutFlowSvc(svcName="CutFlowSvc",
                     athFile=None,
                     seq=None,
                     addAlgInPlace=False,
                     addMetaDataToAllOutputFiles=True,
                     SGkey="CutBookkeepers"):
    """
    Helper to create the CutFlowSvc, extract the needed information from
    the input file, and also schedule all the needed stuff.
    """
    # Create a message logger
    from AthenaCommon.Logging import logging
    msg = logging.getLogger("Create" + svcName)

    # Get the service manager
    from AthenaCommon.AppMgr import ServiceMgr as svcMgr

    # Determine current input stream name
    inputStreamName = GetCurrentStreamName(msg=msg, athFile=athFile)
    msg.debug("CreateCutFlowSvc: Have inputStreamName = %s" %
              (inputStreamName))

    # Create the CutFlowSvc instance(s)
    import AthenaCommon.CfgMgr as CfgMgr
    if not hasattr(svcMgr, "CutFlowSvc"): svcMgr += CfgMgr.CutFlowSvc()
    svcMgr.CutFlowSvc.InputStream = inputStreamName
    #if not hasattr(svcMgr,"FileCutFlowSvc"): svcMgr += CfgMgr.FileCutFlowSvc()
    #svcMgr.FileCutFlowSvc.InputStream   = inputStreamName

    # Make sure MetaDataSvc is ready
    if not hasattr(svcMgr, 'MetaDataSvc'):
        from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import MetaDataSvc
        svcMgr += MetaDataSvc("MetaDataSvc")

    # Add BookkeeperTools
    from EventBookkeeperTools.EventBookkeeperToolsConf import BookkeeperTool

    # Standard event bookkeepers
    inname = "CutBookkeepers"
    outname = "FileBookkeepers"
    cutflowtool = BookkeeperTool(outname,
                                 InputCollName=inname,
                                 OutputCollName=outname)
    svcMgr.ToolSvc += cutflowtool

    # Add tool to MetaDataSvc
    svcMgr.MetaDataSvc.MetaDataTools += [cutflowtool]

    # Add pdf sum of weights counts if appropriate
    from AthenaCommon.GlobalFlags import globalflags
    if globalflags.DataSource() == 'geant4':
        #from PyUtils import AthFile
        #afc = AthFile.fopen( svcMgr.EventSelector.InputCollections[0] )

        # PDF
        name = "PDFSumOfWeights"
        pdfweighttool = BookkeeperTool(name,
                                       OutputCollName=name,
                                       InputCollName=name)
        svcMgr.ToolSvc += pdfweighttool

        # Add tool to MetaDataSvc
        svcMgr.MetaDataSvc.MetaDataTools += [pdfweighttool]

    # Check if we have a sequence given
    if not seq:
        # Fetch the AthAlgSeq, i.e., one of the existing master sequences where one should attach all algorithms
        seq = CfgMgr.AthSequencer("AthAlgSeq")
        pass

    # First of all, schedule EventCounterAlg
    if not hasattr(seq, "AllExecutedEvents"):
        if not seq.isLocked():
            if addAlgInPlace:
                msg.debug(
                    "Adding EventCounterAlg with name AllExecutedEvents to sequence with name %s"
                    % seq.getName())
                seq += CfgMgr.EventCounterAlg("AllExecutedEvents")
                pass
            else:
                # Need to schedule it after the xAODMaker::EventInfoCnvAlg such that xAOD::EventInfo is present
                index = 0
                if hasattr(seq, "xAODMaker::EventInfoCnvAlg"):
                    for alg in seq:
                        index += 1
                        if alg.getName() == "xAODMaker::EventInfoCnvAlg": break
                        pass
                    pass
                msg.debug(
                    "Adding EventCounterAlg with name AllExecutedEvents to sequence with name %s at position %i"
                    % (seq.getName(), index))
                seq.insert(index, CfgMgr.EventCounterAlg("AllExecutedEvents"))
                pass
            pass
        else:
            msg.info(
                "Could NOT add EventCounterAlg with name AllExecutedEvents to locked sequence with name %s"
                % seq.getName())
            pass
        pass

    # If wanted, add the meta-data to all output files
    if addMetaDataToAllOutputFiles:
        msg.debug(
            "Adding CutBookkeepers the the output meta data of all output streams"
        )
        from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
        # Explicitely add file metadata from input and from transient store,
        # but only the ones that we always create.
        MSMgr.AddMetaDataItemToAllStreams("xAOD::CutBookkeeperContainer#" +
                                          SGkey)
        MSMgr.AddMetaDataItemToAllStreams("xAOD::CutBookkeeperAuxContainer#" +
                                          SGkey + "Aux.*")
        MSMgr.AddMetaDataItemToAllStreams(
            "xAOD::CutBookkeeperContainer#Incomplete" + SGkey)
        MSMgr.AddMetaDataItemToAllStreams(
            "xAOD::CutBookkeeperAuxContainer#Incomplete" + SGkey + "Aux.*")
        SGkey = "FileBookkeepers"
        MSMgr.AddMetaDataItemToAllStreams("xAOD::CutBookkeeperContainer#" +
                                          SGkey)
        MSMgr.AddMetaDataItemToAllStreams("xAOD::CutBookkeeperAuxContainer#" +
                                          SGkey + "Aux.*")
        MSMgr.AddMetaDataItemToAllStreams(
            "xAOD::CutBookkeeperContainer#Incomplete" + SGkey)
        MSMgr.AddMetaDataItemToAllStreams(
            "xAOD::CutBookkeeperAuxContainer#Incomplete" + SGkey + "Aux.*")
        pass

    return
Beispiel #5
0
IOVDbSvc.GlobalTag = ConditionsTag

import JetRec.ParticleJetCompatibility

if TriggerOn == 1:
    # Set up trigger configuration service and metadata service it relies on, for analysis job without RecExCommon
    # set up trigger decision tool

    # set up metadata services ... NB comment if "aod" state is selected above
    from EventInfoMgt.EventInfoMgtConf import TagInfoMgr
    ServiceMgr += TagInfoMgr()
    #ServiceMgr.TagInfoMgr.AddGeoModelTags = False
    from IOVDbMetaDataTools.IOVDbMetaDataToolsConf import IOVDbMetaDataTool
    ToolSvc += IOVDbMetaDataTool("IOVDbMetaDataTool")
    from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import MetaDataSvc
    ServiceMgr += MetaDataSvc("MetaDataSvc")
    ServiceMgr.MetaDataSvc.MetaDataContainer = "MetaDataHdr"
    ServiceMgr.MetaDataSvc.MetaDataTools += ["IOVDbMetaDataTool"]
    import IOVDbSvc.IOVDb

    from RecExConfig.RecFlags import rec
    rec.readAOD = True
    rec.doWriteAOD = False
    rec.doWriteESD = False

    #    from TrigDecisionTool.TrigDecisionConf import TrigDecisionTool
    #    tdt = TrigDecisionTool()
    from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
    tdt = Trig__TrigDecisionTool()
    ToolSvc += tdt
    # flags needed for TriggerConfigGetter
Beispiel #6
0
#------------------------------------------------------------------------------
# Good Run List
#------------------------------------------------------------------------------
if do_grl and sample == 'data':
    # add LumiBlockMetaDataTool to ToolSvc and configure
    from LumiBlockComps.LumiBlockCompsConf import LumiBlockMetaDataTool
    theLumiBlockMetaDataTool = LumiBlockMetaDataTool("LumiBlockMetaDataTool")
    theLumiBlockMetaDataTool.calcLumi = False  # False by default
    theLumiBlockMetaDataTool.storeXMLFiles = True
    theLumiBlockMetaDataTool.applyDQCuts = True
    theLumiBlockMetaDataTool.OutputLevel = INFO
    ToolSvc += theLumiBlockMetaDataTool

    # add ToolSvc.LumiBlockMetaDataTool to MetaDataSvc
    from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import MetaDataSvc
    theMetaDataSvc = MetaDataSvc("MetaDataSvc")
    theMetaDataSvc.MetaDataTools += [theLumiBlockMetaDataTool]
    svcMgr += theMetaDataSvc

    # Configure the goodrunslist selector tool
    from GoodRunsLists.GoodRunsListsConf import *
    theGoodRunsListSelectorTool = GoodRunsListSelectorTool()
    theGoodRunsListSelectorTool.GoodRunsListVec = ['MyLBCollection.xml']
    theGoodRunsListSelectorTool.PassThrough = False
    theGoodRunsListSelectorTool.OutputLevel = INFO
    ToolSvc += theGoodRunsListSelectorTool

    ## This Athena job consists of algorithms that loop over events;
    ## here, the (default) top sequence is used:
    from AthenaCommon.AlgSequence import AlgSequence, AthSequencer
    job = AlgSequence()