/* zetubou.C ver.1.7.5 作成者:Hidemitsu Asano 2007年度p3 基本的にngdaqのバイナリデータに対応してます。 好きなように改造して下さい。不具合があったら御一報を。 */ using namespace std; void style() //いろんな設定の定義 { Int_t fon=22; gROOT->SetStyle("Plain"); //gStyle->SetOptTitle(0);//タイトル消去 gStyle->SetOptTitle(1); //gStyle->SetOptStat(0000000);//右上のステータス消去 gStyle->SetOptStat(1111111); //gStyle->SetOptFit(0000); gStyle->SetOptFit(1111); gStyle->SetPadLeftMargin(0.1); gStyle->SetPadRightMargin(0.31); gStyle->SetPadBottomMargin(0.1); gStyle->SetTitleXOffset(1.1); gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); gStyle->SetHistLineWidth(3); gStyle->SetTitleYOffset(1.1); gStyle->SetTitleFont(fon); gStyle->SetTitleFont(fon,"Y"); gStyle->SetLabelFont(fon); gStyle->SetLabelFont(fon,"Y"); gStyle->SetTextFont(fon); gStyle->SetStatFont(fon); gStyle->SetStatFontSize(0.03); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetStatH(0.7); gStyle->SetStatW(0.28); gStyle->SetStatY(0.88); gStyle->SetLabelSize(0.03,"x"); gStyle->SetLabelSize(0.03,"y"); } //Eカウンター側のヒスト作成 usage "dat2e("****.dat" ,"title",binの数(区切りの数),範囲min,範囲max)" bool dat2e(Char_t *filename, Char_t *histname ,Double_t nbinx,Double_t xmin,Double_t xmax) { gROOT->Reset(); unsigned short buf[4]; FILE *fp; style();//上の設定適用 TCanvas *c1 = new TCanvas( "c1", "c1",500,0,800,600);//ラベル、タイトル、画面に出現する座標(x,y)、大きさ(w,h) TH1D *h1 = new TH1D( "h1", histname,nbinx, xmin, xmax); fp = fopen(filename, "rb"); if(fp == NULL) { cout<<"Input-file doesn't exist.Check your file name"<Fill(buf[1]); } fclose(fp); h1->Draw(); h1->GetXaxis()->SetTitle("E-counter");//X軸のタイトル return true; } //c1->SaveAs("*****.ps")で画面をセーブ可、dEはc2、scatはc3。 //gPad->SetLogy() でy軸ログスケール //gPad->SetLogy(0) で元通り //gPad->Modified(); //gPad->Update(); //カットをかける場合。 dEの範囲を指定。これでその範囲外のデータははじける。 bool dat2e(Char_t *filename, Char_t *histname ,Double_t nbinx,Double_t xmin,Double_t xmax,Double_t dEmin,Double_t dEmax) { gROOT->Reset(); unsigned short buf[4]; FILE *fp; style();//上の設定適用 TCanvas *c1 = new TCanvas( "c1", "c1",500,0,800,600);//ラベル、タイトル、画面に出現する座標(x,y)、大きさ(w,h) TH1D *h1 = new TH1D( "h1", histname,nbinx, xmin, xmax); fp = fopen(filename, "rb"); if(fp == NULL) { cout<<"Input-file doesn't exist.Check your file name"<dEmax || buf[2]Fill(buf[1]); } fclose(fp); h1->Draw(); h1->GetXaxis()->SetTitle("E-counter");//X軸のタイトル return true; } //dEカウンターのヒスト bool dat2de(Char_t *filename, Char_t *histname ,Double_t nbinx,Double_t xmin,Double_t xmax) { gROOT->Reset(); unsigned short buf[4]; FILE *fp; style();//上の設定適用 TCanvas *c2 = new TCanvas( "c2", "c2",500,0,800,600);//ラベル、タイトル、画面に出現する座標(x,y)、大きさ(w,h) TH1D *h2 = new TH1D( "h2", histname,nbinx, xmin, xmax); fp = fopen(filename, "rb"); if(fp == NULL) { cout<<"Input-file doesn't exist.Check your file name"<Fill(buf[2]); } fclose(fp); h2->Draw(); h2->GetXaxis()->SetTitle("#DeltaE-counter");//X軸のタイトル return true; } //カットをかける場合。 bool dat2de(Char_t *filename, Char_t *histname ,Double_t nbinx,Double_t xmin,Double_t xmax,Double_t Emin,Double_t Emax) { gROOT->Reset(); unsigned short buf[4]; FILE *fp; style();//上の設定適用 TCanvas *c2 = new TCanvas( "c2", "c2",500,0,800,600);//ラベル、タイトル、画面に出現する座標(x,y)、大きさ(w,h) TH1D *h2 = new TH1D( "h2", histname,nbinx, xmin, xmax); fp = fopen(filename, "rb"); if(fp == NULL) { cout<<"Input-file doesn't exist.Check your file name"<Emax || buf[1]Fill(buf[2]); } fclose(fp); h2->Draw(); h2->GetXaxis()->SetTitle("#DeltaE-counter");//X軸のタイトル return true; } bool dat2scat(Char_t *filename, Char_t *histname)//両方+散布図を画面を分割して一枚に表示 { gROOT->Reset(); //gBenchmark->Start("drawhist"); unsigned short buf[4]; FILE *fp; fp = fopen(filename, "rb"); if(fp == NULL) { cout << "絶望した!ファイルが開けなくて絶望した!" << endl; return false; } const int nbinx = 1000; const int nbiny = 1008; const int xmin = 1; const int xmax = 4001; const int ymin = 1; const int ymax = 8065; style(); gStyle->SetHistLineWidth(1); gStyle->SetPadLeftMargin(0.1); gStyle->SetPadRightMargin(0.1); gStyle->SetPadBottomMargin(0.1); gStyle->SetTitleXOffset(0); gStyle->SetPadGridX(2); gStyle->SetPadGridY(2); gStyle->SetTitleYOffset(0); gStyle->SetStatFontSize(0.03); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); TH2D *h3 = new TH2D( "h3", histname,nbinx, xmin, xmax,nbiny, ymin, ymax ); while(1) { if (!(fread(buf,2,4,fp))) break; h3->Fill(buf[1],buf[2]); } fclose(fp); TCanvas *c3 = new TCanvas("c3", "c3", 500, 0, 800,800); c3->Divide(2,2); c3->cd(1); gStyle->SetOptTitle(0); h3->ProjectionX()->Draw(); c3->cd(2); gStyle->SetOptStat(1111111); h3->ProjectionY()->Draw(); gStyle->SetOptStat(1111111); c3->cd(3); gStyle->SetOptTitle(1); h3->Draw("scat"); gStyle->SetOptStat(1111); //gBenchmark->Show("drawhist"); return true; } bool dat2scat(Char_t *filename, Char_t *histname,Double_t nbinx,Double_t xmin, Double_t xmax,Double_t nbiny,Double_t ymin,Double_t ymax)//両方+散布図+範囲限定散布図 { gROOT->Reset(); unsigned short buf[4]; FILE *fp; fp = fopen(filename, "rb"); if(fp == NULL) { cout << "絶望した!ファイルが開けないことに絶望した!" << endl; return false; } style(); gStyle->SetHistLineWidth(1); gStyle->SetPadLeftMargin(0.1); gStyle->SetPadRightMargin(0.1); gStyle->SetPadBottomMargin(0.1); gStyle->SetTitleXOffset(0); gStyle->SetPadGridX(2); gStyle->SetPadGridY(2); gStyle->SetTitleYOffset(0); gStyle->SetStatFontSize(0.03); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); TH2D *h3 = new TH2D( "h3", histname,1000, 1, 4001,1008, 1, 8065 ); TH2D *h4 = new TH2D( "h4", histname,nbinx, xmin, xmax,nbiny, ymin, ymax); while(1) { if (!(fread(buf,2,4,fp))) break; h3->Fill(buf[1],buf[2]); h4->Fill(buf[1],buf[2]); } fclose(fp); TCanvas *c3 = new TCanvas("c3", "c3", 500, 0, 800,800); c3->Divide(2,2); c3->cd(1); gStyle->SetOptTitle(0); h3->ProjectionX()->Draw(); c3->cd(2); gStyle->SetOptStat(1111111); h3->ProjectionY()->Draw(); gStyle->SetOptStat(1111111); c3->cd(3); gStyle->SetOptTitle(1); h3->Draw("scat"); gStyle->SetOptStat(1111); c3->cd(4); h4->Draw("scat"); //gBenchmark->Show("drawhist"); return true; } //手抜きガウスフィット void gfitE(double xmin,double xmax) { TF1* funcE = new TF1("funcE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])",xmin,xmax);//ここでfitの関数名、表式、範囲を指定 funcE->SetLineColor(3);//1:black 2:red 3:bright green 4:britht blue 5:yellow 6:hot pink 7:aqua 8:green 9:blue funcE->SetParNames("const","mean","sigma"); funcE->SetParLimits(0,0,h1->GetEntries()*h1->GetBinWidth(2)); Double_t ms,mmax; ms= h1->GetMaximumBin()*h1->GetBinWidth(2); mmax=ms + c1->GetUxmin(); funcE->SetParameters(100,mmax,10);//初期値の設定 funcE->SetParLimits(2,0,xmax-xmin+10); h1->Fit("funcE","","",xmin,xmax); h1->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl;//Number of Degrees of Freedom cout << "Chisquare/NDF="<GetChisquare()/funcE->GetNDF() << endl; gROOT->Reset(); } void gfitdE(double xmin,double xmax) { TF1* funcdE = new TF1("funcdE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])",xmin,xmax); funcdE->SetLineColor(3);//1:black 2:red 3:bright green 4:britht blue 5:yellow 6:hot pink 7:aqua 8:green 9:blue funcdE->SetParameters(100,0,10);//初期値の設定 funcdE->SetParNames("const","mean","sigma"); funcdE->SetParLimits(0,0,h2->GetEntries()*h2->GetBinWidth(2)); Double_t ms,mmax; ms= h2->GetMaximumBin()*h2->GetBinWidth(2); mmax=ms + c2->GetUxmin(); funcdE->SetParameters(100,mmax,10); funcdE->SetParLimits(2,0,xmax-xmin+10); h2->Fit("funcdE","","",xmin,xmax); h2->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcdE->GetNDF() << endl; gROOT->Reset(); } //ガウシアンfit(Eカウンター用)usage gfitE(範囲min,範囲max,gaussianの高さ,mean,sigma) void gfitE(double xmin,double xmax,double height,double mean,double sigma) { TF1* funcE = new TF1("funcE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])",xmin,xmax);//ここでfitの関数名、表式、範囲を指定 funcE->SetLineColor(3);//1:black 2:red 3:bright green 4:britht blue 5:yellow 6:hot pink 7:aqua 8:green 9:blue funcE->SetParameters(height,mean,sigma);//初期値の設定 funcE->SetParNames("const","mean","sigma"); funcE->SetParLimits(0,0,h1->GetEntries()*h1->GetBinWidth(2)); funcE->SetParLimits(1,xmin,xmax); h1->Fit("funcE","","",xmin,xmax); h1->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl;//Number of Degrees of Freedom cout << "Chisquare/NDF="<GetChisquare()/funcE->GetNDF() << endl; gROOT->Reset(); } void gfitdE(double xmin,double xmax,double height,double mean,double sigma)//dE用 { TF1* funcdE = new TF1("funcdE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])",xmin,xmax); funcdE->SetLineColor(3); funcdE->SetParameters(height,mean,sigma); funcdE->SetParNames("const","mean","sigma"); funcdE->SetParLimits(0,0,h2->GetEntries()*h2->GetBinWidth(2)); funcdE->SetParLimits(1,xmin,xmax); h2->Fit("funcdE","","",xmin,xmax); h2->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcdE->GetNDF() << endl; gROOT->Reset(); } //ガウシアン+線形fit(Eカウンター用)usage gfitE(範囲min,範囲max,gaussianの高さ,mean,sigma,直線の傾き,y切片) void gfitE(double xmin,double xmax,double height,double mean,double sigma,double katamuki, double seppen) { TF1* funcE = new TF1("funcE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]*x+[4]",xmin,xmax);//ここでfitの関数名、表式、範囲を指定 funcE->SetLineColor(3);//1:black 2:red 3:bright green 4:britht blue 5:yellow 6:hot pink 7:aqua 8:green 9:blue funcE->SetParameters(height,mean,sigma,katamuki,seppen);//初期値の設定 funcE->SetParNames("const","mean","sigma","slope","intercept"); funcE->SetParLimits(0,0,h1->GetEntries()*h1->GetBinWidth(2)); funcE->SetParLimits(1,xmin,xmax); h1->Fit("funcE","","",xmin,xmax); h1->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl;//Number of Degrees of Freedom cout << "Chisquare/NDF="<GetChisquare()/funcE->GetNDF() << endl; gROOT->Reset(); } void gfitdE(double xmin,double xmax,double height,double mean,double sigma,double katamuki, double seppen)//dE用 { TF1* funcdE = new TF1("funcdE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]*x+[4]",xmin,xmax); funcdE->SetLineColor(3); funcdE->SetParameters(height,mean,sigma,katamuki,seppen); funcdE->SetParNames("const","mean","sigma","slope","intercept"); funcdE->SetParLimits(1,xmin,xmax); funcdE->SetParLimits(0,0,h2->GetEntries()*h2->GetBinWidth(2)); h2->Fit("funcdE","","",xmin,xmax); h2->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcdE->GetNDF() << endl; gROOT->Reset(); } //ガウシアン二つ void gfitE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2) { TF1* funcE = new TF1("funcE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5])",xmin,xmax); funcE->SetLineColor(3); funcE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2); funcE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2"); funcE->SetParLimits(0,0,h1->GetEntries()*h1->GetBinWidth(2)); funcE->SetParLimits(3,0,h1->GetEntries()); funcE->SetParLimits(1,xmin,xmax); funcE->SetParLimits(4,xmin,xmax); h1->Fit("funcE","","",xmin,xmax); h1->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcE->GetNDF() << endl; gROOT->Reset(); } void gfitdE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2) { TF1* funcdE = new TF1("funcdE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5])",xmin,xmax); funcdE->SetLineColor(3); funcdE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2); funcdE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2"); funcE->SetParLimits(0,0,h2->GetEntries()*h2->GetBinWidth(2)); funcE->SetParLimits(3,0,h2->GetEntries()); funcdE->SetParLimits(1,xmin,xmax); funcdE->SetParLimits(4,xmin,xmax); h2->Fit("funcdE","","",xmin,xmax); h2->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcdE->GetNDF() << endl; gROOT->Reset(); } //ガウシアン二つ+線形 void gfitE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2,double katamuki ,double seppen) { TF1* funcE = new TF1("funcE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5])+[6]*x+[7] ",xmin,xmax); funcE->SetLineColor(3); funcE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2,katamuki,seppen); funcE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2","slope","intercept"); funcE->SetParLimits(0,0,h1->GetEntries()*h1->GetBinWidth(2)); funcE->SetParLimits(3,0,h1->GetEntries()); funcE->SetParLimits(1,xmin,xmax); funcE->SetParLimits(4,xmin,xmax); h1->Fit("funcE","","",xmin,xmax); h1->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcE->GetNDF() << endl; gROOT->Reset(); } void gfitdE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2,double katamuki ,double seppen) { TF1* funcdE = new TF1("funcdE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5]+[6]*x+[7])",xmin,xmax); funcdE->SetLineColor(3); funcdE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2,katamuki,seppen); funcdE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2","slope","intercept"); funcdE->SetParLimits(0,0,h2->GetEntries()*h2->GetBinWidth(2)); funcdE->SetParLimits(3,0,h2->GetEntries()); funcdE->SetParLimits(1,xmin,xmax); funcdE->SetParLimits(4,xmin,xmax); h2->Fit("funcdE","","",xmin,xmax); h2->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcdE->GetNDF() << endl; gROOT->Reset(); } //ガウシアン3つ void gfitE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2,double height3,double mean3,double sigma3) { TF1* funcE = new TF1("funcE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5])+[6]/(sqrt(2*3.14159265358979)*[8])*exp(-(x-[7])*(x-[7])/2./[8]/[8])",xmin,xmax); funcE->SetLineColor(3); funcE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2,height3,mean3,sigma3); funcE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2","const3","mean3","sigma3"); funcE->SetParLimits(0,0,h1->GetEntries()*h1->GetBinWidth(2)); funcE->SetParLimits(3,0,h1->GetEntries()); funcE->SetParLimits(6,0,h1->GetEntries()); funcE->SetParLimits(1,xmin,xmax); funcE->SetParLimits(4,xmin,xmax); funcE->SetParLimits(7,xmin,xmax); h1->Fit("funcE","","",xmin,xmax); h1->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcE->GetNDF() << endl; gROOT->Reset(); } void gfitdE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2,double height3,double mean3,double sigma3) { TF1* funcdE = new TF1("funcdE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5])+[6]/(sqrt(2*3.14159265358979)*[8])*exp(-(x-[7])*(x-[7])/2./[8]/[8])",xmin,xmax); funcdE->SetLineColor(3); funcdE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2,height3,mean3,sigma3); funcdE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2","const3","mean3","sigma3"); funcdE->SetParLimits(0,0,h2->GetEntries()*h2->GetBinWidth(2)); funcdE->SetParLimits(3,0,h2->GetEntries()); funcdE->SetParLimits(6,0,h2->GetEntries()); funcdE->SetParLimits(1,xmin,xmax); funcdE->SetParLimits(4,xmin,xmax); funcdE->SetParLimits(7,xmin,xmax); h2->Fit("funcdE","","",xmin,xmax); h2->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcdE->GetNDF() << endl; gROOT->Reset(); } //まさかのガウシアン3つ+線形 void gfitE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2,double height3,double mean3,double sigma3,double katamuki ,double seppen) { TF1* funcE = new TF1("funcE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5])+[6]/(sqrt(2*3.14159265358979)*[8])*exp(-(x-[7])*(x-[7])/2./[8]/[8])+[9]*x+[10]",xmin,xmax); funcE->SetLineColor(3); funcE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2,height3,mean3,sigma3,katamuki,seppen); funcE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2","const3","mean3","sigma3","slope","intercept"); funcE->SetParLimits(0,0,h1->GetEntries()*h1->GetBinWidth(2)); funcE->SetParLimits(3,0,h1->GetEntries()); funcE->SetParLimits(6,0,h1->GetEntries()); funcE->SetParLimits(1,xmin,xmax); funcE->SetParLimits(4,xmin,xmax); funcE->SetParLimits(7,xmin,xmax); h1->Fit("funcE","","",xmin,xmax); h1->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcE->GetNDF() << endl; gROOT->Reset(); } void gfitdE(double xmin,double xmax,double height1,double mean1,double sigma1,double height2, double mean2, double sigma2,double height3,double mean3,double sigma3,double katamuki ,double seppen) { TF1* funcdE = new TF1("funcdE","[0]/(sqrt(2*3.14159265358979)*[2])*exp(-(x-[1])*(x-[1])/2./[2]/[2])+[3]/(sqrt(2*3.14159265358979)*[5])*exp(-(x-[4])*(x-[4])/2./[5]/[5])+[6]/(sqrt(2*3.14159265358979)*[8])*exp(-(x-[7])*(x-[7])/2./[8]/[8])+[9]*x+[10]",xmin,xmax); funcdE->SetLineColor(3); funcdE->SetParameters(height1,mean1,sigma1,height2,mean2,sigma2,height3,mean3,sigma3,katamuki,seppen); funcdE->SetParNames("const1","mean1","sigma1","const2","mean2","sigma2","const3","mean3","sigma3","slope","intercept"); funcdE->SetParLimits(0,0,h2->GetEntries()*h2->GetBinWidth(2)); funcdE->SetParLimits(3,0,h2->GetEntries()); funcdE->SetParLimits(6,0,h2->GetEntries()); funcdE->SetParLimits(1,xmin,xmax); funcdE->SetParLimits(4,xmin,xmax); funcdE->SetParLimits(7,xmin,xmax); h2->Fit("funcdE","","",xmin,xmax); h2->Draw(); cout << "Chisquare="<GetChisquare() << endl; cout << "NDF=" <GetNDF() << endl; cout << "Chisquare/NDF="<GetChisquare()/funcdE->GetNDF() << endl; gROOT->Reset(); }