Skip to content

Instantly share code, notes, and snippets.

@ram1123
Last active July 4, 2018 11:13
Show Gist options
  • Select an option

  • Save ram1123/26e727227cbc30929641177ea5cd42bc to your computer and use it in GitHub Desktop.

Select an option

Save ram1123/26e727227cbc30929641177ea5cd42bc to your computer and use it in GitHub Desktop.
Issue: Compare Integral of histogram and equivalent function

(PyROOT) Read Histogram from tree

import ROOT as r

fin = r.TFile.Open("root://cmseos.fnal.gov//store/user/rasharma/SecondStep/WWTree_2018_01_07_12h02/HaddedFiles/Hadds_for_BkgEstimation/WWTree_WJets.root")

treeIn = fin.Get("otree")

c1 = r.TCanvas("c1","c1",800,600)

h1 = r.TH1F("h1","",22,40,150)
h1.Sumw2()
h1.SetMinimum(0.)
h1.SetMaximum(850.)

#cutString = #"wSampleWeight*35867.06*genWeight*" \
	    # "pu_Weight*trig_eff_Weight*id_eff_Weight*btag0Wgt*" \
cutString =  "(l_pt2<0 && " \
	     "l_pt1>30 && abs(l_eta1)<2.5 && " \
	     "pfMET_Corr>50 && " \
	     "PuppiAK8_jet_tau2tau1<0.55 && " \
	     "ungroomed_PuppiAK8_jet_pt>200 && abs(ungroomed_PuppiAK8_jet_eta)<2.4 && " \
	     "mass_lvj_type0>600 && mass_lvj_type0<4000 && " \
	     "nBTagJet_loose==0 && " \
	     "BosonCentrality_type0>1.0 && " \
	     "ZeppenfeldWL_type0/vbf_maxpt_jj_Deta<0.3 && " \
	     "ZeppenfeldWH/vbf_maxpt_jj_Deta <0.3 && " \
	     "vbf_maxpt_jj_m>800 && " \
	     "vbf_maxpt_jj_Deta>4.0 && " \
	     "vbf_maxpt_j1_pt>30 && vbf_maxpt_j2_pt>30) && " \
	     "PuppiAK8_jet_mass_so>40 && PuppiAK8_jet_mass_so<150"


treeIn.Draw("PuppiAK8_jet_mass_so>>h1",cutString)

f1 = r.TF1("f1","(0.85)*9528.33*TMath::Exp(-0.025973*x)*(1. + TMath::Erf((x-68.8813)/40.3924))/2.",40,150)
f1.SetLineColor(2)
f1.Draw("same")
print "Entries from MC = ",h1.GetEntries(),h1.Integral()
print "Entries from fit = ",f1.Integral(40,150)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment