Root Cern Export Data:导出特定数据类型
Root Cern Export Data: export a specific data type
正如我在标题中所写,我正在尝试从树中导出数据,当我尝试导出名为 "ADCVal" 的分支时,我已经按照 . It's work but i've problem when i try to export a specific branch. The Print 找到了树是崩溃。我认为问题是 "ADCVal" 是一个向量,所以我必须提取每个元素。我如何修改代码并将分支的每个元素关联到一个变量。
我知道这似乎是一个简单的问题,但我的 c++/root 知识真的很差。谢谢大家
作为起点,您可以使用 MakeClass
方法,这会为您编写代码:
root org.root
root [0]
Attaching file org.root as _file0...
(TFile *) 0x2670460
root [1] .ls
TFile** org.root
TFile* org.root
KEY: TTree SomeTree SomeTree
root [2] SomeTree->MakeClass("removeme")
Info in <TTreePlayer::MakeClass>: Files: removeme.h and removeme.C generated from TTree: B02DD
(Int_t) 0
root [3]
然后您可以查看 removeme.h 以了解如何将 SetBranchAddress
与数组一起使用。归结为
Float_t ADCVal[10];
tr->SetBranchAddress("ADCVal", ADCVal);
然后您可以在调用 tr->GetEntry(i);
后访问 ADCVal[0]
、ADCVal[1]
、...
正如我在标题中所写,我正在尝试从树中导出数据,当我尝试导出名为 "ADCVal" 的分支时,我已经按照
作为起点,您可以使用 MakeClass
方法,这会为您编写代码:
root org.root
root [0]
Attaching file org.root as _file0...
(TFile *) 0x2670460
root [1] .ls
TFile** org.root
TFile* org.root
KEY: TTree SomeTree SomeTree
root [2] SomeTree->MakeClass("removeme")
Info in <TTreePlayer::MakeClass>: Files: removeme.h and removeme.C generated from TTree: B02DD
(Int_t) 0
root [3]
然后您可以查看 removeme.h 以了解如何将 SetBranchAddress
与数组一起使用。归结为
Float_t ADCVal[10];
tr->SetBranchAddress("ADCVal", ADCVal);
然后您可以在调用 tr->GetEntry(i);
ADCVal[0]
、ADCVal[1]
、...