def makeHist3D_(tree, y, z, options, weightedMC=False): print "Filling tree for cut %s" % options.cut finalCut = makeCut(options.cut) if weightedMC: #finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*trgSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta,2)*leptonSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta)*leptonSF_We(LepGood2_pdgId,LepGood2_pt,LepGood2_eta) " % finalCut # add trigger SF for triggering object # add also prefiring, but should decide which lepton to use (unless using jet function) finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*_get_muonSF_recoToSelection(LepGood1_pdgId,LepGood1_rocPt,LepGood1_eta)*_get_muonSF_recoToSelection(LepGood2_pdgId,LepGood2_rocPt,LepGood2_eta)*triggerSFforChargedLeptonMatchingTriggerWlike(isOddEvent(evt),(LepGood_matchedTrgObjMuDR[0]>0.0 || LepGood_matchedTrgObjTkMuDR[0] > 0.0),(LepGood_matchedTrgObjMuDR[1] >0.0 || LepGood_matchedTrgObjTkMuDR[1]>0.0),LepGood_pdgId[0],LepGood_pdgId[1],LepGood_rocPt[0],LepGood_rocPt[1],LepGood_eta[0],LepGood_eta[1])" % finalCut finalCut = scalarToVector(finalCut) yexpr, yedges = y zexpr, zedges = z xbins, xmin, xmax = map(float, options.xvar[1].split(",")) xedges = [ xmin + i * (xmax - xmin) / int(xbins) for i in xrange(0, int(xbins) + 1) ] hist = ROOT.TH3D("hist", "hist", len(xedges) - 1, array('f', xedges), len(yedges) - 1, array('f', yedges), len(zedges) - 1, array('f', zedges)) nent = tree.Draw( "%s:%s:%s>>hist" % (scalarToVector(zexpr), scalarToVector(yexpr), scalarToVector(options.xvar[0])), finalCut, "goff", options.maxEntries) hist = ROOT.gROOT.FindObject("hist") if weightedMC: for bx in xrange(hist.GetNbinsX() + 2): for by in xrange(hist.GetNbinsY() + 2): for bz in xrange(hist.GetNbinsZ() + 2): hist.SetBinContent(bx, by, bz, max(0, hist.GetBinContent(bx, by, bz))) return hist
def makeHist2D( tree, options, weightedMC=False, dmvar="0.5*mZ1*TMath::Hypot(LepGood_ptErrTk[0]/LepGood_pt[0], LepGood_ptErrTk[1]/LepGood_pt[1])", dmbins=50, dmrange=[0.3, 5]): print "Filling tree for cut %s" % options.cut finalCut = makeCut(options.cut) if weightedMC: #finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*trgSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta,2)*leptonSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta)*leptonSF_We(LepGood2_pdgId,LepGood2_pt,LepGood2_eta) " % finalCut # add trigger SF for triggering object # add also prefiring, but should decide which lepton to use (unless using jet function) finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*_get_muonSF_recoToSelection(LepGood1_pdgId,LepGood1_rocPt,LepGood1_eta)*_get_muonSF_recoToSelection(LepGood2_pdgId,LepGood2_rocPt,LepGood2_eta)*triggerSFforChargedLeptonMatchingTriggerWlike(isOddEvent(evt),(LepGood_matchedTrgObjMuDR[0]>0.0 || LepGood_matchedTrgObjTkMuDR[0] > 0.0),(LepGood_matchedTrgObjMuDR[1] >0.0 || LepGood_matchedTrgObjTkMuDR[1]>0.0),LepGood_pdgId[0],LepGood_pdgId[1],LepGood_rocPt[0],LepGood_rocPt[1],LepGood_eta[0],LepGood_eta[1])" % finalCut finalCut = scalarToVector(finalCut) tree.Draw( "%s:%s>>hist(%s,%d,%g,%g)" % (scalarToVector(dmvar), scalarToVector(options.xvar[0]), scalarToVector(options.xvar[1]), dmbins, dmrange[0], dmrange[1]), finalCut, "goff", options.maxEntries) hist = ROOT.gROOT.FindObject("hist") if weightedMC: for bx in xrange(hist.GetNbinsX() + 2): for by in xrange(hist.GetNbinsY() + 2): hist.SetBinContent(bx, by, max(0, hist.GetBinContent(bx, by))) return hist
def makeHist3D_(tree, y, z, options, weightedMC=False): print "Filling tree for cut %s" % options.cut finalCut = makeCut(options.cut) if weightedMC: finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*trgSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta,2)*leptonSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta)*leptonSF_We(LepGood2_pdgId,LepGood2_pt,LepGood2_eta) " % finalCut finalCut = scalarToVector(finalCut) yexpr, yedges = y zexpr, zedges = z xbins, xmin, xmax = map(float, options.xvar[1].split(",")) xedges = [ xmin + i * (xmax - xmin) / int(xbins) for i in xrange(0, int(xbins) + 1) ] hist = ROOT.TH3D("hist", "hist", len(xedges) - 1, array('f', xedges), len(yedges) - 1, array('f', yedges), len(zedges) - 1, array('f', zedges)) nent = tree.Draw( "%s:%s:%s>>hist" % (scalarToVector(zexpr), scalarToVector(yexpr), scalarToVector(options.xvar[0])), finalCut, "goff", options.maxEntries) hist = ROOT.gROOT.FindObject("hist") if weightedMC: for bx in xrange(hist.GetNbinsX() + 2): for by in xrange(hist.GetNbinsY() + 2): for bz in xrange(hist.GetNbinsZ() + 2): hist.SetBinContent(bx, by, bz, max(0, hist.GetBinContent(bx, by, bz))) return hist
def makeHist1D(tree, options, weightedMC=False): print "Filling tree for cut %s" % options.cut finalCut = makeCut(options.cut) if weightedMC: finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*trgSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta,2)*leptonSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta)*leptonSF_We(LepGood2_pdgId,LepGood2_pt,LepGood2_eta)" % finalCut finalCut = scalarToVector(finalCut) tree.Draw( "%s>>hist(%s)" % (scalarToVector(options.xvar[0]), options.xvar[1]), finalCut, "goff", options.maxEntries) print "Done, fitting." hist = ROOT.gROOT.FindObject("hist") if weightedMC: for b in xrange(hist.GetNbinsX() + 2): hist.SetBinContent(b, max(0, hist.GetBinContent(b))) hist.GetXaxis().SetTitle(options.xtitle) return hist
def makeHist1D(tree, options, weightedMC=False): print "Filling tree for cut %s" % options.cut finalCut = makeCut(options.cut) if weightedMC: #finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*trgSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta,2)*leptonSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta)*leptonSF_We(LepGood2_pdgId,LepGood2_pt,LepGood2_eta)" % finalCut # add trigger SF for triggering object # add also prefiring, but should decide which lepton to use (unless using jet function) finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*_get_muonSF_recoToSelection(LepGood1_pdgId,LepGood1_rocPt,LepGood1_eta)*_get_muonSF_recoToSelection(LepGood2_pdgId,LepGood2_rocPt,LepGood2_eta)*triggerSFforChargedLeptonMatchingTriggerWlike(isOddEvent(evt),(LepGood_matchedTrgObjMuDR[0]>0.0 || LepGood_matchedTrgObjTkMuDR[0] > 0.0),(LepGood_matchedTrgObjMuDR[1] >0.0 || LepGood_matchedTrgObjTkMuDR[1]>0.0),LepGood_pdgId[0],LepGood_pdgId[1],LepGood_rocPt[0],LepGood_rocPt[1],LepGood_eta[0],LepGood_eta[1])" % finalCut finalCut = scalarToVector(finalCut) tree.Draw( "%s>>hist(%s)" % (scalarToVector(options.xvar[0]), options.xvar[1]), finalCut, "goff", options.maxEntries) print "Done, fitting." hist = ROOT.gROOT.FindObject("hist") if weightedMC: for b in xrange(hist.GetNbinsX() + 2): hist.SetBinContent(b, max(0, hist.GetBinContent(b))) hist.GetXaxis().SetTitle(options.xtitle) return hist
def makeHist2D( tree, options, weightedMC=False, dmvar="0.5*mZ1*TMath::Hypot(LepGood_ptErr[0]/LepGood_pt[0], LepGood_ptErr[1]/LepGood_pt[1])", dmbins=50, dmrange=[0.3, 5]): print "Filling tree for cut %s" % options.cut finalCut = makeCut(options.cut) if weightedMC: finalCut = "(%s) * puw2016_nTrueInt_36fb(nTrueInt)*trgSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta,2)*leptonSF_We(LepGood1_pdgId,LepGood1_pt,LepGood1_eta)*leptonSF_We(LepGood2_pdgId,LepGood2_pt,LepGood2_eta) " % finalCut finalCut = scalarToVector(finalCut) tree.Draw( "%s:%s>>hist(%s,%d,%g,%g)" % (scalarToVector(dmvar), scalarToVector(options.xvar[0]), scalarToVector(options.xvar[1]), dmbins, dmrange[0], dmrange[1]), finalCut, "goff", options.maxEntries) hist = ROOT.gROOT.FindObject("hist") if weightedMC: for bx in xrange(hist.GetNbinsX() + 2): for by in xrange(hist.GetNbinsY() + 2): hist.SetBinContent(bx, by, max(0, hist.GetBinContent(bx, by))) return hist