Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions | Variables
python.POOLtoHEPMC_Skeleton Namespace Reference

Functions

def fromRunArgs (runArgs)
 

Variables

 jobPropertiesDisallowed
 

Function Documentation

◆ fromRunArgs()

def python.POOLtoHEPMC_Skeleton.fromRunArgs (   runArgs)

Definition at line 18 of file POOLtoHEPMC_Skeleton.py.

18 def fromRunArgs(runArgs):
19  # Start the logger and identify ourselves
20  from AthenaCommon.Logging import logging
21  log = logging.getLogger('POOLtoHEPMC')
22  log.info('*** Starting POOLtoHEPMC translation ***')
23 
24  # Print some job information
25  log.info('*** Transformation run arguments ***')
26  log.info(str(runArgs))
27 
28  # Set up the flags we need
29  log.info('*** Setting-up configuration flags ***')
30  from AthenaConfiguration.AllConfigFlags import initConfigFlags
31  flags = initConfigFlags()
32  commonRunArgsToFlags(runArgs, flags)
33 
34  # Set ProductionStep
35  from AthenaConfiguration.Enums import ProductionStep
36  flags.Common.ProductionStep = ProductionStep.Derivation
37 
38  # Set the input file and configure the input collection key
39  if hasattr(runArgs, 'inputEVNTFile'):
40  flags.Input.Files = runArgs.inputEVNTFile
41  McEventKey = 'GEN_EVENT'
42  elif hasattr(runArgs, 'inputHITSFile'):
43  flags.Input.Files = runArgs.inputHITSFile
44  McEventKey = 'TruthEvent'
45  elif hasattr(runArgs, 'inputRDOFile'):
46  flags.Input.Files = runArgs.inputRDOFile
47  McEventKey = 'TruthEvent'
48  else:
49  log.error('Input EVNT, HITS, or RDO file required for POOLtoHEPMC')
50  # Set the output file
51  if hasattr(runArgs, 'outputHEPMCFile'):
52  if ('.tar' in runArgs.outputHEPMCFile):
53  index = re.search(".tar",runArgs.outputHEPMCFile).span()[0]
54  my_output_HepMCFile = runArgs.outputHEPMCFile[:index]+'.hepmc'
55  else:
56  log.error('Output should be a tar.gz file but it is '+runArgs.outputHEPMCFile)
57  else:
58  log.error('OutputHEPMCFile required for POOLtoHEPMC')
59 
60  # Setup perfmon flags from runargs
61  from PerfMonComps.PerfMonConfigHelpers import setPerfmonFlagsFromRunArgs
62  setPerfmonFlagsFromRunArgs(flags, runArgs)
63 
64  # Pre-include
65  processPreInclude(runArgs, flags)
66 
67  # Pre-exec
68  processPreExec(runArgs, flags)
69 
70  # To respect --athenaopts
71  flags.fillFromArgs()
72 
73  # Lock flags
74  flags.lock()
75 
76  # Do the configuration of the main services
77  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
78  cfg = MainServicesCfg(flags)
79 
80  # Set us up for reading a POOL file
81  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
82  cfg.merge(PoolReadCfg(flags))
83 
84  # Use the WriteHepMC AlgTool from TruthIO to do the conversion
85  from AthenaConfiguration.ComponentFactory import CompFactory
86  cfg.addEventAlgo( CompFactory.WriteHepMC( 'WriteHepMC',
87  OutputFile = my_output_HepMCFile,
88  McEventKey = McEventKey ) )
89 
90  # Post-include
91  processPostInclude(runArgs, flags, cfg)
92 
93  # Post-exec
94  processPostExec(runArgs, flags, cfg)
95 
96  import time
97  tic = time.time()
98 
99  # Run the final accumulator
100  sc = cfg.run()
101 
102  # Compress the output file
103  log.info('Compressing HEPMC output (may take a moment)')
104  import tarfile
105  with tarfile.open(runArgs.outputHEPMCFile,'w:gz') as out_tar:
106  out_tar.add( my_output_HepMCFile )
107 
108  # And remove the uncompressed version
109  log.debug('Deleting original (uncompressed) file')
110  import os
111  os.remove( my_output_HepMCFile )
112 
113  # All done, now just report back
114  log.info("Ran POOLtoHEPMC in " + str(time.time()-tic) + " seconds")
115 
116  sys.exit(not sc.isSuccess())
117 

Variable Documentation

◆ jobPropertiesDisallowed

python.POOLtoHEPMC_Skeleton.jobPropertiesDisallowed

Definition at line 16 of file POOLtoHEPMC_Skeleton.py.

CxxUtils::span
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
python.TransformUtils.processPreExec
def processPreExec(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:41
python.TransformUtils.processPostExec
def processPostExec(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:50
python.POOLtoHEPMC_Skeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: POOLtoHEPMC_Skeleton.py:18
python.TransformUtils.processPostInclude
def processPostInclude(runArgs, flags, cfg)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:69
python.TransformUtils.processPreInclude
def processPreInclude(runArgs, flags)
Definition: Tools/PyJobTransforms/python/TransformUtils.py:62
python.PerfMonConfigHelpers.setPerfmonFlagsFromRunArgs
def setPerfmonFlagsFromRunArgs(flags, runArgs)
Definition: PerfMonConfigHelpers.py:3
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69