ATLAS Offline Software
postInclude.SortInput.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 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()) )
19 sortTag = locals().get("AthenaInputSortTag", "LumiBlockN")
20 sortOrd = locals().get("AthenaInputSortOrder", "Ascending")
21 
22 from CollectionUtilities.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 sorter.execute(inputs, outputCollection=tmpCollFile, sortAttribute=sortTag, sortOrder=sortOrd)
28 
29 # Reading Events through References require a populated FileCatalog
30 for inpfile in inputs:
31  os.system('pool_insertFileToCatalog {}'.format(inpfile))
32 
33 # Tell Athena to use the sorted collection instead of the original inputs
34 ServiceMgr.EventSelector.InputCollections = [tmpCollFile + ".root"]
35 ServiceMgr.EventSelector.CollectionType = "ExplicitROOT"
vtune_athena.format
format
Definition: vtune_athena.py:14
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
str
Definition: BTagTrackIpAccessor.cxx:11