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


Python ROOT.RooRealVar类代码示例

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


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

示例1: plotPDF

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,代码行数:28,代码来源:phiStudies.py

示例2: NEvtsCalc

def NEvtsCalc( uPars, uEPars):
	Pars 			= {}
	Pars[0]			= RooRealVar('c1', 'Exponential constant', -1, -10, 0)
	Pars[1] 		= RooRealVar('ExpY', 'Background Yield', 100, 0, 10000000)
	Pars[2]			= RooRealVar('Mean', 'Voigtian Mean' , 90.0, 20, 180.0)
	Pars[3]			= RooRealVar('Width', 'Voigtian Width' , 5.0, 0.5, 40.0)
	Pars[4]			= RooRealVar('Sigma', 'Voigtian Sigma' , 5.0, 0.5, 40.0)
	Pars[5]			= RooRealVar('VoY', 'Signal Yield', 100, 0, 10000000)
	if len(Pars) != len(uPars):
		print 'The input array has a weird number of entries...'
		return 0
	if len(uPars) != len(uEPars):
		print 'The input arrays are of different sizes...'
		return 0
	for x in xrange(0, 6):
		Pars[x].setVal(uPars[x])
		Pars[x].setError(uEPars[x])
	v			= RooRealVar('v', 'Invariant Mass (GeV)', 60, 120)
	Voigt 			= RooVoigtian('Voigt', 'Voigtian - Signal', v, Pars[2], Pars[3], Pars[4])
## Calculate integral from -2sigma to 2sigma
	VStDev_r		= Voigt.sigma(v)
	VStDev			= VStDev_r.getVal()
	v.setRange("sobRange", Pars[2].getVal() - 2.*VStDev, Pars[2].getVal() + 2.*VStDev)
	integralSig     	= Voigt.createIntegral(RooArgSet(v), RooFit.NormSet(RooArgSet(v)), RooFit.Range("sobRange"))
	FinalNumber		= integralSig.getVal()*Pars[5].getVal()
	return FinalNumber
开发者ID:rateixei,项目名称:eFakeRate,代码行数:26,代码来源:Calculator.py

示例3: main

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,代码行数:27,代码来源:generate.py

示例4: buildPdf

def buildPdf(ws, p):

    mass = RooRealVar("mass", "mass", p.minMass, p.maxMass)
    getattr(ws,'import')(mass)

    # Construct signal pdf
    mean = RooRealVar("mean", "mean", 90, 85, 95)
    width = RooRealVar("width", "width", 2.4952, 1, 3)
    width.setConstant(ROOT.kTRUE)
    sigma = RooRealVar("sigma", "sigma", 1.2, 0.2, 10)
    signalAll = RooVoigtian("signalAll", "signalAll", mass, mean, width, sigma)

    turnOnAll = RooRealVar("turnOnAll","turnOnAll", 80., 40., 150.)
    widthAll_bkg = RooRealVar("widthAll","widthAll", 2., 0., 50.)
    decayAll_bkg = RooRealVar("decayAll","decayAll", 80., 20., 150.)
    meanB = RooRealVar("meanB", "meanB", 90, 60, 130)
    sigmaB = RooRealVar("sigmaB", "sigmaB", 10, 1, 20)
    bkg_a1 = RooRealVar("bkg_a1", "bkg_a1", 0., -2., 2.)
    bkg_a2 = RooRealVar("bkg_a2", "bkg_a2", 0., -2., 2.)
    backgroundAll = RooGaussian("backgroundAll", "backgroundAll", mass, meanB, sigmaB)

    # Construct composite pdf
    sigAll = RooRealVar("sigAll", "sigAll", 2000, 0, 100000)
    bkgAll = RooRealVar("bkgAll", "bkgAll", 100, 0, 10000)
    modelAll = RooAddPdf("modelAll", "modelAll", RooArgList(signalAll, backgroundAll), RooArgList(sigAll, bkgAll))
    if p.NoBkgd:
        modelAll = RooAddPdf("modelAll", "modelAll", RooArgList(signalAll), RooArgList(sigAll))
    # Define pdf for all probes

    # Construct signal pdf.
    # NOTE that sigma is shared with the signal sample model
    signalPass = RooVoigtian("signalPass","signalPass",mass,mean,width,sigma)
    # Construct the background pdf
    backgroundPass = RooGaussian("backgroundPass", "backgroundPass", mass, meanB, sigmaB)

    # Construct the composite model
    efficiency = RooRealVar("efficiency","efficiency",0.9,0.3,1.)
    sigPass = RooFormulaVar("sigPass", "@0*@1", RooArgList(sigAll, efficiency))
    bkgPass = RooRealVar("bkgPass", "bkgPass", 100, 0, 10000)
    modelPass = RooAddPdf("modelPass", "modelPass", RooArgList(signalPass, backgroundPass), RooArgList(sigPass, bkgPass))
    if p.NoBkgd:
        modelPass = RooAddPdf("modelPass", "modelPass", RooArgList(signalPass), RooArgList(sigPass))

    frac = RooRealVar("frac", "frac", 0.8, 0., 1.)

    # Define combined pdf for simultaneous fit

    # Define category to distinguish physics and control samples events
    sample = RooCategory("sample","sample")
    sample.defineType("all")
    sample.defineType("pass")

    simPdf = RooSimultaneous("simPdf","simultaneous pdf",sample)

    # Associate model with the physics state and model_ctl with the control state
    simPdf.addPdf(modelAll,"all")
    simPdf.addPdf(modelPass,"pass")
    # ws.import(simPdf)
    getattr(ws,'import')(simPdf)
开发者ID:CalPolyPat,项目名称:PyRoot,代码行数:59,代码来源:TagAndProbe.py

示例5: fit

    def fit(self):
        fit_variable = RooRealVar("fit_variable", "fit_variable", self.fit_boundaries[0], self.fit_boundaries[1])
        fit_variable.setBins(self.histograms[self.data_label].nbins())
        variables = RooArgList()
        variables.add(fit_variable)
        variable_set = RooArgSet()
        variable_set.add(fit_variable)

        roofit_histograms = {}
        roofit_pdfs = {}
        roofit_variables = {}

        N_min = 0.0
        N_max = self.normalisation[self.data_label] * 2.0
        pdf_arglist = RooArgList()
        variable_arglist = RooArgList()

        roofit_histograms[self.data_label] = RooDataHist(
            self.data_label, self.data_label, variables, self.histograms[self.data_label]
        )
        for sample in self.samples:
            roofit_histogram = RooDataHist(sample, sample, variables, self.histograms[sample])
            roofit_histograms[sample] = roofit_histogram
            roofit_pdf = RooHistPdf("pdf" + sample, "pdf" + sample, variable_set, roofit_histogram)
            roofit_pdfs[sample] = roofit_pdf
            roofit_variable = RooRealVar(sample, sample + " events", self.normalisation[sample], N_min, N_max)
            roofit_variables[sample] = roofit_variable
            pdf_arglist.add(roofit_pdf)
            variable_arglist.add(roofit_variable)

        model = RooAddPdf("model", "sum of all known", pdf_arglist, variable_arglist)
        use_model = model
        if self.constraints:
            arg_set = RooArgSet(model)
            constraints = self.get_fit_normalisation_constraints(model, roofit_variables)
            for constraint in constraints:
                arg_set.add(constraint)
            model_with_constraints = RooProdPdf(
                "model_with_constraints", "model  with gaussian constraints", arg_set, RooLinkedList()
            )
            use_model = model_with_constraints

        if self.method == "TMinuit":
            # WARNING: number of cores changes the results!!!
            self.saved_result = use_model.fitTo(
                roofit_histograms[self.data_label],
                RooFit.Minimizer("Minuit2", "Migrad"),
                RooFit.NumCPU(1),
                RooFit.Extended(),
                RooFit.Save(),
            )

        results = {}
        for sample in self.samples:
            results[sample] = (roofit_variables[sample].getVal(), roofit_variables[sample].getError())
        self.results = results
开发者ID:RemKamal,项目名称:DailyPythonScripts,代码行数:56,代码来源:Fitting.py

示例6: doMCFit

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,代码行数:54,代码来源:mcFit.py

示例7: fit

	def fit(self, save_to, signal_name=None, fix_p3=False, fit_range=[300., 1200.], fit_strategy=1):
		# Run a RooFit fit

		# Create background PDF
		p1 = RooRealVar('p1','p1',args.p1,0.,100.)
		p2 = RooRealVar('p2','p2',args.p2,0.,60.)
		p3 = RooRealVar('p3','p3',args.p3,-10.,10.)
		if args.fix_p3:
			p3.setConstant()
		background_pdf = RooGenericPdf('background_pdf','(pow([email protected]/%.1f,@1)/pow(@0/%.1f,@[email protected]*log(@0/%.1f)))'%(self.collision_energy,self.collision_energy,self.collision_energy),RooArgList(self.mjj_,p1,p2,p3))
		background_pdf.Print()
		data_integral = data_histogram.Integral(data_histogram.GetXaxis().FindBin(float(fit_range[0])),data_histogram.GetXaxis().FindBin(float(fit_range[1])))
		background_norm = RooRealVar('background_norm','background_norm',data_integral,0.,1e+08)
		background_norm.Print()

		# Create signal PDF and fit model
		if signal_name:
			signal_pdf = RooHistPdf('signal_pdf', 'signal_pdf', RooArgSet(self.mjj_), self.signal_roohistograms_[signal_name])
			signal_pdf.Print()
			signal_norm = RooRealVar('signal_norm','signal_norm',0,-1e+05,1e+05)
			signal_norm.Print()
			model = RooAddPdf("model","s+b",RooArgList(background_pdf,signal_pdf),RooArgList(background_norm,signal_norm))
		else:
			model = RooAddPdf("model","b",RooArgList(background_pdf),RooArgList(background_norm))

		# Run fit
		res = model.fitTo(data_, RooFit.Save(kTRUE), RooFit.Strategy(fit_strategy))

		# Save to workspace
		self.workspace_ = RooWorkspace('w','workspace')
		#getattr(w,'import')(background,ROOT.RooCmdArg())
		getattr(self.workspace_,'import')(background_pdf,RooFit.Rename("background"))
		getattr(self.workspace_,'import')(background_norm,ROOT.RooCmdArg())
		getattr(self.workspace_,'import')(self.data_roohistogram_,RooFit.Rename("data_obs"))
		getattr(self.workspace_, 'import')(model, RooFit.Rename("model"))
		if signal_name:
			getattr(self.workspace_,'import')(signal_roohistogram,RooFit.Rename("signal"))
			getattr(self.workspace_,'import')(signal_pdf,RooFit.Rename("signal_pdf"))
			getattr(self.workspace_,'import')(signal_norm,ROOT.RooCmdArg())
	
		self.workspace_.Print()
		self.workspace_.writeToFile(save_to)
		if signal_name:
			roofit_results[signal_name] = save_to
		else:
			roofit_results["background"] = save_to
开发者ID:DryRun,项目名称:StatisticalTools,代码行数:46,代码来源:fits.py

示例8: main

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,代码行数:50,代码来源:test.py

示例9: fitPed

def fitPed(hist, ws, name='x'):
    maxBin = hist.GetMaximumBin()
    x = ws.var(name)
    #rds = ds.reduce('{1}<{0:0.2f}'.format(hist.GetBinLowEdge(maxBin+2),name))
    #rds.Print()
    x.setRange('ped_fit', x.getMin(), hist.GetBinLowEdge(maxBin+3))
    pedMean = RooRealVar('pedMean', 'mean_{ped}', hist.GetBinCenter(maxBin),
                         x.getMin(), x.getMax())
    pedMean.Print()
    pedWidth = RooRealVar('pedWidth', 'sigma_{ped}', 1., 0., 10.)
    pedWidth.Print()
    ped = RooGaussian('ped', 'ped', x, pedMean, pedWidth)

    pedMean.setConstant(False)
    ped.fitTo(ws.data('ds'), RooFit.Minos(False), RooFit.Range('ped_fit'),
              RooFit.PrintLevel(0))

    getattr(ws, 'import')(ped)
开发者ID:mendezdpatricia,项目名称:usercode,代码行数:18,代码来源:pedRoutines.py

示例10: get_num_sig_bkg

def get_num_sig_bkg(hist_DataTemplate,
                    hist_SignalTemplate,
                    hist_BackgdTemplate,
                    fit_range_min,
                    fit_range_max):
    '''Given 3 input histograms (TH1F), and a fit range, this function finds
    the amount of signal and background that sum up to the data histogram.
    It does histogram fits.'''
    # Find range of data template
    data_min = hist_DataTemplate.GetXaxis().GetXmin()
    data_max = hist_DataTemplate.GetXaxis().GetXmax()
    
    # Create basic variables
    x = RooRealVar("x","x",data_min,data_max)
    x.setBins(hist_DataTemplate.GetXaxis().GetNbins())  # Binned x values
    nsig = RooRealVar("nsig","number of signal events"    , 0, hist_DataTemplate.Integral())
    nbkg = RooRealVar("nbkg","number of background events", 0, hist_DataTemplate.Integral())
    
    # Create RooDataHists from input TH1Fs
    dh = RooDataHist("dh","dh",RooArgList(x),hist_DataTemplate)
    ds = RooDataHist("ds","ds",RooArgList(x),hist_SignalTemplate)
    db = RooDataHist("db","db",RooArgList(x),hist_BackgdTemplate)
    
    # Create Probability Distribution Functions from Monte Carlo
    sigPDF = RooHistPdf("sigPDF", "sigPDF", RooArgSet(x), ds)
    bkgPDF = RooHistPdf("bkgPDF", "bkgPDF", RooArgSet(x), db)
    
    model = RooAddPdf("model","(g1+g2)+a",RooArgList(bkgPDF,sigPDF),RooArgList(nbkg,nsig))
    
    # Find the edges of the bins that contain the fit range min/max
    data_min = hist_DataTemplate.GetXaxis().GetBinLowEdge(hist_DataTemplate.GetXaxis().FindFixBin(fit_range_min))
    data_max = hist_DataTemplate.GetXaxis().GetBinUpEdge(hist_DataTemplate.GetXaxis().FindFixBin(fit_range_max))
    
    r = model.fitTo(dh,RooFit.Save(),RooFit.Minos(0),RooFit.PrintEvalErrors(0),
                    RooFit.Extended(),RooFit.Range(data_min,data_max))
    r.Print("v")

    #print nsig.getVal(), nsig.getError(), nbkg.getVal(), nbkg.getError()
    #  Create pull distribution
    #mcstudy = RooMCStudy(model, RooArgSet(x), RooFit.Binned(1), RooFit.Silence(),
    #                     RooFit.Extended(),
    #                     RooFit.FitOptions(RooFit.Save(1),
    #                                       RooFit.PrintEvalErrors(0),
    #                                       RooFit.Minos(0))
    #                    )
    #mcstudy.generateAndFit(500)                          # Generate and fit toy MC
    #pull_dist = mcstudy.plotPull(nsig, -3.0, 3.0, 30, 1)  # make pull distribution
    pull_dist = None
    return [nsig.getVal(), nsig.getError(), nbkg.getVal(), nbkg.getError(), pull_dist]
开发者ID:jll911,项目名称:UserCode,代码行数:49,代码来源:find_num_sig.py

示例11: saveLandauHistoSignalToNoise

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,代码行数:44,代码来源:MakeClusterPlots.py

示例12: __init__

    def __init__( self, roovar, **kwargs ):
        '''
        To build the class, the variable to be blinded must be provided. In < scale >
        one modifies the range of values for the blinded variable. Also the names for
        the constant variable and the generated formula can be modified.
        '''
        
        name = roovar.GetName()
        print 'Defining a new blinded variable for <', name, '>'

        scale  = kwargs.get( 'scale', 1000 )
        eqname = kwargs.get( 'bvarname', name + '_BlindExpr' )

        ''' The seed is different for each call, which guarantees the blinding procedure '''
        print 'Generating new set of random bounds'
        rndm = TRandom3( 0 )
        vmin = roovar.getMin()
        boundlo = rndm.Uniform( vmin, vmin*scale )
        vmax = roovar.getMax()
        boundhi = rndm.Uniform( vmax, vmax*scale )

        clonename = name + '_BLIND'
        blindVar = RooRealVar( clonename, clonename, roovar.getVal(), boundlo, boundhi )
        print 'Created clone variable named <', clonename, '>'
        
        alpha = ( vmax - vmin )/( boundhi - boundlo )
        beta  = ( vmax*boundlo - vmin*boundhi )/( vmax - vmin )

        blindVar.setVal( alpha*( roovar.getVal() - beta ) )

        alpha = RooConstVar( 'alpha', 'alpha', alpha )
        beta  = RooConstVar( 'beta', 'beta', beta )
        
        formula = 'alpha*( %s - beta)' % clonename
        varlist = RooArgList( blindVar, alpha, beta )
        blindEq = RooFormulaVar( eqname, eqname, formula, varlist )
        print 'The blinding formula is:', formula
        
        self.Alpha    = alpha
        self.Beta     = beta
        self.BlindEq  = blindEq
        self.BlindVar = blindVar
开发者ID:mrpPhys,项目名称:Isis,代码行数:42,代码来源:RooFitTools.py

示例13: test_plot

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,代码行数:20,代码来源:__init__.py

示例14: __init__

 def __init__(self, file_names, br_name="mass"):
     self.file_names = file_names
     self.br_name = br_name
     min_x = 8
     max_x = 12
     self.obs = RooRealVar("obs", "m4l", min_x, max_x)
     self.nbins = int((max_x - min_x) * 20)
     self.obs.setBin(self.nbins)
     # self.ws = ROOT.RooWorkspace("combined", "combined")
     self.obs.setRange("fit", 8.5, 11.5)
     self.dummy_hists = []
     self.chi2_cut = 10000
开发者ID:xju2,项目名称:xaodtools,代码行数:12,代码来源:upsilon_fit.py

示例15: __init__

	def __init__(self, mass_range=[0., 2000.]):
		self.data_histogram_ = None
		self.data_roohistogram_ = None
		self.luminosity_ = 0.
		self.collision_energy_ = 8000.
		self.signal_histograms_ = {}
		self.signal_roohistograms_ = {}
		self.signal_names_ = []

		# Fit storage
		self.simple_fit_ = None
		self.mjj_ = RooRealVar('mjj','mjj',float(mass_range[0]),float(mass_range[1]))
		self.workspace_ = None
开发者ID:DryRun,项目名称:StatisticalTools,代码行数:13,代码来源:fits.py


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