1 |
nowak |
1.1 |
import ROOT
|
2 |
|
|
import sys, re, math, os
|
3 |
|
|
sys.path.append("/afs/naf.desy.de/user/n/nowaf/UserCode/nowaf/PythonScripts/")
|
4 |
|
|
import definitions as Def
|
5 |
|
|
import styles as Style
|
6 |
|
|
import MakeRealTauEst_cff as RT
|
7 |
|
|
|
8 |
|
|
if __name__ == "__main__":
|
9 |
|
|
|
10 |
|
|
Def.SetGlobalStyles()
|
11 |
|
|
ROOT.gStyle.SetPadRightMargin(0.11)
|
12 |
|
|
ROOT.gStyle.SetLabelSize(0.03,"XYZ")
|
13 |
|
|
|
14 |
|
|
fileDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/ScanTanBeta40/"
|
15 |
|
|
dir = "ScanAnalyzerPre/"
|
16 |
|
|
|
17 |
|
|
fileList = []
|
18 |
|
|
f = os.popen( "ls " + fileDir + "*.root" )
|
19 |
|
|
for i in f.readlines():
|
20 |
|
|
file = str.split( i, " " )[ -1 ]
|
21 |
|
|
file = file.rstrip()
|
22 |
|
|
#print file
|
23 |
|
|
if re.search( "ScanTanBeta40_", file ):
|
24 |
|
|
continue
|
25 |
|
|
#print file
|
26 |
|
|
fileList.append( file )
|
27 |
|
|
pass
|
28 |
|
|
|
29 |
|
|
histList = []
|
30 |
|
|
histListnEvts = []
|
31 |
|
|
for file in fileList:
|
32 |
|
|
#print file
|
33 |
|
|
rootfile = ROOT.TFile.Open( file )
|
34 |
|
|
#print type( rootfile )
|
35 |
|
|
#print type( rootfile.Get( dir + "xSec" ) )
|
36 |
|
|
#print type( fileList[ -1 ] )
|
37 |
|
|
histList.append( rootfile.Get( dir + "xSec" ) )
|
38 |
|
|
histListnEvts.append( rootfile.Get( dir + "nEvts" ) )
|
39 |
|
|
histList[ -1 ].SetDirectory( 0 )
|
40 |
|
|
histListnEvts[ -1 ].SetDirectory( 0 )
|
41 |
|
|
rootfile.Close()
|
42 |
|
|
pass
|
43 |
|
|
|
44 |
|
|
h_xsec = ROOT.TH2F( "xsec", "xsec",
|
45 |
|
|
histList[ 0 ].GetNbinsX() / 2,
|
46 |
|
|
histList[ 0 ].GetXaxis().GetXmin() - 5,
|
47 |
|
|
histList[ 0 ].GetXaxis().GetXmax() + 5,
|
48 |
|
|
histList[ 0 ].GetNbinsY() / 2,
|
49 |
|
|
histList[ 0 ].GetYaxis().GetXmin() - 5,
|
50 |
|
|
histList[ 0 ].GetYaxis().GetXmax() + 5 )
|
51 |
|
|
h_xsec.SetDirectory( 0 )
|
52 |
|
|
Style.setHistStyle( h_xsec, xTitle="M_{0}", yTitle="M_{1/2}" )
|
53 |
|
|
|
54 |
|
|
h_nEvts = ROOT.TH2F( "nEvts", "nEvts",
|
55 |
|
|
histListnEvts[ 0 ].GetNbinsX() / 2,
|
56 |
|
|
histListnEvts[ 0 ].GetXaxis().GetXmin() - 5,
|
57 |
|
|
histListnEvts[ 0 ].GetXaxis().GetXmax() + 5,
|
58 |
|
|
histListnEvts[ 0 ].GetNbinsY() / 2,
|
59 |
|
|
histListnEvts[ 0 ].GetYaxis().GetXmin() - 5,
|
60 |
|
|
histListnEvts[ 0 ].GetYaxis().GetXmax() + 5 )
|
61 |
|
|
h_nEvts.SetDirectory( 0 )
|
62 |
|
|
Style.setHistStyle( h_nEvts, xTitle="M_{0}", yTitle="M_{1/2}" )
|
63 |
|
|
|
64 |
|
|
for hist in histList:
|
65 |
|
|
#print hist.GetName()
|
66 |
|
|
for x in range( 0, int( hist.GetXaxis().GetXmax() ), 20 ):
|
67 |
|
|
for y in range( 0, int( hist.GetXaxis().GetXmax() ), 20 ):
|
68 |
|
|
bin = hist.FindBin( x,y )
|
69 |
|
|
entry = hist.GetBinContent( bin )
|
70 |
|
|
#print entry
|
71 |
|
|
if entry <= 0.:
|
72 |
|
|
continue
|
73 |
|
|
|
74 |
|
|
xsecbin = h_xsec.FindBin( x,y )
|
75 |
|
|
xsecEntry = h_xsec.GetBinContent( xsecbin )
|
76 |
|
|
if not xsecEntry == 0.:
|
77 |
|
|
continue
|
78 |
|
|
### *10**9 to get the xsec in pb
|
79 |
|
|
h_xsec.SetBinContent( xsecbin, entry * 10**9 )
|
80 |
|
|
pass
|
81 |
|
|
pass
|
82 |
|
|
pass
|
83 |
|
|
|
84 |
|
|
for hist in histListnEvts:
|
85 |
|
|
#print hist.GetName()
|
86 |
|
|
for x in range( 0, int( hist.GetXaxis().GetXmax() ), 20 ):
|
87 |
|
|
for y in range( 0, int( hist.GetXaxis().GetXmax() ), 20 ):
|
88 |
|
|
bin = hist.FindBin( x,y )
|
89 |
|
|
entry = hist.GetBinContent( bin )
|
90 |
|
|
#print entry
|
91 |
|
|
if entry <= 0.:
|
92 |
|
|
continue
|
93 |
|
|
|
94 |
|
|
nEvtsbin = h_nEvts.FindBin( x,y )
|
95 |
|
|
nEvtsEntry = h_nEvts.GetBinContent( nEvtsbin )
|
96 |
|
|
|
97 |
|
|
addentry = entry + nEvtsEntry
|
98 |
|
|
h_nEvts.SetBinContent( nEvtsbin, addentry )
|
99 |
|
|
|
100 |
|
|
pass
|
101 |
|
|
pass
|
102 |
|
|
pass
|
103 |
|
|
|
104 |
|
|
#cDict = {}
|
105 |
|
|
|
106 |
|
|
#cDict[ "xs" ] = ROOT.TCanvas( "xsec" , "xsec" )
|
107 |
|
|
#cDict[ "xs" ].cd()
|
108 |
|
|
#h_xsec.GetZaxis().SetRangeUser( 0,4 )
|
109 |
|
|
#h_xsec.Draw( "COLZ" )
|
110 |
|
|
|
111 |
|
|
#thefile = ROOT.TFile.Open( fileDir + "ScanTanBeta10_i.root", "UPDATE" )
|
112 |
|
|
thefile = ROOT.TFile.Open( "ScanTanBeta40_misc.root", "RECREATE" )
|
113 |
|
|
#thedir = thefile.GetDirectory( dir )
|
114 |
|
|
thefile.mkdir( "misc" )
|
115 |
|
|
thedir = thefile.GetDirectory( "misc" )
|
116 |
|
|
h_xsec.SetDirectory( thedir )
|
117 |
|
|
h_nEvts.SetDirectory( thedir )
|
118 |
|
|
#thefile.WriteTObject( h_xsec)
|
119 |
|
|
thedir.Write()
|
120 |
|
|
thefile.Close()
|
121 |
|
|
|
122 |
|
|
Def.DontQuit()
|