1 |
lantonel |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
import os
|
3 |
|
|
import sys
|
4 |
lantonel |
1.8 |
from optparse import OptionParser
|
5 |
lantonel |
1.1 |
|
6 |
lantonel |
1.2 |
from OSUT3Analysis.Configuration.configurationOptions import *
|
7 |
|
|
from OSUT3Analysis.Configuration.processingUtilities import *
|
8 |
lantonel |
1.1 |
|
9 |
ahart |
1.9 |
from ROOT import TFile, TH1D
|
10 |
|
|
|
11 |
lantonel |
1.8 |
parser = OptionParser()
|
12 |
lantonel |
1.1 |
parser = set_commandline_arguments(parser)
|
13 |
lantonel |
1.8 |
(arguments, args) = parser.parse_args()
|
14 |
lantonel |
1.1 |
|
15 |
lantonel |
1.7 |
if arguments.localConfig:
|
16 |
lantonel |
1.1 |
sys.path.append(os.getcwd())
|
17 |
lantonel |
1.7 |
exec("from " + arguments.localConfig.rstrip('.py') + " import *")
|
18 |
lantonel |
1.1 |
|
19 |
lantonel |
1.7 |
condor_dir = set_condor_output_dir(arguments)
|
20 |
lantonel |
1.1 |
|
21 |
|
|
#save a list of composite datasets
|
22 |
|
|
composite_datasets = get_composite_datasets(datasets)
|
23 |
|
|
#save a list of datasets with composite datasets split up
|
24 |
|
|
split_datasets = split_composite_datasets(datasets)
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
#merge first layer
|
28 |
ahart |
1.9 |
flags = TH1D ("flags", "", 1, 0, 1)
|
29 |
|
|
flags.GetXaxis ().SetBinLabel (1, "noWeights")
|
30 |
|
|
if arguments.noWeights:
|
31 |
|
|
flags.SetBinContent (1, 1)
|
32 |
|
|
|
33 |
lantonel |
1.1 |
for dataset in split_datasets:
|
34 |
|
|
dataset_dir = "%s/%s" % (condor_dir,dataset)
|
35 |
ahart |
1.9 |
if arguments.noWeights:
|
36 |
|
|
command = "mergeHists -w 1 -p %s %s" % (dataset_dir, dataset_dir)
|
37 |
|
|
else:
|
38 |
ahart |
1.13 |
command = "mergeHists -l %g -p %s %s" % (intLumi, dataset_dir, dataset_dir)
|
39 |
lantonel |
1.1 |
print "Merging output for",dataset, "dataset"
|
40 |
|
|
#print command
|
41 |
|
|
os.system(command)
|
42 |
ahart |
1.9 |
fout = TFile (dataset_dir + ".root", "update")
|
43 |
|
|
fout.cd ()
|
44 |
|
|
flags.Write ()
|
45 |
|
|
fout.Close
|
46 |
lantonel |
1.1 |
|
47 |
|
|
#merge together components of composite datasets
|
48 |
|
|
for composite_dataset in composite_datasets:
|
49 |
|
|
component_datasets_list = ""
|
50 |
|
|
component_dataset_file_path = ""
|
51 |
|
|
composite_dataset_dir = "%s/%s" % (condor_dir,composite_dataset)
|
52 |
|
|
for component_dataset in composite_dataset_definitions[composite_dataset]:
|
53 |
|
|
component_dataset_dir = "%s/%s" % (condor_dir,component_dataset)
|
54 |
|
|
component_dataset_file_path = component_dataset_dir + ".root"
|
55 |
|
|
if os.path.isfile(component_dataset_file_path):
|
56 |
|
|
component_datasets_list = component_datasets_list + " " + component_dataset_file_path
|
57 |
|
|
command = "mergeHists -p %s %s" % (composite_dataset_dir, component_datasets_list)
|
58 |
|
|
print "Merging component datasets for",composite_dataset, "dataset"
|
59 |
|
|
#print command
|
60 |
|
|
os.system(command)
|
61 |
ahart |
1.9 |
fout = TFile (dataset_dir + ".root", "update")
|
62 |
|
|
fout.cd ()
|
63 |
|
|
flags.Write ()
|
64 |
|
|
fout.Close
|
65 |
lantonel |
1.1 |
|
66 |
|
|
#recreate plots file with all datasets combined and in pretty colors
|
67 |
|
|
args = "-c %s" % condor_dir.partition('/')[2]
|
68 |
lantonel |
1.7 |
|
69 |
|
|
#pass all the options on to the plot and cutflow making scripts
|
70 |
|
|
if arguments.localConfig:
|
71 |
|
|
args = args + " -l " + arguments.localConfig
|
72 |
|
|
if arguments.normalizeToData:
|
73 |
lantonel |
1.4 |
args = args + " -n "
|
74 |
lantonel |
1.7 |
if arguments.normalizeToUnitArea:
|
75 |
lantonel |
1.5 |
args = args + " -u "
|
76 |
lantonel |
1.7 |
if arguments.noStack:
|
77 |
lantonel |
1.5 |
args = args + " -e "
|
78 |
lantonel |
1.7 |
if arguments.makeRatioPlots:
|
79 |
lantonel |
1.6 |
args = args + " -r "
|
80 |
lantonel |
1.11 |
if arguments.draw2DPlots:
|
81 |
|
|
args = args + " --2D "
|
82 |
lantonel |
1.7 |
if arguments.outputFileName:
|
83 |
|
|
args = args + " -o " + arguments.outputFileName
|
84 |
lantonel |
1.12 |
if arguments.rebinFactor:
|
85 |
|
|
args = args + " -b " + arguments.rebinFactor
|
86 |
lantonel |
1.5 |
|
87 |
lantonel |
1.1 |
print "running makePlots.py"
|
88 |
|
|
os.system("makePlots.py %s" % args)
|
89 |
|
|
print "running makeCutFlows.py"
|
90 |
|
|
os.system("makeCutFlows.py %s" % args)
|