当前位置: 首页>>代码示例>>Python>>正文


Python RooRealVar.frame方法代码示例

本文整理汇总了Python中ROOT.RooRealVar.frame方法的典型用法代码示例。如果您正苦于以下问题:Python RooRealVar.frame方法的具体用法?Python RooRealVar.frame怎么用?Python RooRealVar.frame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ROOT.RooRealVar的用法示例。


在下文中一共展示了RooRealVar.frame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def main():
    # Mjj0 of TT MC Bkg
    f1 = TFile("Merged_TT_TuneCUETP8M1_13TeV-powheg-pythia8-runallAnalysis.root")
    h_Mjj = f1.Get("histfacFatJet_ZLight/h_Mjj0")
    h_Mjj.GetXaxis().SetRangeUser(0,300)
    var_mean = h_Mjj.GetMean()

    # Build Gaussian PDF
    x     = RooRealVar(  'x',     'x',                0, 300 )
    mean  = RooRealVar(  'mean',  'mean of gaussian', var_mean )
    sigma = RooRealVar(  'sigma', 'width of gaussian', 5)
    gauss = RooGaussian( 'gauss', 'gaussian PDF', x, mean, sigma)
    data  = RooDataHist("data","Mjj dataset",RooArgList(x), h_Mjj);
    
    # Plot PDF
    xframe = x.frame(RooFit.Title("Gaussian p.d.f."))
    gauss.plotOn( xframe )
    gauss.plotOn(xframe,RooFit.LineColor(2)) 
    
    # Generate a toy MC set
    # data = gauss.generate( RooArgSet(x), 10000 )
    # Plot PDF and toy data overlaid
    xframe2 = x.frame(RooFit.Title("Gaussian p.d.f. with Mjj"))
    # data.plotOn( xframe2, RooLinkedList() )
    # data.plotOn( xframe2 )
    data.plotOn( xframe2 )
    gauss.plotOn( xframe2)
    # Fit PDF to toy
    mean.setConstant( kFALSE )
    sigma.setConstant( kFALSE )
    gauss.fitTo(data)
    
    c1 = TCanvas("c1","Example",800,400)
    c1.Divide(3)
    c1.cd(1)
    gPad.SetLeftMargin(0.15)
    xframe.GetYaxis().SetTitleOffset(1.6)
    xframe.Draw()
    
    c1.cd(2)
    gPad.SetLeftMargin(0.15)
    xframe2.GetYaxis().SetTitleOffset(1.6)
    xframe2.Draw() 

    c1.SaveAs('testMjj0.png')
    
    # # Print final value of parameters
    fout = TFile("output.root","recreate")
    c1.Write()
    fout.Close()
开发者ID:fyingtsai,项目名称:Fitting,代码行数:52,代码来源:test.py

示例2: plotPDF

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def plotPDF():


    gStyle.SetOptFit(1111)
    x_var = 'Tau_DTF_Phi_M' #'Phi_M'
    #x_var = 'Phi_M'
    x = RooRealVar(x_var, 'm_{#Phi}', 1008,1032, 'MeV')
    x = RooRealVar(x_var, 'm_{#Phi}', 0,10, 'MeV')
    
#    mean = RooRealVar("#mu","#mu",1020,1010,1025)
    mean = RooRealVar("#mu","#mu",5) 
    gamma = RooRealVar("#Gamma_{0}","#Gamma",3,0.1,10)
    spin = RooRealVar("J","J",1)
    radius = RooRealVar("radius","radius",0.003)#, 0, 0.01)
#    m_K = RooRealVar("m_K","m_K", 493.677)
    m_K = RooRealVar("m_K","m_K", 0.5)
    NRBW = ROOT.RooBreitWigner('BW','BW',x,mean, gamma)
    RBW = ROOT.RooRelBreitWigner('BW','BW',x,mean, gamma,spin,radius,m_K,m_K)

    frame = x.frame(RooFit.Title('Breit Wigner'))
    NRBW.plotOn(frame, RooFit.LineWidth(2),RooFit.LineColor(ROOT.kRed), RooFit.LineStyle(1))
    RBW.plotOn(frame, RooFit.LineWidth(2),RooFit.LineColor(ROOT.kBlue), RooFit.LineStyle(2))

    c1 = TCanvas('c1', 'c1')
    frame.Draw()
    c1.Update()

    return c1
开发者ID:gdujany,项目名称:tau2PhiMuAnalysis,代码行数:30,代码来源:phiStudies.py

示例3: main

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def main():
    # independent variable
    x = RooRealVar("x", "x", -10, 10)

    # parameters
    width = RooRealVar("width", "gaussian width", 2.,   0., 10.)
    mean  = RooRealVar("mean",  "gaussian mean",  0., -10., 10.)
    decay = RooRealVar("decay", "decay coeff",   -0.5, -1.0, 0.)

    # instantiate the custom pdf
    pdf = RooExpAndGauss("pdf", "custom pdf", x, mean, width, decay)

    # generate random dataset
    toydata = pdf.generate(RooArgSet(x), 5000)

    # fit back to the dataset (I expect it will fit quite well!)
    pdf.fitTo(toydata, rf.Strategy(2))

    # plot the thing
    canvas = TCanvas()
    plot = x.frame(50)
    toydata.plotOn(plot)
    pdf.plotOn(plot)
    plot.Draw()
    canvas.SaveAs("plots/fittedRooExpAndGauss_fromPython.pdf")

    return
开发者ID:samcunliffe,项目名称:CustomRooFit,代码行数:29,代码来源:generate.py

示例4: doMCFit

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def doMCFit(dataSet, x_var, addTitlePlot=''):  
    
    cuts_str = ''
    data = dataSet.reduce( RooFit.Cut(cuts_str) )

    x=RooRealVar(x_var, 'm_{#tau}',1757,1797,'MeV')
    numBins = 100 # define here so that if I change it also the ndof change accordingly
    x.setBins(numBins)

    ######################################################
    # DEFINE PDF
    ######################################################
    
    w = RooWorkspace('w')
    getattr(w,'import')(x)
    w.factory('''RooDSCBShape::DSCB({0},
    #mu[1777, 1760,1790],
    #sigma[5,0,10],
    #alpha[1.2], n[50, 1, 150],
    #alpha, n
    )'''.format(x_var))
    #w.var('n').setConstant(False)
    signal = w.pdf('DSCB')
    # w.factory('''RooGaussian::GG({0},
    # #mu, #sigma
    # )'''.format(x_var))
    # signal = w.pdf('GG')
  
    # Fit
    fit_region = x.setRange('fit_region',1757,1797)
    result = signal.fitTo(dataSet, RooFit.Save(), RooFit.Range('fit_region'))

    # Frame
    frame = x.frame(RooFit.Title(' Combined mass KK#mu '+addTitlePlot))
    dataSet.plotOn(frame)
    signal.plotOn(frame, RooFit.LineWidth(2))

    # Legends
    signal.paramOn(frame, RooFit.Layout(0.6,0.9,0.9))
    chi2 = round(frame.chiSquare(),2)
    leg = TLegend(0.3,0,.10,.10)
    leg.SetBorderSize(0)
    leg.SetFillStyle(0)
    leg.AddEntry(0,'#chi^{2} ='+str(chi2),'')
    frame.addObject(leg)

    c1 = TCanvas('c1', 'c1')
    frame.Draw()
    c1.Update()

    for prm in ('#mu', '#sigma', '#alpha', 'n'): # TODO: automatize finding of variables from the function
        w.var(prm).setConstant()
    
    return w, c1
开发者ID:gdujany,项目名称:tau2PhiMuAnalysis,代码行数:56,代码来源:mcFit.py

示例5: saveLandauHistoSignalToNoise

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def saveLandauHistoSignalToNoise(histo,outfile,canvas,XaxisTitle="",YaxisTitle="",plotTitle="",stats=0):
	ex = "Null Fit"
	signal_to_noise = RooRealVar("signal_to_noise", "Signal to Noise", 0, 50)
	landau_data = RooDataHist("landau_data", "landau_data", RooArgList(signal_to_noise), histo)

	ml = RooRealVar("ml","mean landau",25, 20, 26)
	sl = RooRealVar("sl","sigma landau", 5, 2, 10)
	landau = RooLandau("lx","lx",signal_to_noise,ml,sl)
  
	mg = RooRealVar("mg","mg",0) ;
	sg = RooRealVar("sg","sg", 2, 1, 8)
	gauss = RooGaussian("gauss","gauss",signal_to_noise,mg,sg)

	lxg = RooNumConvPdf("lxg", "lxg", signal_to_noise, landau, gauss)

	result = lxg.fitTo(landau_data)

	frame = signal_to_noise.frame()
	landau_data.plotOn(frame)

	lxg.plotOn(frame)

	frame.Draw("")
	frame.SetTitle(plotTitle)
	frame.GetXaxis().SetTitle(XaxisTitle)
	frame.GetYaxis().SetTitle(YaxisTitle)
	frame.SetStats(stats)
	frame.Write(plotTitle)

	canvas.Print(outfile+".pdf")

	peak = []
	
	try:
		mean = RooRealVar(result.floatParsFinal().find("landau_mean"))
		err = RooRealVar(mean.errorVar())
		peak.append(mean.GetVal())
		peak.append(err.GetVal())
	except Exception as ex:
		print(ex)
		peak.append(0)
		peak.append(0)

	return peak
开发者ID:JeffersonLab,项目名称:HPS-CODE,代码行数:46,代码来源:MakeClusterPlots.py

示例6: test_plot

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def test_plot():
    c = TCanvas('c', 'canvas', 300, 300)

    x = RooRealVar("x","x",-10,10)
    mean = RooRealVar("mean","mean of gaussian",1,-10,10) 
    sigma = RooRealVar("sigma","width of gaussian",1,0.1,10)

    gauss = RooGaussian("gauss","gaussian PDF",x,mean,sigma) 

    xframe = x.frame(RooFit.Title("Gaussian p.d.f."))
    #gauss.plotOn(xframe)
    sigma.setVal(3)
    
    as_x = RooArgSet(x)
    data = gauss.generate(as_x,10000)
    data.plotOn(xframe, RooFit.MarkerSize(0.6), RooFit.MarkerStyle(20)) 
    xframe.Draw()

    pdffile = 'test.pdf'
    c.SaveAs(pdffile)
开发者ID:cms-bph,项目名称:BToKstarMuMu,代码行数:22,代码来源:__init__.py

示例7: dump_simple

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def dump_simple():
    # try poisson
    roo_lam = RooRealVar("lambda", ".", lam, 0.0, 1.5)
    roo_x = RooRealVar('x', 'x range', 0, bins)

    model = RooPoisson("poisson", "Poisson Model", roo_x, roo_lam)

    #data = model.generate(RooArgSet(roo_x), n_events)

    data = RooDataSet('data', 'Data', RooArgSet(roo_x))
    for val in unbinned_from_binned(xdata, ydata):
        roo_x.setVal(val)
        data.add(RooArgSet(roo_x))

    #// --- Perform extended ML fit of composite PDF to toy data ---
    fitresult = model.fitTo(data, RooFit.Save(), RooFit.PrintLevel(-1)) ;

    #// --- Plot toy data and composite PDF overlaid ---
    mesframe = roo_x.frame(bins) ;
    data.plotOn(mesframe) ;
    model.plotOn(mesframe) ;
    mesframe.Draw()
开发者ID:mokapharr,项目名称:diploma-thesis-code,代码行数:24,代码来源:roofit_simple.py

示例8: studyVqqResolution

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
def studyVqqResolution(rootFile):

    #get all from file
    histos={}
    inF=TFile.Open(rootFile)
    keys=inF.GetListOfKeys()
    for k in keys:
        obj=inF.Get(k.GetName())
        obj.SetDirectory(0)
        histos[k.GetName()]=obj
    inF.Close()

    #plot
    gROOT.SetBatch()
    gROOT.SetStyle('Plain')
    gStyle.SetOptStat(0)
    gStyle.SetOptFit(1111)
    gStyle.SetOptTitle(0)
    gStyle.SetStatFont(42)

    kin=['','30to40','40to50','50to75','75to100','100toInf']
    for k in kin:        
        c=TCanvas('c','c',600,600)
        c.cd()
        c.SetCanvasSize(1000,500)
        c.SetWindowSize(1000,500)
        c.Divide(2,1)
        c.cd(1)
        histos['deta'+k+'barrel'].SetLineWidth(2)
        histos['deta'+k+'barrel'].SetTitle('barrel')
        histos['deta'+k+'barrel'].Draw('hist')
        histos['deta'+k+'endcap'].SetLineWidth(2)
        histos['deta'+k+'endcap'].SetLineStyle(7)
        histos['deta'+k+'endcap'].SetTitle('endcap')
        histos['deta'+k+'endcap'].Draw('histsame')
        leg=TLegend(0.6,0.92,0.9,0.98)
        leg.SetFillStyle(0)
        leg.SetBorderSize(0)
        leg.SetTextFont(42)
        leg.AddEntry(histos['deta'+k+'barrel'],'barrel','f')
        leg.AddEntry(histos['deta'+k+'endcap'],'endcap','f')
        leg.SetNColumns(2)
        leg.Draw()
        drawHeader()
        c.cd(2)
        histos['dphi'+k+'barrel'].SetLineWidth(2)
        histos['dphi'+k+'barrel'].SetTitle('barrel')
        histos['dphi'+k+'barrel'].Draw('hist')
        histos['dphi'+k+'endcap'].SetLineWidth(2)
        histos['dphi'+k+'endcap'].SetLineStyle(7)
        histos['dphi'+k+'endcap'].SetTitle('endcap')
        histos['dphi'+k+'endcap'].Draw('histsame')
        c.Modified()
        c.Update()
        c.SaveAs('dr_%s.png'%k)


    labels=[]
    responseVars=['dpt','den','dphi','deta','dr']
    for r in responseVars:
        barrelResponse=TGraphErrors()
        barrelResponse.SetName(r+'barrelresponse')
        barrelResponse.SetLineWidth(2)
        barrelResponse.SetFillStyle(0)
        barrelResponse.SetMarkerStyle(20)
        barrelCoreResponse=barrelResponse.Clone(r+'barrelcoreresponse')
        endcapResponse=TGraphErrors()
        endcapResponse.SetName(r+'endcapresponse')
        endcapResponse.SetLineWidth(2)
        endcapResponse.SetFillStyle(0)
        endcapResponse.SetMarkerStyle(24)
        endcapCoreResponse=endcapResponse.Clone(r+'endcapresponse')
        for k in kin: 
            c.cd()
            c.Clear()
            c.SetWindowSize(1000,500)
            c.Divide(2,1)
            for i in [1,2] :
                c.cd(i)
                reg='barrel'
                if i==2: reg='endcap' 

                h=histos[r+k+reg]
                x=RooRealVar("x", h.GetXaxis().GetTitle(), h.GetXaxis().GetXmin(), h.GetXaxis().GetXmax())
                data=RooDataHist("data", "dataset with x", RooArgList(x), h)
                frame=x.frame()
                RooAbsData.plotOn( data, frame, RooFit.DataError(RooAbsData.SumW2) )

                mean1=RooRealVar("mean1","mean1",0,-0.5,0.5);
                sigma1=RooRealVar("sigma1","sigma1",0.1,0.01,1.0);
                gauss1=RooGaussian("g1","g",x,mean1,sigma1)
                
                if r=='dpt' or r=='den' :
                    mean2=RooRealVar("mean2","mean2",0,-0.5,0.5);
                    sigma2=RooRealVar("sigma2","sigma2",0.1,0.01,1.0);
                    alphacb=RooRealVar("alphacb","alphacb",1,0.1,3);
                    ncb=RooRealVar("ncb","ncb",4,1,100)
                    gauss2 = RooCBShape("cb2","cb",x,mean2,sigma2,alphacb,ncb);
                else:
                    mean1.setRange(0,0.5)
#.........这里部分代码省略.........
开发者ID:UMN-CMS,项目名称:PFCal,代码行数:103,代码来源:studyVqqResolution.py

示例9: TFile

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
if args[0].startswith('MC'):
    from ROOT import TFile
    sig_file = TFile(input_data['sig_cache'])
    sig_data = sig_file.Get(input_data['sig_dataset'])
    prompt_file = TFile(input_data['prompt_cache'])
    prompt_data = prompt_file.Get(input_data['prompt_dataset'])
else:
    sig_file = TFile("/project/bfys/jleerdam/data/Bs2Jpsiphi/Reco14/fitNTuple_peakBkg_2011_2012_Reco14_TOS_HLT2B_20140415.root")
    sig_tree = sig_file.Get("DecayTree")
    period = 'p' + args[0][:4]
    sig_data = RooDataSet('sig_data', 'sig_data', RooArgSet(momentum, weight, runPeriod),
                          RooFit.Import(sig_tree), RooFit.WeightVar(weight),
                          RooFit.Cut('runPeriod == runPeriod::%s' % period))

    from ROOT import TFile
    prompt_file = TFile(input_data['cache'])
    prompt_data = prompt_file.Get(input_data['dataset'])

    
from ROOT import TCanvas
canvas = TCanvas('momentum_canvas', 'momentum_canvas', 600, 400)
canvas.SetLogy()
frame = momentum.frame(Range = (0, 500000))
from ROOT import kBlue, kGreen
sig_data.plotOn(frame, Rescale = (1 / sig_data.sumEntries()), MarkerColor = kBlue)
prompt_data.plotOn(frame, Rescale = (1 / prompt_data.sumEntries()), MarkerColor = kGreen)
frame.GetXaxis().SetTitle("P_{B} [MeV]")
frame.GetYaxis().SetTitle("scaled candidates")
frame.GetYaxis().SetRangeUser(0.00005, 0.1)
frame.Draw()
开发者ID:GerhardRaven,项目名称:P2VV,代码行数:32,代码来源:plot_momentum.py

示例10: doDataFit

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]

#.........这里部分代码省略.........
    else:
        parameters.add(RooArgSet(alpha, beta, q0))

    #together
    chibs = RooArgList(chib1_pdf,chib2_pdf,background)    
    
    # ndof
    floatPars = parameters.selectByAttrib("Constant",ROOT.kFALSE)
    ndof = numBins - floatPars.getSize() - 1

    # # Here I have as parameters N1, N2, and N_background
    # n_chib1 = RooRealVar("n_chib1","n_chib1",1250, 0, 50000)
    # n_chib2 =  RooRealVar("n_chib2","n_chib2",825, 0, 50000)
    # n_background = RooRealVar('n_background','n_background',4550, 0, 50000)
    # ratio_list = RooArgList(n_chib1, n_chib2, n_background)
    # modelPdf = RooAddPdf('ModelPdf', 'ModelPdf', chibs, ratio_list)

    # Here I have as parameters N_12, ratio_12, N_background
    n_chib = RooRealVar("n_chib","n_chib",2075, 0, 100000)
    ratio_21 = RooRealVar("ratio_21","ratio_21",0.6, 0, 1)
    n_chib1 = RooFormulaVar("n_chib1","@0/([email protected])",RooArgList(n_chib, ratio_21))
    n_chib2 = RooFormulaVar("n_chib2","@0/(1+1/@1)",RooArgList(n_chib, ratio_21))
    n_background = RooRealVar('n_background','n_background',4550, 0, 50000)
    ratio_list = RooArgList(n_chib1, n_chib2, n_background)
    parameters.add(RooArgSet(n_chib1, n_chib2, n_background))
    modelPdf = RooAddPdf('ModelPdf', 'ModelPdf', chibs, ratio_list)
    
    print 'Fitting to data'
    fit_region = x.setRange("fit_region",9.7,10.1)
    result=modelPdf.fitTo(data,RooFit.Save(), RooFit.Range("fit_region"))
    
        
    # define frame
    frame = x.frame()
    frame.SetNameTitle("fit_resonance","Fit Resonanace")
    frame.GetXaxis().SetTitle(x_axis_label )
    frame.GetYaxis().SetTitle( "Events/5 MeV " )
    frame.GetXaxis().SetTitleSize(0.04)
    frame.GetYaxis().SetTitleSize(0.04)
    frame.GetXaxis().SetTitleOffset(1.1)
    frame.GetXaxis().SetLabelSize(0.04)
    frame.GetYaxis().SetLabelSize(0.04)
    frame.SetLineWidth(1)
    frame.SetTitle(plotTitle) 
    
    # plot things on frame
    data.plotOn(frame, RooFit.MarkerSize(0.7))
    chib1P_set = RooArgSet(chib1_pdf)
    modelPdf.plotOn(frame,RooFit.Components(chib1P_set), RooFit.LineColor(ROOT.kGreen+2), RooFit.LineStyle(2), RooFit.LineWidth(1))
    chib2P_set = RooArgSet(chib2_pdf)
    modelPdf.plotOn(frame, RooFit.Components(chib2P_set),RooFit.LineColor(ROOT.kRed), RooFit.LineStyle(2), RooFit.LineWidth(1))
    background_set =  RooArgSet(background)
    modelPdf.plotOn(frame,RooFit.Components(background_set), RooFit.LineColor(ROOT.kBlack), RooFit.LineStyle(2), RooFit.LineWidth(1))
    modelPdf.plotOn(frame, RooFit.LineWidth(2))
    frame.SetName("fit_resonance")  

    # Make numChib object
    numChib = NumChib(numChib=n_chib.getVal(), s_numChib=n_chib.getError(), ratio_21=ratio_21.getVal(), s_ratio_21=ratio_21.getError(), numBkg=n_background.getVal(), s_numBkg=n_background.getError(), corr_NB=result.correlation(n_chib, n_background),corr_NR=result.correlation(n_chib, ratio_21) , name='numChib'+output_suffix+ptBin_label,q0=q0.getVal(),s_q0=q0.getError(),alpha=alpha.getVal(),s_alpha=alpha.getError(), beta=beta.getVal(), s_beta=beta.getError(), chiSquare=frame.chiSquare())
    #numChib.saveToFile('numChib'+output_suffix+'.txt')

    if noPlots:
        chi2 = frame.chiSquare()
        del frame
        return numChib, chi2
    
    # Legend
开发者ID:gdujany,项目名称:chibAnalysis,代码行数:70,代码来源:dataFit.py

示例11: FitStatus

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
from helpers import FitStatus
print FitStatus(fitresult.status())


## Plot results
# # Use when debugging plots
# dataset = dataset.reduce(RooFit.EventRange(0, 100))

# reduce precision otherwise plotting doesn't work
time.setRange('fullrange', epsilon, 15.0)
RooAbsReal.defaultIntegratorConfig().setEpsAbs(1e-5)
RooAbsReal.defaultIntegratorConfig().setEpsRel(1e-5)

dkcatset = RooArgSet(decaycat)
tframe1 = time.frame(RooFit.Range(0., time.getMax()), RooFit.Name('ptime'),
                     RooFit.Title('Ds#pi - powerlaw, DsK - powerlaw * %s ratio' %
                                  ratiofn))
dsetlist[0].plotOn(tframe1, RooFit.MarkerStyle(kOpenTriangleDown))
DsPi_Model.plotOn(tframe1, RooFit.LineColor(kBlue))
dsetlist[1].plotOn(tframe1, RooFit.MarkerStyle(kFullTriangleUp))
DsK_Model.plotOn(tframe1, RooFit.LineColor(kBlue+2))
# PDF.plotOn(tframe1, RooFit.Slice(decaycat, 'DsPi'),
#            RooFit.ProjWData(dkcatset, dataset, True),
#            RooFit.LineColor(kBlue))
# PDF.plotOn(tframe1, RooFit.Slice(decaycat, 'DsK'),
#            RooFit.ProjWData(dkcatset, dataset, True),
#            RooFit.LineColor(kBlue+2))
Bdecay.plotOn(tframe1, RooFit.LineColor(kRed))
dspi_acceptance.plotOn(tframe1, RooFit.LineColor(kGreen),
                       RooFit.Normalization(500, RooAbsReal.Relative))
dsk_acceptance.plotOn(tframe1, RooFit.LineColor(kGreen+2),
开发者ID:suvayu,项目名称:Bs2DsKTools,代码行数:33,代码来源:ltFit.py

示例12: RooWorkspace

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
                  pedCut, 'goff')

    pedhist = gDirectory.Get('pedhist')
    ws = RooWorkspace('ws')
    x = RooRealVar('x', 'energy', minPed, maxPed, 'fC')
    x.Print()

    ds = fillDataSet(dataTree.GetV1(), x, dataTree.GetSelectedRows())
    getattr(ws, 'import')(ds)
    findOnePe(pedhist, ws, Npe=opts.npe)

    pedPlusOne = ws.pdf('pedPlusOne')
    peMean = ws.var('peMean')
    pedMean = ws.var('pedMean')
    ## pedhist.Draw()
    ## onePeF.Draw('same')

    xf = x.frame(x.getMin(), x.getMax(), int(x.getMax()-x.getMin()))
    ds.plotOn(xf)
    pedPlusOne.plotOn(xf) #,
                      #RooFit.Range('pedPlus_fit'))
    pedPlusOne.plotOn(xf, #RooFit.Range('pedPlus_fit'),
                      RooFit.Components("bg*"),
                      RooFit.LineColor(kRed),
                      RooFit.LineStyle(kDashed))
    xf.Draw()
    gPad.Update()

    print '\nsingle fC/pe for HO ({0}, {1}):'.format(opts.eta, opts.phi),\
          '{0:0.3f} +/- {1:0.3f}'.format(peMean.getVal(), peMean.getError())
开发者ID:mendezdpatricia,项目名称:usercode,代码行数:32,代码来源:pedRoutines.py

示例13: mbc_single_3s

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]

#.........这里部分代码省略.........
    MINUIT = 'ermh4'

    if err_type == 'ASYM':
        MINUIT = 'erh4'
        
    if test:
        sys.stdout.write('Will save epsfile as: %s \n' %epsfile)
        sys.stdout.write('Will save txtfile as: %s \n' %txtfile)
        return
    
    if dataset.numEntries() == 0:
        N1.setVal(0)
        N2.setVal(0)
    else:
        # Start Fitting
        fitres = totalPdf.fitTo(dataset, MINUIT)
        fitres.Print('v')

    # Save plots
    canvas = TCanvas('canvas','mbc', 1200, 400);
    canvas.Divide(3,1)

    canvas_1 = canvas.GetListOfPrimitives().FindObject('canvas_1')
    canvas_2 = canvas.GetListOfPrimitives().FindObject('canvas_2')
    canvas_1.SetLogy(1) 
    canvas_2.SetLogy(1)

    LineColorRed = RooFit.LineColor(kRed)
    LineColorBlue = RooFit.LineColor(kBlue)
    LineWidth = RooFit.LineWidth(1) #0.6)

    # Plot the D 
    canvas.cd(1)
    mbcFrame=mbc.frame()
    mbcFrame=mbc.frame(60)

    dflav.setLabel('dflav')
    ebas = RooArgSet(ebeam, dflav)
    ebeamdata = RooDataHist("ebeamdata", "ebeamdata", ebas, dataset)
    
    dataset.plotOn(mbcFrame, RooFit.Cut("dflav==dflav::dflav"))
    mbcFrame.getAttMarker().SetMarkerSize(0.6)
    mbcFrame.Draw()

    Slice = RooFit.Slice(dflav)
    ProjWData = RooFit.ProjWData(ebas, ebeamdata)
    
    totalPdf.plotOn(mbcFrame, LineColorRed, LineWidth, Slice, ProjWData)
    chisq1 = mbcFrame.chiSquare()*mbcFrame.GetNbinsX()
    mbcFrame.Draw()

    as_bkg1 = RooArgSet(Bkgd1)
    cp_bkg1 = RooFit.Components(as_bkg1)

    totalPdf.plotOn(mbcFrame, cp_bkg1, Slice, LineColorBlue, LineWidth, ProjWData)

    mbcFrame.SetTitle(title1)
    mbcFrame.SetMinimum(ymin)

    mbcFrame.Draw()

    # Plot the D bar
    canvas.cd(2)
    mbcFrame=mbc.frame()
    mbcFrame=mbc.frame(60)
开发者ID:xshi,项目名称:dhad,代码行数:69,代码来源:fits.py

示例14: RooRealVar

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
x = RooRealVar('mjj','mjj',900,4500)
NBINS = 180
p1 = RooRealVar('p1','p1',5,0,20)
p2 = RooRealVar('p2','p2',5,0,20)
p3 = RooRealVar('p3','p3',0.1,0,1)

model = RooGenericPdf('model','pow([email protected]/8000,@1)/pow(@0/8000,@[email protected]*log(@0/8000))',RooArgList(x,p1,p2,p3))
roohist = RooDataHist('roohist','roohist',RooArgList(x),h)
res = model.fitTo(roohist)


can = TCanvas('can_Mjj_Data','can_Mjj_Data',900,600)
gPad.SetLogy() 
can.cd(1).SetBottomMargin(0.4);

frame1 = x.frame()
frame2 = x.frame();
roohist.plotOn(frame1,RooFit.Binning(NBINS))
model.plotOn(frame1)
hpull = frame1.pullHist();
frame2.addPlotable(hpull,'p');

frame1.SetMinimum(0.5)
frame1.GetXaxis().SetTitle('')
frame1.GetXaxis().SetLabelSize(0.0)
frame1.GetYaxis().SetTickLength(0.06)
frame1.Draw()

pad = TPad('pad','pad',0.,0.,1.,1.);
pad.SetTopMargin(0.6);
pad.SetFillColor(0);
开发者ID:nhanvtran,项目名称:cmsdas2014,代码行数:33,代码来源:FitData.py

示例15: fitTo

# 需要导入模块: from ROOT import RooRealVar [as 别名]
# 或者: from ROOT.RooRealVar import frame [as 别名]
    # DAS_EX_2.7
    # Using the fitTo() method of the PDF, fit the data with each function
    # Pass the option RooFit.Save(True) to the fitTo method, and save each result in the roores dictionary:
    roores[func] = pdfs[func].fitTo(rdata, RooFit.Save(True))

#########################
# Make Plots
#########################

# Define canvas
cname = "bkgfit_"+str(nj)+"jet"
canv  = TCanvas(cname,cname,400,424)

# Define RooPlot
nbins = int((ranges["fit","hi"]-ranges["fit","lo"])/binWidth)
rooplot = st.frame(ranges["fit","lo"] ,  ranges["fit","hi"], nbins)
# Add data to plot
rdata.plotOn(rooplot, RooFit.Invisible())

# Add fit functions to plot
for func in ["f1", "f2", "f3"]:
    pdfs[func] .plotOn(rooplot, RooFit.LineColor(fitFuncs[func,"col"]))
    rdata.plotOn(rooplot)

# Draw RooPlot
rooplot.Draw()

############################
# Make legend/text and save plot
############################
开发者ID:TENorbert,项目名称:SUSY-TOOLS,代码行数:32,代码来源:bkgfit_das.py


注:本文中的ROOT.RooRealVar.frame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。