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