#!/usr/bin/python # -*- coding: iso-8859-15 -*- # Anthony Hillairet # April 2009 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 if __name__ == "__main__": # ================ Display (Canvas, pads ...) =================== # # Canvas gStyle.SetCanvasColor ( 10 ) # Background color (white) # gStyle.SetCanvasDefH(500) # Default = 500 # gStyle.SetCanvasDefW(700) # Default = 700 # Output size # gStyle.SetPaperSize ( 20., 24. ) # Default = 20.,26. gStyle.SetPaperSize ( 12., 12. ) # Default = 20.,26. # Pads gStyle.SetPadBorderMode ( 0 ) gStyle.SetPadColor ( 10 ) # Background color (white) gStyle.SetPadLeftMargin (0.08) gStyle.SetPadBottomMargin (0.11) gStyle.SetPadRightMargin (0.14) gStyle.SetPadTopMargin (0.08) # Miscellaneous gStyle.SetFillColor ( 10 ) # Background color (white) gStyle.SetFrameFillColor ( 10 ) # Background color (white) # ================ Fonts variable ================= # Font = 132 # Times roman FontSize = 0.05 # ================ Plots =================== # gStyle.SetOptTitle ( 1 ) # Display histogram titles. gStyle.SetMarkerStyle ( 5 ) # Cross gStyle.SetPalette ( 1 ) # Nicer colour scale for 2D histograms. gStyle.SetHistLineWidth ( 2 ) # ================ Stat Box =================== # # Display name of the histogram, entries, mean, RMS, underflow, overflow gStyle.SetOptStat ( 111111 ) # Good standard stats display. gStyle.SetOptFit ( 1111 ) # Display fit info if available. gStyle.SetStatColor ( 10 ) # Background color (white) gStyle.SetStatX ( 0.95 ) # Statistic box X gStyle.SetStatY ( 0.9 ) # Statistic box Y gStyle.SetStatW ( 0.2 ) # Statistic box width # gStyle.SetStatH ( 0.2 ) # Statistic box height gStyle.SetStatBorderSize ( 1 ) gStyle.SetStatFont(Font) # No Stat box ! # gStyle.SetOptStat ( 0 ) # Good standard stats display. # gStyle.SetOptFit ( 0 ) # Display fit info if available. # ================ Title =================== # gStyle.SetTitleFillColor ( 10 ) # Background color (white) gStyle.SetTitleX ( 0.10 ) # Title box Y gStyle.SetTitleY ( 0.10 ) # Title box Y gStyle.SetTitleW ( 0.50 ) # Title box width gStyle.SetTitleH ( 0.09 ) # Title box height gStyle.SetTitleBorderSize ( 1 ) gStyle.SetTitleFont(Font) gStyle.SetTitleFont(Font, "X") gStyle.SetTitleFont(Font, "Y") gStyle.SetTitleFont(Font, "Z") gStyle.SetTitleFont(Font, "T") gStyle.SetTitleSize(FontSize ) gStyle.SetTitleSize(FontSize,"X") gStyle.SetTitleSize(FontSize,"Y") gStyle.SetTitleSize(FontSize,"Z") gStyle.SetTitleSize(FontSize,"T") # ================ Labels =================== # gStyle.SetLabelFont(Font) gStyle.SetLabelFont(Font, "X") gStyle.SetLabelFont(Font, "Y") gStyle.SetLabelFont(Font, "Z") gStyle.SetLabelFont(Font, "T") gStyle.SetLabelSize(FontSize) gStyle.SetLabelSize(FontSize,"X") gStyle.SetLabelSize(FontSize,"Y") gStyle.SetLabelSize(FontSize,"Z") gStyle.SetLabelSize(FontSize,"T") # =============== Text & Legends ================== # gStyle.SetTextFont(Font) gStyle.SetLegendBorderSize ( 1 ) # ============================================= # # Do not display the canvas in a window, plot in a postscript gROOT.SetBatch(); # Needed to make sure that all the gStyle parameters are passed to the plots gROOT.ForceStyle() # We can have many files in input File = ['029006.root', '008491.root'] HistName = 'H300022' # OutputFile = 'output.ps' # eps is preferable because one can change the size of the output OutputFile = '../T0_Sigmas.eps' Canv = TCanvas() # Axis range # MinX = 0.0 # MaxX = 10 # MinY = -100. # MaxY = 100. gStyle.SetOptStat( 0 ) # gStyle.SetOptFit ( 1111 ) # gStyle.SetStatX ( 0.48 ) # gStyle.SetStatY ( 0.95 ) # gStyle.SetStatW ( 0.21 ) # gStyle.SetStatH ( 0.21 ) Title = ';Plane number;Wire number; #sigma difference (data - MC) [ns]' # F0 = TFile(File[0]) # print F0.Get(HistName).GetBinContent(60) # F1 = TFile(File[1]) # print F1.Get(HistName).GetBinContent(60) F = [] F.append(TFile(File[0])) H = F[0].Get(HistName).Clone() print H.GetBinContent(60) F.append(TFile(File[1])) Htmp= F[1].Get(HistName) print Htmp.GetBinContent(60) H.Add(Htmp,-1.0) print H.GetBinContent(60) H.Draw("colz") H.SetMinimum(-1.0) H.SetMaximum(1.0) # Plots title H.SetTitle(Title) # Change the axis range # H.SetAxisRange(MinX,MaxX,'X') # H.SetAxisRange(MinY,MaxY,'Y') # Change the position of the axis labels H.SetTitleOffset( 0.8, 'Y') # If you want to fit a straight line or something else # H.Fit('pol1', "Q","", 20.0, 150.0) # For Postscript # Canv.Print(OutputFile,"Landscape") # For eps Canv.Print(OutputFile)