3 from importlib
import import_module
7 ROOT.PyConfig.IgnoreCommandLineOptions =
True 9 if __name__ ==
"__main__":
10 from argparse
import ArgumentParser
11 parser = ArgumentParser()
12 parser.add_argument(
"-s",
"--postfix", dest=
"postfix", type=str, default=
None,
13 help=
"Postfix which will be appended to the file name (default: _Friend for friends, _Skim for skims)")
14 parser.add_argument(
"-J",
"--json", dest=
"json", type=str,
15 default=
None, help=
"Select events using this JSON file")
16 parser.add_argument(
"-c",
"--cut", dest=
"cut", type=str,
17 default=
None, help=
"Cut string")
18 parser.add_argument(
"-b",
"--branch-selection", dest=
"branchsel",
19 type=str, default=
None, help=
"Branch selection")
20 parser.add_argument(
"--bi",
"--branch-selection-input", dest=
"branchsel_in",
21 type=str, default=
None, help=
"Branch selection input")
22 parser.add_argument(
"--bo",
"--branch-selection-output", dest=
"branchsel_out",
23 type=str, default=
None, help=
"Branch selection output")
24 parser.add_argument(
"--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_argument(
"--full", dest=
"friend", action=
"store_false", default=
False,
27 help=
"Produce full trees in output (this is the current default)")
28 parser.add_argument(
"--noout", dest=
"noOut", action=
"store_true",
29 default=
False, help=
"Do not produce output, just run modules")
30 parser.add_argument(
"-P",
"--prefetch", dest=
"prefetch", action=
"store_true", default=
False,
31 help=
"Prefetch input files locally instead of accessing them via xrootd")
32 parser.add_argument(
"--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_argument(
"-N",
"--max-entries", dest=
"maxEntries", type=int, default=
None,
35 help=
"Maximum number of entries to process from any single given input tree")
36 parser.add_argument(
"--first-entry", dest=
"firstEntry", type=int, default=0,
37 help=
"First entry to process in the three (to be used together with --max-entries)")
38 parser.add_argument(
"--justcount", dest=
"justcount", default=
False,
39 action=
"store_true", help=
"Just report the number of selected events")
40 parser.add_argument(
"-I",
"--import", dest=
"imports", type=str, default=[], action=
"append",
41 nargs=2, help=
"Import modules (python package, comma-separated list of ")
42 parser.add_argument(
"-z",
"--compression", dest=
"compression", type=str,
43 default=(
"LZMA:9"), help=
"Compression: none, or (algo):(level) ")
44 parser.add_argument(
"outputDir", type=str)
45 parser.add_argument(
"inputFile", type=str, nargs=
'+')
46 options = parser.parse_args()
49 if options.cut
or options.json:
51 "Can't apply JSON or cut selection when producing friends")
54 for mod, names
in options.imports:
56 obj = sys.modules[mod]
57 selnames = names.split(
",")
61 print(
"Loading %s from %s " % (name, mod))
62 if type(getattr(obj, name)) == list:
63 for mod
in getattr(obj, name):
66 modules.append(getattr(obj, name)())
70 "Running with --noout and no modules does nothing!")
71 if options.branchsel !=
None:
72 options.branchsel_in = options.branchsel
73 options.branchsel_out = options.branchsel
74 p = PostProcessor(options.outputDir, options.inputFile,
76 branchsel=options.branchsel_in,
78 compression=options.compression,
79 friend=options.friend,
80 postfix=options.postfix,
81 jsonInput=options.json,
83 justcount=options.justcount,
84 prefetch=options.prefetch,
85 longTermCache=options.longTermCache,
86 maxEntries=options.maxEntries,
87 firstEntry=options.firstEntry,
88 outputbranchsel=options.branchsel_out)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
T mod(const T &a, const T &b)