10 msg = logging.getLogger(__name__)
12 import PyJobTransforms.trfExceptions
as trfExceptions
26 listEvtCommand = [
'AtlListBSEvents',
'-l']
27 listEvtCommand.extend(self.conf.argdict[
'inputBSFile'].value)
32 for line
in subprocess.check_output(listEvtCommand).
split(
"\n"):
33 if line.startswith(
"Index="):
35 splitStrings = line.split(
" ")
36 runprefix, runstr = splitStrings[1].
split(
"=")
37 evtprefix, evtstr = splitStrings[2].
split(
"=")
39 if runprefix !=
"Run" or evtprefix !=
"Event":
40 msg.warning(
"Failed to understand this line from AtlListBSEvents: %s", line)
42 runnumber =
int(runstr)
43 evtnumber =
int(evtstr)
46 rawEventList[runstr +
"-" + evtstr] =
True
47 msg.debug(
"Identified run %s, event %s in input RAW files", runstr, evtstr)
49 msg.warning(
"Failed to understand this line from AtlListBSEvents: %s", line)
50 except subprocess.CalledProcessError
as e:
51 errMsg =
"Call to AtlListBSEvents failed: {0}".
format(e)
54 msg.info(
"Found %d events as skim candidates in RAW inputs", len(rawEventList))
57 slimmedFilterFile =
"slimmedFilterFile.{0}".
format(os.getpid())
58 with open(slimmedFilterFile,
"w")
as slimFF,
open(self.conf.argdict[
'filterFile'].value)
as masterFF:
62 runstr, evtstr = line.split()
63 if runstr +
"-" + evtstr
in rawEventList:
64 msg.debug(
"Found run %s, event %s in master filter list", runstr, evtstr)
65 os.write(slimFF.fileno(), line)
67 except ValueError
as e:
68 msg.warning(
"Failed to understand this line from master filter file: %s %s", line, e)
72 msg.info(
"No events matched in this input file - empty RAW file output will be made")
73 os.write(slimFF.fileno(),
"0 0\n")
74 msg.info(
"Matched %d lines from the master filter file against input events; wrote these to %s", count, slimmedFilterFile)
77 self.
_cmd = [
'acmd.py',
'filter-files']
79 self.
_cmd.
extend((
'-o', self.conf.argdict[
'outputBS_SKIMFile'].value[0]))
81 self.
_cmd.
extend(self.conf.argdict[
'inputBSFile'].value)