def draw(hist, mode=1, log=False): c = rt.TCanvas(hist.GetName(), hist.GetName()) if mode == 2: hist.Draw('colz') if log == True: c.SetLogz() if mode == 1: hist.Draw('ep') if log == True: c.SetLogy() if mode == 'eff': eff_framer.Draw() hist.Draw('same') pf.showlogoprelimsim('CMS') # pf.showTitle('iso_cut = 0.%s'%iso_str) pf.showTitle(hist.GetName()) c.Modified; c.Update() return c
dsmunfl1.Add(dsmunfl2) dsmucfl1.Add(dsmucfl2) dsmusum.Add(dsmucfl1) dsmusum.Add(dsmunfl1) dsmucf.Divide(dsmucfl1, dsmusum) dsmucf.Draw('same') dsmucf.SetMarkerColor(2) smucf.GetXaxis().SetTitle('p_{T}[GeV]') smucf.GetYaxis().SetTitle('Entries (normalized)') smucf.GetXaxis().SetTitleOffset(1.2) smucf.GetYaxis().SetTitleOffset(1.4) pf.showlumi('%.2f M entries' % (ntries / 1000000.)) pf.showlogoprelimsim('CMS') leg = ROOT.TLegend(.18, .76, .4, .9) leg.SetBorderSize(0) leg.SetFillColor(ROOT.kWhite) leg.SetFillStyle(0) leg.SetTextFont(42) leg.SetTextSize(0.03) leg.AddEntry(dsmucf, 'dSA#mu', 'EP') leg.AddEntry(smucf, 'S#mu', 'EP') leg.Draw('apez same') t.Update() print('Updating pads') for tt in [t]:
def checkAcc(mode='mu'): cut_denom = '' cut_num = 'l1_matched_dsmuon_pt > 5 & l2_matched_dsmuon_pt > 5' # CHECK this should work for e os and m os # cut_num += ' & is_in_acc == 1' if mode == 'e': cut_num += ' & l0_matched_electron_pt > 30 & l0_matched_electron_reliso05 < 0.15' Mlist = Mlist_e if mode == 'mu': cut_num += ' & l0_matched_muon_pt > 25 & l0_matched_muon_reliso05 < 0.15' # Mlist = Mlist_mu Mlist = [['2',M2_mu],['5',M5_mu],['8',M8_mu]] for m, mass in Mlist: t = rt.TChain('tree') for f in mass: t.Add(f) b_2disp = np.arange(0.,350,5) b_eff = np.arange(0.,1,0.1) if m=='all': m=0 if float(m) == 1: b_2disp = np.arange(0.,450,50) if float(m) == 4: b_2disp = np.concatenate( (np.arange(0.,200,5),np.arange(200.,300,10), np.arange(300.,350,25)), axis=None ) if float(m) > 4: b_2disp = np.concatenate( (np.arange(0.,150,25), np.arange(150.,200,50), np.arange(200.,350,150)), axis=None) if float(m) == 7: b_2disp = np.concatenate( (np.arange(0.,25,1), np.arange(25.,100,25)), axis=None) if float(m) == 8: b_2disp = np.concatenate( (np.arange(0.,10,1), np.arange(10.,20,5), np.arange(20.,30,10)), axis=None) if float(m) == 9: b_2disp = np.concatenate( (np.arange(0.,5,1), np.arange(5,15,2.5)), axis=None) if float(m) == 10: b_2disp = np.concatenate( (np.arange(0.,2.5,0.5), np.arange(2.5,10,2.5)), axis=None) if m==0: m='all' framer = rt.TH2F('framer','framer',len(b_2disp)-1,b_2disp,len(b_eff)-1,b_eff) framer.SetTitle('; 2D displacement [cm]; Signal acceptance') framer.SetAxisRange(0.,350,"X") framer.SetAxisRange(0.,1,"Y") if m=='all': m=0 if float(m) == 1: framer.SetAxisRange(0.,450,"X") if float(m) == 7: framer.SetAxisRange(0.,100,"X") if float(m) == 8: framer.SetAxisRange(0.,30,"X") if float(m) == 9: framer.SetAxisRange(0.,15,"X") if float(m) == 10: framer.SetAxisRange(0.,10,"X") if m==0: m='1-10' if mode =='mu': mode = '#mu' num = rt.TH1F('num' , 'num' , len(b_2disp)-1, b_2disp) denom = rt.TH1F('denom','denom', len(b_2disp)-1, b_2disp) print '\t mass:', m, 'entries:', t.GetEntries() print '\t denom entries: %i,'%t.GetEntries(cut_denom), 'drawing denom ...' t.Draw('hnl_2d_disp >> denom', cut_denom) print '\t denom done\n\tnum entries: %i,'%t.GetEntries(cut_num), 'drawing num ...' t.Draw('hnl_2d_disp >> num', cut_num) eff = rt.TEfficiency(num, denom) c_eff = rt.TCanvas('eff_M_%s_%s'%(m,mode),'eff_M_%s_%s'%(m,mode)) framer.Draw() eff.Draw('same') pf.showlogoprelimsim('CMS') pf.showlumi('m(N) = %s GeV'%m) pf.showTitle('%s#mu#mu'%mode) c_eff.Modified(); c_eff.Update() c_eff.SaveAs(plotDir + c_eff.GetTitle() + '.root') c_eff.SaveAs(plotDir + c_eff.GetTitle() + '.pdf') c_eff.SaveAs(plotDir + c_eff.GetTitle() + '.png')
def checkAcc(mode='e'): cut_denom = '' cut = 'l1_pt > 0 & l2_pt > 0' if mode == 'e': # cut_mll += ' & l0_matched_electron_pt > 30 & l0_matched_electron_reliso05 < 0.15' Mlist = Mlist_e if mode == 'mu': # cut_mll += ' & l0_matched_muon_pt > 25 & l0_matched_muon_reliso05 < 0.15' Mlist = Mlist_mu if mode == 'cmbd': Mlist = Mlist_em for m, mass in Mlist: t = rt.TChain('tree') for f in mass: t.Add(f) b_m = np.arange(0., 10, 0.1) b_eff = np.arange(0., 1, 0.1) # if m=='all': m=0 # if m=='cmbd':m=11 # if float(m) == 1: # b_m = np.arange(0.,450,50) # if float(m) == 4: # b_m = np.concatenate( (np.arange(0.,200,5),np.arange(200.,300,10), np.arange(300.,350,25)), axis=None ) # if float(m) > 4: # b_m = np.concatenate( (np.arange(0.,150,25), np.arange(150.,200,50), np.arange(200.,350,150)), axis=None) # if float(m) == 7: # b_m = np.concatenate( (np.arange(0.,25,1), np.arange(25.,100,25)), axis=None) # if float(m) == 8: # b_m = np.concatenate( (np.arange(0.,10,1), np.arange(10.,20,5), np.arange(20.,30,10)), axis=None) # if float(m) == 9: # b_m = np.concatenate( (np.arange(0.,5,1), np.arange(5,15,2.5)), axis=None) # if float(m) == 10: # b_m = np.concatenate( (np.arange(0.,2.5,0.5), np.arange(2.5,10,2.5)), axis=None) # if m==0: m='all' # if m==11: m='cmbd' framer = rt.TH2F('framer', 'framer', len(b_m) - 1, b_m, len(b_eff) - 1, b_eff) framer.SetTitle('; 2D displacement [cm]; Signal acceptance') framer.SetAxisRange(0., 350, "X") framer.SetAxisRange(0., 1, "Y") # if m=='all': m=0 # if float(m) == 1: # framer.SetAxisRange(0.,450,"X") # if float(m) == 7: # framer.SetAxisRange(0.,100,"X") # if float(m) == 8: # framer.SetAxisRange(0.,30,"X") # if float(m) == 9: # framer.SetAxisRange(0.,15,"X") # if float(m) == 10: # framer.SetAxisRange(0.,10,"X") # if m==0: m='1-10' if mode == 'mu': mode = '#mu' if mode == 'cmbd': mode = '(e+#mu)' mll = rt.TH1F('mll', 'mll', len(b_m) - 1, b_m) mll.SetTitle('; di-muon mass [GeV]; a.u.') print '\t mass:', m, 'entries:', t.GetEntries() print '\t done\n\thist entries: %i,' % t.GetEntries( cut), 'drawing mll ...' t.Draw('hnl_m_12 >> mll', cut) c_mll = rt.TCanvas('mll_M_%s_%s' % (m, mode), 'mll_M_%s_%s' % (m, mode)) mll.DrawNormalized() pf.showlogoprelimsim('CMS') pf.showlumi('m(N) = %s GeV' % m) pf.showTitle('%s#mu#mu' % mode) c_mll.Modified() c_mll.Update() c_mll.SaveAs(plotDir + c_mll.GetTitle() + '.root') c_mll.SaveAs(plotDir + c_mll.GetTitle() + '.pdf') c_mll.SaveAs(plotDir + c_mll.GetTitle() + '.png')