22 |
|
|
23 |
|
channels = [] |
24 |
|
processed_datasets = [] |
25 |
+ |
texfile = condor_dir + "/cutFlow.tex" |
26 |
|
|
27 |
|
replacements = { |
28 |
|
">":"$>$", |
34 |
|
"\\mu QCD":"\\mu$ $QCD", |
35 |
|
"EM QCD":"EM$ $QCD", |
36 |
|
"BCtoE QCD":"BCtoE$ $QCD", |
37 |
< |
|
38 |
< |
|
37 |
> |
|
38 |
> |
|
39 |
|
"Pt ":"pt ", |
40 |
|
"PT ":"pt ", |
41 |
|
"pT ":"pt ", |
46 |
|
"hT ":"HT ", |
47 |
|
"HT ":"$H_{T}$ ", |
48 |
|
"tig$H_{T}$ ":"tight ", |
49 |
< |
|
49 |
> |
|
50 |
|
"D0":"d0", |
51 |
|
"d0":"$d_{0}$", |
52 |
|
|
77 |
|
for dataset in datasets: |
78 |
|
fileName = condor_dir + "/" + dataset + ".root" |
79 |
|
if not os.path.exists(fileName): |
80 |
< |
print "Couldn't find output file for",dataset,"dataset" |
80 |
> |
#print "Couldn't find output file for",dataset,"dataset" |
81 |
|
continue |
82 |
|
testFile = TFile(fileName) |
83 |
|
if not (testFile.IsZombie()): |
84 |
|
processed_datasets.append(dataset) |
85 |
|
|
86 |
|
if len(processed_datasets) is 0: |
87 |
< |
sys.exit("No datasets have been processed") |
87 |
> |
sys.exit("Can't find any output root files for the given list of datasets") |
88 |
|
|
89 |
|
#### open first input file and re-make its directory structure in the output file |
90 |
|
testFile = TFile(condor_dir + "/" + processed_datasets[0] + ".root") |
99 |
|
continue |
100 |
|
channels.append(key2.GetName()) |
101 |
|
|
102 |
+ |
fout = open (texfile, "w") |
103 |
+ |
fout.write ("\\documentclass{article}\n\n") |
104 |
+ |
fout.write ("\\usepackage[landscape,margin=0.15cm]{geometry}\n\n") |
105 |
+ |
fout.write ("\\usepackage{multirow}\n\n") |
106 |
+ |
fout.write ("\\begin{document}\n\n") |
107 |
+ |
fout.write ("\\pagestyle{empty}\n\n") |
108 |
+ |
fout.close () |
109 |
+ |
|
110 |
+ |
firstChannel = True |
111 |
+ |
|
112 |
+ |
weight = intLumi / 10000.0 |
113 |
+ |
for dataset in processed_datasets: |
114 |
+ |
dataset_file = "%s/%s.root" % (condor_dir,dataset) |
115 |
+ |
os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", weight)) |
116 |
+ |
|
117 |
|
for channel in channels: # loop over final states, which each have their own directory |
118 |
< |
args = "" |
119 |
< |
hist = channel + "CutFlow" |
118 |
> |
fout = open (texfile, "a") |
119 |
> |
if not firstChannel: |
120 |
> |
fout.write ("\\pagebreak\n\n") |
121 |
> |
firstChannel = False |
122 |
> |
fout.write ("\\section{" + channel + " channel}\n\n") |
123 |
> |
fout.close () |
124 |
> |
|
125 |
> |
cutFlowArgs = "" |
126 |
> |
selectionArgs = "" |
127 |
> |
minusOneArgs = "" |
128 |
|
#print hist |
129 |
|
for dataset in processed_datasets: |
130 |
< |
dataset_file = "%s/%s.root" % (condor_dir,dataset) |
130 |
> |
dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) |
131 |
|
#print dataset_file |
132 |
< |
args = args + " " + dataset_file |
133 |
< |
args = args + " " + hist |
134 |
< |
|
132 |
> |
cutFlowArgs = cutFlowArgs + " " + dataset_file |
133 |
> |
selectionArgs = selectionArgs + " " + dataset_file |
134 |
> |
minusOneArgs = minusOneArgs + " " + dataset_file |
135 |
> |
cutFlowArgs = cutFlowArgs + " " + channel + "CutFlow" |
136 |
> |
selectionArgs = selectionArgs + " " + channel + "Selection" |
137 |
> |
minusOneArgs = minusOneArgs + " " + channel + "MinusOne" |
138 |
> |
|
139 |
|
rawlabel = "$" + labels[dataset] + "$" |
140 |
|
label = rawlabel.replace("#","\\") |
141 |
|
label = "'" + label + "'" |
142 |
|
#print label |
143 |
< |
args = args + " " + label |
143 |
> |
cutFlowArgs = cutFlowArgs + " " + label |
144 |
> |
selectionArgs = selectionArgs + " " + label |
145 |
> |
minusOneArgs = minusOneArgs + " " + label |
146 |
|
|
147 |
|
|
148 |
|
#make cutFlowTable objects |
149 |
< |
texfile = "%s/%s.tex" % (condor_dir,channel) |
150 |
< |
os.system("cutFlowTable %s > %s" % (args,texfile)) |
151 |
< |
#reformat tex files |
152 |
< |
for line in fileinput.FileInput(texfile,inplace=1): |
153 |
< |
for replacement in replacements.keys(): |
154 |
< |
line = line.replace(replacement,replacements[replacement]) |
155 |
< |
print line, |
156 |
< |
|
157 |
< |
for line in fileinput.FileInput(texfile,inplace=1): |
158 |
< |
for replacement in secondary_replacements.keys(): |
159 |
< |
line = line.replace(replacement,secondary_replacements[replacement]) |
160 |
< |
print line, |
161 |
< |
|
162 |
< |
#process tex files to make pdf files |
163 |
< |
command = "pdflatex -interaction=batchmode -output-directory=./%s %s > /dev/null" % (condor_dir,texfile) |
164 |
< |
os.system(command) |
165 |
< |
os.system(command) |
166 |
< |
#os.system("rm %s" % texfile) |
167 |
< |
os.system("rm %saux" % (texfile.rstrip("tex"))) |
168 |
< |
os.system("rm %slog" % (texfile.rstrip("tex"))) |
169 |
< |
|
149 |
> |
fout = open (texfile, "a") |
150 |
> |
fout.write ("\\subsection{Cut Flow}\n\n") |
151 |
> |
fout.close () |
152 |
> |
os.system("cutFlowTable -l %g %s >> %s" % (intLumi,cutFlowArgs,texfile)) |
153 |
> |
fout = open (texfile, "a") |
154 |
> |
fout.write ("\\pagebreak\n\n") |
155 |
> |
fout.write ("\\subsection{Individual Selection}\n\n") |
156 |
> |
fout.close () |
157 |
> |
os.system("cutFlowTable -l %g %s >> %s" % (intLumi,selectionArgs,texfile)) |
158 |
> |
fout = open (texfile, "a") |
159 |
> |
fout.write ("\\pagebreak\n\n") |
160 |
> |
fout.write ("\\subsection{Minus One}\n\n") |
161 |
> |
fout.close () |
162 |
> |
os.system("cutFlowTable -l %g %s >> %s" % (intLumi,minusOneArgs,texfile)) |
163 |
> |
|
164 |
> |
for dataset in processed_datasets: |
165 |
> |
dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset) |
166 |
> |
os.remove(dataset_file) |
167 |
> |
|
168 |
> |
#reformat tex files |
169 |
> |
for line in fileinput.FileInput(texfile,inplace=1): |
170 |
> |
for replacement in replacements.keys(): |
171 |
> |
line = line.replace(replacement,replacements[replacement]) |
172 |
> |
print line, |
173 |
> |
|
174 |
> |
for line in fileinput.FileInput(texfile,inplace=1): |
175 |
> |
for replacement in secondary_replacements.keys(): |
176 |
> |
line = line.replace(replacement,secondary_replacements[replacement]) |
177 |
> |
print line, |
178 |
> |
|
179 |
> |
fout = open (texfile, "a") |
180 |
> |
fout.write ("\\end{document}\n") |
181 |
> |
fout.close () |
182 |
> |
|
183 |
> |
#process tex files to make pdf files |
184 |
> |
command = "pdflatex -interaction=batchmode -output-directory=./%s %s > /dev/null" % (condor_dir,texfile) |
185 |
> |
os.system(command) |
186 |
> |
os.system(command) |
187 |
> |
#os.system("rm %s" % texfile) |
188 |
> |
os.system("rm %saux" % (texfile.rstrip("tex"))) |
189 |
> |
os.system("rm %slog" % (texfile.rstrip("tex"))) |