部門 > ROOT > TTree

TTreeクラスについて調べて書く予定。以下、t1をTTreeクラスのオブジェクトとする。

メソッドいくつか

イベント数を表示

t1->GetEntries();

イベント内容を表示

t1->Show(整数);
中の整数がイベント番号で、0から始まる。

Treeの構造を表示

t1.Print();
同じ形のTreeをつくりたいときなどに便利。

TTreeをつくる

ROOT User's Guide(邦訳)のTreesの章に載っている。いちばん最初の例はなんだか複雑なものをつくっているので(XMLでやったほうがいいんじゃないのって感じがする)、p.199の”Example 1: A Tree with Simple Variables”というのがわかりやすい。引用すると、
void tree1w() {
 
//create a tree file tree1.root - create the file, the Tree and a few branches
TFile f("tree1.root","recreate");
TTree t1("t1","a simple Tree with simple variables");
Float_t px, py, pz;
Int_t ev;
 
t1.Branch("px",&px,"px/F");
t1.Branch("py",&py,"py/F");
t1.Branch("pz",&pz,"pz/F");
t1.Branch("ev",&ev,"ev/I");
 
//fill the tree
for (Int_t i=0; i<10000; i++) {
gRandom->Rannor(px,py);
pz = px*px + py*py;
ev = i;
t1.Fill();
}
//save the Tree heade; the file will be automatically closed
//when going out of the function scope
t1.Write();
}
 

 
 
 



とりあえずブクマ

タグ:

ROOT
最終更新:2011年10月31日 09:53