1 |
ferencek |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
|
3 |
|
|
import sys, os, string, re, copy
|
4 |
|
|
from optparse import OptionParser
|
5 |
|
|
from ROOT import *
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
def main():
|
9 |
|
|
# usage description
|
10 |
|
|
usage = "Usage: getPileUpDistribution.py [options] \nExample: ./getPileUpDistribution.py -i PileUp_dist.root"
|
11 |
|
|
|
12 |
|
|
# input parameters
|
13 |
|
|
parser = OptionParser(usage=usage)
|
14 |
|
|
|
15 |
|
|
parser.add_option("-i", "--input_file", dest="input_file",
|
16 |
|
|
help="Input pile-up distribution file",
|
17 |
|
|
metavar="INPUT_FILE")
|
18 |
|
|
|
19 |
|
|
parser.add_option("-o", "--output_file", dest="output_file",
|
20 |
|
|
help="Output pile-up distribution file",
|
21 |
|
|
metavar="OUTPUT_FILE")
|
22 |
|
|
|
23 |
|
|
(options, args) = parser.parse_args()
|
24 |
|
|
|
25 |
|
|
# make sure all necessary input parameters are provided
|
26 |
|
|
if not options.input_file:
|
27 |
|
|
print usage
|
28 |
|
|
sys.exit()
|
29 |
|
|
|
30 |
|
|
file = TFile(options.input_file)
|
31 |
|
|
histo = file.Get('pileup')
|
32 |
|
|
bin_content = []
|
33 |
|
|
|
34 |
|
|
for i in range(1,histo.GetNbinsX()):
|
35 |
|
|
bin_content.append(histo.GetBinContent(i))
|
36 |
|
|
|
37 |
|
|
print bin_content
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
if __name__ == "__main__":
|
41 |
|
|
main()
|