#!/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.05) 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) 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(7,15) gStyle.SetCanvasDefH(700) # Defaults # gStyle.SetCanvasDefW(700) # Defaults # We can have many files in input # FileList = ['TCS2006B_Charac_Ph4_Pa3.root'] FileList = ['TCS2006B_Charac_Ph4_Pa3.root', 'TCS2007C_Charac_Ph4_Pa3.root'] HistName = 'MidTEC_YvsX_Sel' OutputFile = ['../CharacProjX.eps','../CharacProjY.eps'] F=[] Canv = [TCanvas(), TCanvas()] Leg = TLegend(0.25, 0.78,0.55,0.95) MinX = 0.0 MaxX = 6.736 MinY = 0 MaxY = 0.027 # Title = 'TDC time versus TDC width, wire 12;Width [ns];Hit time [ns]' Title = [';X [cm]',';Y [cm]'] LegName = ['2006B','2007C'] t=0 Htmp = [TH1D(),TH1D(),TH1D(),TH1D()] for i,f in enumerate(FileList): F.append( TFile(f) ) H2D = F[i].Get(HistName) H2D.Scale(1.0/H2D.Integral()) 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 ( 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].SetLineStyle(i+1) Htmp[t].SetLineWidth(1) Htmp[t].Draw('same') if ( j == 0 ): Leg.AddEntry(Htmp[t], LegName[i], 'l') t = t + 1 Canv[0].cd() Leg.Draw() # For eps Canv[0].Print(OutputFile[0]) Canv[1].cd() Leg.Draw() # For eps Canv[1].Print(OutputFile[1])