ATLAS Offline Software
Loading...
Searching...
No Matches
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
12import os
13
14from AthenaCommon.AppMgr import ServiceMgr
15inputs = ServiceMgr.EventSelector.InputCollections
16
17# set default sort parameters, read overrides from locals()
18tmpCollFile = locals().get("AthenaInputSortCollName", "sortedEventRefs" + str(os.getpid()) )
19sortTag = locals().get("AthenaInputSortTag", "LumiBlockN")
20sortOrd = locals().get("AthenaInputSortOrder", "Ascending")
21
22from CollectionSvc.SortedCollectionCreator import SortedCollectionCreator
23sorter = 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
27sorter.execute(inputs, outputCollection=tmpCollFile, sortAttribute=sortTag, sortOrder=sortOrd)
28
29# Reading Events through References require a populated FileCatalog
30for inpfile in inputs:
31 os.system('pool_insertFileToCatalog {}'.format(inpfile))
32
33# Tell Athena to use the sorted collection instead of the original inputs
34ServiceMgr.EventSelector.InputCollections = [tmpCollFile + ".root"]
35ServiceMgr.EventSelector.CollectionType = "RootCollection"
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130