1 |
nowak |
1.1 |
import ROOT
|
2 |
|
|
import sys, re, math
|
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 |
|
|
from copy import deepcopy
|
8 |
|
|
|
9 |
|
|
if __name__ == "__main__":
|
10 |
|
|
|
11 |
|
|
#taufile = ROOT.TFile.Open( "/afs/naf.desy.de/group/cms/scratch/nowaf/CMSSW_4_2_4/src/anothertest.root" );
|
12 |
|
|
#muonfile = ROOT.TFile.Open( "/afs/naf.desy.de/group/cms/scratch/nowaf/CMSSW_4_2_4/src/anothertest2.root" );
|
13 |
|
|
#TauDR = taufile->Get( "TauSelectionTaudRJet" )
|
14 |
|
|
#MuonDR = ( TH1F* ) muonfile->Get( "MuonDRJet" )
|
15 |
|
|
|
16 |
|
|
Def.SetGlobalStyles()
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
filename = "/afs/naf.desy.de/group/cms/scratch/nowaf/CMSSW_4_2_4/src/RA2/Configuration/FinalPlots/TauFinalPlot.root"
|
20 |
|
|
filename = "/scratch/hh/lustre/cms/user/nowaf/2011Data/VersionII/Plots/RealTauEst/TTbar_cxxxix.root"
|
21 |
|
|
rootfile = ROOT.TFile.Open( filename )
|
22 |
|
|
TauDR = rootfile.Get( "finalPlotTauPreSelectionMatchedTauControl/TauSelectionTaudRJet" )
|
23 |
|
|
MuonDR = rootfile.Get( "MuonTemplateAnalyzerPre/MuonDRJet" )
|
24 |
|
|
MuonDR.Scale( 0.65 )
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
TauDR.SetDirectory( 0 )
|
28 |
|
|
MuonDR.SetDirectory( 0 )
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
weightHist = TauDR.Clone()
|
32 |
|
|
weightHist.SetDirectory( 0 )
|
33 |
|
|
weightHist.Divide( MuonDR.Clone() )
|
34 |
|
|
|
35 |
|
|
TwoDPlot = rootfile.Get( "MuonTemplateAnalyzerPre/MuonDRJetVsDPhiMHTTau" )
|
36 |
|
|
TwoDPlot.SetDirectory( 0 )
|
37 |
|
|
|
38 |
|
|
TauDPhi = rootfile.Get( "finalPlotTauPreSelectionMatchedTauControl/TauSelectiondPhiMHTTau" )
|
39 |
|
|
TauDPhi.SetDirectory( 0 )
|
40 |
|
|
|
41 |
|
|
TauDPhiWeighted = ROOT.TH1F( "MDRWeighted", "MDRWeighted", TauDPhi.GetNbinsX(), 0, TauDPhi.GetXaxis().GetXmax() )
|
42 |
|
|
TauDPhiWeighted.SetDirectory( 0 )
|
43 |
|
|
|
44 |
|
|
values = [ 0 ] * ( TwoDPlot.GetNbinsX() + 1 )
|
45 |
|
|
for xbin in range( 0, TwoDPlot.GetNbinsX() + 1 ):
|
46 |
|
|
xbincenter = TwoDPlot.GetXaxis().GetBinCenter( xbin )
|
47 |
|
|
#print "xcenter=", xbincenter
|
48 |
|
|
for ybin in range( 0, TwoDPlot.GetNbinsY() + 1 ):
|
49 |
|
|
ybincenter = TwoDPlot.GetYaxis().GetBinCenter( ybin )
|
50 |
|
|
#print "\tycenter=", ybincenter
|
51 |
|
|
xbinvalue = TwoDPlot.GetBinContent( xbin, ybin )
|
52 |
|
|
#print "\tval=", xbinvalue
|
53 |
|
|
weightbin = weightHist.FindBin( ybincenter )
|
54 |
|
|
weight = weightHist.GetBinContent( weightbin )
|
55 |
|
|
values[ xbin ] = values[ xbin ] + xbinvalue * weight
|
56 |
|
|
#values[ xbin ] = values[ xbin ] + xbinvalue
|
57 |
|
|
#print "xbinvalue=", xbinvalue, " weight=", weight
|
58 |
|
|
pass
|
59 |
|
|
pass
|
60 |
|
|
for i in range( 0, len( values ) ):
|
61 |
|
|
TauDPhiWeighted.SetBinContent( i, values[ i ] )
|
62 |
|
|
#print "bin=", i, " val=", values[ i ]
|
63 |
|
|
pass
|
64 |
|
|
TauDPhiWeighted.Scale( 0.65 )
|
65 |
|
|
|
66 |
|
|
TauDPhi.Rebin( 2 )
|
67 |
|
|
TauDPhiWeighted.Rebin( 2 )
|
68 |
|
|
|
69 |
|
|
#TauDR.Draw()
|
70 |
|
|
#TauDR.SetMarkerStyle( 22 )
|
71 |
|
|
#MuonDR.Draw()
|
72 |
|
|
TauDPhi.Draw()
|
73 |
|
|
TauDPhi.SetMarkerStyle( 22 )
|
74 |
|
|
TauDPhiWeighted.SetLineColor( 8 )
|
75 |
|
|
TauDPhiWeighted.Draw( "same" )
|
76 |
|
|
ROOT.gPad.SetLogy( 0 )
|
77 |
|
|
ROOT.gPad.Update()
|
78 |
|
|
#weightHist.Draw()
|
79 |
|
|
|
80 |
|
|
Def.DontQuit()
|
81 |
|
|
|