ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/nowaf/RootFilesInUse/DumpScanInFile.py
Revision: 1.1.1.1 (vendor branch)
Committed: Tue Mar 20 13:12:08 2012 UTC (13 years, 1 month ago) by nowak
Content type: text/x-python
Branch: rootFilesInUse, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
t files in use

File Contents

# Content
1 import ROOT
2 import sys
3 sys.path.append("/afs/naf.desy.de/user/n/nowaf/UserCode/nowaf/PythonScripts/")
4 import definitions as Def
5 import Scan_cff as Scan
6 import ScanDump_cff as Dump
7
8 #########################################################
9 #
10 # Reads in Scan hists and dumps out its content
11 # For limit input
12 #
13 #########################################################
14
15 if __name__ == "__main__":
16
17 #Def.SetGlobalStyles( withTitle=True )
18 #ROOT.gStyle.SetPadRightMargin( 0.11 )
19 #ROOT.gStyle.SetLabelSize( 0.03,"XYZ" )
20 #lumi = 4.533
21 lumi = 4.992
22 title = "L = " + str( round( lumi,1 ) ) + " fb^{-1}, #sqrt{s} = 7 TeV"
23 tanBeta = 40
24
25 Type = ""
26
27 #data = 28
28 #dataQCD=3.3
29 #dataMuon=26.5
30 #dataQCDSystRel=1.15
31 #dataQCDStatRel=1.12
32 #dataMuonSystRel=1.11
33 #dataMuonStatRel=1.09
34
35 #### 26. 01. 2012
36 #data = 28
37 #dataQCD=3.4
38 #dataMuon=26.9
39 #dataQCDSystRel=1.15
40 #dataQCDStatRel=1.11
41 #dataMuonSystRel=1.22
42 #dataMuonStatRel=1.08
43
44 #### 06.02.2012
45 #data = 28
46 #dataQCD=3.4
47 #dataMuon=25.4
48 #dataQCDSystRel=1.15
49 #dataQCDStatRel=1.11
50 #dataMuonSystRel=1.20
51 #dataMuonStatRel=1.09
52
53 #### 15.02.2012
54 #data = 28
55 #dataQCD=3.3
56 #dataMuon=22.4
57 #dataQCDSystRel=1.15
58 #dataQCDStatRel=1.12
59 #dataMuonSystRel=1.20
60 #dataMuonStatRel=1.09
61
62 ### 20.03.2012
63 data = 28
64 dataQCD=3.4
65 dataMuon=25.9
66 dataQCDSystRel=1.29
67 dataQCDStatRel=1.12
68 dataMuonSystRel=1.09
69 dataMuonStatRel=1.09
70
71 #### histDict contains all hists needed in the end
72 datacardDir = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/ScanTanBeta40new_xix/Datacards"
73 #filename = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/ScanTanBeta40new_v_noPDF/Tau_mSUGRA_m0-220to3000_m12-100to1000_tanb-40andA0-m500_7TeV-Pythia6Z_333.root"
74 #filename = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/ScanTanBeta40new_viii/ScanTanBeta40new_viii.root"
75 filename = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/ScanTanBeta40new_xix/ScanTanBeta40new_xix.root"
76 rootfile = ROOT.TFile.Open( filename )
77 histDict = Scan.readInScanHists( rootfile )
78 filenamePDF = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/ScanTanBeta40new_vi_PDF/ScanTanBeta40new_vi_PDF.root"
79 rootfilePDF = ROOT.TFile.Open( filenamePDF )
80 Scan.getPDFHists( rootfilePDF, histDict )
81 rootfile.Close()
82
83 Scan.getAccHist( histDict, "NLO", Type=Type )
84 Scan.getRateHist( histDict, "NLO", lumi=lumi, Type=Type )
85 Scan.getSignalCont( histDict, lumi=lumi, data=dataQCD, Type=Type )
86 Scan.getSignalCont( histDict, backgr="Muon", data=dataMuon, lumi=lumi, Type=Type )
87 for err in [ "JECUp", "JECDn", "TEUp", "TEDn", "NLO2", "NLO05",
88 "MuonIsoUp", "MuonIsoDn", "ElecIsoUp", "ElecIsoDn" ]:
89 Scan.getAccHist( histDict, err, Type=Type, otherApp="NLO" )
90 Scan.getRelAcc( histDict, err, "NLO", Type=Type )
91 Scan.getRateHist( histDict, err, lumi=lumi, Type=Type )
92 Scan.getRelRate( histDict, err, "NLO", Type=Type )
93 pass
94 Scan.getRelPDFErr( histDict,Type=Type )
95 Scan.getCombRelRateErr( histDict, Type=Type )
96 Scan.getCombRelAccErr( histDict, Type=Type )
97
98 #### now prepare dump
99 for xbin in range( 1, histDict[ "ScanAnalyzerNLO" ].GetNbinsX() + 1 ):
100 for ybin in range( 1, histDict[ "ScanAnalyzerNLO" ].GetNbinsY() + 1 ):
101 if( histDict[ "ScanAnalyzerNLO" ].GetBinContent( xbin, ybin ) == 0 ):
102 continue
103
104 m0 = histDict[ "ScanAnalyzerNLO" ].GetXaxis().GetBinCenter( xbin )
105 #### temporary scan only small part
106 if m0 > 800:
107 continue
108 #if not m0 == 400:
109 # continue
110
111 m12 = histDict[ "ScanAnalyzerNLO" ].GetYaxis().GetBinCenter( ybin )
112 #### temporary scan only small part
113 if m12 > 800:
114 continue
115 #if not m12 == 280:
116 # continue
117
118 fileName = datacardDir + "/Datacard_" + str( int( m0 ) ) + "_" + str( int( m12 ) ) + "_" + str( int( tanBeta ) ) + ".txt"
119
120 rateErr = ROOT.Double( 0 )
121 contRealErr = ROOT.Double( 0 )
122 contFakeErr = ROOT.Double( 0 )
123 rate = histDict[ "ScanAnalyzerNLO" ].IntegralAndError( xbin, xbin, ybin, ybin, rateErr )
124 contReal = histDict[ "SignalContMuon" ].IntegralAndError( xbin, xbin, ybin, ybin, contRealErr )
125 contFake = histDict[ "SignalContQCD" ].IntegralAndError( xbin, xbin, ybin, ybin, contFakeErr )
126
127 #print "rate=", rate, " contReal=", contReal, " contFake=", contFake
128
129 cleanedRate = rate - contReal - contFake
130 if cleanedRate < 0:
131 cleanedRate = 0
132 cleanedRateErr = rateErr/rate + 1
133
134
135 JECUp = histDict[ "RateRelJECUp" ].GetBinContent( xbin, ybin )
136 JECDn = histDict[ "RateRelJECDn" ].GetBinContent( xbin, ybin )
137 #print "JEC up=", JECUp, " JEC dn=", JECDn
138 TEUp = histDict[ "RateRelTEUp" ].GetBinContent( xbin, ybin )
139 TEDn = histDict[ "RateRelTEDn" ].GetBinContent( xbin, ybin )
140 #print "TE up=", TEUp, " TE dn=", TEDn
141 NLOUp = histDict[ "RateRelNLO2" ].GetBinContent( xbin, ybin )
142 NLODn = histDict[ "RateRelNLO05" ].GetBinContent( xbin, ybin )
143 #print "NLO up=", NLOUp, " NLO05 dn=", NLODn
144 MIUp = histDict[ "RateRelMuonIsoUp" ].GetBinContent( xbin, ybin )
145 MIDn = histDict[ "RateRelMuonIsoDn" ].GetBinContent( xbin, ybin )
146 #print "MI up=", MIUp +1 , " MI dn=", MIDn + 1
147 EIUp = histDict[ "RateRelElecIsoUp" ].GetBinContent( xbin, ybin )
148 EIDn = histDict[ "RateRelElecIsoDn" ].GetBinContent( xbin, ybin )
149 #print "EI up=", EIUp +1 , " EI dn=", EIDn + 1
150 PDFUp = histDict[ "RateRelPDFUp" ].GetBinContent( xbin, ybin )
151 PDFDn = histDict[ "RateRelPDFDn" ].GetBinContent( xbin, ybin )
152 #print "PDF up=", PDFUp +1 , " PDF dn=", PDFDn + 1
153
154 contRealRel = histDict[ "SignalContMuonRel" ].GetBinContent( xbin, ybin )
155 contFakeRel = histDict[ "SignalContQCDRel" ].GetBinContent( xbin, ybin )
156
157 #if m0 > 500 and m0 < 600 and m12 > 200 and m12 < 300:
158 # print "m0=", m0, " m12=", m12, " rate=", rate, " contReal=", contReal, " contFake=", contFake
159 # print "JECUp=", JECUp
160 # pass
161
162
163 d = Dump.PrintFile( fileName )
164 d.setObservation( data )
165 d.setRate( cleanedRate, dataMuon, dataQCD )
166 #d.setUncert( "uncertLumi", 1.036, [ 0 ] )
167 #d.setUncert( "uncertTrig", 1.063, [ 0 ] )
168 d.setUncert( "uncertLumi", 1.022, [ 0 ] )
169 d.setUncert( "uncertTrig", 1.025, [ 0 ] ) ### new
170 #d.setUncert( "uncertPDF", 1.3, [ 0 ] ) ###### currently flat
171 d.setUncert( "uncertPDF", PDFUp +1, [ 0 ] ) ### are these guys in or out??
172 d.setUncert( "uncertJEC", JECUp, [ 0 ] )
173 d.setUncert( "uncertTE", TEUp, [ 0 ] )
174 ####d.setUncert( "uncertNLO05", NLODn, [ 0 ] ) ### left out because of new policy
175 d.setUncert( "uncertMI", MIUp + 1, [ 0 ] )
176 d.setUncert( "uncertEI", EIUp + 1, [ 0 ] )
177 d.setUncert( "uncertSignalStat", cleanedRateErr, [ 0 ] )
178 #d.setUncert( "uncertRealStat", contRealErr, [ 1 ] )
179 #d.setUncert( "uncertFakeStat", contFakeErr, [ 2 ] )
180 d.setUncert( "uncertFakeStat", dataQCDStatRel, [ 2 ] )
181 d.setUncert( "uncertRealStat", dataMuonStatRel, [ 1 ] )
182 d.setUncert( "uncertFakeSyst", dataQCDSystRel, [ 2 ] )
183 d.setUncert( "uncertRealSyst", dataMuonSystRel, [ 1 ] )
184 d.write()
185 pass
186 pass
187