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