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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/eventgenerator/exgps/macros/plotfiles.py (Version 11.3.0) and /examples/extended/eventgenerator/exgps/macros/plotfiles.py (Version 11.2.1)


  1 #!/usr/bin/python                                   1 #!/usr/bin/python
  2                                                     2 
  3 from ROOT import *                                  3 from ROOT import *
  4 from array import array                             4 from array import array
  5                                                     5 
  6 def plot_1_file (file):                             6 def plot_1_file (file):
  7     gROOT.Reset()                                   7     gROOT.Reset()
  8     input_file_1=TFile(file+'.root','READ')         8     input_file_1=TFile(file+'.root','READ')
  9     h1 = input_file_1.Get("histo/1")                9     h1 = input_file_1.Get("histo/1")
 10     h2 = input_file_1.Get("histo/2")               10     h2 = input_file_1.Get("histo/2")
 11     h3 = input_file_1.Get("histo/3")               11     h3 = input_file_1.Get("histo/3")
 12     h4 = input_file_1.Get("histo/4")               12     h4 = input_file_1.Get("histo/4")
 13     h5 = input_file_1.Get("histo/5")               13     h5 = input_file_1.Get("histo/5")
 14     h6 = input_file_1.Get("histo/6")               14     h6 = input_file_1.Get("histo/6")
 15                                                    15 
 16     c1 = TCanvas('c1', file, 200, 10, 700, 900     16     c1 = TCanvas('c1', file, 200, 10, 700, 900)
 17     c1.Divide(2,3)                                 17     c1.Divide(2,3)
 18                                                    18 
 19     c1.cd(1)                                       19     c1.cd(1)
 20     h1.Draw()                                      20     h1.Draw()
 21     c1.cd(2)                                       21     c1.cd(2)
 22     h2.Draw()                                      22     h2.Draw()
 23     c1.cd(3)                                       23     c1.cd(3)
 24     h3.Draw()                                      24     h3.Draw()
 25     c1.cd(4)                                       25     c1.cd(4)
 26     h4.Draw()                                      26     h4.Draw()
 27     c1.cd(5)                                       27     c1.cd(5)
 28     h5.Draw()                                      28     h5.Draw()
 29     c1.cd(6)                                       29     c1.cd(6)
 30     h6.Draw()                                      30     h6.Draw()
 31     c1.Update()                                    31     c1.Update()
 32     c1.Print("./"+file+".png")                     32     c1.Print("./"+file+".png")
 33                                                    33     
 34     input_file_1.Close()                           34     input_file_1.Close()
 35                                                    35 
 36 #    h_gam.SetLineColor(2)                         36 #    h_gam.SetLineColor(2)
 37                                                    37 
 38 def plot_2_files (file):                           38 def plot_2_files (file):
 39     gROOT.Reset()                                  39     gROOT.Reset()
 40                                                    40 
 41     input_file_1=TFile(file+'a.root','READ')       41     input_file_1=TFile(file+'a.root','READ')
 42     input_file_2=TFile(file+'b.root','READ')       42     input_file_2=TFile(file+'b.root','READ')
 43                                                    43 
 44 #input_file_1.cd()                                 44 #input_file_1.cd()
 45 #h_1_1 = input_file_1.Get("h16")                   45 #h_1_1 = input_file_1.Get("h16")
 46                                                    46 
 47     c1 = TCanvas('c1', file, 200, 10, 700, 500     47     c1 = TCanvas('c1', file, 200, 10, 700, 500)
 48     c1.SetGridx()                                  48     c1.SetGridx()
 49     c1.SetGridy()                                  49     c1.SetGridy()
 50     c1.SetLogx()                                   50     c1.SetLogx()
 51     c1.SetLogy()                                   51     c1.SetLogy()
 52                                                    52 
 53 # histogram for energy spectra                     53 # histogram for energy spectra
 54     n = 41                                         54     n = 41
 55     bin = array( 'f' )                             55     bin = array( 'f' )
 56                                                    56     
 57     for i in range( n ):                           57     for i in range( n ):
 58         bin.append(pow(10,(-2+0.1*i)))             58         bin.append(pow(10,(-2+0.1*i)))
 59 #                                                  59 #
 60     h_1 = TH1F('unbiased','Source Spectrum',40     60     h_1 = TH1F('unbiased','Source Spectrum',40,bin)
 61     h_2 = TH1F('biased','Source Spectrum',40,b     61     h_2 = TH1F('biased','Source Spectrum',40,bin)
 62                                                    62 
 63 #                                                  63 #
 64     input_file_1.cd()                              64     input_file_1.cd()
 65 # get the tuple t1                                 65 # get the tuple t1
 66     t1 = input_file_1.Get('ntuple/MyTuple')        66     t1 = input_file_1.Get('ntuple/MyTuple')
 67     print t1                                       67     print t1
 68     for i in range(t1.GetEntries()):               68     for i in range(t1.GetEntries()):
 69         t1.GetEntry(i)                             69         t1.GetEntry(i)
 70         h_1.Fill(t1.Ekin,t1.weight)                70         h_1.Fill(t1.Ekin,t1.weight)
 71                                                    71             
 72     input_file_2.cd()                              72     input_file_2.cd()
 73 # get the tuple t1                                 73 # get the tuple t1
 74     t2 =  input_file_2.Get('ntuple/MyTuple')       74     t2 =  input_file_2.Get('ntuple/MyTuple')
 75     for i in range(t2.GetEntries()):               75     for i in range(t2.GetEntries()):
 76         t2.GetEntry(i)                             76         t2.GetEntry(i)
 77         h_2.Fill(t2.Ekin,t2.weight)                77         h_2.Fill(t2.Ekin,t2.weight)
 78                                                    78                 
 79     h_2.SetLineStyle(kDashed);                     79     h_2.SetLineStyle(kDashed);
 80     h_2.SetLineColor(kBlue);                       80     h_2.SetLineColor(kBlue);
 81     h_2.Draw();                                    81     h_2.Draw();
 82     h_1.Draw("same") ;                             82     h_1.Draw("same") ;
 83     c1.Update()                                    83     c1.Update()
 84     c1.Print("./"+file+".png")                     84     c1.Print("./"+file+".png")
 85                                                    85     
 86     input_file_1.Close()                           86     input_file_1.Close()
 87     input_file_2.Close()                           87     input_file_2.Close()
 88                                                    88