def uglyHackedInclude(jobOptions): global ToolSvc, ServiceMgr from AthenaCommon.Include import include import __main__ if not hasattr(__main__, 'include'): include.setShowIncludes(False) include.setClean(False) setattr(__main__, 'include', include) if not hasattr(__main__, "ToolSvc"): setattr(__main__, "ToolSvc", ToolSvc) if not hasattr(__main__, "ServiceMgr"): setattr(__main__, "ServiceMgr", ServiceMgr) include(jobOptions)
if not '.py' in a: listOfRuns+=sys.argv[1].split(',') if len(listOfRuns)==0: print 'Usage: makeSLHAFilesForSM.py run1 run2 run3,run4,run5 run6...' sys.exit(0) print 'Getting SLHA files for run(s)',listOfRuns # Fake some things that we won't need later from PyJobTransforms.trfJobOptions import RunArguments runArgs = RunArguments() runArgs.randomSeed = 1234 from AthenaCommon import Logging evgenLog = Logging.logging.getLogger('SLHAGetter') # only really need this once from AthenaCommon.Include import IncludeError, include include.setShowIncludes(False) include('/cvmfs/atlas.cern.ch/repo/sw/Generators/MC12JobOptions/latest/susycontrol/MadGraphControl_SimplifiedModelPreInclude.py') include.block('MC12JobOptions/MadGraphControl_SimplifiedModelPreInclude.py') include.block('MC12JobOptions/MadGraphControl_SimplifiedModelPostInclude.py') for run in listOfRuns: loc_l = glob.glob('/cvmfs/atlas.cern.ch/repo/sw/Generators/MC12JobOptions/latest/share/DSID'+run[0:3]+'xxx/MC12.'+run+'.*') if 0==len(loc_l): print 'Run not found:',run,'in','/cvmfs/atlas.cern.ch/repo/sw/Generators/MC12JobOptions/latest/share/DSID'+run[0:3]+'xxx/MC12.'+run+'.*' continue if len(loc_l)>1: print 'Multiple runs found:',loc_l,'for run',run,'- Using first.' loc = loc_l[0] jobO = open(loc,'r') main_jobO = ''
from AthenaCommon.Logging import * _msg = log # from above import... ## test and set log level try: _msg.setLevel(getattr(logging, opts.msg_lvl)) except: _help_and_exit() ### default file name for ease of use ---------------------------------------- if not opts.scripts and os.path.exists(opts.default_jobopt): _msg.info("using default file %s", opts.default_jobopt) opts.scripts.append(opts.default_jobopt) if not (opts.scripts or opts.fromdb) and opts.run_batch: _msg.error("batch mode requires at least one script") from AthenaCommon.ExitCodes import INCLUDE_ERROR _help_and_exit(INCLUDE_ERROR) del _help_and_exit ### file inclusion and tracing ----------------------------------------------- from AthenaCommon.Include import IncludeError, include include.setShowIncludes(opts.showincludes) include.setClean(opts.drop_cfg) ### pre-execution step ------------------------------------------------------- include("AthenaCommon/Preparation.py") ### execution of user script and drop into batch or interactive mode --------- include("AthenaCommon/Execution.py")
if len(logLevel) == 0: logLevel = ["INFO", "ERROR"] if len(logLevel) == 1: logLevel.append("ERROR") ## test and set log level try: exec('log.setLevel( logging.%s )' % logLevel[0]) except: sys.exit(ExitCodes.OPTIONS_UNKNOWN) ### file inclusion and tracing ----------------------------------------------- from AthenaCommon.Include import Include, IncludeError, include showincludes = eval(PscConfig.optmap['SHOWINCLUDE']) include.setShowIncludes(showincludes) if showincludes: import AthenaCommon.Include as AthCIncMod AthCIncMod.marker = ' -#-' # distinguish bootstrap from other jo-code if PscConfig.optmap['TRACEPATTERN']: import AthenaCommon.Include AthenaCommon.Include.tracePattern = PscConfig.optmap['TRACEPATTERN'] # ### gaudi -------------------------------------------------------------------- try: from GaudiPython import * except ImportError: from gaudimodule import *
runBatch=1 ### python interpreter configuration ----------------------------------------- if not os.getcwd() in sys.path: sys.path = [ os.getcwd() ] + sys.path if not '' in sys.path: sys.path = [ '' ] + sys.path ### logging and messages ----------------------------------------------------- from AthenaCommon.Logging import * ### file inclusion and tracing ----------------------------------------------- from AthenaCommon.Include import Include, IncludeError, include include.setShowIncludes( False ) ### gaudi -------------------------------------------------------------------- from GaudiPython import * from AthenaCommon.Configurable import * from AthenaCommon.OldStyleConfig import * from AthenaCommon.Constants import * preconfig = "AthenaCommon" ### Athena configuration ----------------------------------------------------- theApp = iService( "ApplicationMgr" ) # proxy theApp.Dlls += [ 'AthenaServices' ] include( "%s/Bootstrap.py" % preconfig ) ## create the application manager and start in a non-initialised state
if geo and not detdescrset: prompt = "Enter DetectorDescripton tag [%s]:" % detdescrtag detdescrtagIn = raw_input(prompt).strip() if detdescrtagIn != "": detdescrtag = detdescrtagIn except: print "Failed to get run number and/or conditions tag" sys.exit(0) #Don't let PyRoot open X-connections sys.argv = sys.argv[:1] + ['-b'] #Now inport the athena stuff from AthenaCommon.Include import Include, IncludeError, include include.setShowIncludes(0) from AthenaCommon import CfgMgr from AthenaCommon.AppMgr import theApp from AthenaCommon.AppMgr import ToolSvc, ServiceMgr #, theAuditorSvc #protect against sloppy module authors svcMgr = ServiceMgr toolSvc = ToolSvc from AthenaCommon.Logging import * from AthenaCommon.Constants import * log.setLevel(ERROR) theApp.setOutputLevel(ERROR) from AthenaCommon.Configurable import * from AthenaCommon.OldStyleConfig import * import AthenaCommon.AtlasUnixGeneratorJob
def main(): parser = argparse.ArgumentParser(prog='athenaHLT.py', formatter_class= lambda prog : argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=32, width=100), usage = '%(prog)s [OPTION]... -f FILE jobOptions', add_help=False) parser.expert_groups = [] # Keep list of expert option groups ## Global options g = parser.add_argument_group('Options') g.add_argument('jobOptions', nargs='?', help='job options (or JSON) file') g.add_argument('--file', '--filesInput', '-f', action='append', required=True, help='input RAW file') g.add_argument('--save-output', '-o', metavar='FILE', help='output file name') g.add_argument('--number-of-events', '--evtMax', '-n', metavar='N', default=-1, help='processes N events (<=0 means all)') g.add_argument('--skip-events', '--skipEvents', '-k', metavar='N', default=0, help='skip N first events') g.add_argument('--threads', metavar='N', type=int, default=1, help='number of threads') g.add_argument('--nprocs', metavar='N', type=int, default=1, help='number of children to fork') g.add_argument('--concurrent-events', metavar='N', type=int, help='number of concurrent events if different from --threads') g.add_argument('--log-level', '-l', metavar='LVL', type=arg_log_level, default='INFO,ERROR', help='OutputLevel of athena,POOL') g.add_argument('--precommand', '-c', metavar='CMD', action='append', default=[], help='Python commands executed before job options or database configuration') g.add_argument('--postcommand', '-C', metavar='CMD', action='append', default=[], help='Python commands executed after job options or database configuration') g.add_argument('--debug', '-d', nargs='?', const='child', choices=['parent','child'], help='attach debugger (to child by default)') g.add_argument('--interactive', '-i', action='store_true', help='interactive mode') g.add_argument('--help', '-h', nargs='?', choices=['all'], action=MyHelp, help='show help') ## Performance and debugging g = parser.add_argument_group('Performance and debugging') g.add_argument('--perfmon', action='store_true', help='enable PerfMon') g.add_argument('--leak-check', metavar='<stage>', nargs='?', const='execute', choices=['all','initialize','start','beginrun','execute','finalize','endrun','stop'], help='Perform leak checking during <stage>') g.add_argument('--tcmalloc', action='store_true', default=True, help='use tcmalloc') g.add_argument('--stdcmalloc', action='store_true', help='use stdcmalloc') g.add_argument('--stdcmath', action='store_true', help='use stdcmath library') g.add_argument('--imf', action='store_true', default=True, help='use Intel math library') g.add_argument('--show-includes', '-s', action='store_true', help='show printout of included files') g.add_argument('--timeout', metavar='MSEC', default=60*60*1000, help='timeout in milliseconds') ## Database g = parser.add_argument_group('Database') g.add_argument('--use-database', '-b', action='store_true', help='configure from trigger database, reading keys from COOL if not specified') g.add_argument('--db-server', metavar='DB', default='TRIGGERDB', help='DB server name') g.add_argument('--smk', type=int, default=None, help='Super Master Key') g.add_argument('--l1psk', type=int, default=None, help='L1 prescale key') g.add_argument('--hltpsk', type=int, default=None, help='HLT prescale key') g.add_argument('--dump-config', action='store_true', help='Dump joboptions JSON file') g.add_argument('--dump-config-exit', action='store_true', help='Dump joboptions JSON file and exit') ## Online histogramming g = parser.add_argument_group('Online Histogramming') g.add_argument('--oh-monitoring', '-M', action='store_true', help='enable OH monitoring') g.add_argument('--oh-interval', metavar='SEC', type=int, default=5, help='seconds between histogram publications.') ## Conditions g = parser.add_argument_group('Conditions') g.add_argument('--run-number', '-R', metavar='RUN', type=int, help='run number (if None, read from first event)') g.add_argument('--sor-time', type=arg_sor_time, help='The Start Of Run time. Three formats are accepted: ' '1) the string "now", for current time; ' '2) the number of nanoseconds since epoch (e.g. 1386355338658000000 or int(time.time() * 1e9)); ' '3) human-readable "20/11/18 17:40:42.3043". If not specified the sor-time is read from COOL') g.add_argument('--detector-mask', metavar='MASK', type=arg_detector_mask, help='detector mask (if None, read from COOL), use string "all" to enable all detectors') ## Expert options g = parser.add_argument_group('Expert') parser.expert_groups.append(g) g.add_argument('--joboptionsvc-type', metavar='TYPE', default='TrigConf::JobOptionsSvc', help='JobOptionsSvc type') g.add_argument('--msgsvc-type', metavar='TYPE', default='TrigMessageSvc', help='MessageSvc type') g.add_argument('--partition', '-p', metavar='NAME', default='athenaHLT', help='partition name') g.add_argument('--no-ers-signal-handlers', action='store_true', help='disable ERS signal handlers') g.add_argument('--preloadlib', metavar='LIB', help='preload an arbitrary library') g.add_argument('--unique-log-files', '-ul', action='store_true', help='add pid/timestamp to worker log files') g.add_argument('--debug-fork', action='store_true', help='Dump open files/threads during forking') g.add_argument('--hltresult-size', metavar='MB', type=int, default=10, help='Maximum HLT result size in MB') g.add_argument('--extra-l1r-robs', metavar='ROBS', type=arg_eval, default=[], help='List of additional ROB IDs that are considered part of the L1 result and passed to the HLT') g.add_argument('--ros2rob', metavar='DICT', type=arg_ros2rob, default={}, help='Either a string in the form of python dictionary that contains ros-rob mappings ' 'or a file path that contains such string. For example, /path/to/rosmap.txt or ' '{"ROS0":[0x11205,0x11206],"ROS1":[2120005,2120006]}') g.add_argument('--cfgdict', metavar='DICT', type=arg_eval, default={}, help='HLTMPPy config dictionary with additional options, e.g.: ' '--cfgdict \'{"global": {"log_root" : "/tmp"}}\'') args = parser.parse_args() check_args(parser, args) # set default OutputLevels and file inclusion import AthenaCommon.Logging AthenaCommon.Logging.log.setLevel(getattr(logging, args.log_level[0])) from AthenaCommon.Include import include include.setShowIncludes( args.show_includes ) # consistency checks for arguments if not args.concurrent_events: args.concurrent_events = args.threads # Update args and set athena flags update_run_params(args) if args.use_database: update_trigconf_keys(args) # get HLTMPPY config dictionary cdict = HLTMPPy_cfgdict(args) # Apply any expert-level overrides update_nested_dict(cdict, args.cfgdict) # Modify pre/postcommands if necessary update_pcommands(args, cdict) # Extra Psc configuration from TrigPSC import PscConfig PscConfig.interactive = args.interactive PscConfig.dumpJobProperties = args.dump_config or args.dump_config_exit PscConfig.exitAfterDump = args.dump_config_exit # Select the correct THistSvc from TrigServices.TriggerUnixStandardSetup import _Conf _Conf.useOnlineTHistSvc = args.oh_monitoring # Run HLTMPPU from HLTMPPy.runner import runHLTMPPy runHLTMPPy(cdict)
try: _msg.setLevel (getattr(logging, opts.msg_lvl)) except: _help_and_exit() ### default file name for ease of use ---------------------------------------- if not opts.scripts and os.path.exists(opts.default_jobopt): _msg.info("using default file %s", opts.default_jobopt) opts.scripts.append(opts.default_jobopt) if not (opts.scripts or opts.fromdb) and opts.run_batch: _msg.error( "batch mode requires at least one script" ) from AthenaCommon.ExitCodes import INCLUDE_ERROR _help_and_exit( INCLUDE_ERROR ) del _help_and_exit ### file inclusion and tracing ----------------------------------------------- from AthenaCommon.Include import IncludeError, include include.setShowIncludes(opts.showincludes) include.setClean(opts.drop_cfg) ### pre-execution step ------------------------------------------------------- include( "AthenaCommon/Preparation.py" ) ### execution of user script and drop into batch or interactive mode --------- include( "AthenaCommon/Execution.py" )