ROOT/Macros
励起準位をプロットするマクロ
- 取りあえず書いてみたバージョン。そのうちコメントとかをちゃんと書く。
マクロ: plot_levels.C
インプットファイル: sdpfm.txt, sdpfmu.txt
sdpfm.txt の中身(1列目:エネルギー、2列目:表示する文字列)
0.00 0^{+} 0.66 2^{+} 1.93 2^{+} 2.22 4^{+} ...
Tree に AME2012 の一中性子分離エネルギーの値などを詰める
Sn のファイル: rct2.mas12
rct2.mas12 の読み込みと root ファイルの作成: tree_rct2_mas12.C
root ファイル: tree_rct2_mas12.root
tree_rct2_mas12.root の作成、読み込み、プロット
$ ls rct2.mas12 tree_rct2_mas12.C $ root tree_rct2_mas12.C+ ... some messages ... root [0] Processing tree_rct2_mas12.C+... Skipped: 1 a0p4g2dq A T O M I C M A S S A D J U S T M E N T Skipped: 0 DATE 16 Nov 2012 TIME 18:21 ... root [1] .q $ root tree_rct2_mas12.root ... some messages ... root [0] Attaching file tree_rct2_mas12.root as _file0... root [1] rct2_mas12->Scan() ************************************************************************************************************ * Row * A * elt * Z * Sn * Sn_err * Sn_flag * Sp * Sp_err * ************************************************************************************************************ * 0 * 1 * n * 0 * 0 * 0 * 1 * 0 * 0 * * 1 * 1 * H * 1 * 0 * 0 * 0 * 0 * 0 * * 2 * 2 * H * 1 * 2224.57 * 0 * 1 * 2224.57 * 0 * * 3 * 3 * H * 1 * 6257.23 * 0 * 1 * 0 * 0 * ... root [2] rct2_mas12->Draw("Z:(A-Z)>>(181,-0.5,180.5,121,-0.5,120.5)","Sn*(Sn_flag==1)","colz")
Tree に AME2012 の二中性子分離エネルギーの値などを詰める
S2n のファイル: rct1.mas12
読み込みマクロ: tree_rct1_mas12.C
root ファイル: tree_rct1_mas12.root
Tree に AME2012 の Binding enery などを詰める
Binding energy のファイル: mass.mas12
mass.mas12 の読み込みと root ファイルの作成: tree_mass_mas12.C
root ファイル: tree_mass_mas12.root
tree_mass_mas12.root の作成、読み込み、プロット
$ ls mass.mas12 tree_mass_mas12.C $ root tree_mass_mas12.C+ ... some messages ... root [0] Processing tree_mass_mas12.C+... Skipped: 1 a0znogdq A T O M I C M A S S A D J U S T M E N T Skipped: 0 DATE 16 Nov 2012 TIME 17:44 Skipped: 0 ********************* A= 0 TO 295 Skipped: * file : mass.mas12 * Skipped: ********************* ... root [1] .q $ root tree_mass_mas12.root ... some messages ... root [0] Attaching file tree_mass_mas12.root as _file0... root [1] mass_mas12->Scan() ************************************************************************************************************ * Row * NZ * N * Z * A * EL * O * ME * ME_err * ************************************************************************************************************ * 0 * 1 * 1 * 0 * 1 * n * * 8071.3171 * 0.00046 * * 1 * -1 * 0 * 1 * 1 * H * * 7288.9705 * 9e-05 * * 2 * 0 * 1 * 1 * 2 * H * * 13135.721 * 0.00011 * * 3 * 1 * 2 * 1 * 3 * H * * 14949.806 * 0.00221 * * 4 * -1 * 1 * 2 * 3 * He * * 14931.215 * 0.00233 * * 5 * -3 * 0 * 3 * 3 * Li * -pp * 28667 * 2000 * * 6 * 2 * 3 * 1 * 4 * H * -n * 24621.123 * 100 * * 7 * 0 * 2 * 2 * 4 * He * * 2424.9156 * 6e-05 * * 8 * -2 * 1 * 3 * 4 * Li * -p * 25323.186 * 212.132 * ... root [2] mass_mas12->Draw("Z:N>>h(181,-0.5,180.5,121,-0.5,120.5)","12000-BE","lego2 0") root [3] h->GetXaxis()->SetTitleOffset(1.5) root [4] h->GetYaxis()->SetTitleOffset(1.5) root [5] h->GetXaxis()->SetTitle("Nuetron number #it{N}") root [6] h->GetYaxis()->SetTitle("Atomic number #it{Z}") root [7] h->GetXaxis()->CenterTitle() root [8] h->GetYaxis()->CenterTitle()
try catch のテスト
- マクロでは try と catch が使えない?
except_test_no_name.C を ROOT 5.32/04 でマクロとして実行。
$ root except_test_no_name.C ... some massages ... root [0] Processing except_test_no_name.C... Before std.substr terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr $
except_test.C を ROOT 5.32/04 でマクロとして実行。
$ root except_test.C ... some massages ... root [0] Processing except_test.C... Before std.substr Exception std::out_of_range: basic_string::substr *** Break *** segmentation violation ... some massages ... Root > Function except_test() busy flag cleared *** Break *** keyboard interrupt :0: Root >
except_test.C を ROOT 5.32/04 でコンパイルして実行。
$ root except_test.C+ ... some massages ... root [0] Processing except_test.C+... Info in <TUnixSystem::ACLiC>: creating shared library /path/except_test_C.so Before std.substr Out of Range error: basic_string::substr (int)0 root [1]
while 文中のカンマ演算子
while の中でカンマ演算子 ',' が使えない。コンパイルすれば使える。comma_in_while.C
$ root comma_in_while.C # root comma_in_while.C+ とすれば OK。 ... some massages ... root [0] Processing comma_in_while.C... Error: Symbol j,j is not defined in current scope comma_in_while.C:5: *** Interpreter error recovered *** root [1]
Slider のテスト
$ROOTSYS/tutorial/gui/Slider3Demo.C をベースに Slider を使ったマクロを作った。
マクロ: SliderDemo.C
データファイル: 29ne_optics_output.txt
- マクロとデータファイルを同じディレクトリに置き、以下のように実行。
$ root SliderDemo.C or $ root SliderDemo.C+