#!/usr/bin/python import os,sys from ROOT import * from fpformat import fix def makegstyle(cStyle): cStyle.SetPadBorderMode(0) cStyle.SetOptStat(0) ## Hide stats cStyle.SetOptTitle(1) ## Display histogram titles. cStyle.SetCanvasColor(10) ## Background color (white) cStyle.SetPadColor(10) ## Background color (white) cStyle.SetFillColor(10) ## Background color (white) cStyle.SetTitleFillColor(10) ## Background color (white) cStyle.SetStatColor(10) ## Background color (white) cStyle.SetPalette(1) ## Nicer colour scale for 2D histograms. cStyle.SetTitleBorderSize(0) ##duh return cStyle gStyle = makegstyle(gStyle) #read in histos fu = 'g580a1s3_raw_s80a1s4_rawUSineff.root' fd = 'g580a1s3_raw_s80a1s4_rawDSineff.root' fuf = TFile(fu) iup = fuf.Get('hdiff_pflx').Clone() iuct = fuf.Get('hdiff_pfly').Clone() fud = TFile(fd) idp = fud.Get('hdiff_pflx').Clone() idct = fud.Get('hdiff_pfly').Clone() #change ranges iup.GetXaxis().SetRangeUser(15.,55.) idp.GetXaxis().SetRangeUser(15.,55.) iuct.GetXaxis().SetRangeUser(0.5001,1.00) idct.GetXaxis().SetRangeUser(0.5001,1.00) hs = [iup,idp,iuct,idct] for h in hs: # h.Scale(1000.) # h.SetMinimum(-.999) # h.SetMaximum(1.) h.SetMinimum(-0.999e-3) h.SetMaximum(1e-3) h.SetMarkerStyle(20) # h.GetXaxis().SetMaxDigits(2) #only for tgaxis damn you # h.GetYaxis().SetMaxDigits(2) h.GetXaxis().SetDecimals() h.GetYaxis().SetDecimals() h.GetXaxis().SetTitleOffset(1.3) h.GetYaxis().SetTitleOffset(1.9) h.SetTitleSize(0.07) h.GetXaxis().SetTitleSize(0.07) h.GetYaxis().SetTitleSize(0.07) h.GetXaxis().SetLabelSize(0.07) h.GetYaxis().SetLabelSize(0.07) h.GetXaxis().SetNdivisions(505) h.GetYaxis().SetNdivisions(505) for h in [iup,idp]: h.SetTitle('; p (MeV/c); difference in efficiency (data-sim.)') for h in [iuct,idct]: h.SetTitle('; |cos#theta|; difference in efficiency (data-sim.)') iup.SetTitle('Upstream') idp.SetTitle('Downstream') for h in [iup,idp]: h.Fit('pol0','EM') g = h.GetFunction('pol0') g.SetLineWidth(1) g.SetLineStyle(7) pa = 1E4*g.GetParameter(0) epa = 1E4*g.GetParError(0) print 2*'\n' print 'momentum plot: diff = (',fix(pa,2),'+-',fix(epa,2),') x 10^{-4}' print 2*'\n' for h in [iuct,idct]: h.Fit('pol1','EM') g = h.GetFunction('pol1') g.SetLineWidth(1) g.SetLineStyle(7) pa0 = 1E4*g.GetParameter(0) epa0 = 1E4*g.GetParError(0) pa1 = 1E4*g.GetParameter(1) epa1 = 1E4*g.GetParError(1) print 2*'\n' print 'momentum plot: diff =(',fix(pa0,1),'+-',fix(epa0,1),') + (',fix(pa1,1),'+-',fix(epa1,1),')cos-theta x 10^{-4}' print 2*'\n' c1 = TCanvas('c1','c1') c1.Divide(2,2) for ci in [c1_1,c1_2,c1_3,c1_4]: ci.SetGridx() ci.SetGridy() ci.SetLeftMargin(.25) ci.SetRightMargin(.05) ci.SetBottomMargin(.2) c1.cd(1) iup.Draw() c1.cd(2) idp.Draw() c1.cd(3) iuct.Draw() c1.cd(4) idct.Draw() au = raw_input('>')