167 def writefilelist_hippy(self, firstrun, lastrun, runs, eventsperjob, maxevents, outputfile, usecache=True):
168 runrange =
RunRange(firstrun=firstrun, lastrun=lastrun, runs=runs)
169 if maxevents < 0: maxevents =
float(
"inf")
170 totalevents = sum(datafile.nevents
for datafile
in self.
getfiles(usecache)
if all(run
in runrange
for run
in datafile.runs))
172 raise ValueError(
"No events within the run range!")
173 accepted = rejected = inthisjob = 0.
175 fractiontoaccept = 1.*maxevents / totalevents
178 with open(outputfile,
"w")
as f:
179 for datafile
in self.
getfiles(usecache):
180 if all(run
in runrange
for run
in datafile.runs):
181 if accepted == 0
or accepted / (accepted+rejected) <= fractiontoaccept:
182 if writecomma: f.write(
",")
183 f.write(
"'" + datafile.filename +
"'")
184 accepted += datafile.nevents
185 inthisjob += datafile.nevents
186 if inthisjob >= eventsperjob:
193 rejected += datafile.nevents
194 elif any(run
in runrange
for run
in datafile.runs):
195 raise DatasetError(
"file {} has multiple runs {}, which straddle firstrun or lastrun".
format(datafile.filename, datafile.runs))
bool any(const std::vector< T > &v, const T &what)
def getfiles(self, usecache)
def writefilelist_hippy(self, firstrun, lastrun, runs, eventsperjob, maxevents, outputfile, usecache=True)