ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plottest35.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plottest35.py
1 #!/usr/bin/python
2 
3 from ROOT import *
4 from array import array
5 
6 gROOT.Reset()
7 
8 input_file_1=TFile('test35a.root','READ')
9 input_file_2=TFile('test35b.root','READ')
10 
11 #input_file_1.cd()
12 #h_1_1 = input_file_1.Get("h16")
13 
14 c1 = TCanvas('c1', 'test35', 200, 10, 700, 500)
15 c1.SetGridx()
16 c1.SetGridy()
17 c1.SetLogx()
18 c1.SetLogy()
19 
20 # histogram for energy spectra
21 n = 41
22 bin = array( 'f' )
23 
24 for i in range( n ):
25  bin.append(pow(10,(-2+0.1*i)))
26 #
27 h_1 = TH1F('unbiased','Source Spectrum',40,bin)
28 h_2 = TH1F('biased','Source Spectrum',40,bin)
29 
30 #
31 input_file_1.cd()
32 # get the tuple t1
33 t1 = gROOT.FindObject('MyTuple')
34 for i in range(t1.GetEntries()):
35  t1.GetEntry(i)
36  h_1.Fill(t1.Energy,t1.Weight)
37 
38 input_file_2.cd()
39 # get the tuple t1
40 t1 = gROOT.FindObject("MyTuple")
41 for i in range(t1.GetEntries()):
42  t1.GetEntry(i)
43  h_2.Fill(t1.Energy,t1.Weight)
44 
45 h_2.SetLineStyle(kDashed);
46 h_2.SetLineColor(kBlue);
47 h_2.Draw();
48 h_1.Draw("same") ;
49 c1.Update()
50 c1.Print("./test35.png")
51 
52 input_file_1.Close()
53 input_file_2.Close()
54 
55 
56 
57