コード例 #1
0
ファイル: Ratio.py プロジェクト: perrozzi/gen_ana
def getRatio(hist,reference,min,max,yTitle="",maxUncertainty = 100.,restrict=True):
    from ROOT import gROOT
    theHist, theReference = renewHist(hist,reference,min,max)
    ROOT.gSystem.Load('./tools/Ratio_C.so') 
    from ROOT import coolRatio
    thePlotter = coolRatio()
    theRatio = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,0)
    refError = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,1)
    theRatio.GetXaxis().SetRangeUser(min,max)
    if restrict:
        #theRatio.SetMinimum(0.01)
        #theRatio.SetMaximum(2.49)
        theRatio.SetMinimum(0.7)
        theRatio.SetMaximum(1.3)
    else:
        theRatio.SetMinimum(int(theRatio.GetMinimum()))
        theRatio.SetMaximum(int(theRatio.GetMaximum()*1.5))
    #theRatio.GetYaxis().SetNdivisions(104)
    theRatio.GetYaxis().SetNdivisions(505)
    theRatio.GetYaxis().SetTitle("Ratio")
    theRatio.GetYaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetYaxis().SetTitleOffset(0.6)
    theRatio.GetYaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetXaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetXaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetYaxis().SetTitleOffset(0.4)
    theRatio.GetYaxis().CenterTitle(ROOT.kTRUE)
    theRatio.GetYaxis().SetDrawOption("M")
    theRatio.SetXTitle(yTitle)
    theRatio.SetYTitle("ratio")
    return theRatio, refError
コード例 #2
0
def getRatio(hist,reference,min,max,yTitle="",maxUncertainty = 1000.000,restrict=True):
    from ROOT import gROOT,gSystem
    theHist, theReference = renewHist(hist,reference,min,max)
    try:
        from ROOT import coolRatio
    except ImportError:
        gROOT.ProcessLine('.L $CMSSW_BASE/src/Xbb/python/myutils/Ratio.C')
        from ROOT import coolRatio
    thePlotter = coolRatio()
    theRatio = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,0)
    refError = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,1)
    theRatio.GetXaxis().SetRangeUser(min,max)
    print "theRation: range",min," ",max
    #theRatio.GetXaxis().SetRangeUser(0,1)
    if restrict:
        theRatio.SetMinimum(0.5)
        theRatio.SetMaximum(1.75)
    else:
        theRatio.SetMinimum(int(theRatio.GetMinimum()))
        theRatio.SetMaximum(int(theRatio.GetMaximum()*1.5))
    #theRatio.GetYaxis().SetNdivisions(104)
    theRatio.GetYaxis().SetNdivisions(505)
    theRatio.GetYaxis().SetTitle("Ratio")
    theRatio.GetYaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetYaxis().SetTitleOffset(0.6)
    theRatio.GetYaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetXaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetXaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetYaxis().SetTitleOffset(0.4)
    theRatio.GetYaxis().CenterTitle(ROOT.kTRUE)
    theRatio.GetYaxis().SetDrawOption("M")
    theRatio.SetXTitle(yTitle)
    theRatio.SetYTitle("Data/MC")
    return theRatio, refError
コード例 #3
0
def getRatio(hist,reference,min,max,yTitle="",maxUncertainty = 1000.000,restrict=True):
    from ROOT import gROOT
    theHist, theReference = renewHist(hist,reference,min,max)
    ROOT.gSystem.Load('./myutils/Ratio_C.so') 
    from ROOT import coolRatio
    thePlotter = coolRatio()
    theRatio = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,0)
    refError = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,1)
    theRatio.GetXaxis().SetRangeUser(min,max)
    if restrict:
        theRatio.SetMinimum(0.01)
        theRatio.SetMaximum(2.49)
        #theRatio.SetMinimum(0.35)
        #theRatio.SetMaximum(1.8)
    else:
        theRatio.SetMinimum(int(theRatio.GetMinimum()))
        theRatio.SetMaximum(int(theRatio.GetMaximum()*1.5))
    #theRatio.GetYaxis().SetNdivisions(104)
    theRatio.GetYaxis().SetNdivisions(505)
    theRatio.GetYaxis().SetTitle("Ratio")
    theRatio.GetYaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetYaxis().SetTitleOffset(0.6)
    theRatio.GetYaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetXaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetXaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetYaxis().SetTitleOffset(0.4)
    theRatio.GetYaxis().CenterTitle(ROOT.kTRUE)
    theRatio.GetYaxis().SetDrawOption("M")
    theRatio.SetXTitle(yTitle)
    theRatio.SetYTitle("Data/MC")
    return theRatio, refError
コード例 #4
0
ファイル: Ratio.py プロジェクト: GLP90/Xbb_Mjj
def getRatio(hist,
             reference,
             min,
             max,
             yTitle="",
             maxUncertainty=1000.000,
             restrict=True):

    from ROOT import gROOT

    theHist, theReference = renewHist(hist, reference, min, max)
    #ROOT.gSystem.Load('./myutils/Ratio_C.so')
    ROOT.gSystem.Load(
        '/afs/cern.ch/work/d/dcurry/public/bbar_heppy/CMSSW_7_4_7/src/VHbb/python/myutils/Ratio_C.so'
    )
    #ROOT.gSystem.Load('/afs/cern.ch/work/d/dcurry/public/v25Heppy/CMSSW_7_4_7/src/VHbb/python/myutils/Ratio_C.so')

    from ROOT import coolRatio

    thePlotter = coolRatio()
    theRatio = thePlotter.make_rebinned_ratios(theHist, theReference,
                                               maxUncertainty, False, 0)
    refError = thePlotter.make_rebinned_ratios(theHist, theReference,
                                               maxUncertainty, False, 1)
    theRatio.GetXaxis().SetRangeUser(min, max)
    if restrict:
        theRatio.SetMinimum(0.0)
        theRatio.SetMaximum(1.99)
        #theRatio.SetMinimum(0.5)
        #theRatio.SetMaximum(1.74)
    else:
        theRatio.SetMinimum(int(theRatio.GetMinimum()))
        theRatio.SetMaximum(int(theRatio.GetMaximum() * 1.5))
    #theRatio.GetYaxis().SetNdivisions(104)
    theRatio.GetYaxis().SetNdivisions(505)
    theRatio.GetYaxis().SetTitle("Ratio")
    theRatio.GetYaxis().SetTitleSize(ROOT.gStyle.GetTitleSize() * 2.2)
    theRatio.GetYaxis().SetTitleOffset(0.6)
    theRatio.GetYaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetXaxis().SetTitleSize(ROOT.gStyle.GetTitleSize() * 2.2)
    theRatio.GetXaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetYaxis().SetTitleOffset(0.4)
    theRatio.GetYaxis().CenterTitle(ROOT.kTRUE)
    theRatio.GetYaxis().SetDrawOption("M")
    theRatio.SetXTitle(yTitle)
    theRatio.SetYTitle("Data/MC")
    return theRatio, refError
コード例 #5
0
ファイル: Ratio.py プロジェクト: dcurry09/Heppy
def getRatio(hist, reference, min, max, yTitle="", maxUncertainty = 1000.000, restrict=True):

    from ROOT import gROOT
   
    theHist, theReference = renewHist(hist, reference, min, max)
    #ROOT.gSystem.Load('./myutils/Ratio_C.so') 
    ROOT.gSystem.Load('/afs/cern.ch/work/d/dcurry/public/bbar_heppy/CMSSW_7_1_5/src/VHbb/python/myutils/Ratio_C.so')

    from ROOT import coolRatio

    thePlotter = coolRatio()
    theRatio = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,0)
    refError = thePlotter.make_rebinned_ratios(theHist,theReference,maxUncertainty,False,1)
    theRatio.GetXaxis().SetRangeUser(min,max)
    if restrict:
        #theRatio.SetMinimum(0.01)
        #theRatio.SetMaximum(2.49)
        theRatio.SetMinimum(0.5)
        theRatio.SetMaximum(1.75)
    else:
        theRatio.SetMinimum(int(theRatio.GetMinimum()))
        theRatio.SetMaximum(int(theRatio.GetMaximum()*1.5))
    #theRatio.GetYaxis().SetNdivisions(104)
    theRatio.GetYaxis().SetNdivisions(505)
    theRatio.GetYaxis().SetTitle("Ratio")
    theRatio.GetYaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetYaxis().SetTitleOffset(0.6)
    theRatio.GetYaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetXaxis().SetTitleSize(ROOT.gStyle.GetTitleSize()*2.2)
    theRatio.GetXaxis().SetLabelSize(ROOT.gStyle.GetLabelSize() * 2.2)
    theRatio.GetYaxis().SetTitleOffset(0.4)
    theRatio.GetYaxis().CenterTitle(ROOT.kTRUE)
    theRatio.GetYaxis().SetDrawOption("M")
    theRatio.SetXTitle(yTitle)
    theRatio.SetYTitle("Data/MC")
    return theRatio, refError