122def SortInput(flags, cfg):
123 """Method that should be post-included after a typicaly configured Athena job
124 It will read original input files, create a list of Events in memory, sort them and produce
125 an intermediate Event Collection file that Athena will read instead of the original inputs
126 Event information is read from EventInfoTags (stored by default in all Athena data files)
127 The default sort key value (Lumi) can be oveerriden, as the sorting order
128 The intermediate Collection file can be inspected using CollQuery cmdline utility"""
129 import os
130 inputs = cfg.getService("EventSelector").InputCollections
131
132
133 tmpCollFile = locals().
get(
"AthenaInputSortCollName",
"sortedEventRefs" + str(os.getpid()) +
".root")
134 sortTag = locals().
get(
"AthenaInputSortTag",
"LumiBlockN")
135 sortOrd = locals().
get(
"AthenaInputSortOrder",
"Ascending")
136
137 from CollectionSvc.SortedCollectionCreator import SortedCollectionCreator
138 sorter = SortedCollectionCreator(name="SortEvents")
139
140
141
142
143
144
145 from PyUtils import PoolFile
146 rc = sorter.executeInSubprocess(inputs, outputCollection=tmpCollFile, outputCollectionType=PoolFile.PoolOpts.CollectionType.RootTTreeCollection, sortAttribute=sortTag, sortOrder=sortOrd)
147 if rc != 0:
148 msg.error(f"Sorting failed with exit code: {rc}")
149
150
151 for inpfile in inputs:
152 os.system('pool_insertFileToCatalog {}'.format(inpfile))
153
154 cfg.getService("PoolSvc").AttemptCatalogPatch = False
155
156
157 cfg.getService("EventSelector").InputCollections = [tmpCollFile]
158 cfg.getService("EventSelector").CollectionType = "RootCollection"
159 return cfg
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)