1 |
lantonel |
1.1 |
#!/usr/bin/env python
|
2 |
|
|
import sys
|
3 |
|
|
import os
|
4 |
|
|
import fileinput
|
5 |
|
|
from array import *
|
6 |
|
|
from optparse import OptionParser
|
7 |
|
|
from DisplacedSUSY.Configuration.configurationOptions import *
|
8 |
|
|
from DisplacedSUSY.Configuration.processingUtilities import *
|
9 |
|
|
|
10 |
|
|
parser = OptionParser()
|
11 |
|
|
parser = set_commandline_arguments(parser)
|
12 |
|
|
|
13 |
|
|
(options, args) = parser.parse_args()
|
14 |
|
|
|
15 |
|
|
if options.localConfig:
|
16 |
|
|
sys.path.append(os.getcwd())
|
17 |
|
|
exec("from " + options.localConfig.rstrip('.py') + " import *")
|
18 |
|
|
|
19 |
|
|
condor_dir = set_condor_output_dir(options)
|
20 |
|
|
|
21 |
|
|
from ROOT import TFile, gROOT, gStyle, gDirectory, TKey
|
22 |
|
|
|
23 |
|
|
channels = []
|
24 |
|
|
processed_datasets = []
|
25 |
|
|
|
26 |
|
|
replacements = {
|
27 |
|
|
">":"$>$",
|
28 |
|
|
"<":"$<$",
|
29 |
|
|
"eta ":"$\\eta$ ",
|
30 |
|
|
"#":"Num",
|
31 |
|
|
|
32 |
|
|
"\\rightarrow":"{\\rightarrow}",
|
33 |
|
|
"\\mu QCD":"\\mu$ $QCD",
|
34 |
|
|
"EM QCD":"EM$ $QCD",
|
35 |
|
|
"BCtoE QCD":"BCtoE$ $QCD",
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
"Pt ":"pt ",
|
39 |
|
|
"PT ":"pt ",
|
40 |
|
|
"pT ":"pt ",
|
41 |
|
|
"pt ":"$p_{T}$ ",
|
42 |
|
|
|
43 |
|
|
"Ht ":"HT ",
|
44 |
|
|
"ht ":"HT ",
|
45 |
|
|
"hT ":"HT ",
|
46 |
|
|
"HT ":"$H_{T}$ ",
|
47 |
|
|
"tig$H_{T}$ ":"tight ",
|
48 |
|
|
|
49 |
|
|
"D0":"d0",
|
50 |
|
|
"d0":"$d_{0}$",
|
51 |
|
|
|
52 |
|
|
"MET ":"Met ",
|
53 |
|
|
"MEt ":"Met ",
|
54 |
|
|
"met ":"Met ",
|
55 |
|
|
"Met ":"$\\not\\!\\!{E}_{T}$ ",
|
56 |
|
|
|
57 |
|
|
"MHT ":"Mht ",
|
58 |
|
|
"MHt ":"Mht ",
|
59 |
|
|
"mht ":"Mht ",
|
60 |
|
|
"Mht ":"$\\not\\!\\!{H}_{T}$ ",
|
61 |
|
|
|
62 |
|
|
"M_Z" : "$M_{Z}$",
|
63 |
|
|
"M_mumu" : "$M_{\\mu\\mu}$",
|
64 |
|
|
"M_ee" : "$M_{ee}$",
|
65 |
|
|
"M_ll" : "$M_{ll}$",
|
66 |
|
|
|
67 |
|
|
"|" : "$|$"
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
secondary_replacements = {
|
71 |
|
|
"$$<$":"$<"
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
#### check which input datasets have valid output files
|
76 |
|
|
for dataset in datasets:
|
77 |
|
|
fileName = condor_dir + "/" + dataset + ".root"
|
78 |
|
|
if not os.path.exists(fileName):
|
79 |
|
|
print "Couldn't find output file for",dataset,"dataset"
|
80 |
|
|
continue
|
81 |
|
|
testFile = TFile(fileName)
|
82 |
|
|
if not (testFile.IsZombie()):
|
83 |
|
|
processed_datasets.append(dataset)
|
84 |
|
|
|
85 |
|
|
if len(processed_datasets) is 0:
|
86 |
|
|
sys.exit("No datasets have been processed")
|
87 |
|
|
|
88 |
|
|
#### open first input file and re-make its directory structure in the output file
|
89 |
|
|
testFile = TFile(condor_dir + "/" + processed_datasets[0] + ".root")
|
90 |
|
|
testFile.cd()
|
91 |
|
|
for key in testFile.GetListOfKeys():
|
92 |
|
|
if (key.GetClassName() != "TDirectoryFile"):
|
93 |
|
|
continue
|
94 |
|
|
rootDirectory = key.GetName()
|
95 |
|
|
testFile.cd(key.GetName())
|
96 |
|
|
for key2 in gDirectory.GetListOfKeys():
|
97 |
|
|
if (key2.GetClassName() != "TDirectoryFile"):
|
98 |
|
|
continue
|
99 |
|
|
channels.append(key2.GetName())
|
100 |
|
|
|
101 |
|
|
for channel in channels: # loop over final states, which each have their own directory
|
102 |
|
|
args = ""
|
103 |
|
|
hist = channel + "CutFlow"
|
104 |
|
|
#print hist
|
105 |
|
|
for dataset in processed_datasets:
|
106 |
|
|
dataset_file = "%s/%s.root" % (condor_dir,dataset)
|
107 |
|
|
#print dataset_file
|
108 |
|
|
args = args + " " + dataset_file
|
109 |
|
|
args = args + " " + hist
|
110 |
|
|
|
111 |
|
|
rawlabel = "$" + labels[dataset] + "$"
|
112 |
|
|
label = rawlabel.replace("#","\\")
|
113 |
|
|
label = "'" + label + "'"
|
114 |
|
|
#print label
|
115 |
|
|
args = args + " " + label
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
#make cutFlowTable objects
|
119 |
|
|
texfile = "%s/%s.tex" % (condor_dir,channel)
|
120 |
|
|
os.system("cutFlowTable %s > %s" % (args,texfile))
|
121 |
|
|
#reformat tex files
|
122 |
|
|
for line in fileinput.FileInput(texfile,inplace=1):
|
123 |
|
|
for replacement in replacements.keys():
|
124 |
|
|
line = line.replace(replacement,replacements[replacement])
|
125 |
|
|
print line,
|
126 |
|
|
|
127 |
|
|
for line in fileinput.FileInput(texfile,inplace=1):
|
128 |
|
|
for replacement in secondary_replacements.keys():
|
129 |
|
|
line = line.replace(replacement,secondary_replacements[replacement])
|
130 |
|
|
print line,
|
131 |
|
|
|
132 |
|
|
#process tex files to make pdf files
|
133 |
|
|
command = "pdflatex -interaction=batchmode -output-directory=./%s %s > /dev/null" % (condor_dir,texfile)
|
134 |
|
|
os.system(command)
|
135 |
|
|
os.system(command)
|
136 |
|
|
#os.system("rm %s" % texfile)
|
137 |
|
|
os.system("rm %saux" % (texfile.rstrip("tex")))
|
138 |
|
|
os.system("rm %slog" % (texfile.rstrip("tex")))
|
139 |
|
|
|