ATLAS Offline Software
POOLtoEI_tf.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 #
3 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 #
5 
6 """
7 Run EventIndex on POOL file, produce EI file and send Events to brokers
8 """
9 
10 import sys
11 import time
12 from itertools import cycle
13 
14 # Setup core logging here
15 from PyJobTransforms.trfLogger import msg
16 
17 from PyJobTransforms.transform import transform
18 from PyJobTransforms.trfArgs import addAthenaArguments
19 from PyJobTransforms.trfDecorators import stdTrfExceptionHandler
20 from PyJobTransforms.trfDecorators import sigUsrStackTrace
21 
22 import PyJobTransforms.trfArgClasses as trfArgClasses
23 
24 msg.info('logging set in {}'.format(sys.argv[0]))
25 
26 
27 @stdTrfExceptionHandler
28 @sigUsrStackTrace
29 def main():
30 
31  msg.info('This is {}'.format(sys.argv[0]))
32 
33  trf = getTransform()
34  trf.parseCmdLineArgs(sys.argv[1:])
35 
36  # update datasetname if inputfile has the form "datasetname#filename"
37  # and it has not been specified within the options.
38  args = trf.argdict
39  if "eidsname" not in args:
40  dsname = None
41  for filetype in ('POOL', 'AOD', 'ESD', 'EVNT', 'HITS', 'RDO'):
42  if 'input'+filetype+'File' in args:
43  inputFile = args['input'+filetype+'File']
44  dsname = inputFile.dataset
45  if dsname is not None:
46  obj = trfArgClasses.argString(dsname)
47  args['eidsname'] = obj
48 
49  # execute transformation
50  trf.execute()
51 
52  # process EI output file
53  oname_spb = getOutputNames(args)
54  msg.info('Output file: {}'.format(oname_spb))
55 
56  if (oname_spb is not None and "sendtobroker" in args
57  and args["sendtobroker"].value):
58  # SPB
59  from EventIndexProducer.sendEI_SPB_Lib import eimrun
60  from EventIndexProducer.sendEI_SPB_Lib import options as eioptions
61 
62  # set default options
63  import base64
64  argv2 = []
65  argv2.append("-v") # verbose
66  # add the connect string
67  if "testbrk" in args and args["testbrk"]:
68  # test
69  earg = "fWIqIhAfKiAxAEoxOyMtB0IxLCwASz0tYS8RHStnPBxcZn5/" \
70  "fUdDaGQqBwMiYy44GAozPTYQHiQ8O2BZQjUoLAcFPysqYDMJ" \
71  "cT09QRISABg1MwcXPQlYS308fCkaCzUmNhoSfDx8YhcKNydx" \
72  "Fw5qe3t/WEJoKCgHBzMsKj8HQ3MAGT8+Hx0YFiRecRBsIFAC" \
73  "ewAFWEJoKCgHFTUsPSkAQxQ/LkIiNB86DT08dXAUAh8DBA4g" \
74  "PBl9ERQ8HhoALBwbXBF9CkY+HSRjYVkKKjo5FQo8LS4vH0Mx" \
75  "OyoR"
76  else:
77  # prod
78  earg = "fWIqIhAfKiAxAEoxOyMtB0IoK3EXAyIhYS8cVXN4b0VVfGJi" \
79  "OQcKN2U+AAo1OTslEBcxOitYS30/Lj8HDCotOlghNns7LkEb" \
80  "BwYIDSE4HTsaWEJoOmwRCDQ/ICUaG2k6bFoFNT0hYhcHf31r" \
81  "R0p9Yi47Bw4mKjoHFXx5Bgo/NwobCC42YXsWfyBZF30QPUp9" \
82  "Yi47BxwgKi0REnweOT1CKyEZKjUvA392BwIWFgIeGC4mdxcH" \
83  "PBcPBjwkCWMbexlGNwgic1lLNSA8KhUDKSs+Fw18Oz05EQ=="
84  eargs = ''.join(chr(c ^ ord(k)) for c, k in
85  zip(base64.b64decode(earg),
86  cycle(trf.name))).split(",")
87  argv2.extend(eargs)
88  argv2.append(oname_spb)
89  eiopts = eioptions(argv2)
90 
91  # transfer file
92  eimrun(msg, eiopts)
93 
94  trf.generateReport()
95 
96  msg.info("{} stopped at {}, trf exit code {:d}".format(sys.argv[0],
97  time.asctime(),
98  trf.exitCode))
99  sys.exit(trf.exitCode)
100 
101 
102 # Get the base transform with all arguments added
104  executorSet = set()
105  from EventIndexProducer.EITransformUtils import addEI_Substep
106  from EventIndexProducer.EITransformUtils import addEI_arguments
107  addEI_Substep(executorSet)
108 
109  trf = transform(executor=executorSet,
110  description='EventIndex transform. '
111  'Input must be a POOL file.')
112  addAthenaArguments(trf.parser)
113  addEI_arguments(trf.parser)
114  return trf
115 
116 
117 # Build output file names
118 def getOutputNames(args):
119 
120  if "eifmt" in args:
121  eifmt = args['eifmt'].value
122  else:
123  eifmt = 0 # noqa: F841
124  if "outputEIFile" in args:
125  outputEIFile = args['outputEIFile'].value[0]
126  else:
127  outputEIFile = None
128 
129  # ignore eifmt
130  # keep eifmt format flag for compatibility and future usage
131  if outputEIFile is not None:
132  oname_spb = outputEIFile
133  else:
134  oname_spb = "output.ei.spb"
135 
136  return oname_spb
137 
138 
139 if __name__ == '__main__':
140  main()
python.sendEI_SPB_Lib.eimrun
def eimrun(logger, opt)
Definition: sendEI_SPB_Lib.py:365
vtune_athena.format
format
Definition: vtune_athena.py:14
POOLtoEI_tf.main
def main()
Definition: POOLtoEI_tf.py:29
cycle
double cycle(double a, double b)
Definition: SiHitCollectionCnv_p2.cxx:38
python.EITransformUtils.addEI_Substep
def addEI_Substep(executorSet)
Definition: EITransformUtils.py:15
PyJobTransforms.trfArgClasses
Transform argument class definitions.
python.trfArgs.addAthenaArguments
def addAthenaArguments(parser, maxEventsDefaultSubstep='first', addValgrind=True, addPerfMon=True, addVTune=True)
Options related to running athena in general TODO: Some way to mask certain options (perExec,...
Definition: trfArgs.py:59
POOLtoEI_tf.getOutputNames
def getOutputNames(args)
Definition: POOLtoEI_tf.py:118
POOLtoEI_tf.getTransform
def getTransform()
Definition: POOLtoEI_tf.py:103
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
PyJobTransforms.trfLogger
Logging configuration for ATLAS job transforms.
PyJobTransforms.transform
Main package for new style ATLAS job transforms.
python.EITransformUtils.addEI_arguments
def addEI_arguments(parser)
Definition: EITransformUtils.py:9
Trk::split
@ split
Definition: LayerMaterialProperties.h:38