我正在读取一个结构如下的根文件:
$ root -l Residual_Position_iter_99_R1869.root
.lroot [0]
Attaching file Residual_Position_iter_99_R1869.root as _file0...
s
Warning in <TClass::TClass>: no dictionary for class TF1Parameters is available
root [1] .ls
TFile** Residual_Position_iter_99_R1869.root
TFile* Residual_Position_iter_99_R1869.root
KEY: TH1F Pos_g3xcl_100;1
KEY: TH1F Pos_g3ycl_100;1
KEY: TH1F Pos_g2xcl_100;1
KEY: TH1F Pos_g2ycl_100;1
KEY: TH1F Pos_g1xcl_100;1
KEY: TH1F residual_g1xcl_100;1
KEY: TH1F residual_g1ycl_100;1
KEY: TH1F residual_g2xcl_100;1
KEY: TH1F residual_g2ycl_100;1
KEY: TH1F residual_g3xcl_100;1
KEY: TH1F residual_g3ycl_100;1
为了读这篇文章,我写了一个宏:
import ROOT
from ROOT import TFile, TH1F, TObject
ROOT.gROOT.SetBatch(True) # This will prevent histogram to show
c=ROOT.TCanvas("c","c",800,600)
f1=ROOT.TFile("Residual_Position_iter_99_R1869.root","READ")
h1x=f1.Get("Pos_g1xcl_100"); c.cd(); h1x.Draw()
c.Print("plots/residual.pdf")
此代码工作正常。但它只适用于像 Pos * 这样的分支机构。但如果我更换
h1x=f1.Get("Pos_g1xcl_100");
带
h1x=f1.Get("residual_g1xcl_100");
然后我得到了分段错误[1]。 Pos_g1xcl_100&amp;的区别residual_g1xcl_100是一个是简单的直方图,而后一个是直方图及其拟合。
[1]
TClass :: TClass:0:RuntimeWarning:没有类TF1Parameters的字典可用 TStreamerInfo :: BuildOld:0:RuntimeWarning:无法将TF1 :: fParErrors从type:vector转换为type:Double_t *,skip元素 TStreamerInfo :: BuildOld:0:RuntimeWarning:无法将TF1 :: fParMin从type:vector转换为type:Double_t *,skip元素 TStreamerInfo :: BuildOld:0:RuntimeWarning:无法将TF1 :: fParMax从type:vector转换为type:Double_t *,skip元素 TStreamerInfo :: BuildOld:0:RuntimeWarning:无法将TF1 :: fSave从type:vector转换为type:Double_t *,skip元素 TStreamerInfo :: BuildOld:0:RuntimeWarning:无法将TF1 :: fParams从类型:TF1Parameters *转换为类型:Double_t *,skip元素
*违反* 分段违规