ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
EventIndex
EventGUIDLookup
python
EventGUIDLookup_Skeleton.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
"""EventGUIDLookup_Skeleton.py"""
4
5
import
sys
6
from
AthenaConfiguration.AllConfigFlags
import
initConfigFlags
7
from
AthenaConfiguration.MainServicesConfig
import
MainServicesCfg
8
from
AthenaCommon.Logging
import
logging
9
10
msglog = logging.getLogger(
'EventGUIDLookup_Skeleton'
)
11
12
13
def
_getRunArg
(runArgs, base):
14
attrs = vars(runArgs)
15
candidates = [a
for
a
in
attrs
if
a == base
or
a.startswith(base)]
16
if
not
candidates:
17
raise
AttributeError(
'No runArgs attribute starting with %r (have: %s)'
18
% (base, sorted(attrs.keys())))
19
candidates.sort(key=
lambda
a: (a != base, len(a)))
20
return
getattr(runArgs, candidates[0])
21
22
23
def
_unwrap
(a):
24
if
hasattr(a,
'value'
):
25
a = a.value
26
return
a
if
isinstance(a, list)
else
[a]
27
28
29
def
_loadEventList
(path):
30
requested =
set
()
31
with
open(path)
as
fh:
32
for
lineNo, line
in
enumerate(fh, 1):
33
line = line.strip()
34
if
not
line
or
line.startswith(
'#'
):
35
continue
36
fields = line.split()
37
if
len(fields) < 2:
38
msglog.warning(
'Ignoring malformed line %d in %s: %r'
,
39
lineNo, path, line)
40
continue
41
requested.add((int(fields[0]), int(fields[1])))
42
return
requested
43
44
45
def
fromRunArgs
(runArgs):
46
msglog.info(
'***************** STARTING EventGUIDLookup *****************'
)
47
48
dataType = runArgs.dataType
49
inputDataType = runArgs.inputDataType
50
eventListPath = runArgs.eventList
51
inputFiles = [str(f)
for
f
in
_unwrap
(
_getRunArg
(runArgs,
'inputFile'
))]
52
outputPath =
_unwrap
(
_getRunArg
(runArgs,
'outputTXTFile'
))[0]
53
54
requested =
_loadEventList
(eventListPath)
55
msglog.info(
'Loaded %d requested (run,event) pairs'
, len(requested))
56
57
flags = initConfigFlags()
58
flags.Input.Files = inputFiles
59
flags.Exec.MaxEvents = -1
60
flags.Concurrency.NumThreads = 1
61
flags.lock()
62
63
cfg = MainServicesCfg(flags)
64
65
from
AthenaPoolCnvSvc.PoolReadConfig
import
PoolReadCfg
66
cfg.merge(PoolReadCfg(flags))
67
# (xAODEventInfoCnvAlgDefault import removed -- not needed, and not
68
# verified to exist at that path anyway)
69
70
from
EventGUIDLookup.EventGUIDLookupAlgConfig
import
EventGUIDLookupAlgCfg
71
cfg.merge(EventGUIDLookupAlgCfg(flags, dataType=dataType,
72
inputDataType=inputDataType,
73
requestedEvents=requested,
74
outputFile=outputPath))
75
76
sc = cfg.run()
77
sys.exit(0
if
sc.isSuccess()
else
1)
set
STL class.
EventGUIDLookup_Skeleton.fromRunArgs
fromRunArgs(runArgs)
Definition
EventGUIDLookup_Skeleton.py:45
EventGUIDLookup_Skeleton._getRunArg
_getRunArg(runArgs, base)
Definition
EventGUIDLookup_Skeleton.py:13
EventGUIDLookup_Skeleton._loadEventList
_loadEventList(path)
Definition
EventGUIDLookup_Skeleton.py:29
EventGUIDLookup_Skeleton._unwrap
_unwrap(a)
Definition
EventGUIDLookup_Skeleton.py:23
Generated on
for ATLAS Offline Software by
1.17.0