CERN ROOT 使用事件标头制作树
我需要制作一棵带有事件标题的树。我从一个 ROOT 文件读入两个 ntuples。每个 ntuples 都具有以下格式:
Index Event SubEvent Characteristic1 Characteristic2 ....
1 1 1 322 234
2 1 2 453 324
3 1 3 ... ...
. . . ... ...
. . . ... ...
100 1 100 ... ...
101 2 1 ... ...
102 2 2 ... ...
. . . ... ...
. . . ... ...
. . . ... ...
207 2 107 ... ...
208 3 1 ... ...
209 3 2 ... ...
依此类推,索引运行到大约 200 万个。
我用来创建 ntuples 的格式:
TNtuple *tp = new TNtuple("tp","tp","x:y:z");
TNtuple *tn = new TNtuple("tn","tn","x:y:z");
for(Int_t n = 0; n < nEvents; n++) {
inTree->GetEntry(n);
Int_t nTracks = trackArray->GetEntries();
for(Int_t i = 0; i < nTracks; i++) {
Track* trackData = (Track*)trackArray->At(i);
if(trackData->fCharge == 1)
tp->Fill(trackData->x,trackData->y,trackData->z);
if(trackData->fCharge == -1)
tn->Fill(trackData->x,trackData->y,trackData->z);
}
}
但是,对于 ntuples,我遇到的问题是我想要对其进行的分析变得极其耗时。我希望我的数据结构与我正在读取的数据相同,即一棵有两个分支的树(对于我的两个“文件”),每个分支都包含一个偶数标头,以便我可以循环遍历一个中的事件文件,然后仅针对相同事件在第二个文件上嵌套循环。与上一个问题相关。< /a>
我没有如何构造原始文件的代码,这使得上述写入数据的方式成为可能。
I need to make a Tree with event headers. I read from a ROOT file into two ntuples. Each of these ntuples had the following format:
Index Event SubEvent Characteristic1 Characteristic2 ....
1 1 1 322 234
2 1 2 453 324
3 1 3 ... ...
. . . ... ...
. . . ... ...
100 1 100 ... ...
101 2 1 ... ...
102 2 2 ... ...
. . . ... ...
. . . ... ...
. . . ... ...
207 2 107 ... ...
208 3 1 ... ...
209 3 2 ... ...
and so on, the index runs till about two million.
The format I used to create the ntuples:
TNtuple *tp = new TNtuple("tp","tp","x:y:z");
TNtuple *tn = new TNtuple("tn","tn","x:y:z");
for(Int_t n = 0; n < nEvents; n++) {
inTree->GetEntry(n);
Int_t nTracks = trackArray->GetEntries();
for(Int_t i = 0; i < nTracks; i++) {
Track* trackData = (Track*)trackArray->At(i);
if(trackData->fCharge == 1)
tp->Fill(trackData->x,trackData->y,trackData->z);
if(trackData->fCharge == -1)
tn->Fill(trackData->x,trackData->y,trackData->z);
}
}
However, with ntuples I have the problem that the analysis that I want to do on it becomes impossibly time consuming. I would like to have my data structured in the same way as the data I am reading, i.e a tree with two braches (for my two "files") and each containing an even header, so that I can loop over the events in one file and subsequently nest a loop over the second file only for the same events. Related to previous question.
I do not have the code for how the original file was constructed, which allowed the above way of writing data possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两百万并不算多。
if
改为else if
Two millions is not so much.
if
toelse if