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 |
for section in config.sections():
|
66 |
file_list = []
|
67 |
case_list = []
|
68 |
hist_list = []
|
69 |
for option in config.options( section ):
|
70 |
if not re.search( "afs", config.get( section, option ) ):
|
71 |
fin = Def.ReadInRootFile( "./../test/" + config.get( section, option ) + "/studyXC.root" )
|
72 |
else:
|
73 |
fin = Def.ReadInRootFile( config.get( section, option ) + "/studyXC.root" )
|
74 |
pass
|
75 |
|
76 |
#print type( fin.Get( "h_invMass" ) )
|
77 |
|
78 |
file_list.append( fin )
|
79 |
|
80 |
#hist_list.append( fin.Get( "./h_invMass" ) )
|
81 |
case = ""
|
82 |
if not float( option ) == 1:
|
83 |
case = "xclean"
|
84 |
else:
|
85 |
case = "no xclean"
|
86 |
case_list.append( case )
|
87 |
|
88 |
pass
|
89 |
|
90 |
for file in file_list:
|
91 |
hist_list.append( file.Get( "h_invMass" ) )
|
92 |
pass
|
93 |
|
94 |
c = ROOT.TCanvas( "c_" + section, "h_invMass" + section ,1,71,300,300 )
|
95 |
Def.DrawSmall( c, hist_list, \
|
96 |
color_list,\
|
97 |
case_list,\
|
98 |
"mass pair(e,jet) [GeV]",\
|
99 |
"",\
|
100 |
"",\
|
101 |
False,\
|
102 |
0,
|
103 |
False,\
|
104 |
"ur",\
|
105 |
"ths_", saves )
|
106 |
|
107 |
|
108 |
pass
|
109 |
|
110 |
|
111 |
|
112 |
Def.DontQuit()
|