haidong, jin双高斯拟合code
Pasted Graphic 2
TFile *_file0 = TFile::Open("muonhist_high_pt_0530.root")
.ls
M2vsDca->ProjectionY(1,300)
M2vsDca->ProjectionY("a",1,300)
a->Draw()
TF1 *g2 = new TF1("g2","[0]*exp(-(x-[1])*(x-[1])/2/[2]/[2])/sqrt(6.2832)/[2]+[3]\*exp(-(x-[4])*(x-[4])/2/[5]/[5])/sqrt(6.2832)/[5]",-0.5, 2.0);
注意次高斯函数形式是第一个参数是面积×bin宽这样可以直接得到raw yield,第二个参数是中心,第三个参数是半高宽。
double par[6]={100,0.01,0.02,1000,0.02,0.03};
g2->SetParameters(par);
g2->SetRange(0.003,0.013);
his->Fit("g2","r");
a->Fit("g2","r");
g2->SetRange(0.005,0.03)
a->Fit("g2","r");
double par[6]={1.2,0.01,0.02,4.4,0.02,0.03};
g2->SetParameters(par);
a->Fit("g2","r");
g2->SetRange(0.005,0.026)
g2->SetRange(0.006,0.026)
a->Fit("g2","r");
double par[6]={1.2,0.01,0.002,4.4,0.02,0.003};
次初始化可以看出,第一个参数是估算面×bin。第二个是大致中心位置,第三个是估算的半高
g2->SetParameters(par);
a->Fit("g2","r");
M2vsDca1->ProjectionY(1,300)
.ls
M2vsDca->ProjectionY(1,300)
.q


M2vsDca1->GetNbinsX()
M2vsDca1->GetNbinsY()
M2vsDca1->ProjectionX("b",181,230)
b->Draw()
以上是得到Xbin总数Ybin总数,把2HistX投影到b,并且Y取181-230bin区

jin:
tofr->Draw("yglobal:xglobal>>h2(200,-200,200,200,-200,200")
这样可以自己制定范围和bin no.



TFile f1("some.root");
TH1D *t1 = new TH1D();
TH1D *t2 = new TH1D();
some->Draw("some1>>t1","cut");
some->Draw("some2>>t2","cut");
TFile f2("out.root");
t1->Write();
t2->Write();
f2.Close();


画登高图的一些技巧:
root [23] gStyle->SetPalette(1,0)
root [24] c1->Draw("contz")
root [25] gStyle->SetPalette(1,0)
然后右键点击出来菜单选择SetMinimum