#!/usr/bin/python # -*- coding: iso-8859-15 -*- import os,sys # import getopt ##maybe it's supposed to be sys.argv[:] ... maybe tmpargv = sys.argv sys.argv = [ '-n' ] from ROOT import * sys.argv = tmpargv # import psyco # psyco.full() # from time import sleep # from optparse import OptionParser # from ROOT_Tools import RootHandler # from CommandLineMod import CommandLine if __name__ == "__main__": gStyle.SetTitleBorderSize ( 0 ) # duh # gStyle.SetTitleBorderSize ( 1 ) gStyle.SetPadBorderMode ( 0 ) gStyle.SetOptStat ( 111111 ) # Good standard stats display. gStyle.SetOptFit ( 1111 ) # Display fit info if available. # gStyle.SetMarkerStyle ( 24 ) # Open circle. gStyle.SetOptTitle ( 1 ) # Display histogram titles. gStyle.SetCanvasColor ( 10 ) # Background color (white) gStyle.SetPadColor ( 10 ) # Background color (white) gStyle.SetFillColor ( 10 ) # Background color (white) # gStyle.SetHistFillColor ( 10 ) # Background color (white) gStyle.SetFrameFillColor ( 10 ) # Background color (white) gStyle.SetStatColor ( 10 ) # Background color (white) gStyle.SetTextFont ( 132 ) gStyle.SetPadLeftMargin (0.15) gStyle.SetPadBottomMargin (0.13) gStyle.SetPadTopMargin (0.07) gStyle.SetPadRightMargin (0.05) gStyle.SetTitleFillColor ( 10 ) # Background color (white) gStyle.SetTitleFontSize ( 0.08 ) # Title Font Size gStyle.SetTitleX ( 0.10 ) # Title box width gStyle.SetTitleW ( 0.50 ) # Title box width gStyle.SetTitleH ( 0.09 ) # Title box width gStyle.SetStatX ( 0.95 ) # Statistic box width gStyle.SetStatW ( 0.2 ) # Statistic box width gStyle.SetStatBorderSize ( 1 ) gStyle.SetLegendBorderSize ( 1 ) gStyle.SetPalette ( 1 ) # Nicer colour scale for 2D histograms. gStyle.SetPaperSize ( 20., 24. ) gStyle.SetHistLineWidth ( 1 ) gStyle.SetLabelFont(132) gStyle.SetLabelFont(132,"X") gStyle.SetLabelFont(132,"Y") gStyle.SetLabelFont(132,"Z") gStyle.SetLabelFont(132,"T") gStyle.SetTitleFont(132) gStyle.SetTitleFont(132,"X") gStyle.SetTitleFont(132,"Y") gStyle.SetTitleFont(132,"Z") gStyle.SetTitleFont(132,"T") gStyle.SetLabelSize(0.06) gStyle.SetLabelSize(0.06,"X") gStyle.SetLabelSize(0.06,"Y") gStyle.SetLabelSize(0.06,"Z") gStyle.SetLabelSize(0.06,"T") gStyle.SetTitleSize(0.06 ) gStyle.SetTitleSize(0.06,"X") gStyle.SetTitleSize(0.06,"Y") gStyle.SetTitleSize(0.06,"Z") gStyle.SetTitleSize(0.06,"T") gStyle.SetTextFont(132) gStyle.SetStatFont(132) gStyle.SetStripDecimals(kFALSE) gROOT.SetBatch() gROOT.ForceStyle() # No Stats ! gStyle.SetOptStat ( 0 ) # Good standard stats display. gStyle.SetOptFit ( 0 ) # Display fit info if available. gStyle.SetTitleW ( 0.70 ) # Title box width # gStyle.SetPaperSize(17,19) gStyle.SetPaperSize(14,15) gStyle.SetCanvasDefW(900) # Defaults gStyle.SetCanvasDefH(500) # Defaults # We can have many files in input # FileList = ['TCS2006B_Charac_Ph4_Pa3.root'] # FileList = ['g473a1s2_raw_s73a8s3_rawUSineff.root'] # HistName = ['effhist_s73a8s3_raw_pflx','effhist_g473a1s2_raw_pflx','effhist_s73a8s3_raw_pfly','effhist_g473a1s2_raw_pfly'] # OutputFile = ['../Inefficiency_s73.eps'] FileList = ['g580a1s3_raw_s80a1s3_rawDSineff.root'] HistName = ['effhist_s80a1s3_raw_pflx','effhist_g580a1s3_raw_pflx','effhist_s80a1s3_raw_pfly','effhist_g580a1s3_raw_pfly'] OutputFile = ['../Inefficiency_s80_DS.eps'] F=[] Canv = TCanvas() # Leg = TLegend(0.38, 0.35,0.72,0.5) Leg = TLegend(0.65, 0.73,0.95,0.93) # Leg2 = TLegend(0.36, 0.34,0.71,0.39) MinX = 0.4 MaxX = 1.0 # MinX = -0.049 # MaxX = 0.049 MinY = -2000 MaxY = 73000 # Title = 'TDC time versus TDC width, wire 12;Width [ns];Hit time [ns]' Title = ';Downstream inefficiency' # Title = ';Downstream inefficiency (1 - #epsilon)' LegName = ['Data','MC'] t=0 H = [] # H = [TH1D(),TH1D(),TH1D(),TH1D()] Canv.cd() # MainPad = TPad("MainPad","MainPad", 0., 0.4, 1., 1.) # # MainPad.SetLogy() # MainPad.Draw() # DiffPad = TPad("DiffPad", "DiffPad", 0., 0.0, 1., 0.4) # DiffPad.Draw() LeftPad = TPad("LeftPad","LeftPad", 0., 0., 0.5, 1.) # LeftPad.SetLogy() LeftPad.Draw() LeftPad.SetGrid(1,3) RightPad = TPad("RightPad","RightPad", 0.5, 0., 1., 1.) # RightPad.SetLogy() RightPad.Draw() RightPad.SetGrid(1,3) # for i,f in enumerate(FileList): MonTest = TGaxis() MonTest.SetMaxDigits(2) F.append( TFile(FileList[0]) ) for i,h in enumerate(HistName): H.append(F[0].Get(h)) # MainPad.cd() # MainPad.SetBottomMargin (0.0) # gPad.SetLogY() # print "here ",i," =>",H[i].GetMean(),H[i].GetMeanError() # H.SetNdivision(505) if ( i < 2 ): LeftPad.cd() else: RightPad.cd() if ( i == 0 or i == 2): H[i].SetLineColor(4) H[i].SetLineWidth(1) H[i].SetMarkerColor(4) H[i].SetMarkerStyle(4) H[i].SetMarkerSize(0.6) H[i].SetNdivisions(505) # H[i].SetMaxDigits(2) # SetMaxDigits(2) # H[i].Rebin(40) # H[i].Scale(2000000/H[i].Integral()) H[i].Draw('E') # H[i].SetLabelSize(0) H[i].SetTitle(Title) if ( i < 2 ): H[i].SetAxisRange(11.0,54,'X') H[i].SetTitle(';Momentum [MeV/c]'+Title) else: H[i].SetAxisRange(0.52,1.0,'X') H[i].SetTitle(';cos#theta '+Title) # H[i].SetAxisRange(MinY,MaxY,'Y') # H.SetLineWidth(1) # H[i].SetTitleSize(0.05,"Y") H[i].SetTitleOffset( 1.2, 'Y') # H.Fit('pol1', "Q","", 20.0, 150.0) # H.GetFunction('pol1').SetLineWidth(1) # Hdiff = H[i].Clone() # Hdiff = TH1D("PercDiff",H[i].GetTitle(), H[i].GetNbinsX(), H[i].GetXaxis().GetXmin(), H[i].GetXaxis().GetXmax()) if ( i == 0): Leg.AddEntry(H[i], LegName[i], 'P') else: H[i].SetLineColor(2) H[i].SetMarkerColor(2) # Htmp[t].SetLineWidth(1) H[i].SetMarkerStyle(5) H[i].SetMarkerSize(0.6) # H[i].Rebin(40) #H[i].Scale(1/H[i].Integral()) # H[i].Scale(2000000/H[i].Integral()) #H[i].Scale(H[0].Integral()/H[i].Integral()) H[i].Draw('sameE') if ( i ==1 ): Leg.AddEntry(H[i], LegName[i], 'p') Leg.Draw() # for j in range(Hdiff.GetNbinsX()): # if ( H[0].GetBinContent(j) != 0 and H[1].GetBinContent(j) != 0 ): # Val = ( H[0].GetBinContent(j) - H[1].GetBinContent(j)) / H[1].GetBinContent(j) # Err = ( H[0].GetBinContent(j)/H[1].GetBinContent(j)) * sqrt( ( H[0].GetBinError(j) * H[0].GetBinError(j) / (H[0].GetBinContent(j)*H[0].GetBinContent(j))) + ( H[1].GetBinError(j) * H[1].GetBinError(j) / (H[1].GetBinContent(j)*H[1].GetBinContent(j)))) # # Err = sqrt( ( H[0].GetBinError(j) * H[0].GetBinError(j) ) + ( H[1].GetBinError(j) * H[1].GetBinError(j) )) # # print H[0].GetBinCenter(j), Err, Val, sqrt( ( H[0].GetBinError(j) * H[0].GetBinError(j) / (H[0].GetBinContent(j)*H[0].GetBinContent(j))) + ( H[1].GetBinError(j) * H[1].GetBinError(j) / (H[1].GetBinContent(j)*H[1].GetBinContent(j)))) # else: # Val = 0 # Err = 0 # Hdiff.SetBinContent(j, Val * 100) # Hdiff.SetBinError(j, Err * 100) # # print Hdiff.GetBinError(j) # # Hdiff.Scale(100.) # DiffPad.cd() # DiffPad.SetGrid() # Hdiff.SetTitleSize(0.07) # Hdiff.SetTitleSize(0.07,"X") # Hdiff.SetTitleSize(0.09,"Y") # Hdiff.SetTitleSize(0.07,"Z") # Hdiff.SetTitleSize(0.07,"T") # Hdiff.SetTitleOffset(0.5,"Y") # Hdiff.SetTitle(';#Delta#theta = #theta^{US} - #theta^{DS} [rad];%') # Hdiff.SetLabelSize(0.07) # Hdiff.SetLabelSize(0.07,"X") # Hdiff.SetLabelSize(0.07,"Y") # Hdiff.SetLabelSize(0.07,"Z") # Hdiff.SetLabelSize(0.07,"T") # DiffPad.SetTopMargin (0.0) # DiffPad.SetBottomMargin (0.20) # Hdiff.Draw('E1') # Hdiff.SetMarkerStyle(0) # Hdiff.SetAxisRange(MinX,MaxX,'X') # Hdiff.SetAxisRange(-12,14,'Y') # Leg.AddEntry(H[i], LegName[i]+' '+str(H[i].GetEntries()), 'p') # Leg.AddEntry(H[i], LegName[i], 'p') # for j,H in enumerate([H2D.ProjectionX(LegName[i]+'_X'), H2D.ProjectionY(LegName[i]+'_Y')]): # # Shift to change the X axis from mofia coordinates to drift distance # Htmp[t].SetName('TmpHisto'+str(i)+str(j)) # Htmp[t].SetBins(H.GetNbinsX(),H.GetXaxis().GetXmin()+3.368,H.GetXaxis().GetXmax()+3.368) # for b in range(1, (H.GetNbinsX()+1) ): # Htmp[t].SetBinContent(b, H.GetBinContent(b)) # Canv[j].cd() # if ( i == 0): # Htmp[t].Draw() # Htmp[t].SetTitle(Title[j]) # Htmp[t].SetAxisRange(MinX,MaxX,'X') # Htmp[t].SetAxisRange(MinY,MaxY,'Y') # Htmp[t].SetLineWidth(1) # Htmp[t].SetTitleOffset( 1.2, 'Y') # # H.Fit('pol1', "Q","", 20.0, 150.0) # # H.GetFunction('pol1').SetLineWidth(1) # else: # if ( i > 3 ): # Htmp[t].SetLineColor(i+2) # Htmp[t].SetMarkerColor(i+2) # else: # Htmp[t].SetLineColor(i+1) # Htmp[t].SetMarkerColor(i+1) # Htmp[t].SetLineWidth(1) # Htmp[t].Draw('same') # if ( j == 0 ): # Leg.AddEntry(Htmp[t], LegName[i], 'l') # t = t + 1 # Leg2.AddEntry(Hdiff, LegName[2], 'l') Canv.cd() # Leg.Draw() # Leg2.Draw() # For eps Canv.Print(OutputFile[0]) # Canv[1].cd() # Leg.Draw() # # For eps # Canv[1].Print(OutputFile[1])