45 """read all input collections into memory"""
46 from PyUtils
import PoolFile
51 for inFileName
in inputCollections:
52 self.
debug(
"Opening {}".format(inFileName))
53 iColl = self.
collSvc.open(
"Input", PoolFile.PoolOpts.CollectionType.RootCollection, inFileName)
54 self.
debug(
"{} opened".format(inFileName))
57 self.
info(
"Reading Events from {}".format(inFileName))
59 cursor = iColl.cursor()
62 row = cursor.currentRow()
64 t = [ row.token().toString() ]
66 t.append( row.attributeList()[nam].data[ self.
attrTypes[nam] ]() )
74 self.
info(
"Finished reading input collections, total events read: {}".format(len(self.
allRows)) )
88 """write sorted collection into a Collection file"""
89 self.
info(
"Writing Event collection {}".format(outputCollection))
95 row = self.
pool.CollectionRowBuffer()
96 dstColl.initNewRow( row )
98 row.token().fromString( t[0] )
101 row.attributeList()[nam].setValue[type]( t[idx+1] )
102 dstColl.insertRow( row )
107 def execute(self, inputCollections, outputCollection, outputCollectionType, sortAttribute="LumiBlockN",
108 sortOrder="Ascending"):
109 sort_opts = (
"Ascending",
"Descending")
110 self.
info(
"Executing SortedCollectionCreator, inputs={}, output='{}' ({}), sort by: {}, order: {}"
111 .format(inputCollections, outputCollection, outputCollectionType, sortAttribute, sortOrder))
112 if isinstance(inputCollections, str):
113 inputs = [inputCollections]
115 inputs = inputCollections
116 if sortOrder.lower()
not in [opt.lower()
for opt
in sort_opts]:
117 raise Exception(self.
name +
": Accepted sortOrder values are: " + str(sort_opts))
118 sortReverse = ( sortOrder.lower()[0] ==
"d" )