Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:06

0001 #!/usr/bin/python
0002 
0003 from ROOT import *
0004 from array import array
0005 
0006 gROOT.Reset()
0007 
0008 input_file_1=TFile('test35a.root','READ')
0009 input_file_2=TFile('test35b.root','READ')
0010 
0011 #input_file_1.cd()
0012 #h_1_1 = input_file_1.Get("h16")
0013 
0014 c1 = TCanvas('c1', 'test35', 200, 10, 700, 500)
0015 c1.SetGridx()
0016 c1.SetGridy()
0017 c1.SetLogx()
0018 c1.SetLogy()
0019 
0020 # histogram for energy spectra
0021 n = 41
0022 bin = array( 'f' )
0023 
0024 for i in range( n ):
0025     bin.append(pow(10,(-2+0.1*i)))
0026 #
0027 h_1 = TH1F('unbiased','Source Spectrum',40,bin)
0028 h_2 = TH1F('biased','Source Spectrum',40,bin)
0029 
0030 #
0031 input_file_1.cd()
0032 # get the tuple t1
0033 t1 = gROOT.FindObject('MyTuple')
0034 for i in range(t1.GetEntries()):
0035     t1.GetEntry(i)
0036     h_1.Fill(t1.Energy,t1.Weight)
0037 
0038 input_file_2.cd()
0039 # get the tuple t1
0040 t1 = gROOT.FindObject("MyTuple")
0041 for i in range(t1.GetEntries()):
0042     t1.GetEntry(i)
0043     h_2.Fill(t1.Energy,t1.Weight)
0044 
0045 h_2.SetLineStyle(kDashed);
0046 h_2.SetLineColor(kBlue);
0047 h_2.Draw();
0048 h_1.Draw("same") ;
0049 c1.Update()
0050 c1.Print("./test35.png")
0051 
0052 input_file_1.Close()
0053 input_file_2.Close()
0054 
0055 
0056 
0057