File indexing completed on 2025-02-23 09:21:06
0001
0002
0003 from ROOT import *
0004 from array import array
0005
0006 def plot_1_file (file):
0007 gROOT.Reset()
0008 input_file_1=TFile(file+'.root','READ')
0009 h1 = input_file_1.Get("histo/1")
0010 h2 = input_file_1.Get("histo/2")
0011 h3 = input_file_1.Get("histo/3")
0012 h4 = input_file_1.Get("histo/4")
0013 h5 = input_file_1.Get("histo/5")
0014 h6 = input_file_1.Get("histo/6")
0015
0016 c1 = TCanvas('c1', file, 200, 10, 700, 900)
0017 c1.Divide(2,3)
0018
0019 c1.cd(1)
0020 h1.Draw()
0021 c1.cd(2)
0022 h2.Draw()
0023 c1.cd(3)
0024 h3.Draw()
0025 c1.cd(4)
0026 h4.Draw()
0027 c1.cd(5)
0028 h5.Draw()
0029 c1.cd(6)
0030 h6.Draw()
0031 c1.Update()
0032 c1.Print("./"+file+".png")
0033
0034 input_file_1.Close()
0035
0036
0037
0038 def plot_2_files (file):
0039 gROOT.Reset()
0040
0041 input_file_1=TFile(file+'a.root','READ')
0042 input_file_2=TFile(file+'b.root','READ')
0043
0044
0045
0046
0047 c1 = TCanvas('c1', file, 200, 10, 700, 500)
0048 c1.SetGridx()
0049 c1.SetGridy()
0050 c1.SetLogx()
0051 c1.SetLogy()
0052
0053
0054 n = 41
0055 bin = array( 'f' )
0056
0057 for i in range( n ):
0058 bin.append(pow(10,(-2+0.1*i)))
0059
0060 h_1 = TH1F('unbiased','Source Spectrum',40,bin)
0061 h_2 = TH1F('biased','Source Spectrum',40,bin)
0062
0063
0064 input_file_1.cd()
0065
0066 t1 = input_file_1.Get('ntuple/MyTuple')
0067 print t1
0068 for i in range(t1.GetEntries()):
0069 t1.GetEntry(i)
0070 h_1.Fill(t1.Ekin,t1.weight)
0071
0072 input_file_2.cd()
0073
0074 t2 = input_file_2.Get('ntuple/MyTuple')
0075 for i in range(t2.GetEntries()):
0076 t2.GetEntry(i)
0077 h_2.Fill(t2.Ekin,t2.weight)
0078
0079 h_2.SetLineStyle(kDashed);
0080 h_2.SetLineColor(kBlue);
0081 h_2.Draw();
0082 h_1.Draw("same") ;
0083 c1.Update()
0084 c1.Print("./"+file+".png")
0085
0086 input_file_1.Close()
0087 input_file_2.Close()
0088