ATLAS Offline Software
Loading...
Searching...
No Matches
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 reference 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 (LumiBlockN) can be overridden. The sorting order is ascending.
9
10import os
11
12from AthenaCommon.AppMgr import ServiceMgr
13inputs = ServiceMgr.EventSelector.InputCollections
14
15# set default sort parameters, read overrides from locals()
16tmpCollFile = locals().get("AthenaInputSortCollName", "sortedEventRefs" + str(os.getpid()) + ".root")
17sortTag = locals().get("AthenaInputSortTag", "LumiBlockN")
18
19from OutputStreamAthenaPool.SortedInputFileCreator import SortedInputFileCreator
20sorter = SortedInputFileCreator()
21# Sort Inputs based on one of the EventInfoTag attributes
22# Store sorted event references in a temporary file
23# This should run as postInclude, so we assume EventSelector.InputCollections is set earlier
24sorter.execute(inputs, outputFile=tmpCollFile, sortAttribute=sortTag)
25
26# Reading Events through References require a populated FileCatalog
27for inpfile in inputs:
28 os.system('pool_insertFileToCatalog {}'.format(inpfile))
29
30ServiceMgr.PoolSvc.AttemptCatalogPatch = False
31
32# Tell Athena to use the sorted collection instead of the original inputs
33ServiceMgr.EventSelector.InputCollections = [tmpCollFile]
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132