continue mass = float(fname.split('_')[-1]) 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 W+jets plotters wjPlotters=[] for sample in ["WJetsToLNu_HT1200to2500","WJetsToLNu_HT2500toInf","WJetsToLNu_HT400to600","WJetsToLNu_HT600to800","WJetsToLNu_HT800to1200",'WJetsToLNu_HT100to200','WJetsToLNu_HT200to400']: wjPlotters.append(TreePlotter('samples/'+sample+'.root','tree')) wjPlotters[-1].setupFromFile('samples/'+sample+'.pck') wjPlotters[-1].addCorrectionFactor('xsec','tree') wjPlotters[-1].addCorrectionFactor('genWeight','tree') wjPlotters[-1].addCorrectionFactor('puWeight','tree') WJets = MergedPlotter(wjPlotters) tt=TreePlotter('samples/TTJets.root','tree') tt.setupFromFile('samples/TTJets.pck') tt.addCorrectionFactor('xsec','tree') tt.addCorrectionFactor('genWeight','tree') tt.addCorrectionFactor('puWeight','tree') #create the Z+jets plotters zPlotters=[] for sample in ['DYJetsToLL_M50_HT100to200','DYJetsToLL_M50_HT200to400','DYJetsToLL_M50_HT400to600','DYJetsToLL_M50_HT600toInf']: zPlotters.append(TreePlotter('samples/'+sample+'.root','tree')) zPlotters[-1].setupFromFile('samples/'+sample+'.pck') zPlotters[-1].addCorrectionFactor('xsec','tree') zPlotters[-1].addCorrectionFactor('genWeight','tree') zPlotters[-1].addCorrectionFactor('puWeight','tree')
import ROOT from CMGTools.VVResonances.plotting.TreePlotter import TreePlotter from CMGTools.VVResonances.plotting.MergedPlotter import MergedPlotter from CMGTools.VVResonances.plotting.StackPlotter import StackPlotter #create the W+jets plotters wjPlotters=[] WJets = TreePlotter('samples/WJetsToLNu_50ns.root','tree') WJets.setupFromFile('samples/WJetsToLNu_50ns.pck') WJets.addCorrectionFactor('xsec','xsec',0.0,'lnN') WJets.addCorrectionFactor('genWeight','genWeight',0.0,'lnN') WJets.setFillProperties(1001,ROOT.kAzure-9) TTJets = TreePlotter('samples/TTJets_50ns.root','tree') TTJets.setupFromFile('samples/TTJets_50ns.pck') TTJets.addCorrectionFactor('xsec','xsec',0.0,'lnN') TTJets.addCorrectionFactor('genWeight','genWeight',0.0,'lnN') TTJets.setFillProperties(1001,ROOT.kGreen-5) qcdPlotters=[] for sample in [ "QCD_Pt1000to1400_50ns","QCD_Pt120to170_50ns","QCD_Pt1400to1800_50ns","QCD_Pt170to300_50ns","QCD_Pt1800to2400_50ns","QCD_Pt2400to3200_50ns","QCD_Pt300to470_50ns","QCD_Pt3200_50ns","QCD_Pt470to600_50ns","QCD_Pt600to800_50ns","QCD_Pt800to1000_50ns","QCD_Pt80to120_50ns"
import ROOT from CMGTools.VVResonances.plotting.TreePlotter import TreePlotter from CMGTools.VVResonances.plotting.MergedPlotter import MergedPlotter from CMGTools.VVResonances.plotting.StackPlotter import StackPlotter #create the W+jets plotters wjPlotters = [] WJets = TreePlotter('samples/WJetsToLNu_50ns.root', 'tree') WJets.setupFromFile('samples/WJetsToLNu_50ns.pck') WJets.addCorrectionFactor('xsec', 'xsec', 0.0, 'lnN') WJets.addCorrectionFactor('genWeight', 'genWeight', 0.0, 'lnN') WJets.setFillProperties(1001, ROOT.kAzure - 9) TTJets = TreePlotter('samples/TTJets_50ns.root', 'tree') TTJets.setupFromFile('samples/TTJets_50ns.pck') TTJets.addCorrectionFactor('xsec', 'xsec', 0.0, 'lnN') TTJets.addCorrectionFactor('genWeight', 'genWeight', 0.0, 'lnN') TTJets.setFillProperties(1001, ROOT.kGreen - 5) qcdPlotters = [] for sample in [ "QCD_Pt1000to1400_50ns", "QCD_Pt120to170_50ns", "QCD_Pt1400to1800_50ns", "QCD_Pt170to300_50ns", "QCD_Pt1800to2400_50ns", "QCD_Pt2400to3200_50ns", "QCD_Pt300to470_50ns", "QCD_Pt3200_50ns", "QCD_Pt470to600_50ns", "QCD_Pt600to800_50ns", "QCD_Pt800to1000_50ns", "QCD_Pt80to120_50ns" ]: qcdPlotters.append(TreePlotter('samples/' + sample + '.root', 'tree'))
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()): 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
import ROOT from CMGTools.VVResonances.plotting.TreePlotter import TreePlotter from CMGTools.VVResonances.plotting.StackPlotter import StackPlotter ROOT.gROOT.ProcessLine('.x tdrstyle.C') w = TreePlotter('samples/W.root','tree') w.addCorrectionFactor('xsec','xsec',0.0,'lnN') w.addCorrectionFactor('mc','l_mcPt>0',0.0,'lnN') w.setFillProperties(0,ROOT.kWhite) w.setLineProperties(1,ROOT.kOrange+10,3) qcd = TreePlotter('samples/W.root','tree') qcd.addCorrectionFactor('xsec','xsec',0.0,'lnN') qcd.addCorrectionFactor('mc','l_mcPt==0',0.0,'lnN') qcd.setFillProperties(3003,ROOT.kBlue) qcd.setLineProperties(1,ROOT.kBlue,3) #Stack lStack = StackPlotter() lStack.addPlotter(qcd,"QCD","Non prompt","background") lStack.addPlotter(w,"Prompt_leptons","Prompt","signal")
"WJetsToLNu_HT800to1200", 'WJetsToLNu_HT100to200', 'WJetsToLNu_HT200to400' ]: #for sample in ["WJetsToLNu_HT1200to2500","WJetsToLNu_HT2500toInf","WJetsToLNu_HT400to600","WJetsToLNu_HT600to800","WJetsToLNu_HT800to1200",'WJetsToLNu_HT100to200','WJetsToLNu_HT200to400']: wjPlotters.append(TreePlotter('samples/' + sample + '.root', 'tree')) wjPlotters[-1].setupFromFile('samples/' + sample + '.pck') wjPlotters[-1].addCorrectionFactor('xsec', 'tree') wjPlotters[-1].addCorrectionFactor('genWeight', 'tree') wjPlotters[-1].addCorrectionFactor('puWeight', 'tree') # wjPlotters[-1].addCorrectionFactor('0.82','flat') WJets = MergedPlotter(wjPlotters) ttO = TreePlotter('samples/TTJets.root', 'tree') ttO.setupFromFile('samples/TTJets.pck') ttO.addCorrectionFactor('xsec', 'tree') ttO.addCorrectionFactor('genWeight', 'tree') ttO.addCorrectionFactor('puWeight', 'tree') ttO.addCorrectionFactor( '(!(lnujj_l2_mergedVTruth==1&&lnujj_l2_nearestBDRTruth>0.8))', 'tree') ttM = TreePlotter('samples/TTJets.root', 'tree') ttM.setupFromFile('samples/TTJets.pck') ttM.addCorrectionFactor('xsec', 'tree') ttM.addCorrectionFactor('genWeight', 'tree') ttM.addCorrectionFactor('puWeight', 'tree') ttM.addCorrectionFactor( '(lnujj_l2_mergedVTruth==1&&lnujj_l2_nearestBDRTruth>0.8)', 'tree') qcdPlotters = [] for sample in [
from CMGTools.VVResonances.plotting.StackPlotter import StackPlotter #create the W+jets plotters wjPlotters=[] for sample in ['WJetsToLNu_HT100to200','WJetsToLNu_HT200to400','WJetsToLNu_HT400to600','WJetsToLNu_HT600toInf']: wjPlotters.append(TreePlotter('samples/'+sample+'.root','tree')) wjPlotters[-1].setupFromFile('samples/'+sample+'.pck') wjPlotters[-1].addCorrectionFactor('xsec','xsec',0.0,'lnN') wjPlotters[-1].addCorrectionFactor('genWeight','genWeight',0.0,'lnN') WJets = MergedPlotter(wjPlotters) WJets.setFillProperties(1001,ROOT.kAzure-9) RSGWWLNuQQ = TreePlotter('samples/RSGravToWWToLNQQ_kMpl01_2500.root','tree') RSGWWLNuQQ.setupFromFile('samples/RSGravToWWToLNQQ_kMpl01_2500.pck') RSGWWLNuQQ.setFillProperties(0,ROOT.kWhite) RSGWWLNuQQ.setLineProperties(1,ROOT.kOrange+10,3) RSGWWLNuQQ.addCorrectionFactor('xsec',0.001,0.0,'lnN') #Stack vvStack = StackPlotter() vvStack.addPlotter(WJets,"W+jets","W+Jets","background") vvStack.addPlotter(RSGWWLNuQQ,"RSG2000","RSGWW #rightarrow l#nu QQ","signal")
"WJetsToLNu_HT1200to2500", "WJetsToLNu_HT2500toInf", "WJetsToLNu_HT400to600", "WJetsToLNu_HT600to800", "WJetsToLNu_HT800to1200", 'WJetsToLNu_HT100to200', 'WJetsToLNu_HT200to400' ]: wjPlotters.append(TreePlotter('samples/' + sample + '.root', 'tree')) wjPlotters[-1].setupFromFile('samples/' + sample + '.pck') wjPlotters[-1].addCorrectionFactor('xsec', 'tree') wjPlotters[-1].addCorrectionFactor('genWeight', 'tree') wjPlotters[-1].addCorrectionFactor('puWeight', 'tree') WJets = MergedPlotter(wjPlotters) tt = TreePlotter('samples/TTJets.root', 'tree') tt.setupFromFile('samples/TTJets.pck') tt.addCorrectionFactor('xsec', 'tree') tt.addCorrectionFactor('genWeight', 'tree') tt.addCorrectionFactor('puWeight', 'tree') #create the Z+jets plotters zPlotters = [] for sample in [ 'DYJetsToLL_M50_HT100to200', 'DYJetsToLL_M50_HT200to400', 'DYJetsToLL_M50_HT400to600', 'DYJetsToLL_M50_HT600toInf' ]: zPlotters.append(TreePlotter('samples/' + sample + '.root', 'tree')) zPlotters[-1].setupFromFile('samples/' + sample + '.pck') zPlotters[-1].addCorrectionFactor('xsec', 'tree') zPlotters[-1].addCorrectionFactor('genWeight', 'tree') zPlotters[-1].addCorrectionFactor('puWeight', 'tree')
from CMGTools.VVResonances.plotting.MergedPlotter import MergedPlotter from CMGTools.VVResonances.plotting.StackPlotter import StackPlotter #create the W+jets plotters wjPlotters = [] for sample in [ 'WJetsToLNu_HT100to200', 'WJetsToLNu_HT200to400', 'WJetsToLNu_HT400to600', 'WJetsToLNu_HT600toInf' ]: wjPlotters.append(TreePlotter('samples/' + sample + '.root', 'tree')) wjPlotters[-1].setupFromFile('samples/' + sample + '.pck') wjPlotters[-1].addCorrectionFactor('xsec', 'xsec', 0.0, 'lnN') wjPlotters[-1].addCorrectionFactor('genWeight', 'genWeight', 0.0, 'lnN') WJets = MergedPlotter(wjPlotters) WJets.setFillProperties(1001, ROOT.kAzure - 9) RSGWWLNuQQ = TreePlotter('samples/RSGravToWWToLNQQ_kMpl01_2500.root', 'tree') RSGWWLNuQQ.setupFromFile('samples/RSGravToWWToLNQQ_kMpl01_2500.pck') RSGWWLNuQQ.setFillProperties(0, ROOT.kWhite) RSGWWLNuQQ.setLineProperties(1, ROOT.kOrange + 10, 3) RSGWWLNuQQ.addCorrectionFactor('xsec', 0.001, 0.0, 'lnN') #Stack vvStack = StackPlotter() vvStack.addPlotter(WJets, "W+jets", "W+Jets", "background") vvStack.addPlotter(RSGWWLNuQQ, "RSG2000", "RSGWW #rightarrow l#nu QQ", "signal")