if args.asimov != '' and args.saveTrees: print 'Cannot use --save-trees together with --asimov.' sys.exit(1) fullLumi = 0. effLumi = 0. for sName in plotConfig.obs.samples: fullLumi += allsamples[sName].lumi effLumi += allsamples[sName].lumi / plotConfig.prescales[sName] # from config import jsonLumi, jsonLumiBlinded # fullLumi = min(jsonLumi, fullLumi) # effLumi = min(jsonLumiBlinded, effLumi) canvas = DataMCCanvas() if args.plotDir: if args.plotDir == '-': plotDir = '' else: plotDir = args.plotDir else: plotDir = 'monophoton/' + args.config if plotDir and args.clearDir: for plot in os.listdir(WEBDIR + '/' + plotDir): os.remove(WEBDIR + '/' + plotDir + '/' + plot) print "Starting plot making for %s." % plotConfig.name
import math import array thisdir = os.path.dirname(os.path.realpath(__file__)) basedir = os.path.dirname(thisdir) sys.path.append(basedir) from plotstyle import DataMCCanvas from datasets import allsamples from main.plotconfig import VariableDef import config import ROOT as r r.gROOT.SetBatch(True) lumi = min(config.jsonLumi, allsamples['smu-16b2-d'].lumi + allsamples['smu-16c2-d'].lumi + allsamples['smu-16d2-d'].lumi) canvas = DataMCCanvas(lumi = lumi) probePixel = '!probe.pixelVeto' zMassCut = 'z.mass > 81. && z.mass < 101.' dPhiCut = 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - jets.phi[0])) > 3.' metCut = 't1Met.met > 50.' dPhiMetCut = 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - t1Met.phi)) < 0.5' jetPtCut = 'jets.pt[0] > 100.' dPhiJetCut = 't1Met.minJetDPhi > 0.5' njetsCut = 'jets.size == 1' variables = [ VariableDef('Met', 'E_{T}^{miss}', 't1Met.met', [10 * x for x in range(0, 10)] + [100 + 20 * x for x in range(0,5)] + [200, 250, 300], unit = 'GeV', overflow = True), # VariableDef('dPhi', '#Delta#phi(Z, jet)', 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - jets.phi))', (15, 0., math.pi) ), # VariableDef('dPhiJetMet', '#Delta#phi(E_{T}^{miss}, jet)', 'TMath::Abs(TVector2::Phi_mpi_pi(t1Met.phi - jets.phi))', (15, 0., math.pi) ), VariableDef('dPhiZMet', '#Delta#phi(Z, E_{T}^{miss})', 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - t1Met.phi))', (15, 0., math.pi) ), # VariableDef('jetEta', '|#eta_{j}|', 'TMath::Abs(jets.eta[0])', (10, 0., 5.), applyFullSel = True),
import math import ROOT as r basedir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.append(basedir) from plotstyle import SimpleCanvas, RatioCanvas, DataMCCanvas from datasets import allsamples import config from pprint import pprint outputFile = r.TFile.Open(basedir + '/data/gjetsTFactor.root', 'recreate') lumi = min( config.jsonLumi, allsamples['sph-16b2-d'].lumi + allsamples['sph-16c2-d'].lumi + allsamples['sph-16d2-d'].lumi) canvas = DataMCCanvas(lumi=lumi) dtree = r.TChain('events') dtree.Add(config.skimDir + '/sph-16*2-d_monoph.root') print dtree.GetEntries() btree = r.TChain('events') btree.Add(config.skimDir + '/sph-16*2-d_hfake.root') btree.Add(config.skimDir + '/sph-16*2-d_efake.root') bmctree = r.TChain('events') # bmctree.Add(config.skimDir + '/znng-130_monoph.root') # bmctree.Add(config.skimDir + '/wnlg-130_monoph.root') # bmctree.Add(config.skimDir + '/wg_monoph.root') # NLO sample to get around pT/MET > 130 GeV cut on LO sample bmctree.Add(config.skimDir + '/wglo_monoph.root') bmctree.Add(config.skimDir + '/wlnu-*_monoph.root')
""" binnings = { 'Low': array.array('d', [0. + 10. * x for x in range(10)] + [100., 120., 140., 170.] + [200. + 50. * x for x in range(9)] ), 'High': array.array('d', [0. + 10. * x for x in range(10)] + [100., 120., 140., 170.] + [200. + 50. * x for x in range(9)] ) } dmets = [] bmets = [] gmets = [] mcmets = [] lumi = allsamples['sph-d3'].lumi + allsamples['sph-d4'].lumi canvas = DataMCCanvas(lumi = lumi) for region, sel in regions: binning = binnings[region] dname = 'dmet'+region dmet = r.TH1D(dname, ';E_{T}^{miss} (GeV); Events / GeV', len(binning) - 1, binning) dmet.SetMinimum(0.002) dmet.Sumw2() dtree.Draw('t1Met.met>>'+dname, sel, 'goff') bname = 'bmet'+region bmet = r.TH1D(bname, ';E_{T}^{miss} (GeV); Events / GeV', len(binning) - 1, binning) bmet.SetMinimum(0.002) bmet.Sumw2() btree.Draw('t1Met.met>>'+bname, 'weight * '+sel, 'goff')
samples = [('zllg', r.TColor.GetColor(0xff, 0x99, 0x33)), ('ttg', r.TColor.GetColor(0xbb, 0xaa, 0xff)), ('wlnu', r.TColor.GetColor(0xff, 0xee, 0x99)), ('wg', r.TColor.GetColor(0x99, 0xee, 0xff)), ('tt', r.TColor.GetColor(0xff, 0xaa, 0xcc)), ('dy-50', r.TColor.GetColor(0x99, 0xff, 0xaa))] mcTrees = [] for sample, color in samples: mcTree = r.TChain('skim') mcTree.Add('/scratch5/ballen/hist/monophoton/phoMet/skim_' + sample + '*.root') mcTrees.append((sample, color, mcTree)) lumi = allsamples['sel-d3'].lumi + allsamples['sel-d4'].lumi canvas = DataMCCanvas(lumi=lumi) varString = '(probe.ptReco / probe.ptCorr)' probeEtaCuts = [('TMath::Abs(probe.eta) < 0.8', 'low'), ('TMath::Abs(probe.eta > 0.8)', 'high')] recoilCuts = [('recoil.pt > %i.' % pt, 'recoil' + str(pt)) for pt in [170, 200, 250, 300, 400]] njetsCut = 'njets < 2' tagEtaCut = 'TMath::Abs(tag.eta) < 0.2' cuts = [] for recoilCut in recoilCuts: allCuts = cuts + [recoilCut[0]]
thisdir = os.path.dirname(os.path.realpath(__file__)) basedir = os.path.dirname(thisdir) sys.path.append(basedir) from plotstyle import DataMCCanvas from datasets import allsamples from main.plotutil import PlotDef from main.plotconfig import getConfig import config import ROOT as r r.gROOT.SetBatch(True) lumi = sum([s.lumi for s in allsamples.getmany('sph-16*-m')]) canvas = DataMCCanvas(lumi=lumi) varDef = PlotDef('phoPt', 'E_{T}^{#gamma}', 'photons.scRawPt[0]', [175.0, 200., 250., 300., 400., 600., 1000.0], unit='GeV', overflow=True) gj = ['gj-100', 'gj-200', 'gj-400', 'gj-600'] wlnun = [ 'wlnun-0', 'wlnun-50', 'wlnun-100', 'wlnun-250', 'wlnun-400', 'wlnun-600' ] top = ['ttg', 'tg'] gg = ['gg-40', 'gg-80'] zllg = ['zllg-130-o', 'zllg-300-o']
histFile = ROOT.TFile.Open(args.histFile) # closes if not args.replot #################### ## DRAW / ANALYZE ## #################### if args.plotDir == '-' and not ('count' in plotNames or args.bbb or args.chi2): # nothing to do sys.exit(0) print 'Drawing plots..' canvas = DataMCCanvas() nentries = (1 + len(plotConfig.bkgGroups) + len(plotConfig.signalPoints)) ncolumns = math.ceil(float(nentries) / 5.) xmin = 0.35 if ncolumns > 2 else 0.55 canvas.legend.setPosition(xmin, SimpleCanvas.YMAX - 0.01 - 0.035 * 5, 0.92, SimpleCanvas.YMAX - 0.01) if args.plotDir: if args.plotDir == '-': plotDir = '' else: plotDir = args.plotDir if plotDir.startswith(plotstyle.WEBDIR): plotDir = plotDir.replace(plotstyle.WEBDIR, '') else:
import math import array thisdir = os.path.dirname(os.path.realpath(__file__)) basedir = os.path.dirname(thisdir) sys.path.append(basedir) from plotstyle import DataMCCanvas from datasets import allsamples from main.plotconfig import VariableDef import config import ROOT as r r.gROOT.SetBatch(True) lumi = min(config.jsonLumi, allsamples['smu-16b2-d'].lumi + allsamples['smu-16c2-d'].lumi + allsamples['smu-16d2-d'].lumi) canvas = DataMCCanvas(lumi = lumi) probePixel = '!probe.pixelVeto' zMassCut = 'z.mass > 81. && z.mass < 101.' dPhiCut = 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - jets.phi[0])) > 3.' dPhiMetCut = 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - t1Met.phi)) < 0.5' jetPtCut = 'jets.pt[0] > 100.' dPhiJetCut = 't1Met.minJetDPhi > 0.5' monojetCut = 'jets.size == 1' njetsCut = 'jets.size < 3' variables = [ VariableDef('met', 'E_{T}^{miss}', 't1Met.met', [25 * x for x in range(2, 4)] + [100 + 50 * x for x in range(0, 8)], unit = 'GeV', overflow = True, logy = True), # VariableDef('dPhi', '#Delta#phi(Z, jet)', 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - jets.phi))', (15, 0., math.pi) ), # VariableDef('dPhiJetMet', '#Delta#phi(E_{T}^{miss}, jet)', 'TMath::Abs(TVector2::Phi_mpi_pi(t1Met.phi - jets.phi))', (15, 0., math.pi) ), VariableDef('dPhiZMet', '#Delta#phi(Z, E_{T}^{miss})', 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - t1Met.phi))', (15, 0., math.pi) ), VariableDef('jetPt', 'p_{T}^{j}', 'jets.pt[0]', (20, 0., 1000.), unit = 'GeV', applyFullSel = True, logy = True),
data.Add('/mnt/hadoop/scratch/yiiyama/monophoton/skim/sph-16*-m_tpeg.root') outputFile.cd() data.Draw('probes.sieie>>hdata', selection, 'goff') hmc.Scale(hdata.GetSumOfWeights() / hmc.GetSumOfWeights()) ratio = hdata.Clone('ratio') ratio.Divide(hmc) line = ROOT.TF1('line', '[0] + [1] * x', 0.0085, 0.0105) line.SetParameters(1.5, -100.) ratio.Fit(line) outputFile.cd() hmc.Write() hdata.Write() ratio.Write() line.Write('fit') # visualize canvas = DataMCCanvas(lumi=sum(s.lumi for s in allsamples.getmany('sph-16*-m'))) canvas.legend.setPosition(0.7, 0.7, 0.9, 0.9) canvas.addStacked(hmc, title='MC', color=ROOT.kBlue, style=3003) canvas.addObs(hdata, title='Data') canvas.printWeb('purity', 'sieie_ratio', logy=False)
("zllg", r.TColor.GetColor(0xFF, 0x99, 0x33)), ("ttg", r.TColor.GetColor(0xBB, 0xAA, 0xFF)), ("wlnu", r.TColor.GetColor(0xFF, 0xEE, 0x99)), ("wg", r.TColor.GetColor(0x99, 0xEE, 0xFF)), ("tt", r.TColor.GetColor(0xFF, 0xAA, 0xCC)), ("dy-50", r.TColor.GetColor(0x99, 0xFF, 0xAA)), ] mcTrees = [] for sample, color in samples: mcTree = r.TChain("skim") mcTree.Add("/scratch5/ballen/hist/monophoton/phoMet/skim_" + sample + "*.root") mcTrees.append((sample, color, mcTree)) lumi = allsamples["sel-d3"].lumi + allsamples["sel-d4"].lumi canvas = DataMCCanvas(lumi=lumi) varString = "(probe.ptReco / probe.ptCorr)" probeEtaCuts = [("TMath::Abs(probe.eta) < 0.8", "low"), ("TMath::Abs(probe.eta > 0.8)", "high")] recoilCuts = [("recoil.pt > %i." % pt, "recoil" + str(pt)) for pt in [170, 200, 250, 300, 400]] njetsCut = "njets < 2" tagEtaCut = "TMath::Abs(tag.eta) < 0.2" cuts = [] for recoilCut in recoilCuts: allCuts = cuts + [recoilCut[0]] for probeEtaCut in probeEtaCuts: finalCuts = allCuts + [probeEtaCut[0]]
import ROOT ROOT.gROOT.SetBatch(True) fitDiagnostics = sys.argv[1] plots = sys.argv[2] # plots with random fakemet name = sys.argv[3] sigScale = float(sys.argv[4]) fakeNorm = float(sys.argv[5]) originalMu = 0.1 dist = 'mtPhoMet' signal = 'dph-nlo-125' region = 'gghg' canvas = DataMCCanvas() source = ROOT.TFile.Open(fitDiagnostics) bkg = source.Get('shapes_fit_s/gghg/total_background') fake = source.Get('shapes_fit_s/gghg/fakemet') sig = source.Get('shapes_fit_s/gghg/total_signal') data = source.Get('shapes_fit_s/gghg/data') bkg.Add(fake, -1.) plotsSource = ROOT.TFile.Open(plots) bkgTrue = plotsSource.Get(dist + '/bkgtotal') fakeTrue = plotsSource.Get(dist + '/fakemet') sigTrue = plotsSource.Get(dist + '/samples/' + signal + '_' + region)
thisdir = os.path.dirname(os.path.realpath(__file__)) basedir = os.path.dirname(thisdir) sys.path.append(basedir) from plotstyle import DataMCCanvas from datasets import allsamples from main.plotconfig import VariableDef import config import ROOT as r r.gROOT.SetBatch(True) smuLumi = sum(allsamples[s].lumi for s in [ 'smu-16b-r', 'smu-16c-r', 'smu-16d-r', 'smu-16e-r', 'smu-16f-r', 'smu-16g-r', 'smu-16h' ]) canvas = DataMCCanvas(lumi=smuLumi) probePixel = '!probe.pixelVeto' zMassCut = 'z.mass > 81. && z.mass < 101.' dPhiCut = 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - jets.phi[0])) > 3.' dPhiMetCut = 'TMath::Abs(TVector2::Phi_mpi_pi(z.phi - t1Met.phi)) < 0.5' jetPtCut = 'jets.pt[0] > 100.' dPhiJetCut = 't1Met.minJetDPhi > 0.5' monojetCut = 'jets.size == 1' njetsCut = 'jets.size < 3' variables = [ VariableDef('met', 'E_{T}^{miss}', 't1Met.met', [25 * x