ATLAS Offline Software
Loading...
Searching...
No Matches
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"""
7Run EventIndex on POOL file, produce EI file and send Events to brokers
8"""
9
10import sys
11import time
12from itertools import cycle
13
14# Setup core logging here
15from PyJobTransforms.trfLogger import msg
16
17from PyJobTransforms.transform import transform
18from PyJobTransforms.trfArgs import addAthenaArguments
19from PyJobTransforms.trfDecorators import stdTrfExceptionHandler
20from PyJobTransforms.trfDecorators import sigUsrStackTrace
21
22import PyJobTransforms.trfArgClasses as trfArgClasses
23
24msg.info('logging set in {}'.format(sys.argv[0]))
25
26
27@stdTrfExceptionHandler
28@sigUsrStackTrace
29def 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
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
139if __name__ == '__main__':
140 main()
double cycle(double a, double b)
STL class.
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
getOutputNames(args)
Main package for new style ATLAS job transforms.
Transform argument class definitions.
Logging configuration for ATLAS job transforms.