#!/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 def FuncFdecay1( x ): if ( x[0] > 8): return ( exp((-x[0]+8.1)/26.0) ) else: return 0 def FuncFdecay2( x ): if ( x[0] > -35): return ( exp((-x[0]-35)/26.0) ) else: return 0 def FuncFdecay3( x ): if ( x[0] > 51): return ( exp((-x[0]+51)/26.0) ) else: return 0 def FuncFdecay4( x ): if ( x[0] > -78): return ( exp((-x[0]-78.0)/26.0) ) else: return 0 def FuncFfull( x ): return ( 10000 *( FuncFdecay1(x) + FuncFdecay2(x) +FuncFdecay3(x) + FuncFdecay4(x) )) if __name__ == "__main__": gStyle.SetTitleBorderSize ( 0 ) # duh gStyle.SetPadBorderMode ( 0 ) gStyle.SetOptStat ( 111111 ) # Good standard stats display. gStyle.SetOptFit ( 1111 ) # Display fit info if available. gStyle.SetMarkerStyle ( 3 ) # double cross. gStyle.SetMarkerSize ( 1.0 ) # double cross. 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.SetFuncColor ( 10 ) # Background color (white) gStyle.SetStatColor ( 10 ) # Background color (white) gStyle.SetTextFont ( 132 ) gStyle.SetPadRightMargin (0.05) gStyle.SetPadLeftMargin (0.12) gStyle.SetPadBottomMargin (0.14) gStyle.SetPadTopMargin (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.SetTitleBorderSize ( 0 ) gStyle.SetStatW ( 0.3 ) # Statistic box width gStyle.SetStatX ( 0.95 ) # Statistic box width gStyle.SetStatY ( 0.4 ) # 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.05) gStyle.SetLabelSize(0.05,"X") gStyle.SetLabelSize(0.05,"Y") gStyle.SetLabelSize(0.05,"Z") gStyle.SetLabelSize(0.05,"T") gStyle.SetTitleSize(0.05 ) gStyle.SetTitleSize(0.05,"X") gStyle.SetTitleSize(0.05,"Y") gStyle.SetTitleSize(0.05,"Z") gStyle.SetTitleSize(0.05,"T") gStyle.SetTextFont(132) gStyle.SetTextSize(0.1) # SetTextAttributes # SetTextAlign # SetTextAngle # SetTextColor # SetTextFont # SetTextSizePixels 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(15,9) gStyle.SetCanvasDefH(700) # Defaults gStyle.SetCanvasDefW(1000) # Defaults # We can have many files in input # FileList = sys.argv[1].split(',') # FileList = 'sum84-9-1_clk_raw.root' # Fname = 'sum84-9-1_clk_raw.root' # HistList = ['TCAPm12widthCut/TCAP_before','TCAPm12widthCut/TCAP_after'] # # HistName = # # OutputFile = sys.argv[3] OutputFile = '../TCAP_Structure.eps' # F=[] Canv = TCanvas() # # Leg = TLegend(0.7, 0.7,0.9,0.9) MinX = -10 MaxX = 110 # # Title = [';TDC hit time [ns]',';Drift time [#mu s];Residuals [#mu m]'] # Title = ';TCAP time [ns];Count' # # LegName = ['Before','After'] # # Canv.Divide(len(HistList)) # # Canv.Divide(len(FileList)) # # F = [] # F = TFile(Fname) # TPT = [] # TT = [] # # for i,f in enumerate(FileList): # H = F.Get(HistList[0]) # H.Draw() Ffull = TF1("Fdecay1", FuncFfull,-40,90) Ffull.SetLineWidth(1) Ffull.SetLineStyle(1) Ffull.GetHistogram().SetAxisRange(0,13000,'Y') Ffull.GetHistogram().SetTitleOffset(1.2,'Y') Ffull.GetHistogram().SetTitle(";Time of flight [ns];Counts") Ffull.Draw("") # Fdecay1 = TF1("Fdecay1", FuncFdecay1,-40,90) # Fdecay1.SetLineWidth(1) # Fdecay1.SetLineStyle(1) # Fdecay1.GetHistogram().SetAxisRange(0,1.2,'Y') # Fdecay1.GetHistogram().SetTitle("") # Fdecay1.Draw("") # Fdecay2 = TF1("Fdecay2", FuncFdecay2,-40,110) # Fdecay2.SetLineWidth(1) # Fdecay2.SetLineStyle(1) # Fdecay2.Draw("same") # # Fdecay3 = TF1("Fdecay3", FuncFdecay3,5,110) # Fdecay3.SetLineWidth(1) # Fdecay3.SetLineStyle(1) # Fdecay3.Draw("same") # Fdecay4 = TF1("Fdecay4", FuncFdecay4,-80,110) # Fdecay4.SetLineWidth(1) # Fdecay4.SetLineStyle(1) # Fdecay4.Draw("same") # FGaussPi1 = TF1("FGaussPi1", "gaus",-20,30) # FGaussPi1.SetParameter(0,0.4) # FGaussPi1.SetParameter(1,5.8) # FGaussPi1.SetParameter(2,1.5) # FGaussPi1.SetLineWidth(1) # FGaussPi1.SetLineStyle(1) # FGaussPi1.Draw("same") # FGaussPi2 = TF1("FGaussPi2", "gaus",-50,-20) # FGaussPi2.SetParameter(0,0.4) # FGaussPi2.SetParameter(1,-37.2) # FGaussPi2.SetParameter(2,1.5) # FGaussPi2.SetLineWidth(1) # FGaussPi2.SetLineStyle(1) # FGaussPi2.Draw("same") # FGaussPi3 = TF1("FGaussPi3", "gaus",30,80) # FGaussPi3.SetParameter(0,0.4) # FGaussPi3.SetParameter(1,48.8) # FGaussPi3.SetParameter(2,1.5) # FGaussPi3.SetLineWidth(1) # FGaussPi3.SetLineStyle(1) # FGaussPi3.Draw("same") # FGaussMuCld1 = TF1("FGaussMuCld1", "gaus",-20,30) # FGaussMuCld1.SetParameter(0,0.7) # FGaussMuCld1.SetParameter(1,8.1) # FGaussMuCld1.SetParameter(2,1.5) # FGaussMuCld1.SetLineWidth(1) # FGaussMuCld1.SetLineStyle(1) # FGaussMuCld1.Draw("same") # FGaussMuCld2 = TF1("FGaussMuCld2", "gaus",-50,-20) # FGaussMuCld2.SetParameter(0,0.7) # FGaussMuCld2.SetParameter(1,-35.0) # FGaussMuCld2.SetParameter(2,1.5) # FGaussMuCld2.SetLineWidth(1) # FGaussMuCld2.SetLineStyle(1) # FGaussMuCld2.Draw("same") # FGaussMuCld3 = TF1("FGaussMuCld3", "gaus",30,80) # FGaussMuCld3.SetParameter(0,0.7) # FGaussMuCld3.SetParameter(1,51.1) # FGaussMuCld3.SetParameter(2,1.5) # FGaussMuCld3.SetLineWidth(1) # FGaussMuCld3.SetLineStyle(1) # FGaussMuCld3.Draw("same") # Ffull = TF1("Ffull", FuncFfull,5,104) # Ffull.SetLineWidth(1) # Ffull.Draw("same") # # H.SetTitle( Title) # H.SetAxisRange(MinX,MaxX,'X') # H.SetTitleOffset( 0.8, 'Y') # 29 55 # for i,HistName in enumerate(HistList): # Canv.cd(i+1) # # # F.append( TFile(Fname) ) # # H = F[i].Get(HistName) # # # F.append(TFile(f)) # # H = F[i].Get(HistName) # H = F.Get(HistName) # # H.Draw() # # H.GetHistogram().SetTitle( Title) # H.SetTitle( Title) # # # TPT.append(TPaveText( )) # # TPT[i].SetX1NDC(0.45) # # TPT[i].SetX2NDC(0.65) # # TPT[i].SetY1NDC(0.35) # # TPT[i].SetY2NDC(0.47) # # if ( i == 0): # # TT.append(TPT[i].AddText('Data')) # # # H.Draw() # # H.SetTitle(Title) # # H.SetAxisRange(MinY,MaxY,'Y') # # H.SetLineWidth(2) # # H.SetTitleOffset( 1.2, 'Y') # # else: # # TT.append(TPT[i].AddText('MC')) # # # H.GetHistogram().SetTitleOffset( 1.2, 'Y') # # # if ( i > 3 ): # # # H.SetLineColor(i+2) # # # else: # # # H.SetLineColor(i+1) # # # H.SetLineWidth(2) # # # H.Draw('same') # # # Leg.AddEntry(H, LegName[i], 'l') # # TPT[i].SetBorderSize(0) # # TT[i].SetTextAlign(22) # # TPT[i].Draw() # Leg.Draw() # For Postscript # Canv.Print(OutputFile,"Landscape") # For eps Canv.Print(OutputFile)