In [2]:
import ROOT
import matplotlib.pyplot as plt
import numpy as np

import composition.analysis.plotting as plotting 

%matplotlib inline

In [104]:
f = ROOT.TFile('fitComp_3yData_C1_035_noshift.root')
fig, ax = plt.subplots()
for composition in ['proton', 'helium', 'oxygen', 'iron', 'tot_espectrum']:
    
    if composition != 'tot_espectrum':
        spectrum_TH1D = f.Get('{}_spec'.format(composition))
    else:
        spectrum_TH1D = f.Get('tot_espectrum')
        composition = 'total'

    spectrum = [spectrum_TH1D.GetBinContent(i)for i in range(1, spectrum_TH1D.GetNbinsX()+1)]
    spectrum_err = [spectrum_TH1D.GetBinError(i) for i in range(1, spectrum_TH1D.GetNbinsX()+1)]
    bin_centers = [spectrum_TH1D.GetBinCenter(i)for i in range(1, spectrum_TH1D.GetNbinsX()+1)]

    spectrum = np.asarray(spectrum)
    spectrum_err = np.asarray(spectrum_err)
    bin_centers = np.asarray(bin_centers)
    
    ax.errorbar(bin_centers, spectrum, yerr=spectrum_err, marker='.', ls='None', label=composition)
#     ax.errorbar(bin_centers, (10**bin_centers)**2.7 * spectrum, yerr=spectrum_err, marker='.', ls='None', label=composition)
    
ax.set_xlabel('$\mathrm{\log_{10}(E_{reco}/GeV)}$')
ax.set_ylabel('Flux')
ax.set_xlim([6.4, 9.0])
ax.set_yscale("log", nonposy='clip')
ax.grid()
# ax.legend(loc='upper left')
plt.show()



In [ ]:


In [ ]:


In [ ]:


In [83]:
bin_centers


Out[83]:
array([ 5.05,  5.15,  5.25,  5.35,  5.45,  5.55,  5.65,  5.75,  5.85,
        5.95,  6.05,  6.15,  6.25,  6.35,  6.45,  6.55,  6.65,  6.75,
        6.85,  6.95,  7.05,  7.15,  7.25,  7.35,  7.45,  7.55,  7.65,
        7.75,  7.85,  7.95,  8.1 ,  8.3 ,  8.5 ,  8.7 ,  8.9 ,  9.1 ,
        9.3 ,  9.5 ,  9.7 ,  9.9 ])

In [67]:
f = ROOT.TFile('fitComp_3yData_C1_035_noshift.root')
fig, ax = plt.subplots()
for composition in ['proton', 'helium', 'oxygen', 'iron']:

    spectrum_graph = f.Get('{}_flux'.format(composition))
    spectrum_TH1D = spectrum_graph.GetHistogram()

    spectrum = [spectrum_TH1D.GetBinContent(i)for i in range(1, spectrum_TH1D.GetNbinsX()+1)]
    spectrum_err = [spectrum_TH1D.GetBinError(i) for i in range(1, spectrum_TH1D.GetNbinsX()+1)]
    bin_centers = [spectrum_TH1D.GetBinCenter(i)for i in range(1, spectrum_TH1D.GetNbinsX()+1)]

    spectrum = np.asarray(spectrum)
    print(spectrum)
    spectrum_err = np.asarray(spectrum_err)
    bin_centers = np.asarray(bin_centers)
    
    ax.errorbar(bin_centers, spectrum, yerr=spectrum_err, marker='.', ls='None', label=composition)
#     ax.errorbar(bin_centers, (10**bin_centers)**2.7 * spectrum, yerr=spectrum_err, marker='.', ls='None', label=composition)
    
ax.set_xlabel('$\mathrm{\log_{10}(E_{reco}/GeV)}$')
ax.set_ylabel('Flux')
# ax.set_xlim([6.4, 9.0])
# ax.set_yscale("log", nonposy='clip')
ax.grid()
ax.legend()
plt.show()


[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.
  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]

In [96]:
f = ROOT.TFile('fitComp_3yData_C1_035_noshift.root')
g = f.Get('proton_flux')
hist = g.GetHistogram()

In [99]:
hist.Get


Out[99]:
0.0

In [ ]: