9 |
|
|
10 |
|
parser = OptionParser() |
11 |
|
parser = set_commandline_arguments(parser) |
12 |
+ |
(arguments, args) = parser.parse_args() |
13 |
|
|
14 |
< |
(options, args) = parser.parse_args() |
14 |
< |
|
15 |
< |
if options.localConfig: |
14 |
> |
if arguments.localConfig: |
15 |
|
sys.path.append(os.getcwd()) |
16 |
< |
exec("from " + options.localConfig.rstrip('.py') + " import *") |
16 |
> |
exec("from " + arguments.localConfig.rstrip('.py') + " import *") |
17 |
|
|
18 |
< |
condor_dir = set_condor_output_dir(options) |
18 |
> |
condor_dir = set_condor_output_dir(arguments) |
19 |
|
|
20 |
|
from ROOT import TFile, gROOT, gStyle, gDirectory, TKey |
21 |
|
|
26 |
|
replacements = { |
27 |
|
">":"$>$", |
28 |
|
"<":"$<$", |
29 |
< |
"eta ":"$\\eta$ ", |
29 |
> |
" eta ":" $\\eta$ ", |
30 |
> |
" abs(eta) ":" $|\\eta|$ ", |
31 |
|
"#":"Num", |
32 |
|
|
33 |
|
"\\rightarrow":"{\\rightarrow}", |
36 |
|
"BCtoE QCD":"BCtoE$ $QCD", |
37 |
|
|
38 |
|
|
39 |
< |
"Pt ":"pt ", |
40 |
< |
"PT ":"pt ", |
41 |
< |
"pT ":"pt ", |
42 |
< |
"pt ":"$p_{T}$ ", |
43 |
< |
|
44 |
< |
"Ht ":"HT ", |
45 |
< |
"ht ":"HT ", |
46 |
< |
"hT ":"HT ", |
47 |
< |
"HT ":"$H_{T}$ ", |
48 |
< |
"tig$H_{T}$ ":"tight ", |
39 |
> |
" pt ":" $p_{T}$ ", |
40 |
> |
" ht ":"$H_{T}$ ", |
41 |
|
|
50 |
– |
"D0":"d0", |
42 |
|
"d0":"$d_{0}$", |
43 |
|
|
44 |
< |
"MET ":"Met ", |
45 |
< |
"MEt ":"Met ", |
46 |
< |
"met ":"Met ", |
47 |
< |
"Met ":"$\\not\\!\\!{E}_{T}$ ", |
48 |
< |
|
49 |
< |
"MHT ":"Mht ", |
50 |
< |
"MHt ":"Mht ", |
51 |
< |
"mht ":"Mht ", |
52 |
< |
"Mht ":"$\\not\\!\\!{H}_{T}$ ", |
44 |
> |
" MET ":" Met ", |
45 |
> |
" MEt ":" Met ", |
46 |
> |
" met ":" Met ", |
47 |
> |
" Met ":"$\\not\\!\\!{E}_{T}$ ", |
48 |
> |
|
49 |
> |
" MHT ":" Mht ", |
50 |
> |
" MHt ":" Mht ", |
51 |
> |
" mht ":" Mht ", |
52 |
> |
" Mht ":"$\\not\\!\\!{H}_{T}$ ", |
53 |
|
|
54 |
|
"M_Z" : "$M_{Z}$", |
55 |
|
"M_mumu" : "$M_{\\mu\\mu}$", |
56 |
|
"M_ee" : "$M_{ee}$", |
57 |
|
"M_ll" : "$M_{ll}$", |
58 |
|
|
68 |
– |
"|" : "$|$" |
59 |
|
} |
60 |
|
|
61 |
|
secondary_replacements = { |
62 |
|
"$$<$":"$<" |
63 |
+ |
|
64 |
|
} |
65 |
|
|
66 |
|
|
68 |
|
for dataset in datasets: |
69 |
|
fileName = condor_dir + "/" + dataset + ".root" |
70 |
|
if not os.path.exists(fileName): |
71 |
< |
print "Couldn't find output file for",dataset,"dataset" |
71 |
> |
#print "Couldn't find output file for",dataset,"dataset" |
72 |
|
continue |
73 |
|
testFile = TFile(fileName) |
74 |
|
if not (testFile.IsZombie()): |
75 |
|
processed_datasets.append(dataset) |
76 |
|
|
77 |
|
if len(processed_datasets) is 0: |
78 |
< |
sys.exit("No datasets have been processed") |
78 |
> |
sys.exit("Can't find any output root files for the given list of datasets") |
79 |
|
|
80 |
|
#### open first input file and re-make its directory structure in the output file |
81 |
|
testFile = TFile(condor_dir + "/" + processed_datasets[0] + ".root") |
91 |
|
channels.append(key2.GetName()) |
92 |
|
|
93 |
|
fout = open (texfile, "w") |
94 |
< |
fout.write ("\\documentclass{article}\n\n") |
94 |
> |
fout.write ("\\documentclass[a2paper,8pt]{article}\n\n") |
95 |
|
fout.write ("\\usepackage[landscape,margin=0.15cm]{geometry}\n\n") |
96 |
|
fout.write ("\\usepackage{multirow}\n\n") |
97 |
|
fout.write ("\\begin{document}\n\n") |
100 |
|
|
101 |
|
firstChannel = True |
102 |
|
|
103 |
< |
for channel in channels: # loop over final states, which each have their own directory |
104 |
< |
fout = open (texfile, "a") |
105 |
< |
if not firstChannel: |
106 |
< |
fout.write ("\\pagebreak\n\n") |
107 |
< |
firstChannel = False |
108 |
< |
fout.write ("\\section{" + channel + " channel}\n\n") |
109 |
< |
fout.close () |
103 |
> |
weight = intLumi / 10000.0 |
104 |
> |
for dataset in processed_datasets: |
105 |
> |
dataset_file = "%s/%s.root" % (condor_dir,dataset) |
106 |
> |
fin = TFile (dataset_file) |
107 |
> |
flags = fin.Get ("flags") |
108 |
> |
noWeights = flags and flags.GetBinContent (1) |
109 |
> |
fin.Close () |
110 |
> |
if types[dataset] != "data" and not noWeights: |
111 |
> |
os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", weight)) |
112 |
> |
else: |
113 |
> |
os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", 1.0)) |
114 |
|
|
115 |
< |
args = "" |
116 |
< |
hist = channel + "CutFlow" |
115 |
> |
for channel in channels: # loop over final states, which each have their own directory |
116 |
> |
formatted_channel = channel.replace("_"," ") |
117 |
> |
cutFlowArgs = "" |
118 |
> |
selectionArgs = "" |
119 |
> |
minusOneArgs = "" |
120 |
|
#print hist |
121 |
|
for dataset in processed_datasets: |
122 |
< |
dataset_file = "%s/%s.root" % (condor_dir,dataset) |
122 |
> |
dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) |
123 |
|
#print dataset_file |
124 |
< |
args = args + " " + dataset_file |
125 |
< |
args = args + " " + hist |
124 |
> |
cutFlowArgs = cutFlowArgs + " " + dataset_file |
125 |
> |
selectionArgs = selectionArgs + " " + dataset_file |
126 |
> |
minusOneArgs = minusOneArgs + " " + dataset_file |
127 |
> |
cutFlowArgs = cutFlowArgs + " " + channel + "CutFlow" |
128 |
> |
selectionArgs = selectionArgs + " " + channel + "Selection" |
129 |
> |
minusOneArgs = minusOneArgs + " " + channel + "MinusOne" |
130 |
|
|
131 |
|
rawlabel = "$" + labels[dataset] + "$" |
132 |
|
label = rawlabel.replace("#","\\") |
133 |
|
label = "'" + label + "'" |
134 |
|
#print label |
135 |
< |
args = args + " " + label |
135 |
> |
cutFlowArgs = cutFlowArgs + " " + label |
136 |
> |
selectionArgs = selectionArgs + " " + label |
137 |
> |
minusOneArgs = minusOneArgs + " " + label |
138 |
|
|
139 |
|
|
140 |
|
#make cutFlowTable objects |
141 |
< |
os.system("cutFlowTable %s >> %s" % (args,texfile)) |
141 |
> |
fout = open (texfile, "a") |
142 |
> |
if not firstChannel: |
143 |
> |
fout.write ("\\pagebreak\n\n") |
144 |
> |
firstChannel = False |
145 |
> |
fout.write ("\\section*{" + formatted_channel + " channel}\n\n") |
146 |
> |
fout.write ("\\subsection*{Cut flow}\n\n") |
147 |
> |
fout.close () |
148 |
> |
os.system("cutFlowTable -l %g -m %s >> %s" % (intLumi,cutFlowArgs,texfile)) |
149 |
> |
fout = open (texfile, "a") |
150 |
> |
fout.write ("\\pagebreak\n\n") |
151 |
> |
fout.write ("\\section*{" + formatted_channel + " channel}\n\n") |
152 |
> |
fout.write ("\\subsection*{Individual selection}\n\n") |
153 |
> |
fout.close () |
154 |
> |
os.system("cutFlowTable -l %g %s >> %s" % (intLumi,selectionArgs,texfile)) |
155 |
> |
fout = open (texfile, "a") |
156 |
> |
fout.write ("\\pagebreak\n\n") |
157 |
> |
fout.write ("\\section*{" + formatted_channel + " channel}\n\n") |
158 |
> |
fout.write ("\\subsection*{Minus one}\n\n") |
159 |
> |
fout.close () |
160 |
> |
os.system("cutFlowTable -l %g %s >> %s" % (intLumi,minusOneArgs,texfile)) |
161 |
> |
|
162 |
> |
for dataset in processed_datasets: |
163 |
> |
dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) |
164 |
> |
os.remove(dataset_file) |
165 |
|
|
166 |
|
#reformat tex files |
167 |
|
for line in fileinput.FileInput(texfile,inplace=1): |