ATLAS Offline Software
Loading...
Searching...
No Matches
EventPicking.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4
5'''
6@file EventPicking.py
7@author ATLAS Computing Activity
8@brief A thin wrapper around 'acmd filter-files' utility
9'''
10
11def main(args=None):
12 import PyUtils.acmdlib as acmdlib
13 import PyUtils.scripts # noqa: F401 (register all plugins)
14
15 cmd_name = 'filter-files'
16 cmd = acmdlib.Plugins.load(cmd_name)
17 if cmd is None:
18 return 2
19
20 # Parse user input
21 import argparse
22 parser = argparse.ArgumentParser(prog='EventPicking',
23 description='Select events identified by run number (mc channel number'
24 ' in case of Monte Carlo), event number from the input (POOL/BS) file(s).')
25 parser.add_argument('--inputFiles', required=True,
26 help='input (POOL/BS) file(s) separated with commas')
27 parser.add_argument('--outputFile', required=True,
28 help='output file')
29 parser.add_argument('--eventList', required=True,
30 help='text file containing <run number> <event number> [<guid>] record(s) (one per line)')
31 args, _ = parser.parse_known_args(args=args)
32
33 # Convert our arguments to arguments expected by 'acmd filter-files' utility
34 args.files = args.inputFiles.split(',')
35 args.output = args.outputFile
36
37 # Parse input file that contains run_number, event_number[, guid] combinations
38 evtList = []
39 with open(args.eventList) as f:
40 for line in f:
41 run, evt, *guid = line.rstrip().split()
42 evtList.append((int(run), int(evt)))
43 args.selection = repr(evtList)
44
45 del args.inputFiles, args.outputFile, args.eventList
46
47 return cmd.main(args)
48
49# Main executable
50if __name__ == "__main__":
51 import sys
52 sys.exit(main())
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
int main()
Definition hello.cxx:18