3 from argparse
import ArgumentParser
5 from pprint
import pprint
7 commentRE = re.compile (
r'#.*$')
9 if __name__ ==
"__main__":
10 parser = ArgumentParser()
11 parser.add_argument(
'--loadFromFile', dest=
'loadFromFile', default=[],
14 help=
"Name of text file containing filenames" )
15 parser.add_argument(
'--prefix', dest=
'prefix', type=str,
17 help=
"Prefix to add to files" )
18 parser.add_argument(
'--bx', dest=
'bx', type=int,
20 help=
"Bunch crossing to check (0 = in-time)" )
21 parser.add_argument(
"file", metavar=
"file.root", type=str, nargs=
'*')
22 options = parser.parse_args()
24 from DataFormats.FWLite
import Events, Handle
26 listOfFiles = options.file
27 for filename
in options.loadFromFile:
28 source = open (filename,
'r') 30 line = commentRE.sub (
'', line).
strip()
34 listOfFiles.append (line)
40 listOfFiles.append( options.prefix + name )
43 raise RuntimeError(
"You have not provided any files")
45 events = Events (listOfFiles)
47 handle = Handle(
'vector<PileupSummaryInfo>')
48 label = (
'addPileupInfo')
56 event.getByLabel (label, handle)
57 pileups = handle.product()
58 for pileup
in pileups:
59 if pileup.getBunchCrossing() == options.bx:
61 if pileup == pileups[-1]
and len(pileups)>1 :
62 raise RuntimeError(
"Requested BX not found in file")
64 num = pileup.getPU_NumInteractions()
66 if num
not in countDict:
71 print(
"total",
int(total),
"\ncounts:")
72 pprint (countDict, width=1)
76 for key, count
in countDict.items():
77 renormDict[key] = count / total
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)