Exemple #1
0
def runFits(data,options):
    axis=ROOT.TAxis(options.binsy,options.miny,options.maxy)

   #first pass     
    graphs=[]
    for i in range(0,1):
        graphs.append(ROOT.TGraphErrors())

    for i in range(1,axis.GetNbins()+1):
    
        center=axis.GetBinCenter(i)
        h = data.drawTH1(options.varx,options.cut+"&&({vary}>{mini}&&{vary}<{maxi})".format(vary=options.vary,mini=axis.GetBinLowEdge(i),maxi=axis.GetBinUpEdge(i)),str(options.lumi),options.binsx,options.minx,options.maxx) 
        histo=copy.deepcopy(h)
        fitter=Fitter(['M'])
        fitter.w.var("M").setVal((options.maxx-options.minx)/2.0)
        fitter.w.var("M").setMax(options.maxx)
        fitter.w.var("M").setMin(options.minx)
        fitter.pow('model','M')
        fitter.importBinnedData(histo,['M'],'data')   
        fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1)])
        chi=fitter.projection("model","data","M","debugfit_"+str(i)+".pdf")
    
        for j,g in enumerate(graphs):
            c,cerr=fitter.fetch("c_"+str(j))
            g.SetPoint(i-1,center,c)
            g.SetPointError(i-1,0.0,cerr)
    pol0=ROOT.TF1("pol3","pol3",options.minx,options.maxx)
    graphs[0].Fit(pol0)
    
    #create json
    data={}
    data['p0']=returnString(pol0,options)
    f=open(options.output+".json","w")
    json.dump(data,f)
    f.close()
    return graphs
Exemple #2
0
fitter.importBinnedData(histo, ['x'], 'data')

if options.function == 'expo':
    fitter.expo('model', 'x')
    parameterization['type'] = 'expo'

if options.function == 'twoExp':
    fitter.twoExp('model', 'x')
    parameterization['type'] = 'erfexp'

if options.function == 'expoTail':
    fitter.expoTail('model', 'x')
    parameterization['type'] = 'expoTail'

if options.function == 'pow':
    fitter.pow('model', 'x')
    parameterization['type'] = 'expo'

if options.function == 'upperCB':
    fitter.upperCB('model', 'x')
    parameterization['type'] = 'upperCB'
    parameterization['c_0'] = 0.0
    parameterization['c_2'] = 1.0
    parameterization['c_3'] = 5.0
    parameterization['c_5'] = 5.0

if options.function == 'erfpow':
    fitter.erfpow('model', 'x')
    parameterization['type'] = 'erfpow'

if options.function == 'erfpowinv':