Ejemplo n.º 1
0
 def draw(self, var, cut=''):
     same = ''
     for tree in self.trees.values():
         tree.Draw(var, cut, same)
         Style.nextStyle().formatHisto(tree.GetHistogram())
         if same == '':
             same = 'same'
Ejemplo n.º 2
0
 def draw(self, var, cut=''):
     same = ''
     for tree in self.trees.values():
         tree.Draw( var, cut, same)
         Style.nextStyle().formatHisto( tree.GetHistogram() )
         if same == '':
             same = 'same'
Ejemplo n.º 3
0
def wJetScale(mtplot, dataName):

    # WJets_data = data - DY - TTbar
    wjet = copy.deepcopy(mtplot.Hist(dataName))
    wjet.Add(mtplot.Hist('DYJets'), -1)
    try:
        dyJetsFakes = mtplot.Hist('DYJets_Fakes')
        wjet.Add(mtplot.Hist('DYJets_Fakes'), -1)
    except:
        pass
    # FIXME
    wjet.Add(mtplot.Hist('TTJets'), -1)

    # adding the WJets_data estimation to the stack
    mtplot.AddHistogram('Data - DY - TT', wjet.weighted, 1010)
    mtplot.Hist('Data - DY - TT').stack = False
    # with a nice pink color
    pink = kPink + 7
    sPinkHollow = Style(lineColor=pink, markerColor=pink, markerStyle=4)
    mtplot.Hist('Data - DY - TT').SetStyle(sPinkHollow)

    # determine scaling factor for the WJet MC
    mtmin, mtmax = 60, 200
    # scale = WJets_data / WJets
    scale_WJets = mtplot.Hist('Data - DY - TT').Integral(True, mtmin, mtmax) \
                  / mtplot.Hist('WJets').Integral(True, mtmin, mtmax)
    # apply this additional scaling factor to the WJet component
    # mtplot.Hist('WJets').Scale(scale_WJets)

    # hide the WJets_data component from the mtplot. can be set to True interactively
    mtplot.Hist('Data - DY - TT').on = True

    return scale_WJets
Ejemplo n.º 4
0
 def addTree(self, key, tree, pdf=False):
     print 'adding ', key, tree.GetName()
     if pdf:
         tree.SetWeight( 1./tree.GetEntries(), 'global')
     self.trees[key] = tree
     if len( self.leaveList ) == 0:
         self.leaveList = self.leaves( key )
     self.styles[key] = Style.nextStyle()
Ejemplo n.º 5
0
def fW(mtplot, dataName, xmin, xmax, VVgroup=None, channel='TauMu'):

    wjet = copy.deepcopy(mtplot.Hist(dataName))
    oldIntegral = wjet.Integral(True, xmin, xmax)
    wjet.Add(mtplot.Hist('Ztt'), -1)
    wjet.Add(mtplot.Hist('Ztt_ZL'), -1)
    wjet.Add(mtplot.Hist('Ztt_ZJ'), -1)
    wjet.Add(mtplot.Hist('Ztt_TL'), -1)
    wjet.Add(mtplot.Hist('TTJets'), -1)
    if VVgroup:
        wjet.Add(mtplot.Hist('VV'), -1)

    subtrIntegral = wjet.Integral(True, xmin, xmax)

    relSysError = 0.1 * (oldIntegral - subtrIntegral) / subtrIntegral
    print 'W+Jets, high MT: Relative error due to BG subtraction', relSysError

    mtplot.AddHistogram('Data-DY-TT-VV', wjet.weighted, 1010)
    mtplot.Hist('Data-DY-TT-VV').stack = False
    # with a nice pink color
    pink = kPink + 7
    sPinkHollow = Style(lineColor=pink, markerColor=pink, markerStyle=4)
    mtplot.Hist('Data-DY-TT-VV').SetStyle(sPinkHollow)

    data_integral = mtplot.Hist('Data-DY-TT-VV').Integral(True, xmin, xmax)

    error_data = Double(0.)
    error_mc = Double(0.)
    data_integral_jan = mtplot.Hist('Data-DY-TT-VV').weighted.IntegralAndError(
        mtplot.Hist('Data-DY-TT-VV').weighted.FindFixBin(xmin),
        mtplot.Hist('Data-DY-TT-VV').weighted.FindFixBin(xmax) - 1, error_data)

    if data_integral_jan != data_integral:
        print 'WARNING, not the same integral in w+jets estimation'

    print 'Adding relative error due to data error', error_data / data_integral
    relSysError = math.sqrt(error_data**2 / data_integral**2 + relSysError**2)
    print 'TOTAL ERROR on high mass SF', relSysError
    mc_integral = mtplot.Hist('WJets').Integral(True, xmin, xmax)
    # Do not double-count W+jets uncertainty (is in high-low ratio)
    return data_integral, mc_integral
Ejemplo n.º 6
0
def fW(mtplot, dataName, xmin, xmax, VVgroup=None, channel='TauMu'):

    wjet = copy.deepcopy(mtplot.Hist(dataName))
    wjet.Add(mtplot.Hist('Ztt'), -1)
    wjet.Add(mtplot.Hist('Ztt_ZL'), -1)
    wjet.Add(mtplot.Hist('Ztt_ZJ'), -1)
    wjet.Add(mtplot.Hist('Ztt_TL'), -1)
    wjet.Add(mtplot.Hist('TTJets'), -1)
    if VVgroup:
        wjet.Add(mtplot.Hist('VV'), -1)

    mtplot.AddHistogram('Data-DY-TT-VV', wjet.weighted, 1010)
    mtplot.Hist('Data-DY-TT-VV').stack = False
    # with a nice pink color
    pink = kPink + 7
    sPinkHollow = Style(lineColor=pink, markerColor=pink, markerStyle=4)
    mtplot.Hist('Data-DY-TT-VV').SetStyle(sPinkHollow)

    data_integral = mtplot.Hist('Data-DY-TT-VV').Integral(True, xmin, xmax)
    mc_integral = mtplot.Hist('WJets').Integral(True, xmin, xmax)
    return data_integral, mc_integral
Ejemplo n.º 7
0
import os, sys
from ROOT import gROOT, TFile, TCanvas, TH1F, TGraphAsymmErrors, TChain

from CMGTools.RootTools.RootTools import *
from CMGTools.RootTools.Style import *

gROOT.Macro(os.path.expanduser('~/rootlogon.C'))

style1 = Style()
style2 = Style(markerColor=2, lineColor=2)
style3 = Style(markerColor=3, lineColor=3)
style4 = Style(markerColor=4, lineColor=4)
style5 = Style(markerColor=5, lineColor=5)

basename = 'rfio:/castor/cern.ch/cms/store/cmst3/user/lenzip/CMG/SusyLP/WJetsToLNu_TuneD6T_7TeV-madgraph-tauola/Spring11-PU_S1_START311_V1G1-v1/CMGtuple/'
vfile = []
for i in range(6):
    vfile.append(basename + 'susy_tree_CMG_' + str(i) + '.root')

events = TChain('Events', 'Events')
for file in vfile:
    events.AddFile(file)
#file = TFile( sys.argv[1] )
#events = file.Get('Events')

from CMGTools.RootTools.cmgTuple import *

cmg = cmgTuple(events)

LPcanvas = TCanvas('LPcanvas', 'LP', 1000, 800)
LPcanvas.Divide(2, 3)
    FULL_mt_ss_wjet.Add(FULL_mt_ss.Hist('TTJets'), -1)

    if FULL_mt_ss.histosDict.get('VV', None) != None:
        FULL_mt_ss_wjet.Add(FULL_mt_ss.Hist('VV'), -1)
    else:
        print 'VV group not found, VV not subtracted'

    # adding the WJets_data estimation to the stack
    FULL_mt_ss.AddHistogram(
        'Data - DY - TT',  #PG put it back in the 
        FULL_mt_ss_wjet.weighted,
        1010)
    FULL_mt_ss.Hist('Data - DY - TT').stack = False
    # with a nice pink color
    pink = kPink + 7
    sPinkHollow = Style(lineColor=pink, markerColor=pink, markerStyle=4)
    FULL_mt_ss.Hist('Data - DY - TT').SetStyle(sPinkHollow)

    #PG compare the MC-subtracted data to the WJets MC only for SS
    #PG ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

    can0 = TCanvas('can0', '', 100, 100, 600, 600)
    p_main = TPad("p1", "", 0, 0.3, 1, 1)
    p_ratio = TPad("p1", "", 0, 0, 1, 0.3)
    p_main.Draw()
    p_main.SetLogy()
    p_ratio.Draw()

    p_main.cd()
    W_ss_WJets = FULL_mt_ss.Hist('WJets').weighted
    W_ss_Data = FULL_mt_ss.Hist('Data - DY - TT').weighted
numPt1 = ROOT.TH1F(fileHLTToAK5.Get('h_turnOnPt_'))
denPt1 = ROOT.TH1F(fileHLTToAK5.Get('h_turnOnPtDen_'))
numPt1.Sumw2()
numPt1.Divide(denPt)
numPt1.SetMinimum(0.)
numPt1.SetMaximum(1.)
sRed.formatHisto( numPt1 )
numPt1.Draw("SAMES")

numPt2 = ROOT.TH1F(fileHLTToAK5.Get('h_turnOnPt_'))
denPt2 = ROOT.TH1F(fileHLTToAK5.Get('h_turnOnPtDen_'))
numPt2.Sumw2()
numPt2.Divide(denPt)
numPt2.SetMinimum(0.)
numPt2.SetMaximum(1.)
sBlack = Style(fillColor=1)
sBlack.formatHisto( numPt2 )
numPt2.Draw("SAMES")

leg = TLegend(0.7,0.7,0.9,0.9)
leg.SetHeader("turn on")
leg.AddEntry(numPt0, "ak5 pf jet > 30 GeV, |eta| < 2.6, to ak5 pfjets")
leg.AddEntry(numPt1, "ak5 pf jet > 30 GeV, |eta| < 2.6, to ak5 pfjets, L1L2L3")
leg.AddEntry(numPt2, "ak5 pf jet > 30 GeV, |eta| < 2.6, to ak5 pfjets, chs L1L2L3")
leg.Draw("SAMES")

## leg = TLegend(0.7,0.7,0.9,0.9)
## leg.SetHeader("turn on")
## leg.AddEntry(numPt0, "ak5 pfnopu jet > 30 GeV, |eta| < 2.6, to ak5 pfjets")
## leg.AddEntry(numPt1, "ak5 pfnopu jet > 30 GeV, |eta| < 2.6, to ak5 pfjets, L1L2L3")
## leg.AddEntry(numPt2, "ak5 pfnopu jet > 30 GeV, |eta| < 2.6, to ak5 pfjets, chs L1L2L3")
Ejemplo n.º 10
0
from CMGTools.RootTools.Style import *

sZZ = Style(lineColor=4, lineWidth=4, fillColor=4, fillStyle=3013)
sWW = Style(lineColor=3, lineWidth=4, fillColor=4, fillStyle=3013)
sQQ = Style(lineColor=6, lineWidth=4, fillColor=4, fillStyle=3013)
sHiggs = Style(lineColor=2, lineWidth=4, fillStyle=0)
Ejemplo n.º 11
0
denPt1 = ROOT.TH1F(file.Get('h_turnOnPtEtalt1Den'))
numPt1.Sumw2()
numPt1.Divide(denPt1)
numPt1.SetMinimum(0.1)
numPt1.SetMaximum(1.)
sRed.formatHisto( numPt1 )
numPt1.Draw("SAMES")


numPt2 = ROOT.TH1F(file.Get('h_turnOnPtEtalt2'))
denPt2 = ROOT.TH1F(file.Get('h_turnOnPtEtalt2Den'))
numPt2.Sumw2()
numPt2.Divide(denPt2)
numPt2.SetMinimum(0.1)
numPt2.SetMaximum(1.)
sCyan = Style(fillColor=7, markerColor = 7)
sCyan.formatHisto( numPt2 )
numPt2.Draw("SAMES")

numPt3 = ROOT.TH1F(file.Get('h_turnOnPtEtalt3'))
denPt3 = ROOT.TH1F(file.Get('h_turnOnPtEtalt3Den'))
numPt3.Sumw2()
numPt3.Divide(denPt3)
numPt3.SetMinimum(0.1)
numPt3.SetMaximum(1.)
sGreen = Style(fillColor=3, markerColor = 3)
sGreen.formatHisto( numPt3 )
numPt3.Draw("SAMES")

numPt4 = ROOT.TH1F(file.Get('h_turnOnPtEtalt4'))
denPt4 = ROOT.TH1F(file.Get('h_turnOnPtEtalt4Den'))
Ejemplo n.º 12
0
sViolet.lineColor = sViolet.markerColor
styleSet.append(sViolet)
sOrange = Style(fillStyle = 0, lineColor = kOrange, markerColor = kOrange)
styleSet.append(sOrange)
sCyan = Style(fillStyle = 0, lineColor = kCyan, markerColor = kCyan)
styleSet.append(sCyan)
sMagenta = Style(fillStyle = 0, lineColor = kMagenta, markerColor = kMagenta)
styleSet.append(sMagenta)

for style in styleSet :
    style.fillColor = 0
import CMGTools.RootTools.Style as Style


for key in tFile.GetListOfKeys():
    name = key.GetName()
    
    if re.match(histoName, name):
        if first :
            Style.nextStyle().formatHisto( tFile.Get( name ) )
            leg.AddEntry( tFile.Get( name ) )
            tFile.Get( name ).SetTitle(histoName)
            tFile.Get( name ).Draw()
            first = False
        else :
            Style.nextStyle().formatHisto( tFile.Get( name ) )
            tFile.Get( name ).Draw("SAMES")
            leg.AddEntry( tFile.Get( name ) )
    leg.Draw("SAMES")
c0.SaveAs( outputDirName + '/' + histoName + '.png' )