Пример #1
0
    def configure(self):

        log = logging.getLogger("TrigDecisionGetterRun2")

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        #if hasOnlyLVL1:
        #from RecExConfig.ObjKeyStore import objKeyStore
        #objKeyStore.addStreamESD('TrigDec::TrigDecision','TrigDecision')
        #objKeyStore.addStreamAOD('TrigDec::TrigDecision','TrigDecision')

        from RecExConfig.RecFlags import rec
        if ( rec.doWriteESD() or rec.doWriteAOD() or rec.doESD() or rec.doAOD() ) and \
               ( not ( rec.readAOD() or rec.readESD() or rec.doWriteBS()) ):
            log.info("Will write TrigDecision object to storegate")

            from TrigDecisionMaker.TrigDecisionMakerConfig import WriteTrigDecision
            trigDecWriter = WriteTrigDecision()  # noqa: F841

            #           WritexAODTrigDecision() is called within WriteTrigDecision()

            # inform TD maker that some parts may be missing
            if TriggerFlags.dataTakingConditions() == 'Lvl1Only':
                topSequence.TrigDecMaker.doL2 = False
                topSequence.TrigDecMaker.doEF = False
                topSequence.TrigDecMaker.doHLT = False
                topSequence.TrigNavigationCnvAlg.doL2 = False
                topSequence.TrigNavigationCnvAlg.doEF = False
                topSequence.TrigNavigationCnvAlg.doHLT = False
            elif TriggerFlags.dataTakingConditions() == 'HltOnly':
                from AthenaCommon.AlgSequence import AlgSequence
                topSequence.TrigDecMaker.doL1 = False
            # Decide based on the doMergedHLTResult to assume a merged, or a
            # split HLT:
            if not TriggerFlags.doMergedHLTResult():
                topSequence.TrigDecMaker.doHLT = False
                topSequence.TrigNavigationCnvAlg.doL2 = False
                topSequence.TrigNavigationCnvAlg.doHLT = False
            else:
                topSequence.TrigDecMaker.doL2 = False
                topSequence.TrigDecMaker.doEF = False
                topSequence.TrigNavigationCnvAlg.doL2 = False
                topSequence.TrigNavigationCnvAlg.doEF = False
                pass

        else:
            log.info("Will not write TrigDecision object to storegate")

        return True
Пример #2
0
    def configure(self):
        #         from AthenaServices.AthenaServicesConf import AthenaOutputStream
        #         from AthenaCommon.AppMgr import ServiceMgr
        #         from AthenaCommon.AlgSequence import AlgSequence
        #         topSequence = AlgSequence()

        #         ### the following was gotten from the LVL1TriggerGetter not sure if needed when not simulation
        #         if not (TriggerFlags.fakeLVL1() or TriggerFlags.doLVL1()):
        #            DetFlags.readRIOPool.LVL1_setOn()

        #         # ***Temp : needed to enable required combination of thresholds
        #         #           mu4,mu6,mu10,mu11,mu20,mu40
        #         # Will be replaced by config. from Lvl1ConfigSvc
        #         if hasattr(ServiceMgr,'RPCcablingSimSvc'):
        #             ServiceMgr.RPCcablingSimSvc.HackFor1031 = True
        if jobproperties.Global.InputFormat() == 'bytestream':
            theApp.Dlls += ["TrigT1Calo"]
            include("TrigT1CaloByteStream/ReadLVL1CaloBS_jobOptions.py")
        #         ###

        from AthenaCommon.AlgSequence import AlgSequence
        topSequence = AlgSequence()

        if recAlgs.doTrigger():
            if (rec.doESD() or rec.doAOD()) and (not(rec.readAOD() or \
                                                         rec.readESD())):
                if jobproperties.Global.InputFormat() == 'bytestream':
                    # Decode ROIB::RoIBResult from ByteStream
                    from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import L1ByteStreamDecodersRecExSetup
                    L1ByteStreamDecodersRecExSetup()
                from AnalysisTriggerAlgs.AnalysisTriggerAlgsConfig import \
                    RoIBResultToAOD
                topSequence += RoIBResultToAOD("RoIBResultToxAOD")
                pass
            pass

        from TrigEDMConfig.TriggerEDM import getLvl1ESDList
        objKeyStore.addManyTypesStreamESD(getLvl1ESDList())
        from TrigEDMConfig.TriggerEDM import getLvl1AODList
        objKeyStore.addManyTypesStreamAOD(getLvl1AODList())

        return True
Пример #3
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
Пример #4
0
#        protectedInclude ("ObjMissingET/ObjMissingET_CBNT_jobOptions.py")

#if recAlgs.doMissingETSig() or rec.readESD() or rec.readAOD() :
#        protectedInclude ("MissingETSig/MissingETSig_CBNT_jobOptions.py")

## #comment out until statuscode is fixed
# not supported anymore
## if recAlgs.doEFlow() or rec.readESD():
##          protectedInclude ("eflowRec/jobOptions_CBNT_eflow.py")

## if recAlgs.doEFlowJet():
##         protectedInclude ("eflowRec/ConeJetEflow_CBNT_jobOptions.py")

if rec.doHeavyIon():
    protectedInclude("HIRecExample/HIRec_CBNT_jobOptions.py")

if recAlgs.doTrigger() or (rec.readESD() and not rec.noESDTrigger()):
    protectedInclude("TriggerRelease/jobOfragment_TriggerCBNT.py")

if rec.doAOD() or rec.readAOD():
    protectedInclude("CBNT_AOD/AOD_CBNT_jobOptions.py")

if recAlgs.doAtlfast():
    protectedInclude("CBNT_AOD/AOD_CBNT_FastTree_jobOptions.py")

protectedInclude("CBNT_Athena/CBNT_Audit_jobOptions.py")

#CBNT_Audit.detailedTime = false ; // put in the ntuple CPU time per algrithm
# list of algorithms to be monitored (by default take them all)
#CBNT_Audit.Algs += { "GenzModule", "CBNT_Athena" } ;
Пример #5
0
    try:
        from JetRec.JetRecFlags import jobproperties
        jobproperties.JetRecFlags.Enabled = False
    except Exception:
        treatException("Could not instantiate JetRecFlags")

    try:
        from tauRec.tauRecFlags import jobproperties
        jobproperties.tauRecFlags.Enabled = False
    except Exception:
        treatException("Could not instantiate tauRecFlags")

if rec.doESD() and rec.doHeavyIon():
    include("HIRecExample/heavyion_flagsESD.py")
if rec.doAOD() and rec.doHeavyIon():
    include("HIRecExample/heavyion_flagsAOD.py")

if rec.doESD() and rec.doHIP():
    include("HIRecExample/hip_flagsESD.py")
if rec.doAOD() and rec.doHIP():
    include("HIRecExample/hip_flagsAOD.py")

# minimal reconstruction defaults

if rec.doMinimalRec():
    include("RecExCond/MinimalRec_flagsESD.py")

# now translate all the rec.doInDet doCalo etc... into lower level flags
# not complete yet
Пример #6
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
Пример #7
0
    def configure(self):

        # Don't do anything for data jobs:
        from AthenaCommon.GlobalFlags import globalflags
        if globalflags.DataSource() == "data":
            return True

        # Also check that this is not a reconstruction job, as the
        # slimming could mess up such a job very badly.
        from RecExConfig.RecFlags import rec
        if rec.doESD() or rec.doAOD():
            return True

        # Let the user know what we're doing:
        __log = logging.getLogger("TrigNavSlimming")
        __log.info("Configuring Trigger Navigation Slimming")

        # Construct the object/container names for which the navigation
        # should have references:
        from TrigEDMConfig.TriggerEDM import getTriggerObjList, TriggerL2List, TriggerEFList, TriggerHLTList, TriggerResultsList
        tlist = getTriggerObjList(
            'AODFULL',
            [TriggerL2List, TriggerEFList, TriggerHLTList, TriggerResultsList])
        from RecExConfig.ObjKeyStore import cfgKeyStore
        objlist = []
        for t, kset in tlist.iteritems():
            for k in kset:
                __log.debug("Checking for object %s#%s" % (t, k))
                # Notice that we can't use the isInInput(...) function.
                # Calling getAODList(...) earlier adds all the trigger
                # objects to be available in the transient store. Even
                # though they won't be. This is why we can't use this
                # singleton in a reconstruction job.
                if cfgKeyStore.isInInputFile(t, k):
                    objlist += ["%s#%s" % (t, k)]
                    pass
                pass
            pass
        __log.info("Will retain references for objects: %s" % objlist)

        actions = ['SyncThinning', 'Reload']
        if objlist:
            actions.append('DropFeatures')

        # Set up the slimming algorithm:
        from TrigNavTools.TrigNavToolsConf import HLT__TrigNavigationSlimming, TrigNavigationThinningTool, HLT__TrigNavigationSlimmingTool

        from AthenaServices.AthenaServicesConf import ThinningSvc
        from AthenaCommon.AppMgr import ToolSvc, ServiceMgr
        thinningSvc = ThinningSvc()
        ServiceMgr += thinningSvc
        navSlimmingTool = HLT__TrigNavigationSlimmingTool()
        navSlimmingTool.Actions = actions
        navSlimmingTool.ThinningSvc = thinningSvc
        navSlimmingTool.FeatureInclusionList = objlist

        navThinningTool = TrigNavigationThinningTool()
        navThinningTool.ActInPlace = True
        navThinningTool.SlimmingTool = navSlimmingTool
        navThinningTool.ThinningSvc = thinningSvc
        ToolSvc += navThinningTool

        slimmer = HLT__TrigNavigationSlimming()
        slimmer.ThinningTool = navThinningTool

        self.__sequence += slimmer

        # Signal that everything went okay:
        return True
Пример #8
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
Пример #9
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():
            bs = ByteStreamUnpackGetter()

        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():
            tdt = TrigDecisionGetter()

        # 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" )
            topSequence += RoiWriter()
            # write out the RoiDescriptorStores
            from TrigEDMConfig.TriggerEDM 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, thinningSvc, edm):
            from AthenaCommon.AlgSequence import AlgSequence 
            topSequence = AlgSequence()
            from TrigNavTools.TrigNavToolsConf import HLT__StreamTrigNavSlimming, HLT__TrigNavigationSlimming
            from TrigNavTools.TrigNavToolsConfig import navigationSlimming

            edmlist = list(y.split('-')[0] for x in edm.values() for y in x) #flatten names
          
            # from HLT result drop unrecorded features
            # slimmerHLT = HLT__StreamTrigNavSlimming('HLTNavSlimmer_%s'%stream)
            slimmerHLT = HLT__TrigNavigationSlimming('TrigNavigationSlimmer_%s'%stream)
            tHLT = navigationSlimming({'name':'HLTNav_%s'%stream, 'mode':'cleanup', 
                                                          'ThinningSvc':thinningSvc, 'result':'HLTResult_HLT',
                                                          'features':edmlist})
            #tHLT.SlimmingTool.OutputLevel=DEBUG
            tHLT.ActInPlace=True
            slimmerHLT.ThinningTool = tHLT
            print slimmerHLT.ThinningTool
            topSequence += slimmerHLT
            log.info("Configured slimming of HLT")
            del edmlist


        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        from AthenaServices.Configurables import ThinningSvc, createThinningSvc
        
        _doSlimming = True
        if _doSlimming and rec.readRDO() and rec.doWriteAOD():
            if not hasattr(svcMgr, 'ThinningSvc'): # if the default is there it is configured for AODs
                svcMgr += ThinningSvc(name='ThinningSvc', Streams=['StreamAOD'])             
            _addSlimming('StreamAOD', svcMgr.ThinningSvc, _TriggerESDList ) #Use ESD item list also for AOD!
            log.info("configured navigation slimming for AOD output")
            
        if _doSlimming and rec.readRDO() and rec.doWriteESD(): #rec.doWriteESD() and not rec.readESD(): 
            if not  hasattr(svcMgr, 'ESDThinningSvc'):
                svcMgr += ThinningSvc(name='ESDThinningSvc', Streams=['StreamESD']) # the default is configured for AODs
            _addSlimming('StreamESD', svcMgr.ESDThinningSvc, _TriggerESDList )                
            log.info("configured navigation slimming for ESD output")              
            



        objKeyStore.addManyTypesStreamESD( _TriggerESDList )                        
        objKeyStore.addManyTypesStreamAOD( _TriggerAODList )        
            
        return True
Пример #10
0
doESD = rec.doESD()  # if false, all algorithms are switched off by defaults
#only switched minimal algorithm
recAlgs.donewTracking = True
donewTracking = recAlgs.donewTracking()
#
recAlgs.doEmCluster = True
doEmCluster = recAlgs.doEmCluster()
#
recAlgs.doEgamma = True
doEgamma = recAlgs.doEgamma()
#
recAlgs.doConversion = True
doConversion = recAlgs.doConversion()
#
rec.doAOD = False
doAOD = rec.doAOD()
#
rec.doWriteAOD = False
doWriteAOD = rec.doWriteAOD()
#
rec.doWriteESD = False
doWriteESD = rec.doWriteESD()
#
rec.doWriteTAG = False
doWriteTAG = rec.doWriteTAG()
# number of event to process
#from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
#athenaCommonFlags.EvtMax= 2000
EvtMax = 2000

include("RecExCommon/RecExCommon_flags.py")