部門 > ROOT > つくったヒストグラムをROOTファイルに書きこむ

「部門/ROOT/つくったヒストグラムをROOTファイルに書きこむ」の編集履歴(バックアップ)一覧はこちら

部門/ROOT/つくったヒストグラムをROOTファイルに書きこむ - (2011/11/08 (火) 00:21:49) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

[[ROOT User's Guide>http://root.cern.ch/drupal/content/users-guide]]([[邦訳>http://www.dw-sapporo.co.jp/technology/root_cint_dw_documents/]])のInput/Outputの章に載っている。その最初のペイジから引用すると、 #highlight(c++){{TObjArray Hlist(0); // create an array of Histograms TH1F* h; // create a pointer to a histogram // make and fill 15 histograms and add them to the object array for (Int_t i = 0; i < 15; i++) { sprintf(name,"h%d",i); sprintf(title,"histo nr:%d",i); h = new TH1F(name,title,100,-4,4); Hlist.Add(h); h->FillRandom("gaus",1000); } // open a file and write the array to the file TFile f("demo.root","recreate"); Hlist->Write(); f.Close(); } }} と書くことでdemo.rootというファイルに15のTH1Fクラスのヒストグラムを用意し、そこにガウシアンで乱数を入れることができる。ここの部分をFill(hogehoge)とすれば好きな変数のヒストグラムができる。
[[ROOT User's Guide>http://root.cern.ch/drupal/content/users-guide]]([[邦訳>http://www.dw-sapporo.co.jp/technology/root_cint_dw_documents/]])のInput/Outputの章に載っている。その最初のペイジから引用すると、 #highlight(c++){{TObjArray Hlist(0); // create an array of Histograms TH1F* h; // create a pointer to a histogram // make and fill 15 histograms and add them to the object array for (Int_t i = 0; i < 15; i++) { sprintf(name,"h%d",i); sprintf(title,"histo nr:%d",i); h = new TH1F(name,title,100,-4,4); Hlist.Add(h); h->FillRandom("gaus",1000); } // open a file and write the array to the file TFile f("demo.root","recreate"); Hlist->Write(); f.Close(); } }} と書くことでdemo.rootというファイルに15のTH1Fクラスのヒストグラムを用意し、そこにガウシアンで乱数を入れることができる。ここの部分をFill(hogehoge)とすれば好きな変数のヒストグラムができる。 ちなみに、TFile f("demo.root","recreate");っていうのはHlistをWriteする直前がいいみたい。あんまり前でやっておくと、Segmentation violation になる気がする。なんでかは知らない。

表示オプション

横に並べて表示:
変化行の前後のみ表示: