Example #1
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
Example #2
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
Example #3
0
#FIXME: Subsequent algorithms may alter the event info object (setting Error bits)
if not objKeyStore.isInInput( "xAOD::EventInfo"):
    from xAODEventInfoCnv.xAODEventInfoCreator import xAODMaker__EventInfoCnvAlg
    topSequence+=xAODMaker__EventInfoCnvAlg()
    pass



###################################################################
#
# functionality : monitor memory and cpu time
#

#
#now write out Transient Event Store content in POOL
if rec.doWriteESD() or rec.doWriteAOD() or rec.doWriteRDO() or rec.doWriteTAG():
    import AthenaPoolCnvSvc.WriteAthenaPool


# Must make sure that no OutStream's have been declared
#FIXME
theApp.OutStream = []




MetaDataStore=svcMgr.MetaDataStore


#Lumiblocks and EventBookkeepers
if rec.doFileMetaData():
Example #4
0
    for i in RecExCommonFlags.keys():
        # delete old flags unless required otherwise
        if i in varInit:
            print "now deleting:", i
            exec 'del %s' % i

if athenaCommonFlags.FilesInput() == []:
    from RecExConfig.RecoFunctions import InputFileNames
    athenaCommonFlags.FilesInput = InputFileNames()
    logRecExCommon_flags.info(
        "athenaCommonFlags.FilesInput override input file specification")
# from now on athenaCommonFlags.FilesInput() can reliably be used to have input file list

# 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
Example #5
0
    # include DetFlags
    # by default everything is off
    from AthenaCommon.DetFlags import DetFlags
    # switch on tasks for all detectors
    DetFlags.detdescr.all_setOn()
    # switch on dcs for all detectors
    try:
        # need AthenaCommon
        DetFlags.dcs.all_setOn()
    except Exception:
        logRecExCommon_DetFlags.warning("could not set DetFlags.dcs")
        pass

    from RecExConfig.RecFlags import rec
    if not rec.readESD() and not rec.readAOD() and not rec.doWriteRDO():
        DetFlags.makeRIO.all_setOn()
    else:
        DetFlags.makeRIO.all_setOff()
        #calo cells are there on ESD
        if rec.readESD():
            DetFlags.readRIOPool.Calo_setOn()
            # savannah 73686
            from RecExConfig.AutoConfiguration import IsInInputFile
            from InDetRecExample.InDetKeys import InDetKeys
            if IsInInputFile('InDet::PixelClusterContainer',
                             InDetKeys.PixelClusters()):
                DetFlags.readRIOPool.pixel_setOn()
            if IsInInputFile('InDet::SCT_ClusterContainer',
                             InDetKeys.SCT_Clusters()):
                DetFlags.readRIOPool.SCT_setOn()
Example #6
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)
Example #7
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)