最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

ROOT37: histogram畫圖

2023-08-30 22:29 作者:guanming-yf  | 我要投稿


ROOT37運(yùn)行最終效果

void ana3(){

? // read the TFile WFM_Analysis.root

? TFile *file = new TFile( "WFM_Analysis.root", "read" );

? TTree *tree = (TTree*)file->Get("WFM");

? // get data?

? const int N = tree->GetEntries();

? double timestamp, energy1, energy2, time1, time2;

? bool flag_coin;

? tree->SetBranchAddress( "TimeStamp", &timestamp );

? tree->SetBranchAddress( "PeakEnergy1", &energy1 );

? tree->SetBranchAddress( "PeakEnergy2", &energy2 );

? tree->SetBranchAddress( "PeakTime1", &time1 );

? tree->SetBranchAddress( "PeakTime2", &time2 );

? tree->SetBranchAddress( "Flag_Coin", &flag_coin );

??

? // plot

? TH1D *hgamma1 = new TH1D( "hgamma1", "Energy distribution of gamma1", 200, 300, 700 );

? TH1D *hlifetime = new TH1D( "hlifetime", "Lifetime of ep annihilation", 100, 0, 20 );

??

? for( int i=0; i<N; i++ ){

? ? tree->GetEntry( i );

? ? hgamma1->Fill( energy1 );

? ? if( flag_coin == 1 ){

? ? ? hlifetime->Fill( timestamp );

? ? }

? }

? TF1 *f1 = new TF1( "f1", "[0]*exp(-x/[1])+[2]", 0, 20 );

? f1->SetParameters( 50, 3, 1 );

? f1->SetLineWidth( 2 );

??

? TCanvas *c1 = new TCanvas();

? hgamma1->Draw();

? TCanvas *c2 = new TCanvas("c2", "lifeitme", 1200, 500);

? c2->Divide( 2, 1 );

? c2->cd(1);

? hlifetime->SetStats(0);

? hlifetime->SetMarkerStyle( 8 );

? hlifetime->SetMarkerColor( 1 );

? hlifetime->SetLineWidth( 2 );

? hlifetime->GetXaxis()->SetTitle( "Time [#mus]" );

? hlifetime->GetYaxis()->SetTitle( "ep annihilation / 0.2#mus" );

? hlifetime->GetYaxis()->SetRangeUser( 0, 200 );

??

? hlifetime->Draw("ep");

? hlifetime->Fit( "f1" );

? TLegend *leg = new TLegend( 0.6, 0.7, 0.94, 0.89 );

? leg->AddEntry( hlifetime, "Experiment Data" );

? leg->AddEntry( f1, "Exponential Fitting" );

? leg->Draw("same");

? double chisq = f1->GetChisquare();

? int ndf = f1->GetNDF();

? TPaveText *text = new TPaveText( 0.4, 0.4, 0.7, 0.6, "NDC");

? text->SetTextAlign( 12 );

? text->AddText( "ep#rightarrow #gamma#gamma" );

? text->AddText( Form("#chi^{2}/ndf = %.02f/%d", chisq, ndf) );

? text->AddText( Form("Lifetime = %.02f #pm %.02f [#mus]", f1->GetParameter(1), f1->GetParError(1) ));

? text->Draw( "same" );

? c2->cd(2);

? hlifetime->SetFillColor( 8 );

? hlifetime->Draw();

? leg->Draw("same");

? text->Draw( "same" );

? c2->Print( "lifetime.pdf" );

}




ROOT37: histogram畫圖的評論 (共 條)

分享到微博請遵守國家法律
永胜县| 浙江省| 乐清市| 扎囊县| 禄劝| 陵水| 沧源| 南康市| 大安市| 海伦市| 禹州市| 藁城市| 大理市| 阳信县| 抚顺县| 绥滨县| 阿克陶县| 永登县| 新安县| 额尔古纳市| 个旧市| 河池市| 新郑市| 获嘉县| 涿鹿县| 和政县| 康保县| 文登市| 杂多县| 龙泉市| 阳城县| 沅陵县| 平凉市| 盘山县| 双桥区| 洪洞县| 高要市| 九龙城区| 庄河市| 彭水| 隆尧县|