当前位置: 首页>>代码示例>>C++>>正文


C++ TVectorD::Sum方法代码示例

本文整理汇总了C++中TVectorD::Sum方法的典型用法代码示例。如果您正苦于以下问题:C++ TVectorD::Sum方法的具体用法?C++ TVectorD::Sum怎么用?C++ TVectorD::Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TVectorD的用法示例。


在下文中一共展示了TVectorD::Sum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: plotqfit

void plotqfit(int fixv2=0,int fixg2=0){
    const int nbin24 = 12;
    const double avgtrkbin[nbin24]={44.36,54.33,68.63,88.39,108.2,131.3,162.1,196.6,227.5,247.2,269.2,301.2};
    const double V24[nbin24]={0.02965,0.03913,0.04832,0.04941,0.04822,0.04955,0.049,0.04805,0.04709,0.04665,0.04772,0.04797};
    int xtheta=0;
    gStyle->SetOptStat(1011);
    gStyle->SetOptFit(1111);
TFile *f = TFile::Open("mergedV_Sum.root");
TFile *fout = TFile::Open("qfitV.root","Update");
TVectorD *vecDNevent = (TVectorD*)f->Get(Form("Nevent"));
TVectorD *vecDavgmult = (TVectorD*)f->Get(Form("avgmultall"));
TVectorD *vecDtotmult = (TVectorD*)f->Get(Form("totmultall"));
TVectorD *vecDavgpt = (TVectorD*)f->Get(Form("avgpt"));
TVectorD *vecDavgpt2 = (TVectorD*)f->Get(Form("avgpt2"));
TVectorD *vecDavgtrk = (TVectorD*)f->Get(Form("avgtrk"));
TVectorD *vecDq22 = (TVectorD*)f->Get(Form("q22"));
TVectorD *vecDq24 = (TVectorD*)f->Get(Form("q24"));
double avgmultall = vecDtotmult->Sum()/vecDNevent->Sum();
double *avgmult = vecDavgmult->GetMatrixArray();
double *avgtrk = vecDavgtrk->GetMatrixArray();
double *avgpt = vecDavgpt->GetMatrixArray();
double *avgpt2 = vecDavgpt2->GetMatrixArray();
double *q22 = vecDq22->GetMatrixArray();
double *q24 = vecDq24->GetMatrixArray();
TLatex *t= new TLatex();
t->SetNDC();
t->SetTextSize(0.04);
t->SetTextFont(42);
/*
if(fixg2){
TH1D* hq2all = new TH1D("hq2all","hq2all",1000,0,10);
for(int ibin=0;ibin<nbin;ibin++){	//ibin<1
TH1D* hq2 = (TH1D*)f->Get(Form("D_%d/hq2",ibin));
hq2all->Add(hq2);
}
TF1 *ffit = new TF1(Form("ffit"),"1./(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10);
TF1* f1fit = new TF1(Form("f1fit"),"x/(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10);
TH1D* hq2all_cp = (TH1D*)hq2all->Clone("hq2all_cp");
hq2all->Scale(1./hq2all->Integral(0,-1,"width"));
hq2all->Draw();
divideByBinCenter(hq2all_cp);
ffit->SetParameters(1,0.05,avgmultall);
f1fit->SetParameters(1,0.05,avgmultall);
ffit->FixParameter(2,avgmultall);
f1fit->FixParameter(2,avgmultall);
hq2all->Fit(Form("f1fit"),"R","",0,10);
double g2all = f1fit->GetParameter(0);
}
*/
for(int ibin=0;ibin<nbin;ibin++){	//ibin<1
 //   if(ibin!=100) continue;
TH1D* hq = (TH1D*)f->Get(Form("D_%d/D_%d/hq",ibin,xtheta));
TH1D* hqx = (TH1D*)f->Get(Form("D_%d/hqx",ibin));
TH1D* hqy = (TH1D*)f->Get(Form("D_%d/hqy",ibin));
TH1D* hq2 = (TH1D*)f->Get(Form("D_%d/hq2",ibin));
TH1D* hq2nonf = (TH1D*)f->Get(Form("D_%d/hq2nonf",ibin));
int k;
for(k=0;k<nbin24;k++){
    if(avgtrk[ibin]>avgtrkbin[k]&& avgtrk[ibin]<=avgtrkbin[k+1])
        break;
}
        //multiplyByBinCenter(hq);
        hq->Scale(1./hq->Integral(0,-1,"width"));
        //normalizeByBinWidth(hq);
        //multiplyByBinCenter(hqx);
        hqx->Scale(1./hqx->Integral(0,-1,"width"));
        //normalizeByBinWidth(hqx);
        //multiplyByBinCenter(hqy);
        hqy->Scale(1./hqy->Integral(0,-1,"width"));
        //normalizeByBinWidth(hqy);
        hq2->Scale(1./hq2->Integral(0,-1,"width"));
        hq2nonf->Scale(1./hq2nonf->Integral(0,-1,"width"));
TF1 *ffit = new TF1(Form("ffit"),"1./(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10);
TF1* f1fit = new TF1(Form("f1fit"),"x/(0.5*(1+[0]))*TMath::Exp(-([1]*[1]*[2]+x*x)/(1+[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/(0.5*(1+[0])))",0,10);
//ffit = new TF1(Form("ffit"),"1./([0])*TMath::Exp(-([1]*[1]*[2]+x*x)/(2*[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/([0]))",0,10);
//f1fit = new TF1(Form("f1fit"),"x/([0])*TMath::Exp(-([1]*[1]*[2]+x*x)/(2*[0]))*TMath::BesselI0(x*[1]*TMath::Sqrt([2])/([0]))",0,10);
ffit->SetParNames("g2","v2","M");
f1fit->SetParNames("g2","v2","M");
//ffit->SetParNames("#sigma2","v2","M");
//f1fit->SetParNames("sigma2","v2","M");
ffit->SetParameters(0.1,0.05,avgmult[ibin]);
f1fit->SetParameters(0.1,0.05,avgmult[ibin]);
if(fixv2){
ffit->FixParameter(1,V24[k]);
f1fit->FixParameter(1,V24[k]);
}
if(fixg2){
    double sigma2 = avgpt2[ibin]/2./avgpt[ibin]/avgpt[ibin];
    double g2all = 2*sigma2-1;
    ffit->FixParameter(0,g2all);
    f1fit->FixParameter(0,g2all);
}

//f1fit->FixParameter(0,0);
//f1fit->FixParameter(0,0);
ffit->FixParameter(2,avgmult[ibin]);
f1fit->FixParameter(2,avgmult[ibin]);
/*
hq->Fit(Form("f1fit"),"R","P",0,10);
TCanvas *c2 = new TCanvas("c2","c2",1000,500);
//.........这里部分代码省略.........
开发者ID:XuQiao,项目名称:HI,代码行数:101,代码来源:plotqfit.C


注:本文中的TVectorD::Sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。