10 msg = logging.getLogger(__name__)
12 import PyJobTransforms.trfExceptions
as trfExceptions
26 listEvtCommand = [
'AtlListBSEvents',
'-l']
27 listEvtCommand.extend(self.conf.argdict[
'inputBSFile'].value)
31 longlist = subprocess.check_output(listEvtCommand).
decode(
'utf-8')
33 for line
in longlist.split(
"\n"):
34 if line.startswith(
"Index="):
36 splitStrings = line.split(
" ")
37 runprefix, runstr = splitStrings[1].
split(
"=")
38 evtprefix, evtstr = splitStrings[2].
split(
"=")
40 if runprefix !=
"Run" or evtprefix !=
"Event":
41 msg.warning(
"Failed to understand this line from AtlListBSEvents (1): %s", line)
43 runnumber =
int(runstr)
44 evtnumber =
int(evtstr)
47 rawEventList[runstr +
"-" + evtstr] =
True
48 msg.debug(
"Identified run %s, event %s in input RAW files", runstr, evtstr)
50 msg.warning(
"Failed to understand this line from AtlListBSEvents (2): %s", line)
51 except subprocess.CalledProcessError
as e:
52 errMsg =
"Call to AtlListBSEvents failed: {0}".
format(e)
55 msg.info(
"Found %d events as skim candidates in RAW inputs", len(rawEventList))
58 slimmedFilterFile =
"slimmedFilterFile.{0}".
format(os.getpid())
59 with open(slimmedFilterFile,
"w")
as slimFF,
open(self.conf.argdict[
'filterFile'].value)
as masterFF:
64 if runstr +
"-" + evtstr
in rawEventList:
65 msg.debug(
"Found run %s, event %s in master filter list", runstr, evtstr)
66 os.write(slimFF.fileno(), line.encode(
'utf-8'))
68 except ValueError
as e:
69 msg.warning(
"Failed to understand this line from master filter file: %s %s", line, e)
73 msg.info(
"No events matched in this input file - empty RAW file output will be made")
74 os.write(slimFF.fileno(), b
"0 0\n")
75 msg.info(
"Matched %d lines from the master filter file against input events; wrote these to %s", count, slimmedFilterFile)
80 for line
in open(slimmedFilterFile):
81 events +=
'%s,' % line.split()[-1]
84 self.
_cmd = [
'AtlCopyBSEvent']
87 self.
_cmd.
extend((
'-o', self.conf.argdict[
'outputBS_SKIMFile'].value[0]))
88 self.
_cmd.
extend(self.conf.argdict[
'inputBSFile'].value)