ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
PyJobTransforms
share
postInclude.SortInput.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3
# Joboptions fragment that should be post-included after a typicaly configured Athena job
4
# It will read original input files, create a list of Events in memory, sort them and produce
5
# an intermediate Event Collection file that Athena will read instead of the original inputs
6
7
# Event information is read from EventInfoTags (stored by default in all Athena data files)
8
# The default sort key value (Lumi) can be oveerriden, as the sorting order
9
10
# The intermediate Collection file can be inspected using CollQuery cmdline utility
11
12
import
os
13
14
from
AthenaCommon.AppMgr
import
ServiceMgr
15
inputs = ServiceMgr.EventSelector.InputCollections
16
17
# set default sort parameters, read overrides from locals()
18
tmpCollFile = locals().
get
(
"AthenaInputSortCollName"
,
"sortedEventRefs"
+ str(os.getpid()) +
".root"
)
19
sortTag = locals().
get
(
"AthenaInputSortTag"
,
"LumiBlockN"
)
20
sortOrd = locals().
get
(
"AthenaInputSortOrder"
,
"Ascending"
)
21
22
from
CollectionSvc.SortedCollectionCreator
import
SortedCollectionCreator
23
sorter = SortedCollectionCreator(name=
"SortEvents"
)
24
# Sort Inputs based on one of the EventInfoTag attributes
25
# Store sorted event collection in a temporary file
26
# This should run as postInclude, so we assume EventSelector.InputCollections is set earlier
27
from
PyUtils
import
PoolFile
28
sorter.execute(inputs, outputCollection=tmpCollFile, outputCollectionType=PoolFile.PoolOpts.CollectionType.RootTTreeCollection, sortAttribute=sortTag, sortOrder=sortOrd)
29
30
# Reading Events through References require a populated FileCatalog
31
for
inpfile
in
inputs:
32
os.system(
'pool_insertFileToCatalog {}'
.format(inpfile))
33
34
ServiceMgr.PoolSvc.AttemptCatalogPatch =
False
35
36
# Tell Athena to use the sorted collection instead of the original inputs
37
ServiceMgr.EventSelector.InputCollections = [tmpCollFile]
38
ServiceMgr.EventSelector.CollectionType =
"RootCollection"
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition
hcg.cxx:132
Generated on
for ATLAS Offline Software by
1.17.0