def runFits(data,options): # axis=ROOT.TAxis(10,array('d',[600,800,900,1000,1250,1500,2000,2500,3000,3500,4000])) axis=ROOT.TAxis(9,array('d',[800,900,1000,1250,1500,2000,2500,3000,3500,4000])) graphs={'meanW':ROOT.TGraphErrors(),'sigmaW':ROOT.TGraphErrors(),'alphaW':ROOT.TGraphErrors(),'alphaW2':ROOT.TGraphErrors(),'n':ROOT.TGraphErrors(),'meanTop':ROOT.TGraphErrors(),'sigmaTop':ROOT.TGraphErrors(),'alphaTop':ROOT.TGraphErrors(),'alphaTop2':ROOT.TGraphErrors(),'f':ROOT.TGraphErrors(),'f2':ROOT.TGraphErrors(),'slope':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.jetDoublePeakExp('model','M') if options.doExp==0: fitter.w.var("f2").setVal(1.0) fitter.w.var("f2").setConstant(1) fitter.w.var("slope").setVal(0.0) fitter.w.var("slope").setConstant(1) if options.fixPars!="": fixedPars =options.fixPars.split(',') for par in fixedPars: parVal = par.split(':') fitter.w.var(parVal[0]).setVal(float(parVal[1])) fitter.w.var(parVal[0]).setConstant(1) fitter.importBinnedData(histo,['M'],'data') fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1),ROOT.RooFit.Minos(0)]) fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1),ROOT.RooFit.Minos(1)]) chi=fitter.projection("model","data","M","debugfitMJJTop_"+options.output+"_"+str(i)+".png","m_{j} (GeV)") chi=fitter.projection("model","data","M","debugfitMJJTop_"+options.output+"_"+str(i)+".pdf","m_{j} (GeV)") for var,graph in graphs.iteritems(): value,error=fitter.fetch(var) graph.SetPoint(i-1,center,value) graph.SetPointError(i-1,0.0,error) F=ROOT.TFile(options.output+".root","RECREATE") F.cd() for name,graph in graphs.iteritems(): graph.Write(name) F.Close()
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
samples[mass] = fname print 'found', filename, 'mass', str(mass) #Now we have the samples: Sort the masses and run the fits N = 0 for mass in sorted(samples.keys()): print 'fitting', str(mass) plotter = TreePlotter(args[0] + '/' + samples[mass] + '.root', 'tree') # plotter.setupFromFile(args[0]+'/'+samples[mass]+'.pck') plotter.addCorrectionFactor('genWeight', 'tree') # plotter.addCorrectionFactor('xsec','tree') plotter.addCorrectionFactor('puWeight', 'tree') fitter = Fitter(['MVV', 'MJJ']) fitter.signal2D('model', ['MVV', 'MJJ']) fitter.w.var("MH").setVal(mass) histo = plotter.drawTH2(options.mjj + ':' + options.mvv, options.cut, "1", 500, 0, 6000, 100, options.minMJJ, options.maxMJJ) fitter.importBinnedData(histo, ['MVV', 'MJJ'], 'data') fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(0)]) fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(0)]) fitter.projection("model", "data", "MVV", "debugVV_" + str(mass) + ".root") fitter.projection("model", "data", "MJJ", "debugJJ_" + str(mass) + ".root") for var, graph in graphs.iteritems(): value, error = fitter.fetch(var) graph.SetPoint(N, mass, value)
def runFits(data, options): # axis=ROOT.TAxis(10,array('d',[600,800,900,1000,1250,1500,2000,2500,3000,3500,4000])) axis = ROOT.TAxis( 10, array('d', [600, 650, 700, 750, 800, 900, 1000, 1250, 1500, 2000, 2500])) graphs = { 'mean': ROOT.TGraphErrors(), 'sigma': ROOT.TGraphErrors(), 'alpha': ROOT.TGraphErrors(), 'n': ROOT.TGraphErrors(), 'alpha2': ROOT.TGraphErrors(), 'n2': ROOT.TGraphErrors(), 'slope': ROOT.TGraphErrors(), 'f': 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) if options.doExp: fitter.jetResonanceNOEXP('model', 'M') fitter.w.var("alpha").setVal(1.48) fitter.w.var("alpha").setConstant(1) fitter.w.var("alpha2").setVal(1.07) fitter.w.var("alpha2").setConstant(1) # fitter.jetResonance('model','M') else: fitter.jetResonanceNOEXP('model', 'M') fitter.w.var("alpha").setVal(1.48) fitter.w.var("alpha").setConstant(1) fitter.w.var("alpha2").setVal(1.07) fitter.w.var("alpha2").setConstant(1) fitter.importBinnedData(histo, ['M'], 'data') fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(1), ROOT.RooFit.Minos(0)]) fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(1), ROOT.RooFit.Minos(1)]) chi = fitter.projection( "model", "data", "M", "debugfitMJJTop_" + options.output + "_" + str(i) + ".png") for var, graph in graphs.iteritems(): value, error = fitter.fetch(var) graph.SetPoint(i - 1, center, value) graph.SetPointError(i - 1, 0.0, error) F = ROOT.TFile(options.output + ".root", "RECREATE") F.cd() for name, graph in graphs.iteritems(): graph.Write(name) F.Close()
#Now we have the samples: Sort the masses and run the fits N = 0 Fhists = ROOT.TFile("massHISTOS_" + options.output, "RECREATE") for mass in sorted(samples.keys()): print 'fitting', str(mass) plotter = TreePlotter(args[0] + '/' + samples[mass] + '.root', 'tree') plotter.addCorrectionFactor('genWeight', 'tree') plotter.addCorrectionFactor('puWeight', 'tree') if options.scaleFactors != '': for s in scaleFactors: plotter.addCorrectionFactor(s, 'tree') fitter = Fitter(['MVV']) fitter.signalResonanceCBGaus('model', 'MVV', mass) if options.fixPars != "1": fixedPars = options.fixPars.split(',') print fixedPars for par in fixedPars: parVal = par.split(':') if len(parVal) > 1: fitter.w.var(parVal[0]).setVal(float(parVal[1])) fitter.w.var(parVal[0]).setConstant(1) fitter.w.var("MH").setVal(mass) binning = truncate( getBinning(options.binsMVV, options.min, options.max, 1000), 0.75 * mass, 1.25 * mass) histo = plotter.drawTH1Binned(
help="name", default="bernstein") parser.add_option("-j", "--json", dest="json", help="name", default="test.json") (options, args) = parser.parse_args() parameterization = {} f = ROOT.TFile(args[0]) histo = f.Get(options.histo) fitter = Fitter(['x', 'y']) fitter.importBinnedData(histo, ['x', 'y'], 'data') if options.function == 'erfexpW2D': fitter.mjjParamErfExp('model', options.json) fitter.fit('model', 'data', [ ROOT.RooFit.SumW2Error(1), ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(fitter.w.var("x"))) ]) fitter.fit('model', 'data', [ ROOT.RooFit.SumW2Error(1), ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(fitter.w.var("x"))) ]) fitter.projectionCond("model", "data", "y", "x", "debug" + options.output + ".png")
samples[mass] = fname print 'found', filename, 'mass', str(mass) #Now we have the samples: Sort the masses and run the fits N = 0 for mass in sorted(samples.keys()): print 'fitting', str(mass) plotter = TreePlotter(args[0] + '/' + samples[mass] + '.root', 'tree') plotter.setupFromFile(args[0] + '/' + samples[mass] + '.pck') plotter.addCorrectionFactor('genWeight', 'tree') plotter.addCorrectionFactor('xsec', 'tree') plotter.addCorrectionFactor('puWeight', 'tree') fitter = Fitter(['m', 'M']) fitter.signal2D('model', options.boson) fitter.w.var("MH").setVal(mass) histo = plotter.drawTH2(options.mjj + ":" + options.mvv, options.cutShape, "1", 500, 0, 13000, 120, 25, 165) histoYield = plotter.drawTH2(options.mjj + ":" + options.mvv, options.cutYield, "1", 130, 0, 13000, 100, 25, 165) fitter.importBinnedData(histo, ['M', 'm'], 'data') fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(0)]) #create the yield # fitter.w.var('m').setMax(options.maxMJJ) # fitter.w.var('m').setMin(options.minMJJ) # integral = fitter.w.pdf("model").createIntegral(ROOT.RooArgSet(fitter.w.var("m"),fitter.w.var("M")))
continue dataPlotters.append(TreePlotter(args[0]+'/'+fname+'.root','tree')) dataPlotters[-1].setupFromFile(args[0]+'/'+fname+'.pck') dataPlotters[-1].addCorrectionFactor('xsec','tree') dataPlotters[-1].addCorrectionFactor('genWeight','tree') dataPlotters[-1].addCorrectionFactor('puWeight','tree') dataPlotters[-1].addCorrectionFactor('truth_genTop_weight','branch') ##dataPlotters[-1].addCorrectionFactor('lnujj_sf','branch') ##dataPlotters[-1].addCorrectionFactor('lnujj_btagWeight','branch') data=MergedPlotter(dataPlotters) h = data.drawTH2(options.vary+":"+options.varx,options.cut,str(options.lumi),options.binsxfit,options.minx,options.maxx,options.binsyfit,options.miny,options.maxy) fitter=Fitter(['MVV','MJJ']) fitter.w.var("MVV").setVal((options.maxx-options.minx)/2.0) fitter.w.var("MVV").setMax(options.maxx) fitter.w.var("MVV").setMin(options.minx) fitter.w.var("MJJ").setVal((options.maxy-options.miny)/2.0) fitter.w.var("MJJ").setMax(options.maxy) fitter.w.var("MJJ").setMin(options.miny) scaleSysts= {'Scale':"0.0094"} resSysts = {'Res':"0.2"} fracSysts = {'TopPt0':"0.2", 'TopPt1':"25000.0/MVV^2"} fitter.jetDoublePeakExpCond('model',['MVV','MJJ'],scaleSysts,resSysts,fracSysts) if options.doExp==0: fitter.w.var("g").setVal(1.0)
def runFits(data, options): axis = ROOT.TAxis(5, array('d', [600, 700, 800, 900, 1000, 1200, 1400])) #first pass graphs = [] for i in range(0, 6): 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.signalMJJCB('model', 'M') fitter.importBinnedData(histo, ['M'], 'data') fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(0), ROOT.RooFit.Minos(1)]) chi = fitter.projection( "model", "data", "M", "debugfitMJJTop_" + options.output + "_" + str(i) + ".png") 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) data = {} pol4 = ROOT.TF1("pol4", "pol4", options.minx, options.maxx) pol3 = ROOT.TF1("pol3", "pol3", options.minx, options.maxx) pol2 = ROOT.TF1("pol2", "pol2", options.minx, options.maxx) pol1 = ROOT.TF1("pol1", "pol1", options.minx, options.maxx) pol0 = ROOT.TF1("pol0", "pol0", options.minx, options.maxx) log = ROOT.TF1("log0", "[0]+[1]*log(x)", options.minx, options.maxx) graphs[0].Fit(log) data['mean'] = returnString(log, options) graphs[1].Fit(pol0) data['sigma'] = returnString(pol0, options) graphs[2].Fit(log) data['alpha1'] = returnString(log, options) graphs[3].Fit(pol0) data['n1'] = returnString(pol0, options) graphs[4].Fit(pol0) data['alpha2'] = returnString(pol0, options) graphs[5].Fit(pol0) data['n2'] = returnString(pol0, options) #create json f = open(options.output + ".json", "w") json.dump(data, f) f.close() return graphs
help="Output JSON", default='') parser.add_option("-i", "--histo", dest="histo", help="name", default="histo") parser.add_option("-f", "--function", dest="function", help="name", default="bernstein") (options, args) = parser.parse_args() parameterization = {} f = ROOT.TFile(args[0]) histo = f.Get(options.histo) fitter = Fitter(['x']) fitter.importBinnedData(histo, ['x'], 'data') if options.function == 'expo': fitter.expo('model', 'x') parameterization['type'] = 'expo' if options.function == 'erfpow': fitter.erfpow('model', 'x') parameterization['type'] = 'erfpow' if options.function == 'erfexp': fitter.erfexp('model', 'x') parameterization['type'] = 'erfexp' if options.function == 'erfexpCB':
SF=SF*float(s) ## Load the samples for all signal mass values plotter = loadSignalNtuples(options.samples,args[0],options.minMX,options.maxMX,SF) ## Sort the masses and run the fits N=0 for mass in sorted(plotter.keys()): print 'fitting',str(mass) ## Get the histo from MC histo = plotter[mass].drawTH1(options.varx,options.cut,"1",options.binsxfit,options.minx,options.maxx) ## Set up the fitter fitter=Fitter(['MVV']) fitter.signalResonance('model','MVV') #fitter.w.var("MH").setVal(mass) fitter.importBinnedData(histo,['MVV'],'data') ## fit fitter.fit('model','data',[ROOT.RooFit.SumW2Error(0)]) #fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1)]) fitter.fit('model','data',[ROOT.RooFit.SumW2Error(0)]) ## control plot fitter.projection("model","data","MVV",options.debugFile+"_"+str(int(mass)).zfill(4)+".root",options.varx,[],[ROOT.RooFit.LineColor(color)]) fitter.projection("model","data","MVV",options.debugFile+"_"+str(int(mass)).zfill(4)+".png",options.varx,[],[ROOT.RooFit.LineColor(color)]) ## Save parameters vs MX for var,graph in graphs.iteritems():
graph = {'scale': ROOT.TGraphErrors(), 'sigma': ROOT.TGraphErrors()} #dataset = data.makeDataSet(options.genvar,options.genCut,-1) for i in range(1, axis.GetNbins() + 1): cBinLo = axis.GetBinLowEdge(i) cBinHi = axis.GetBinUpEdge(i) cBinCenter = axis.GetBinCenter(i) dataset = data.makeDataSet( options.genvar, options.genCut + '*({cvar}>{lo}&&{cvar}<={hi})'.format( cvar=options.condVar, lo=cBinLo - 100, hi=cBinHi + 100), -1) histo = data.drawTH1( options.var, options.cut + '*({cvar}>{lo}&&{cvar}<={hi})'.format( cvar=options.condVar, lo=cBinLo, hi=cBinHi), "1", options.bins, options.mini, options.maxi) fitter = Fitter([options.var]) fitter.importBinnedData(histo, [options.var], 'data') fitter.gaussianSum('model', options.var, dataset, options.genvar) fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(1)]) chi = fitter.projection("model", "data", options.var, "debugPlot_" + str(i) + "_" + options.output, 'x') print i, 'Chi2', chi for nuis in ['scale', 'sigma']: v, vErr = fitter.fetch(nuis) graph[nuis].SetPoint(i, cBinCenter, v) graph[nuis].SetPointError(i, 0, vErr) f2 = ROOT.TFile(options.output, "RECREATE") f2.cd() for g in graph.keys(): graph[g].Write(g)
plotters[-1].setupFromFile(args[0] + '/' + samples[name] + '.pck') plotters[-1].addCorrectionFactor('xsec', 'tree') plotters[-1].addCorrectionFactor('genWeight', 'tree') plotters[-1].addCorrectionFactor('puWeight', 'tree') corrFactor = options.corrFactorW if samples[name].find('Z') != -1: corrFactor = options.corrFactorZ plotters[-1].addCorrectionFactor(corrFactor, 'flat') plotter = MergedPlotter(plotters) print 'Fitting Mjet:' for leg in legs: fitter = Fitter(['x']) #fitter.jetResonanceVjets('model','x') fitter.gaus('model', 'x') if options.fixPars != "1": fixedPars = options.fixPars.split(',') if len(fixedPars) > 1: print " - Fix parameters: ", fixedPars for par in fixedPars: if par == "c_0" or par == "c_1" or par == "c_2": continue parVal = par.split(':') fitter.w.var(parVal[0]).setVal(float(parVal[1])) fitter.w.var(parVal[0]).setConstant(1) #histo = plotter.drawTH1("jj_"+leg+"_softDrop_mass",options.cut+"*(jj_"+leg+"_mergedVTruth==1)","1",80,options.mini,options.maxi) histo = plotter.drawTH1(
def interpolate(histos, axis, options): #create 2D histogram histo2D = ROOT.TH2D("histo2D", "histo2D", options.binsx, options.minx, options.maxx, options.binsy, options.miny, options.maxy) if options.fitFunc == "bernstein3": order = 3 if options.fitFunc == "bernstein4": order = 4 if options.fitFunc == "bernstein5": order = 5 if options.fitFunc == "bifur": order = 3 graphs = [] for i in range(0, order): graphs.append(ROOT.TGraphErrors()) #run the fits for N, h in enumerate(histos): center = axis.GetBinCenter(N + 1) fitter = Fitter(['mjj']) fitter.w.var("mjj").setVal(40) fitter.w.var("mjj").setMax(options.maxy) fitter.w.var("mjj").setMin(options.miny) if options.fitFunc == "bernstein3": fitter.bernstein('model', 'mjj', 3) if options.fitFunc == "bernstein4": fitter.bernstein('model', 'mjj', 4) if options.fitFunc == "bernstein5": fitter.bernstein('model', 'mjj', 5) if options.fitFunc == "bifur": fitter.bifur('model', 'mjj') fitter.importBinnedData(h, ['mjj'], 'data') fitter.fit('model', 'data') fitter.fit('model', 'data') fitter.projection("model", "data", "mjj", "debugProjectionFit_" + str(N) + ".png") for j, g in enumerate(graphs): c, cerr = fitter.fetch("c_" + str(j)) g.SetPoint(N, center, c) g.SetPointError(N, 0.0, cerr) ##OK now interpolate and make histograms! #first make the function fitter = Fitter(['mjj']) if options.fitFunc == "bernstein3": fitter.bernstein('model', 'mjj', 3) order = 3 if options.fitFunc == "bernstein4": fitter.bernstein('model', 'mjj', 4) order = 4 if options.fitFunc == "bernstein5": fitter.bernstein('model', 'mjj', 5) order = 5 if options.fitFunc == "bifur": fitter.bifur('model', 'mjj') order = 3 fitter.w.var("mjj").setVal(80) fitter.w.var("mjj").setMax(options.maxy) fitter.w.var("mjj").setMin(options.miny) for i in range(1, histo2D.GetNbinsX() + 1): x = histo2D.GetXaxis().GetBinCenter(i) print 'Bin:', i, 'Evaluating function at x=', x for j, g in enumerate(graphs): print "c_" + str(j), "=", g.Eval(x) fitter.w.var("c_" + str(j)).setVal(g.Eval(x, 0, "S")) histogram = fitter.w.pdf("model").createHistogram("mjj", options.binsy) for k in range(1, histo2D.GetNbinsY() + 1): bin = histo2D.GetBin(i, k) histo2D.SetBinContent(bin, histogram.GetBinContent(k)) return graphs, histo2D
ext = fnameParts[1] if ext.find("root") == -1: continue dataPlotters.append( TreePlotter(args[0] + '/' + fname + '.root', 'tree')) dataPlotters[-1].setupFromFile(args[0] + '/' + fname + '.pck') dataPlotters[-1].addCorrectionFactor('xsec', 'tree') dataPlotters[-1].addCorrectionFactor('genWeight', 'tree') dataPlotters[-1].addCorrectionFactor('puWeight', 'tree') data = MergedPlotter(dataPlotters) histo = data.drawTH2(options.vary + ":" + options.varx, options.cut, str(options.lumi), options.binsx, options.minx, options.maxx, options.binsy, options.miny, options.maxy) histo = copy.deepcopy(histo) fitter = Fitter(['M', '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.w.var("m").setVal((options.maxy - options.miny) / 2.0) fitter.w.var("m").setMax(options.maxy) fitter.w.var("m").setMin(options.miny) fitter.erfpowParam('model', ['M', 'm']) fitter.importBinnedData(histo, ['M', 'm'], 'data') fitter.fit('model', 'data', [ ROOT.RooFit.SumW2Error(0), ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(fitter.w.var('m'))) ]) fitter.fit('model', 'data', [ ROOT.RooFit.SumW2Error(0), ROOT.RooFit.ConditionalObservables(ROOT.RooArgSet(fitter.w.var('m')))
def runFits(data,options): axis=ROOT.TAxis(options.binsy,options.miny,options.maxy) #first pass graphs=[] for i in range(0,3): 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.erfpow('model','M') fitter.importBinnedData(histo,['M'],'data') fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1),ROOT.RooFit.Minos(1)]) # chi=fitter.projection("model","data","M","debugfitMVV_"+options.output+"_pass1_"+str(i)+".png") for j,g in enumerate(graphs): c,cerr=fitter.fetch("c_"+str(j)) if abs(c-fitter.w.var("c_"+str(j)).getMin())<0.1: cerr=abs(c)*10000 g.SetPoint(i-1,center,c) g.SetPointError(i-1,0.0,cerr) parameter0=ROOT.TF1("pol0","pol0",options.minx,options.maxx) graphs[0].Fit(parameter0) #Second pass after fixing par0 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.erfpow('model','M') fitter.w.var("c_0").setVal(parameter0.Eval(center)) fitter.w.var("c_0").setConstant(1) fitter.importBinnedData(histo,['M'],'data') fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1),ROOT.RooFit.Minos(1)]) # chi=fitter.projection("model","data","M","debugfitMVV_"+options.output+"_pass2_"+str(i)+".png") for j,g in enumerate(graphs): if j>0: c,cerr=fitter.fetch("c_"+str(j)) if abs(c-fitter.w.var("c_"+str(j)).getMin())<0.1: cerr=abs(c)*10000 g.SetPoint(i-1,center,c) g.SetPointError(i-1,0.0,cerr) parameter2=ROOT.TF1("pol3","pol3",options.minx,options.maxx) # log0.SetParameters(1,1) graphs[2].Fit(parameter2) #Third pass after fixing par0 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) #protect for negative weights 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.erfpow('model','M') fitter.w.var("c_0").setVal(parameter0.Eval(center)) fitter.w.var("c_0").setConstant(1) fitter.w.var("c_2").setVal(parameter2.Eval(center)) fitter.w.var("c_2").setConstant(1) fitter.importBinnedData(histo,['M'],'data') fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1),ROOT.RooFit.Minos(1)]) # chi=fitter.projection("model","data","M","debugfitMVV_"+options.output+"_pass3_"+str(i)+".png") for j,g in enumerate(graphs): if j==1: c,cerr=fitter.fetch("c_"+str(j)) if abs(c-fitter.w.var("c_"+str(j)).getMin())<0.1: cerr=abs(c)*10000 g.SetPoint(i-1,center,c) g.SetPointError(i-1,0.0,cerr) parameter1=ROOT.TF1("pol3","pol3",options.minx,options.maxx) graphs[1].Fit(parameter1) #Fourth pass - plotting 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) #protect for negative weights 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.erfpow('model','M') fitter.w.var("c_0").setVal(parameter0.Eval(center)) fitter.w.var("c_0").setConstant(1) fitter.w.var("c_1").setVal(parameter1.Eval(center)) fitter.w.var("c_1").setConstant(1) fitter.w.var("c_2").setVal(parameter2.Eval(center)) fitter.w.var("c_2").setConstant(1) fitter.importBinnedData(histo,['M'],'data') chi=fitter.projection("model","data","M","debugfitMVV_"+options.output+"_pass3_"+str(i)+".png") #create json data={} data['p0']=returnString(parameter0,options) data['p1']=returnString(parameter1,options) data['p2']=returnString(parameter2,options) f=open(options.output+".json","w") json.dump(data,f) f.close() return graphs
samples[mass] = fname print 'found', filename, 'mass', str(mass) #Now we have the samples: Sort the masses and run the fits N = 0 for mass in sorted(samples.keys()): print 'fitting', str(mass) plotter = TreePlotter(args[0] + '/' + samples[mass] + '.root', 'tree') # plotter.setupFromFile(args[0]+'/'+samples[mass]+'.pck') plotter.addCorrectionFactor('genWeight', 'tree') # plotter.addCorrectionFactor('xsec','tree') plotter.addCorrectionFactor('puWeight', 'tree') fitter = Fitter(['x']) fitter.jetResonance('model', 'x') # fitter.w.var("MH").setVal(mass) histo = plotter.drawTH1(options.mvv, options.cut, "1", 40, 40, 160) fitter.importBinnedData(histo, ['x'], 'data') fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(0)]) fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(0), ROOT.RooFit.Minos(1)]) fitter.projection("model", "data", "x", "debugJJ_" + str(mass) + ".png") for var, graph in graphs.iteritems(): value, error = fitter.fetch(var) graph.SetPoint(N, mass, value) graph.SetPointError(N, 0.0, error)
uncWeights = options.uncweight.split(',') uncw1 = uncWeights[0] hGenPtUp = ROOT.TH1F("hGenPtUp", "hGenPtUp", 5000, 0, 5000) hGenPtDn = ROOT.TH1F("hGenPtDn", "hGenPtDn", 5000, 0, 5000) fGenPtUp = ROOT.TF1("fGenPtUp", uncw1.replace("lnujj_l2_gen_pt", "x"), 0, 5000) fGenPtDn = ROOT.TF1("fGenPtDn", '1/' + uncw1.replace("lnujj_l2_gen_pt", "x"), 0, 5000) for i in range(5000): hGenPtUp.Fill(i + 0.5, fGenPtUp.Eval(i + 0.5)) hGenPtDn.Fill(i + 0.5, fGenPtDn.Eval(i + 0.5)) histograms = [] #ok lets populate! 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.factory("GM[15,215]") fitter.factory("weight[0,1e+32]") #datasetPDF=data.makeDataSet('lnujj_l2_gen_softDrop_mass,'+options.var,options.cut,-1) histoPDF = data.drawTH1('lnujj_l2_gen_softDrop_mass', options.cut, "1", options.binsx * 4, options.minx, options.maxx) fitter.w.var("GM").setMin(histoPDF.GetXaxis().GetXmin()) fitter.w.var("GM").setMax(histoPDF.GetXaxis().GetXmax()) fitter.w.var("GM").setBins(histoPDF.GetXaxis().GetNbins()) cList = ROOT.RooArgSet(fitter.w.var("GM"), fitter.w.var("weight"))
## Load the samples for all signal mass values plotter = loadSignalNtuples(options.samples,args[0],options.minMX,options.maxMX) ## Sort the masses and run the fits N=0 for mass in sorted(plotter.keys()): print 'fitting',str(mass) ## Get the histo from MC histo = plotter[mass].drawTH1(options.mvv,options.cut,"1",int((options.maxi-options.mini)/4),options.mini,options.maxi) ## Set up the fitter fitter=Fitter(['x']) if options.doExp==1: fitter.jetResonance('model','x') else: fitter.jetResonanceNOEXP('model','x') if options.fixPars!="": fixedPars =options.fixPars.split(',') for par in fixedPars: parVal = par.split(':') fitter.w.var(parVal[0]).setVal(float(parVal[1])) fitter.w.var(parVal[0]).setConstant(1) #fitter.w.var("MH").setVal(mass) fitter.importBinnedData(histo,['x'],'data') ## fit fitter.fit('model','data',[ROOT.RooFit.SumW2Error(0)])
def runFits(data, options, info): axis = ROOT.TAxis( 8, array('d', [600, 650, 700, 750, 800, 850, 1000, 1200, 1400])) #first pass graphs = { 'mean': ROOT.TGraphErrors(), 'alpha2': ROOT.TGraphErrors(), 'n2': 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) func = ROOT.TF1("func", info['mean'].replace("MH", "x"), 0, 6000) # fitter.w.factory("mean["+str(func.Eval(center))+"]") fitter.w.factory("mean[1,-20,20]") fitter.w.factory( "expr::mean2('{val}+mean',mean)".format(val=func.Eval(center))) func = ROOT.TF1("func", info['sigma'].replace("MH", "x"), 0, 6000) fitter.w.factory("sigma[" + str(func.Eval(center)) + "]") func = ROOT.TF1("func", info['alpha'].replace("MH", "x"), 0, 6000) fitter.w.factory("alpha[" + str(func.Eval(center)) + "]") func = ROOT.TF1("func", info['n'].replace("MH", "x"), 0, 6000) fitter.w.factory("n[" + str(func.Eval(center)) + "]") func = ROOT.TF1("func", info['slope'].replace("MH", "x"), 0, 6000) fitter.w.factory("slope[" + str(func.Eval(center)) + "]") func = ROOT.TF1("func", info['f'].replace("MH", "x"), 0, 6000) fitter.w.factory("f[" + str(func.Eval(center)) + "]") fitter.w.factory("alpha2[3,0.5,6]") fitter.w.factory("n2[6]") name = 'model' peak = ROOT.RooDoubleCB(name, 'modelS', fitter.w.var("M"), fitter.w.function('mean2'), fitter.w.var('sigma'), fitter.w.var('alpha'), fitter.w.var('n'), fitter.w.var("alpha2"), fitter.w.var("n2")) getattr(fitter.w, 'import')(peak, ROOT.RooFit.Rename(name + 'S')) # fitter.w.factory("RooExponential::"+name+"B(M,slope)") # fitter.w.factory("SUM::"+name+"(f*"+name+"S,"+name+"B)") # fitter.signalMJJCB('model','M') fitter.importBinnedData(histo, ['M'], 'data') fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(1)]) fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(1), ROOT.RooFit.Minos(1)]) chi = fitter.projection( "model", "data", "M", "debugfitMJJTop_" + options.output + "_" + str(i) + ".png") c, cerr = fitter.fetch('mean') graphs['mean'].SetPoint(i - 1, center, c) graphs['mean'].SetPointError(i - 1, 0.0, c) c, cerr = fitter.fetch('alpha2') graphs['alpha2'].SetPoint(i - 1, center, c) graphs['alpha2'].SetPointError(i - 1, 0.0, c) c, cerr = fitter.fetch('n2') graphs['n2'].SetPoint(i - 1, center, c) graphs['n2'].SetPointError(i - 1, 0.0, c) data = {} pol4 = ROOT.TF1("pol4", "pol4", options.minx, options.maxx) pol3 = ROOT.TF1("pol3", "pol3", options.minx, options.maxx) pol2 = ROOT.TF1("pol2", "pol2", options.minx, options.maxx) pol1 = ROOT.TF1("pol1", "pol1", options.minx, options.maxx) pol0 = ROOT.TF1("pol0", "pol0", options.minx, options.maxx) log = ROOT.TF1("log0", "[0]+[1]*log(x)", options.minx, options.maxx) graphs['mean'].Fit(log) data['mean'] = info['mean'] + "+" + returnString(log, options) graphs['alpha2'].Fit(log) data['alpha2'] = returnString(log, options) graphs['n2'].Fit(pol0) data['n2'] = returnString(pol0, options) # data['mean']=info['mean'] data['sigma'] = info['sigma'] data['alpha1'] = info['alpha'] data['n1'] = info['n'] #create json f = open(options.output + ".json", "w") json.dump(data, f) f.close() return graphs
def runFits(data,options): jsonFile=open(options.json) info=json.load(jsonFile) meanF = ROOT.TFormula("meanF",info['mean'].replace('MH','x')) sigmaF = ROOT.TFormula("sigmaF",info['sigma'].replace('MH','x')) alphaF = ROOT.TFormula("alphaF",info['alpha'].replace('MH','x')) nF = ROOT.TFormula("nF",info['n'].replace('MH','x')) alpha2F = ROOT.TFormula("alpha2F",info['alpha2'].replace('MH','x')) n2F = ROOT.TFormula("n2F",info['n2'].replace('MH','x')) slopeF = ROOT.TFormula("slopeF",info['slope'].replace('MH','x')) fF = ROOT.TFormula("fF",info['f'].replace('MH','x')) # axis=ROOT.TAxis(10,array('d',[600,800,900,1000,1250,1500,2000,2500,3000,3500,4000])) axis=ROOT.TAxis(10,array('d',[600,650,700,750,800,900,1000,1250,1500,2000,2500])) graphs={'mean':ROOT.TGraphErrors(),'sigma':ROOT.TGraphErrors(),'alpha':ROOT.TGraphErrors(),'n':ROOT.TGraphErrors(),'alpha2':ROOT.TGraphErrors(),'n2':ROOT.TGraphErrors(),'f':ROOT.TGraphErrors(),'slope':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) if options.doExp>=0: ##MICHALIS CHANGED IT fitter.jetResonance('model','M') fitter.w.var("slope").setVal(slopeF.Eval(center)) fitter.w.var("slope").setMin(-2) fitter.w.var("slope").setMax(2) fitter.w.var("slope").setConstant(0) fitter.w.var("f").setVal(fF.Eval(center)) fitter.w.var("f").setMin(0) fitter.w.var("f").setMax(1.) fitter.w.var("f").setConstant(0) else: fitter.jetResonanceNOEXP('model','M') fitter.w.var("mean").setVal(meanF.Eval(center)) fitter.w.var("mean").setMin(meanF.Eval(center)*0.9) fitter.w.var("mean").setMax(meanF.Eval(center)*1.1) fitter.w.var("sigma").setVal(sigmaF.Eval(center)) fitter.w.var("sigma").setMin(sigmaF.Eval(center)*0.5) fitter.w.var("sigma").setMax(sigmaF.Eval(center)*2) # fitter.w.var("alpha").setVal(alphaF.Eval(center)) fitter.w.var("alpha").setVal(1.59049) fitter.w.var("alpha").setConstant(1) fitter.w.var("alpha2").setVal(1.3) fitter.w.var("alpha2").setConstant(1) # fitter.w.var("alpha2").setConstant(1) fitter.importBinnedData(histo,['M'],'data') fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1),ROOT.RooFit.Minos(0)]) fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1),ROOT.RooFit.Minos(1)]) chi=fitter.projection("model","data","M","debugfitMJJTop_"+options.output+"_"+str(i)+".png") for var,graph in graphs.iteritems(): value,error=fitter.fetch(var) graph.SetPoint(i-1,center,value) graph.SetPointError(i-1,0.0,error) F=ROOT.TFile(options.output+".root","RECREATE") F.cd() for name,graph in graphs.iteritems(): graph.Write(name) F.Close()
def runFits(data, options): h = data.drawTH1(options.varx, options.cut, 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.w.var("M").setBins(options.binsx) fitter.jetDoublePeakSF('model', 'M') fitter.importBinnedData(histo, ['M'], 'data') fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(1), ROOT.RooFit.Minos(0)]) fitter.fit('model', 'data', [ROOT.RooFit.SumW2Error(1), ROOT.RooFit.Minos(1)]) fitter.projection("model", "data", "M", options.output + "_debug.png", 'm_{SD}') scaleW = fitter.w.var('meanW').getVal() scaleTop = fitter.w.var('meanTop').getVal() sigmaW = fitter.w.var('sigmaW').getVal() sigmaTop = fitter.w.var('sigmaTop').getVal() slope = fitter.w.var("slope").getVal() fT = fitter.w.var('fT').getVal() fE = fitter.w.var('fE').getVal() NW = fitter.w.var('NW').getVal() NBKG = fitter.w.var('NBKG').getVal() F = ROOT.TFile(options.output, "RECREATE") F.cd() ################################################################# h = fitter.w.pdf("WPeak").createHistogram("M", options.binsx) h.Scale(NW / (options.lumi * h.Integral())) h.Write("W") fitter.w.var('meanW').setVal(scaleW * 1.05) h = fitter.w.pdf("WPeak").createHistogram("M", options.binsx) h.Write("W_scaleUp") fitter.w.var('meanW').setVal(scaleW * 0.95) h = fitter.w.pdf("WPeak").createHistogram("M", options.binsx) h.Write("W_scaleDown") fitter.w.var('meanW').setVal(scaleW) fitter.w.var('sigmaW').setVal(sigmaW * 1.25) h = fitter.w.pdf("WPeak").createHistogram("M", options.binsx) h.Write("W_sigmaUp") fitter.w.var('sigmaW').setVal(sigmaW * 0.75) h = fitter.w.pdf("WPeak").createHistogram("M", options.binsx) h.Write("W_sigmaDown") fitter.w.var('sigmaW').setVal(sigmaW) ################################################################# h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Scale(NBKG / (options.lumi * h.Integral())) h.Write("bkg") fitter.w.var('meanTop').setVal(scaleTop * 1.15) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_scaleUp") fitter.w.var('meanTop').setVal(scaleTop * 0.85) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_scaleDown") fitter.w.var('meanTop').setVal(scaleTop) fitter.w.var('sigmaTop').setVal(sigmaTop * 1.25) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_sigmaUp") fitter.w.var('sigmaTop').setVal(sigmaTop * 0.75) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_sigmaDown") fitter.w.var('sigmaTop').setVal(sigmaTop) fitter.w.var('slope').setVal(slope * 1.5) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_slopeUp") fitter.w.var('slope').setVal(slope * 0.5) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_slopeDown") fitter.w.var('slope').setVal(slope) fitter.w.var('fT').setVal(fT * 1.3) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_fTUp") fitter.w.var('fT').setVal(fT * 0.7) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_fTDown") fitter.w.var('fT').setVal(fT) fitter.w.var('fE').setVal(fE * 1.3) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_fEUp") fitter.w.var('fE').setVal(fE * 0.7) h = fitter.w.pdf("bkg").createHistogram("M", options.binsx) h.Write("bkg_fEDown") fitter.w.var('fE').setVal(fE) F.Close()
p.addCorrectionFactor(1.0 / sigmaW, 'flat') data = MergedPlotter(dataPlotters) orderInfo = {} orders = options.order.split('|') for v in orders: sp = v.split(':') orderInfo[sp[0]] = int(sp[1]) h = data.drawTH2(options.vary + ':' + options.varx, options.cut, str(options.lumi), options.binsx, options.minx, options.maxx, options.binsy, options.miny, options.maxy) histo = copy.deepcopy(h) fitter = Fitter(['M', 'mjj']) 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.w.var("mjj").setVal((options.maxy - options.miny) / 2.0) fitter.w.var("mjj").setMax(options.maxy) fitter.w.var("mjj").setMin(options.miny) #The MJ first that is trivial jsonFile = open(options.json) data = json.load(jsonFile) jsonFile.close() if data['type'] == 'erfexp': fitter.erfexp('modelJ', 'mjj')
#Now we have the samples: Sort the masses and run the fits N=0 for mass in sorted(samples.keys()): if mass<999: continue print 'fitting',str(mass) plotter=TreePlotter(args[0]+'/'+samples[mass]+'.root','tree') plotter.setupFromFile(args[0]+'/'+samples[mass]+'.pck') plotter.addCorrectionFactor('genWeight','tree') plotter.addCorrectionFactor('xsec','tree') plotter.addCorrectionFactor('puWeight','tree') fitter=Fitter(['m','M']) fitter.signal2D('model',options.boson) fitter.w.var("MH").setVal(mass) histo = plotter.drawTH2(options.mjj+":"+options.mvv,options.cutShape,"1",500,0,13000,120,60,140) histoYield = plotter.drawTH2(options.mjj+":"+options.mvv,options.cutYield,"1",130,0,13000,100,25,165) fitter.importBinnedData(histo,['M','m'],'data') fitter.fit('model','data',[ROOT.RooFit.SumW2Error(1)]) #create the yield fitter.w.var('m').setMax(options.maxMJJ) fitter.w.var('m').setMin(options.minMJJ) integral = fitter.w.pdf("model").createIntegral(ROOT.RooArgSet(fitter.w.var("m"),fitter.w.var("M"))) analysisIntegral=integral.getVal()