ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
python.recoTransforms.skimRawExecutor Class Reference

Executor for skimming RAW events according to a list of run and event numbers. More...

Inheritance diagram for python.recoTransforms.skimRawExecutor:
Collaboration diagram for python.recoTransforms.skimRawExecutor:

Public Member Functions

def preExecute (self, input=set(), output=set())
 

Private Attributes

 _cmd
 

Detailed Description

Executor for skimming RAW events according to a list of run and event numbers.

Definition at line 19 of file recoTransforms.py.

Member Function Documentation

◆ preExecute()

def python.recoTransforms.skimRawExecutor.preExecute (   self,
  input = set(),
  output = set() 
)

Definition at line 21 of file recoTransforms.py.

21  def preExecute(self, input = set(), output = set()):
22  # First we need to strip the filter file down to events that are present
23  # in the RAW file we are going to skim. This is because the HI workflow
24  # will provide millions of events in their filter file, more than acmd.py
25  # can cope with.
26  listEvtCommand = ['AtlListBSEvents', '-l']
27  listEvtCommand.extend(self.conf.argdict['inputBSFile'].value)
28  # For best lookup speed, we store the runnumber/eventnumber in a dictionary (set would also
29  # be fast)
30  rawEventList = {}
31  longlist = subprocess.check_output(listEvtCommand).decode('utf-8')
32  try:
33  for line in longlist.split("\n"):
34  if line.startswith("Index="):
35  try:
36  splitStrings = line.split(" ")
37  runprefix, runstr = splitStrings[1].split("=")
38  evtprefix, evtstr = splitStrings[2].split("=")
39  # Check sanity
40  if runprefix != "Run" or evtprefix != "Event":
41  msg.warning("Failed to understand this line from AtlListBSEvents (1): %s", line)
42  else:
43  runnumber = int(runstr) # noqa: F841
44  evtnumber = int(evtstr) # noqa: F841
45  # We build up a string key as "RUN-EVENT", so that we can take advantage of
46  # the fast hash search against a dictionary
47  rawEventList[runstr + "-" + evtstr] = True
48  msg.debug("Identified run %s, event %s in input RAW files", runstr, evtstr)
49  except ValueError:
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)
53  msg.error(errMsg)
54  raise trfExceptions.TransformExecutionException(trfExit.nameToCode("TRF_EXEC_SETUP_FAIL"), errMsg)
55  msg.info("Found %d events as skim candidates in RAW inputs", len(rawEventList))
56 
57  # Now open the list of filter events, and check through them
58  slimmedFilterFile = "slimmedFilterFile.{0}".format(os.getpid())
59  with open(slimmedFilterFile, "w") as slimFF, open(self.conf.argdict['filterFile'].value) as masterFF:
60  count = 0
61  for line in masterFF:
62  try:
63  runstr, evtstr = str(line).split()
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'))
67  count += 1
68  except ValueError as e:
69  msg.warning("Failed to understand this line from master filter file: %s %s", line, e)
70  if count == 0:
71  # If there are no matched events, create a bogus request for run and event 0 to keep
72  # AtlCopyBSEvent.exe CLI
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)
76 
77  # Build up the right command line for AtlCopyBSEvent
78 
79  events = ''
80  for line in open(slimmedFilterFile):
81  events += '%s,' % line.split()[-1]
82  events = events[:-1]
83 
84  self._cmd = ['AtlCopyBSEvent']
85 
86  self._cmd.extend(('-e', events))
87  self._cmd.extend(('-o', self.conf.argdict['outputBS_SKIMFile'].value[0]))
88  self._cmd.extend(self.conf.argdict['inputBSFile'].value)
89 
90  super(skimRawExecutor, self).preExecute()
91 

Member Data Documentation

◆ _cmd

python.recoTransforms.skimRawExecutor._cmd
private

Definition at line 84 of file recoTransforms.py.


The documentation for this class was generated from the following file:
AtlasMcWeight::decode
double decode(number_type binnedWeight)
Convert weight from unsigned to double.
Definition: AtlasMcWeight.cxx:32
vtune_athena.format
format
Definition: vtune_athena.py:14
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
Trk::open
@ open
Definition: BinningType.h:40
ActsTrk::detail::MakeDerivedVariant::extend
constexpr std::variant< Args..., T > extend(const std::variant< Args... > &, const T &)
Definition: MakeDerivedVariant.h:17
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38