1 |
nowak |
1.1 |
import ROOT
|
2 |
|
|
import sys, re
|
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 FakeHelper as FH
|
7 |
|
|
from array import array
|
8 |
|
|
|
9 |
|
|
if __name__ == "__main__":
|
10 |
|
|
|
11 |
|
|
Def.SetGlobalStyles()
|
12 |
|
|
|
13 |
|
|
sampleList = []
|
14 |
|
|
#sampleList.append( "ZJets" )
|
15 |
|
|
sampleList.append( "WJets" )
|
16 |
|
|
#sampleList.append( "TTbar" )
|
17 |
|
|
|
18 |
|
|
fileDict = {}
|
19 |
|
|
fileDict[ "WJets" ] = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/WJets_lxvi.root"
|
20 |
|
|
|
21 |
|
|
dir = "EffRatePre/"
|
22 |
|
|
|
23 |
|
|
initialHistDict = {}
|
24 |
|
|
initialHistDict[ "TauPt" ] = "GenPt"
|
25 |
|
|
|
26 |
|
|
histDict = {}
|
27 |
|
|
for hist in initialHistDict:
|
28 |
|
|
print "----- ", hist
|
29 |
|
|
histDict[ hist ] = {}
|
30 |
|
|
histDict[ initialHistDict[ hist ] ] = {}
|
31 |
|
|
for file in sampleList:
|
32 |
|
|
rootfile = ROOT.TFile.Open( fileDict[ file ] )
|
33 |
|
|
#newrootfile = ROOT.TFile( "./" + file + "_TaNC_TauTemplate.root", "RECREATE" )
|
34 |
|
|
#print file
|
35 |
|
|
histDict[ hist ][ file ] = rootfile.Get( dir + hist )
|
36 |
|
|
histDict[ hist ][ file ].SetDirectory( 0 )
|
37 |
|
|
histDict[ hist ][ file ].UseCurrentStyle()
|
38 |
|
|
histDict[ hist ][ file ].Rebin( 2 )
|
39 |
|
|
|
40 |
|
|
histDict[ initialHistDict[ hist ] ][ file ] = rootfile.Get( dir + initialHistDict[ hist ] )
|
41 |
|
|
histDict[ initialHistDict[ hist ] ][ file ].SetDirectory( 0 )
|
42 |
|
|
histDict[ initialHistDict[ hist ] ][ file ].UseCurrentStyle()
|
43 |
|
|
histDict[ initialHistDict[ hist ] ][ file ].Rebin( 2 )
|
44 |
|
|
|
45 |
|
|
rootfile.Close()
|
46 |
|
|
|
47 |
|
|
lowerBinsHist = FH.getLowerBins( histDict[ hist ][ file ], nEntries=10 )
|
48 |
|
|
lowerBinsHist2 = FH.getLowerBins( histDict[ initialHistDict[ hist ] ][ file ], nEntries=10 )
|
49 |
|
|
|
50 |
|
|
rebinList = FH.mergeList( [ lowerBinsHist, lowerBinsHist2 ] )
|
51 |
|
|
obj = array( 'd' )
|
52 |
|
|
for b in rebinList:
|
53 |
|
|
obj.append( b )
|
54 |
|
|
pass
|
55 |
|
|
histDict[ hist ][ file ] = \
|
56 |
|
|
histDict[ hist ][ file ].Rebin( len( rebinList ) -1 , hist , obj )
|
57 |
|
|
histDict[ initialHistDict[ hist ] ][ file ] = \
|
58 |
|
|
histDict[ initialHistDict[ hist ] ][ file ].Rebin( len( rebinList ) -1 , hist , obj )
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
histDict[ hist ][ file ].Divide( histDict[ initialHistDict[ hist ] ][ file ] )
|
62 |
|
|
|
63 |
|
|
histDict[ hist ][ file ].Smooth()
|
64 |
|
|
|
65 |
|
|
#newrootfile.mkdir( dir.split( "/" )[ 0 ] )
|
66 |
|
|
#thedir = newrootfile.GetDirectory( dir )
|
67 |
|
|
#histDict[ hist ][ file ].SetDirectory( thedir )
|
68 |
|
|
#thedir.Write()
|
69 |
|
|
#newrootfile.Close()
|
70 |
|
|
pass
|
71 |
|
|
pass
|
72 |
|
|
|
73 |
|
|
for file in sampleList:
|
74 |
|
|
newrootfile = ROOT.TFile( "./" + file + "_HPS_eff.root", "RECREATE" )
|
75 |
|
|
newrootfile.mkdir( dir.split( "/" )[ 0 ] )
|
76 |
|
|
thedir = newrootfile.GetDirectory( dir )
|
77 |
|
|
for hist in initialHistDict.keys():
|
78 |
|
|
histDict[ hist ][ file ].SetDirectory( thedir )
|
79 |
|
|
pass
|
80 |
|
|
thedir.Write()
|
81 |
|
|
newrootfile.Close()
|
82 |
|
|
pass
|
83 |
|
|
|