41 parser = ArgumentParser()
42 parser.add_argument(
'fname' , metavar=
'FILE')
43 parser.add_argument(
'-p',
'--partition', default=
'BPIX', help=
'Tracker partition (e.g. BPIX, FPIX, BPIXLYR1, etc.). Default: %(default)s')
44 parser.add_argument(
'-l',
'--list-content' , action=
'store_true', dest=
'list_content', help=
'List the contents of file and exit')
45 parser.add_argument(
'--list-branches', action=
'store_true', help=
'List the branches of the tree and exit')
46 parser.add_argument(
'-t',
'--type' , default=
'barycentre', choices=(
'barycentre',
'beamspot'), type=str.lower, help=
'Default: %(default)s')
47 parser.add_argument(
'--label' , default=
None, help=
'Additional label that is appended to the folder name (i.e. PixelBaryCentreAnalyzer by default)')
48 parser.add_argument(
'--quality' , action=
'store_true', help=
'Read results with the WithPixelQuality flag (default: %(default)s)')
49 parser.add_argument(
'-s',
'--style' , default=
'twiki', choices=(
'twiki',
'latex',
'csv'), type=str.lower, help=
'Table style for the output (default: %(default)s)')
50 parser.add_argument(
'--loglevel' , metavar=
'LEVEL', default=
'WARNING', help=
'Level for the python logging module. Can be either a mnemonic string like DEBUG, INFO or WARNING or an integer (lower means more verbose).')
52 args = parser.parse_args()
53 loglevel = args.loglevel.upper()
if not args.loglevel.isdigit()
else int(args.loglevel)
54 logging.basicConfig(format=
'%(levelname)s:%(module)s:%(funcName)s: %(message)s', level=loglevel)
55 logging.debug(
'args: %s', args)
58 folder =
'PixelBaryCentreAnalyzer' if not args.quality
else 'PixelBaryCentreAnalyzerWithPixelQuality' 59 tree_name =
'PixelBarycentre' if args.type ==
'barycentre' else 'BeamSpot' 60 if(args.label
is not None):
61 tree_name +=
'_'+args.label
62 columns = [
'run'] + [(args.partition
if args.type==
'barycentre' else 'BS')+
'.'+coord
for coord
in (
'x',
'y',
'z')]
64 with TFileContext(args.fname)
as tfile:
65 if(args.list_content):
69 tfolder = tfile.Get(folder)
71 raise KeyError(
'Folder "%s" not found in "%s"' %(folder, args.fname))
73 logging.debug(
'Opened folder "%s"', folder)
74 tree = tfolder.Get(tree_name)
76 logging.error(
'Tree "%s" not found; content of file "%s":', tree_name, args.fname)
78 raise KeyError(tree_name)
80 if(args.list_branches):
84 rdf = ROOT.RDataFrame(tree)
85 logging.info(
'Reading "%s"', tree_name)
86 results = rdf.AsNumpy(columns)
if(threadIdxLocalY==0 &&threadIdxLocalX==0)