3 from importlib
import import_module
7 ROOT.PyConfig.IgnoreCommandLineOptions =
True 9 if __name__ ==
"__main__":
10 from optparse
import OptionParser
11 parser = OptionParser(usage=
"%prog [options] outputDir inputFiles")
12 parser.add_option(
"-s",
"--postfix", dest=
"postfix", type=
"string", default=
None,
13 help=
"Postfix which will be appended to the file name (default: _Friend for friends, _Skim for skims)")
14 parser.add_option(
"-J",
"--json", dest=
"json", type=
"string",
15 default=
None, help=
"Select events using this JSON file")
16 parser.add_option(
"-c",
"--cut", dest=
"cut", type=
"string",
17 default=
None, help=
"Cut string")
18 parser.add_option(
"-b",
"--branch-selection", dest=
"branchsel",
19 type=
"string", default=
None, help=
"Branch selection")
20 parser.add_option(
"--bi",
"--branch-selection-input", dest=
"branchsel_in",
21 type=
"string", default=
None, help=
"Branch selection input")
22 parser.add_option(
"--bo",
"--branch-selection-output", dest=
"branchsel_out",
23 type=
"string", default=
None, help=
"Branch selection output")
24 parser.add_option(
"--friend", dest=
"friend", action=
"store_true", default=
False,
25 help=
"Produce friend trees in output (current default is to produce full trees)")
26 parser.add_option(
"--full", dest=
"friend", action=
"store_false", default=
False,
27 help=
"Produce full trees in output (this is the current default)")
28 parser.add_option(
"--noout", dest=
"noOut", action=
"store_true",
29 default=
False, help=
"Do not produce output, just run modules")
30 parser.add_option(
"-P",
"--prefetch", dest=
"prefetch", action=
"store_true", default=
False,
31 help=
"Prefetch input files locally instead of accessing them via xrootd")
32 parser.add_option(
"--long-term-cache", dest=
"longTermCache", action=
"store_true", default=
False,
33 help=
"Keep prefetched files across runs instead of deleting them at the end")
34 parser.add_option(
"-N",
"--max-entries", dest=
"maxEntries", type=
"long", default=
None,
35 help=
"Maximum number of entries to process from any single given input tree")
36 parser.add_option(
"--first-entry", dest=
"firstEntry", type=
"long", default=0,
37 help=
"First entry to process in the three (to be used together with --max-entries)")
38 parser.add_option(
"--justcount", dest=
"justcount", default=
False,
39 action=
"store_true", help=
"Just report the number of selected events")
40 parser.add_option(
"-I",
"--import", dest=
"imports", type=
"string", default=[], action=
"append",
41 nargs=2, help=
"Import modules (python package, comma-separated list of ")
42 parser.add_option(
"-z",
"--compression", dest=
"compression", type=
"string",
43 default=(
"LZMA:9"), help=
"Compression: none, or (algo):(level) ")
45 (options, args) = parser.parse_args()
48 if options.cut
or options.json:
50 "Can't apply JSON or cut selection when producing friends")
59 for mod, names
in options.imports:
61 obj = sys.modules[mod]
62 selnames = names.split(
",")
66 print(
"Loading %s from %s " % (name, mod))
67 if type(getattr(obj, name)) == list:
68 for mod
in getattr(obj, name):
71 modules.append(getattr(obj, name)())
75 "Running with --noout and no modules does nothing!")
76 if options.branchsel !=
None:
77 options.branchsel_in = options.branchsel
78 options.branchsel_out = options.branchsel
79 p = PostProcessor(outdir, args,
81 branchsel=options.branchsel_in,
83 compression=options.compression,
84 friend=options.friend,
85 postfix=options.postfix,
86 jsonInput=options.json,
88 justcount=options.justcount,
89 prefetch=options.prefetch,
90 longTermCache=options.longTermCache,
91 maxEntries=options.maxEntries,
92 firstEntry=options.firstEntry,
93 outputbranchsel=options.branchsel_out)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
T mod(const T &a, const T &b)