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]:
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()
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]:
In [ ]: