1 |
nowak |
1.1 |
import ROOT
|
2 |
|
|
import sys, re
|
3 |
|
|
sys.path.append( '/afs/naf.desy.de/user/n/nowaf/CMSSW_3_3_6/src/LeptonSel/LeptonSel/rootScripts' )
|
4 |
|
|
import ConfigParser
|
5 |
|
|
import definitions as Def
|
6 |
|
|
|
7 |
|
|
def main(argv):
|
8 |
|
|
#import sys
|
9 |
|
|
|
10 |
|
|
basepath = ''
|
11 |
|
|
|
12 |
|
|
try:
|
13 |
|
|
options, arguments = getopt.getopt(argv, "hp:", ["help","path="])
|
14 |
|
|
|
15 |
|
|
except getopt.GetoptError:
|
16 |
|
|
usage()
|
17 |
|
|
sys.exit(2)
|
18 |
|
|
|
19 |
|
|
for opt, arg in options:
|
20 |
|
|
if opt in ("-h", "--help"):
|
21 |
|
|
usage()
|
22 |
|
|
sys.exit(2)
|
23 |
|
|
elif opt in ("-p", "--path"):
|
24 |
|
|
basepath = arg
|
25 |
|
|
|
26 |
|
|
if basepath == '':
|
27 |
|
|
print "Error! Need path to .cfg file to continue."
|
28 |
|
|
sys.exit(2)
|
29 |
|
|
|
30 |
|
|
return basepath
|
31 |
|
|
|
32 |
|
|
def usage():
|
33 |
|
|
|
34 |
|
|
print "Script to plot all XC study plots for the di lepton analysis"
|
35 |
|
|
print "Options and arguments:"
|
36 |
|
|
print "-h, --help\t\t: print this help message and exit"
|
37 |
|
|
print "-p, --path\t\t: relative path to the .cfg file"
|
38 |
|
|
|
39 |
|
|
pass
|
40 |
|
|
|
41 |
|
|
def readTheConfig(name):
|
42 |
|
|
"""
|
43 |
|
|
read in the config file
|
44 |
|
|
"""
|
45 |
|
|
config = ConfigParser.ConfigParser()
|
46 |
|
|
config.read( name )
|
47 |
|
|
|
48 |
|
|
return config
|
49 |
|
|
|
50 |
|
|
if __name__ == "__main__":
|
51 |
|
|
|
52 |
|
|
import getopt
|
53 |
|
|
|
54 |
|
|
basepath = main(sys.argv[1:])
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
Def.SetGlobalStyles( "emr" )
|
58 |
|
|
|
59 |
|
|
saves = {}
|
60 |
|
|
|
61 |
|
|
config = readTheConfig( basepath )
|
62 |
|
|
|
63 |
|
|
color_list = [1,2,6,8,50,22,40,66,48,58]
|
64 |
|
|
|
65 |
|
|
counter = 0
|
66 |
|
|
rightCase = 0
|
67 |
|
|
|
68 |
|
|
for section in config.sections():
|
69 |
|
|
file_list = []
|
70 |
|
|
case_list = []
|
71 |
|
|
hist_list = []
|
72 |
|
|
for option in config.options( section ):
|
73 |
|
|
if re.search( "afs", config.get( section, option ) ) or re.search( "current", config.get( section, option ) ):
|
74 |
|
|
fin = Def.ReadInRootFile( config.get( section, option ) + "/studyXC.root" )
|
75 |
|
|
else:
|
76 |
|
|
fin = Def.ReadInRootFile( "./../test/" + config.get( section, option ) + "/studyXC.root" )
|
77 |
|
|
pass
|
78 |
|
|
|
79 |
|
|
#print type( fin )
|
80 |
|
|
#print type( fin.Get( "h_Met_all" ) )
|
81 |
|
|
|
82 |
|
|
file_list.append( fin )
|
83 |
|
|
|
84 |
|
|
#hist_list.append( fin.Get( "./h_invMass" ) )
|
85 |
|
|
|
86 |
|
|
case = ""
|
87 |
|
|
if not float( option ) == 1 and not float( option ) == 0:
|
88 |
|
|
case = option
|
89 |
|
|
#if float( option ) == 0.7:
|
90 |
|
|
# rightCase = counter
|
91 |
|
|
else:
|
92 |
|
|
case = "no xclean"
|
93 |
|
|
rightCase = counter
|
94 |
|
|
print counter
|
95 |
|
|
case_list.append( case )
|
96 |
|
|
#case_list.append( case )
|
97 |
|
|
|
98 |
|
|
counter += 1
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
pass
|
102 |
|
|
|
103 |
|
|
## for file in file_list:
|
104 |
|
|
## hist_list.append( file.Get( "h_Met_all_Zee" ) )
|
105 |
|
|
## pass
|
106 |
|
|
## color_list.append( 35 )
|
107 |
|
|
## case_list.append( 'genMet' )
|
108 |
|
|
## hist_list.append( file_list[rightCase].Get( "h_genMet_all_Zee" ) )
|
109 |
|
|
|
110 |
|
|
## c = ROOT.TCanvas( "c_" + section, "met" + section ,1,71,300,300 )
|
111 |
|
|
## Def.DrawSmall( c, hist_list, \
|
112 |
|
|
## color_list,\
|
113 |
|
|
## case_list,\
|
114 |
|
|
## "MET [GeV]",\
|
115 |
|
|
## "",\
|
116 |
|
|
## "",\
|
117 |
|
|
## False,\
|
118 |
|
|
## 1,
|
119 |
|
|
## True,\
|
120 |
|
|
## "ur",\
|
121 |
|
|
## "ths_", saves )
|
122 |
|
|
|
123 |
|
|
## #del hist_list[:]
|
124 |
|
|
## hist_list2 = []
|
125 |
|
|
## for file in file_list:
|
126 |
|
|
## hist_list2.append( file.Get( "h_recoilMet_all" ) )
|
127 |
|
|
## pass
|
128 |
|
|
## color_list.append( 35 )
|
129 |
|
|
## color_list.append( 9 )
|
130 |
|
|
## case_list.append( 'Met' )
|
131 |
|
|
## case_list.append( 'genMet' )
|
132 |
|
|
## hist_list2.append( file_list[rightCase].Get( "h_Met_all" ) )
|
133 |
|
|
## hist_list2.append( file_list[rightCase].Get( "h_genMet_all" ) )
|
134 |
|
|
## #print type( file_list[0] )
|
135 |
|
|
## #print type( hist_list[0] )
|
136 |
|
|
|
137 |
|
|
## c2 = ROOT.TCanvas( "c2_" + section, "met" + section ,1,71,300,300 )
|
138 |
|
|
## Def.DrawSmall( c2, hist_list2, \
|
139 |
|
|
## color_list,\
|
140 |
|
|
## case_list,\
|
141 |
|
|
## "MET [GeV]",\
|
142 |
|
|
## "",\
|
143 |
|
|
## "",\
|
144 |
|
|
## False,\
|
145 |
|
|
## 1,
|
146 |
|
|
## True,\
|
147 |
|
|
## "ur",\
|
148 |
|
|
## "ths2_", saves )
|
149 |
|
|
|
150 |
|
|
hist_list2 = []
|
151 |
|
|
for file in file_list:
|
152 |
|
|
hist_list2.append( file.Get( "h_recoilMet_all" ) )
|
153 |
nowak |
1.2 |
hist_list2.append( file.Get( "h_Met_all" ) )
|
154 |
nowak |
1.1 |
pass
|
155 |
|
|
|
156 |
|
|
case_list2 = []
|
157 |
|
|
for case in case_list:
|
158 |
|
|
case_list2.append( case + '_recoil' )
|
159 |
nowak |
1.2 |
case_list2.append( case + '_calo' )
|
160 |
nowak |
1.1 |
|
161 |
|
|
color_list.append( 35 )
|
162 |
|
|
color_list.append( 9 )
|
163 |
nowak |
1.2 |
case_list2.append( 'genMet' )
|
164 |
|
|
hist_list2.append( file_list[rightCase].Get( "h_genMet_all" ) )
|
165 |
nowak |
1.1 |
|
166 |
|
|
c2 = ROOT.TCanvas( "c2_" + section, "met" + section ,1,71,300,300 )
|
167 |
|
|
Def.DrawSmall( c2, hist_list2, \
|
168 |
|
|
color_list,\
|
169 |
|
|
case_list2,\
|
170 |
|
|
"MET [GeV]",\
|
171 |
|
|
"",\
|
172 |
|
|
"",\
|
173 |
|
|
False,\
|
174 |
|
|
1,
|
175 |
|
|
False,\
|
176 |
|
|
"ur",\
|
177 |
|
|
"ths2_", saves )
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
pass
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
Def.DontQuit()
|