Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/init.php on line 542
ja:root:wantto16 [GiriWiki]

ユーザ用ツール

サイト用ツール


ja:root:wantto16

以前のリビジョンの文書です



Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/parser/handler.php on line 1458

Warning: Declaration of syntax_plugin_note::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/lib/plugins/note/syntax.php on line 79

Warning: Declaration of syntax_plugin_note::render($mode, &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/lib/plugins/note/syntax.php on line 101

Warning: preg_match(): Compilation failed: invalid range in character class at offset 3120 in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/parser/lexer.php on line 118
A PCRE internal error occured. This might be caused by a faulty plugin

====== Eventごとにweightが付いている場合の統計誤差を得たい ====== ---- * weightなしの場合、Nイベントあった場合の統計誤差は√Nで表すことができる。(N ± √N) * weightが全イベントで同じ場合(W)は,中心値 W*N, 誤差W*√N (W*N ± W*√N) * Weightがイベントごとに違う場合(W_i)は、中心値 ΣW_i, 誤差 √( Σ(w_i)^2 ) 最後の場合を、TH1を使って簡単に求める方法を考える。 鍵はTH1::IntegralAndError(). 以下のコードに例を示す。 適当なweight wを与えた10イベントに対して、method 1は√( Σ(w_i)^2 )の顕な計算によって誤差を求めたもの、 method 2はTH1を使った方法。 共に同じ値を返すので、method 2で正しく誤差が求められていることが確かめられる。 <code cpp> void IntegralError() { const Int_t N = 10; const Double_t w[N] = { 0.9, 0.9, 0.9, 0.9, 0.9, 1.0, 1.0, 1.0, 1.0, 1.0 }; {/// method 1 Double_t Integral = 0; Double_t eIntegral = 0; for(Int_t i = 0 ; i < N ; ++i){ Integral += w[i]; eIntegral += pow( w[i], 2 ); } eIntegral = sqrt(eIntegral); ///// result cout << "method 1" << endl; cout << "Integral = " << Integral <<" +/- "<< eIntegral << endl; } {/// method 2 TH1D *h = new TH1D("h","h",1,0,1); h->Sumw2(); for(Int_t i = 0 ; i < N ; ++i) h->Fill( 0., w[i] );///// 0のbinにweightをかけて詰める Double_t eIntegral; Double_t Integral = h->IntegralAndError(0,1+1,eIntegral);/////積分はunderflow(bin=0),overflow(bin=2)も含めるようにしている(一応) ///// result cout << "method 2" << endl; cout << "Integral = " << Integral <<" +/- "<< eIntegral << endl; } } </code> 例えばtreeからある条件を満たすweight付きのイベント数およびその統計誤差を求めたければ、 <code cpp> const TCut cut = "..."; coust TCut weight = "..."; TH1D *h = new TH1D("h","",1,0,1); h->Sumw2(); tree->Project("h","val",cut*weight);///// val は適当な変数名(treeが持っているbranch名の1つ) Double_t eIntegral; Double_t Integral = h->IntegralAndError(0,2,eIntegral); cout << " Integral = " << Integral << " +/- " << eIntegral << " ( " << eIntegral/Integral *100 << " % )" << endl; </code> のようにすれば良い。

ja/root/wantto16.1536151554.txt.gz · 最終更新: 2018/09/05 12:45 by kota