Exemplo n.º 1
0
    def _do_readevgen(cls):
        """ Place to read evgen events.
        """
        from G4AtlasApps.SimFlags import simFlags
        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        AtlasG4Eng.G4Eng.log.verbose('SimSkeleton._do_readevgen :: starting')

        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        ## ReadTR is only present in simFlags for ATLAS geometries with cosmics switched on
        if (not simFlags.ISFRun) and hasattr(simFlags, "ReadTR") and simFlags.ReadTR.statusOn:
            include("CosmicGenerator/SetCosmicGenerator.py")

        if athenaCommonFlags.PoolEvgenInput.statusOn:
            ## Tell the event selector about the evgen input files and event skipping
            if not hasattr(svcMgr, 'EventSelector'):
                import AthenaPoolCnvSvc.ReadAthenaPool
            svcMgr.EventSelector.InputCollections = athenaCommonFlags.PoolEvgenInput()
            if athenaCommonFlags.SkipEvents.statusOn:
                svcMgr.EventSelector.SkipEvents = athenaCommonFlags.SkipEvents()
            from G4AtlasApps.G4Atlas_Metadata import inputFileValidityCheck
            inputFileValidityCheck()
        else:
            ## No input file so assume that we are running a Generator in the same job
            if not hasattr(svcMgr, 'EventSelector'):
                import AthenaCommon.AtlasUnixGeneratorJob
            # TODO: Check that there is at least one algorithm already in the AlgSequence?
            ## Warn if attempting to skip events in a generator job
            if athenaCommonFlags.SkipEvents.statusOn and athenaCommonFlags.SkipEvents()!=0:
                msg = "SimSkeleton._do_readevgen :: athenaCommonFlags.SkipEvents set in a job without an active "
                msg += "athenaCommonFlags.PoolEvgenInput flag: ignoring event skip request"
                AtlasG4Eng.G4Eng.log.warning(msg)

        AtlasG4Eng.G4Eng.log.verbose('SimSkeleton._do_readevgen :: done')
Exemplo n.º 2
0
def getAthFile():
    ## Allow the input check to be skipped.  This should only be done in production
    ##  jobs, in order to avoid peeking and spoiling performance on some systems
    inputAthFileObject = None
    import os
    if not ('G4ATLAS_SKIPFILEPEEK' in os.environ
            and os.environ['G4ATLAS_SKIPFILEPEEK']):
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        if athenaCommonFlags.PoolEvgenInput.statusOn:
            try:
                import PyUtils.AthFile as af
                inputAthFileObject = af.fopen(
                    athenaCommonFlags.PoolEvgenInput()[0])
            except:
                simMDlog.warning("AthFile failed to open %s",
                                 athenaCommonFlags.PoolEvgenInput()[0])
    else:
        simMDlog.info(
            "G4ATLAS_SKIPFILEPEEK environment variable present, so skipping all input file peeking."
        )
    return inputAthFileObject
Exemplo n.º 3
0
def get_metadata(mode='lite'):
    # Allow the input check to be skipped.  This should only be done in production
    # jobs, in order to avoid peeking and spoiling performance on some systems
    import os
    if not ('G4ATLAS_SKIPFILEPEEK' in os.environ
            and os.environ['G4ATLAS_SKIPFILEPEEK']):
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        if athenaCommonFlags.PoolEvgenInput.statusOn:
            try:
                from PyUtils.MetaReader import read_metadata
                input_file = athenaCommonFlags.PoolEvgenInput()[0]
                metadata = read_metadata(input_file, mode=mode)
                metadata = metadata[
                    input_file]  # promote all keys one level up
                return metadata
            except:
                simMDlog.warning("MetaReader failed to open %s",
                                 athenaCommonFlags.PoolEvgenInput()[0])
    else:
        simMDlog.info(
            "G4ATLAS_SKIPFILEPEEK environment variable present, so skipping all input file peeking."
        )
    return None
Exemplo n.º 4
0
class ISF_Input:
    """
     Place to handle the persistency.
    """

    isfiplog.info("in ISF_Input")
    """ Place to read evgen events.
    """
    from G4AtlasApps.SimFlags import simFlags
    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    #G4AtlasEngine.log.verbose('SimSkeleton._do_readevgen :: starting')

    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags

    if athenaCommonFlags.PoolEvgenInput.statusOn:
        ## Tell the event selector about the evgen input files and event skipping
        if not hasattr(svcMgr, 'EventSelector'):
            import AthenaPoolCnvSvc.ReadAthenaPool
        svcMgr.EventSelector.InputCollections = athenaCommonFlags.PoolEvgenInput(
        )
        if athenaCommonFlags.SkipEvents.statusOn:
            svcMgr.EventSelector.SkipEvents = athenaCommonFlags.SkipEvents()
        from ISF_Example.ISF_Metadata import inputFileValidityCheck
        inputFileValidityCheck()
    else:
        ## No input file so assume that we are running a Generator in the same job
        if not hasattr(svcMgr, 'EventSelector'):
            import AthenaCommon.AtlasUnixGeneratorJob
        # TODO: Check that there is at least one algorithm already in the AlgSequence?
        ## Warn if attempting to skip events in a generator job
        if athenaCommonFlags.SkipEvents.statusOn:
            msg = "athenaCommonFlags.SkipEvents set in a job without an active "
            msg += "athenaCommonFlags.PoolEvgenInput flag: ignoring event skip request"
            isfiplog.warning(msg)

    isfiplog.verbose('ISF_Input done')
Exemplo n.º 5
0
        atlasG4log.info('Overriding run number to be: %s ' %
                        runArgs.DataRunNumber)
        simFlags.RunNumber = runArgs.DataRunNumber
elif hasattr(runArgs, 'jobNumber'):
    if runArgs.jobNumber >= 0:
        atlasG4log.info('Using job number ' + str(runArgs.jobNumber) +
                        ' to derive run number.')
        simFlags.RunNumber = simFlags.RunDict.GetRunNumber(runArgs.jobNumber)
        atlasG4log.info('Set run number based on dictionary to ' +
                        str(simFlags.RunNumber))

## Handle cosmics track record
from AthenaCommon.BeamFlags import jobproperties
if jobproperties.Beam.beamType.get_Value() == 'cosmics':
    if hasattr(runArgs, "inputEVNT_TRFile"):
        simFlags.ReadTR = athenaCommonFlags.PoolEvgenInput()[0]
    else:
        if hasattr(runArgs, "outputEVNT_TRFile"):
            simFlags.WriteTR = runArgs.outputEVNT_TRFile
        include('CosmicGenerator/jobOptions_ConfigCosmicProd.py')

## Add filters for non-cosmics simulation
## FIXME: This block should be moved out of the skeleton into job options.
if jobproperties.Beam.beamType.get_Value() != 'cosmics':
    if simFlags.CavernCuts:
        simFlags.EventFilter.set_Off()
        # Make a bigger world volume for cavern bg
        simFlags.WorldZRange.set_Value(26050)
    else:
        simFlags.EventFilter.set_On()
Exemplo n.º 6
0
        configureRunNumberOverrides()

    ## SimSkeleton._do_readevgen
    from G4AtlasApps.SimFlags import simFlags
    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
    ## ReadTR is only present in simFlags for ATLAS geometries with cosmics switched on
    if (not simFlags.ISFRun) and hasattr(
            simFlags, "ReadTR") and simFlags.ReadTR.statusOn:
        include("CosmicGenerator/SetCosmicGenerator.py")

    if athenaCommonFlags.PoolEvgenInput.statusOn:
        ## Tell the event selector about the evgen input files and event skipping
        if not hasattr(svcMgr, 'EventSelector'):
            import AthenaPoolCnvSvc.ReadAthenaPool
        svcMgr.EventSelector.InputCollections = athenaCommonFlags.PoolEvgenInput(
        )
        if athenaCommonFlags.SkipEvents.statusOn:
            svcMgr.EventSelector.SkipEvents = athenaCommonFlags.SkipEvents()
        from G4AtlasApps.G4Atlas_Metadata import inputFileValidityCheck
        inputFileValidityCheck()
    else:
        ## No input file so assume that we are running a Generator in the same job
        if not hasattr(svcMgr, 'EventSelector'):
            import AthenaCommon.AtlasUnixGeneratorJob
        # TODO: Check that there is at least one algorithm already in the AlgSequence?
        ## Warn if attempting to skip events in a generator job
        if athenaCommonFlags.SkipEvents.statusOn and athenaCommonFlags.SkipEvents(
        ) != 0:
            msg = "SimSkeleton._do_readevgen :: athenaCommonFlags.SkipEvents set in a job without an active "
            msg += "athenaCommonFlags.PoolEvgenInput flag: ignoring event skip request"
            print msg