本文整理汇总了C++中TVectorD::GetMatrixArray方法的典型用法代码示例。如果您正苦于以下问题:C++ TVectorD::GetMatrixArray方法的具体用法?C++ TVectorD::GetMatrixArray怎么用?C++ TVectorD::GetMatrixArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVectorD
的用法示例。
在下文中一共展示了TVectorD::GetMatrixArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotv2vseta
void plotv2vseta(){
int ibin=0;
TFile *f = TFile::Open("mergedv_Prod2_eta.root");
TFile *fProd = TFile::Open("mergedv_Prod2_eta.root");
TVectorD *vecDv2 = (TVectorD*)f->Get(Form("D_%d/vmean",ibin));
TVectorD *vecDv2err = (TVectorD*)f->Get(Form("D_%d/deltavmean",ibin));
TVectorD *vecDavgeta = (TVectorD*)f->Get(Form("D_%d/avgeta",ibin));
TVectorD *vecDv2_ = (TVectorD*)fProd->Get(Form("D_%d/vmean",ibin));
TVectorD *vecDv2err_ = (TVectorD*)fProd->Get(Form("D_%d/deltavmean",ibin));
TVectorD *vecDavgeta_ = (TVectorD*)fProd->Get(Form("D_%d/avgeta",ibin));
double *avgeta = vecDavgeta->GetMatrixArray();
double *v2 = vecDv2->GetMatrixArray();
double *v2err = vecDv2err->GetMatrixArray();
double *avgeta_ = vecDavgeta_->GetMatrixArray();
double *v2_ = vecDv2_->GetMatrixArray();
double *v2err_ = vecDv2err_->GetMatrixArray();
double v2corr[netav],v2corr_[netav];
for(int i=0;i<netav;i++){
v2corr[i]=v2[i];
v2corr_[i]=v2_[i];
}
TCanvas *c1 = new TCanvas();
/*V2vsPt->SetLineColor(2);
V2vsPt->SetTitle("v_{2} vs momentum");
V2vsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
V2vsPt->GetYaxis()->SetTitle("v_{2}");
V2vsPt->GetYaxis()->SetRangeUser(0,0.1);
V2vsPt->Draw();
*/
TGraphErrors *gr=new TGraphErrors(netav,avgeta,v2corr,0,v2err);
TGraphErrors *grProd=new TGraphErrors(netav,avgeta_,v2corr_,0,v2err_);
gr->SetTitle("v_{2} vs #eta");
gr->GetXaxis()->SetTitle("#eta");
gr->GetYaxis()->SetTitle("v_{2}");
gr->SetMarkerSize(1.3);
gr->SetMarkerColor(1);
gr->SetMarkerStyle(20);
grProd->SetMarkerStyle(29);
grProd->SetMarkerColor(4);
gr->Draw("AP");
grProd->Draw("Psame");
TLegend *tl = new TLegend(0.6,0.2,0.8,0.35);
tl->SetFillColor(0);
tl->SetBorderSize(0);
tl->SetTextSize(0.05);
//tl->AddEntry(V2vsPt,"input v_{2}","lp");
tl->AddEntry(gr,"LYZ Sum method","lp");
tl->AddEntry(grProd,"LYZ Prod method","lp");
tl->Draw("same");
TLatex *tlx = new TLatex(0.2,0.3,"260<multi<300");
tlx->SetNDC();
tlx->SetTextSize(0.045);
tlx->Draw("same");
c1->Print("v2vseta.png");
f->Close();
}
示例2: plotv2vspt
void plotv2vspt(){
int ibin=0;
TFile *f = TFile::Open("mergedv_Prod2_inV2.root");
TFile *fProd = TFile::Open("mergedv_Prod2.root");
TVectorD *vecDv2 = (TVectorD*)f->Get(Form("D_%d/vmean",ibin));
TVectorD *vecDv2err = (TVectorD*)f->Get(Form("D_%d/deltavmean",ibin));
TVectorD *vecDavgpt = (TVectorD*)f->Get(Form("D_%d/avgpt",ibin));
TVectorD *vecDv2_ = (TVectorD*)fProd->Get(Form("D_%d/vmean",ibin));
TVectorD *vecDv2err_ = (TVectorD*)fProd->Get(Form("D_%d/deltavmean",ibin));
TVectorD *vecDavgpt_ = (TVectorD*)fProd->Get(Form("D_%d/avgpt",ibin));
double *avgpt = vecDavgpt->GetMatrixArray();
double *v2 = vecDv2->GetMatrixArray();
double *v2err = vecDv2err->GetMatrixArray();
double *avgpt_ = vecDavgpt_->GetMatrixArray();
double *v2_ = vecDv2_->GetMatrixArray();
double *v2err_ = vecDv2err_->GetMatrixArray();
double v2corr[nptv],v2corr_[nptv];
for(int i=0;i<nptv;i++){
v2corr[i]=v2[i];
v2corr_[i]=v2_[i];
}
TCanvas *c1 = new TCanvas();
V2vsPt->SetLineColor(2);
V2vsPt->SetTitle("v_{2} vs momentum");
V2vsPt->GetXaxis()->SetTitle("p_{T} (GeV/c)");
V2vsPt->GetYaxis()->SetTitle("v_{2}");
V2vsPt->GetYaxis()->SetRangeUser(-0.1,0.13);
V2vsPt->Draw();
TGraphErrors *gr=new TGraphErrors(nptv,avgpt,v2corr,0,v2err);
TGraphErrors *grProd=new TGraphErrors(nptv,avgpt_,v2corr_,0,v2err_);
gr->SetTitle("v_{2} vs momentum");
gr->GetXaxis()->SetTitle("p_{T} (GeV/c)");
gr->GetYaxis()->SetTitle("v_{2}");
gr->SetMarkerSize(1.3);
gr->SetMarkerColor(1);
gr->SetMarkerStyle(20);
grProd->SetMarkerStyle(29);
grProd->SetMarkerColor(4);
gr->Draw("Psame");
grProd->Draw("Psame");
TLegend *tl = new TLegend(0.6,0.2,0.8,0.35);
tl->SetFillColor(0);
tl->SetBorderSize(0);
tl->SetTextSize(0.05);
tl->AddEntry(V2vsPt,"input v_{2}","lp");
tl->AddEntry(gr,"LYZ Prod method inV2","lp");
tl->AddEntry(grProd,"LYZ Prod method","lp");
tl->Draw("same");
TLatex *tlx = new TLatex(0.2,0.3,Form("STEG, 15M events, mult=%d",(trkbin[0]+trkbin[1])/2));
tlx->SetNDC();
tlx->SetTextSize(0.045);
tlx->Draw("same");
c1->Print("v2vspt.png");
f->Close();
}
示例3: plotqfit
void plotqfit() {
int xtheta=0;
gStyle->SetOptStat(1011);
gStyle->SetOptFit(1111);
TFile *f = TFile::Open("mergedV_Sum.root");
TFile *fout = TFile::Open("qfitV.root","Recreate");
TVectorD *vecDavgmult = f->Get(Form("avgmultall"));
TVectorD *vecDavgtrk = f->Get(Form("avgtrk"));
double *avgmult = vecDavgmult->GetMatrixArray();
double *avgtrk = vecDavgtrk->GetMatrixArray();
TLatex *t= new TLatex();
t->SetNDC();
t->SetTextSize(0.04);
t->SetTextFont(42);
for(int ibin=0; ibin<nbin; ibin++) { //ibin<1
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));
//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"));
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);
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]);
//ffit->FixParameter(1,0);
//f1fit->FixParameter(1,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",500,1000);
c2->Divide(1,2);
c2->cd(1)->SetLogy();
fixedFontHist(hqx,1.6,2.0);
hqx->SetTitle("");
hqx->GetXaxis()->SetTitle("q_{x}");
hqx->GetYaxis()->SetTitle("#frac{dN}{dq_{x}}");
hqx->GetYaxis()->SetRangeUser(1e-10,1);
hqx->Fit(Form("f1fit"),"R","",0,10);
c2->cd(2)->SetLogy();
TH1D* hqx_cp = (TH1D*)hqx->Clone("hqx_cp");
fixedFontHist(hqx_cp,1.6,2.0);
divideByBinCenter(hqx_cp);
hqx_cp->GetYaxis()->SetTitle("#frac{dN}{q_{x}dq_{x}}");
hqx_cp->GetYaxis()->SetRangeUser(1e-10,10);
hqx_cp->Fit(Form("ffit"),"R","",0,10);
t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f", avgtrk[ibin]));
TCanvas *c3 = new TCanvas("c3","c3",500,1000);
c3->Divide(1,2);
c3->cd(1);
fixedFontHist(hqy,1.6,2.0);
hqy->SetTitle("");
hqy->GetXaxis()->SetTitle("q_{y}");
hqy->GetYaxis()->SetTitle("#frac{dN}{dq_{y}}");
hqy->GetYaxis()->SetRangeUser(0,1);
hqy->SetMarkerStyle(24);
hqy->SetMarkerSize(0.5);
hqy->Fit(Form("f1fit"),"R","",0,10);
hqy->Draw("Psame");
c3->cd(2)->SetLogy();
TH1D* hqy_cp = (TH1D*)hqy->Clone("hqy_cp");
fixedFontHist(hqy_cp,1.6,2.0);
divideByBinCenter(hqy_cp);
hqy_cp->GetYaxis()->SetTitle("#frac{dN}{q_{y}dq_{y}}");
hqy_cp->GetYaxis()->SetRangeUser(1e-10,10);
hqy_cp->SetMarkerStyle(24);
hqy_cp->SetMarkerSize(0.5);
hqy_cp->Fit(Form("ffit"),"R","",0,10);
hqy_cp->Draw("Psame");
t->DrawLatex(0.5,0.2,Form("N_{trk}^{offline} = %.2f",avgtrk[ibin]));
TCanvas *c4 = new TCanvas("c4","c4",500,1000);
c4->Divide(1,2);
c4->cd(1);
fixedFontHist(hq2,1.6,2.0);
hq2->SetTitle("");
hq2->GetXaxis()->SetTitle("q_{2}");
hq2->GetYaxis()->SetTitle("#frac{dN}{dq_{2}}");
hq2->GetYaxis()->SetRangeUser(0,1);
hq2->SetMarkerStyle(24);
hq2->SetMarkerColor(4);
hq2->SetLineColor(4);
//.........这里部分代码省略.........
示例4: 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);
//.........这里部分代码省略.........
示例5: plotgvsr
void plotgvsr(){
int xbin=0; //xbin<1
int xptbin=1; //xptbin<13
int xtheta=4; //xtheta<5
TFile *f = TFile::Open("mergedV_Sum.root");
TVectorD *vecDr = f->Get(Form("D_%d/r",xbin));
TVectorD *vecDg2 = f->Get(Form("D_%d/D_%d/D_%d/G2",xbin,xptbin,xtheta));
TVectorD *vecDsigma2 = f->Get(Form("D_%d/D_%d/sigma2",xbin,xptbin));
TVectorD *vecDV = f->Get(Form("D_%d/D_%d/V",xbin,xptbin));
TVectorD *vecDavgmult = f->Get(Form("D_%d/avgmult",xbin));
double *r = vecDr->GetMatrixArray();
double *g2 = vecDg2->GetMatrixArray();
double *sigma2 = vecDsigma2->GetMatrixArray();
double *V = vecDV->GetMatrixArray();
double *avgmult = vecDavgmult->GetMatrixArray();
cout<<sigma2[0]<<endl;
cout<<V[0]<<endl;
TCanvas *c1 = new TCanvas;
c1->SetLogy();
TGraph *gr=new TGraph(nstepr,r,g2);
gr->GetXaxis()->SetTitle("r");
gr->GetYaxis()->SetTitle("|G^{#theta}(ir)|");
if(isSimple)
gr->GetXaxis()->SetRangeUser(0,1);
else
gr->GetXaxis()->SetRangeUser(0.05,0.2);
gr->GetYaxis()->SetRangeUser(1e-8,1);
gr->SetTitle("");
gr->SetMarkerSize(1);
gr->SetMarkerColor(1);
gr->SetMarkerStyle(20);
gr->Draw("AP");
TLatex *t= new TLatex();
t->SetNDC();
t->SetTextSize(0.03);
if(xtheta==0)
t->DrawLatex(0.2,0.8,Form("%d<mult<%d, %.1f<p_{T}<%.1f, theta = %d", trkbin[xbin+1],trkbin[xbin],ptbin[xptbin],ptbin[xptbin+1],xtheta));
else
t->DrawLatex(0.2,0.8,Form("%d<mult<%d, %.1f<p_{T}<%.1f, theta = #frac{%d}{%d}#pi", trkbin[xbin+1],trkbin[xbin],ptbin[xptbin],ptbin[xptbin+1],xtheta,ntheta*nn));
double inV2 = 0.065;
TF1 *gcl = new TF1("gcl","TMath::Power(exp(-[0]*x*x/4)*TMath::BesselJ0([1]*x),2)",0,1);
//gcl->SetParameters(sigma2[xtheta],V[xtheta]*sigma2[xtheta]);
//gcl->SetParameters(300,0.065*300);
gcl->SetParameters(sigma2[xtheta]+V[xtheta]*V[xtheta]*avgmult[xbin]*avgmult[xbin]-inV2*inV2*avgmult[xbin]*avgmult[xbin],inV2*avgmult[xbin]);
gcl->SetLineColor(2);
TLegend *leg = new TLegend(0.6,0.7,0.8,0.9);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetTextSize(0.03);
leg->AddEntry(gr,"Analysis result","P");
leg->AddEntry(gcl,"theoretical prediction","L");
leg->Draw("same");
gcl->Draw("same");
c1->Print("gvsr.png");
f->Close();
}
示例6: writeSignalHistosForModel
void writeSignalHistosForModel(std::vector<TH1D *>& vsd,
const TString& sigmodel,
TFile *allHistFile)
{
for (int ichan=0; ichan<NUMCHAN; ichan++) {
TH1D * sdh = vsd[ichan];
// Find limit window from gaussian fit to signal peak.
//
double wid = sdh->GetRMS();
double mean = sdh->GetMean();
//TCanvas *c1 = new TCanvas(s,s,300,300);
TFitResultPtr r = sdh->Fit("gaus","QNS","",mean-2.5*wid,mean+2.5*wid);
cout<<" mean= "<<mean<<", RMS= "<<wid<<", Fit sigma= "<<r->Parameter(2)<<endl;
//cout<<r->Parameter(0)<<" "<<r->Parameter(1)<<" "<<r->Parameter(2)<<endl;
TAxis *xax = sdh->GetXaxis();
#if 0
int lobin = xax->FindFixBin(r->Parameter(1)-2*r->Parameter(2));
int hibin = xax->FindFixBin(r->Parameter(1)+2*r->Parameter(2));
sd.sumwinmin = xax->GetBinLowEdge(lobin);
sd.sumwinmax = xax->GetBinUpEdge(hibin);
#elif 0
int lobin = xax->FindFixBin(140); sd.sumwinmin=140; // 1 bin left,
int hibin = xax->FindFixBin(170)-1; sd.sumwinmax=170; // 2 bins right
#else
int lobin = xax->FindFixBin(sumwinmin);
int hibin = xax->FindFixBin(sumwinmax)-1;
#endif
int nbins = hibin-lobin+1;
// for variable binning - all histos must have the same binning per channel
TVectorD xbins = TVectorD(sdh->GetNbinsX(),sdh->GetXaxis()->GetXbins()->GetArray());
TVectorD xwindow = xbins.GetSub(lobin-1,hibin);
xax->SetRange(lobin,hibin);
// Copy contents to window-restricted signal histogram
// and write to output file.
//
TString name = Form("Signal%s_%s",sigmodel.Data(),channames[ichan]);
printf("Booking TH1D(%s,%s,%d,xwindowarray)\n",
name.Data(),sdh->GetTitle(),nbins);
TH1D *signm = new TH1D(name.Data(),
sdh->GetTitle(),
nbins,
xwindow.GetMatrixArray());
// make copies of the histograms that are restricted to the
// bin range lobin-hibin
//
for (int ibin=lobin; ibin<=hibin; ibin++)
signm->SetBinContent((ibin-lobin+1),
sdh->GetBinContent(ibin)
*sdh->GetBinWidth(ibin)
);
if (!sigmodel.CompareTo("wh"))
signm->Scale(whsigscaleto);
else
signm->Scale(sigscaleto);
allHistFile->WriteTObject(signm);
} // channel loop
} // writeSignalHistosForModel
示例7: plotV2vstheta
void plotV2vstheta(){
TFile *f;
int isSum=0;
const int ntotbin=5;
const int trkpointmin[ntotbin] = {120,150,185,220,260};
const int trkpointmax[ntotbin] = {150,185,220,260,300};
int trkbin=1;
int xbin=0;
c1 = new TCanvas("c1"," ",1200,700);
makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03);
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetErrorX(0);
TH1D *hFrame = new TH1D("","",100,0,2);
hFrame->SetTitle("");
hFrame->GetXaxis()->SetTitle("#theta");
hFrame->GetYaxis()->SetTitle("reference V_{2}");
hFrame->GetYaxis()->SetTitleOffset(1.1);
hFrame->GetXaxis()->SetTitleSize(0.04);
hFrame->GetYaxis()->SetTitleSize(0.04);
hFrame->GetXaxis()->SetRangeUser(0,1.5);
hFrame->SetMinimum(0.020);
hFrame->SetMaximum(0.060);
for(int trkbin=0;trkbin<ntotbin; trkbin++){
if(isSum==0){
f = TFile::Open(Form("M%d%d/mergedV_Prod.root",trkpointmax[trkbin],trkpointmin[trkbin]));
}
else{
f = TFile::Open(Form("M%d%d/mergedV_Sum.root",trkpointmax[trkbin],trkpointmin[trkbin]));
}
TVectorD* vecVmean = (TVectorD*)f->Get(Form("D_%d/Vmean",xbin));
TVectorD* vecV = (TVectorD*)f->Get(Form("D_%d/D_0/V",xbin));
double Vmean = (*vecVmean)[0];
double *V = vecV->GetMatrixArray();
double theta[ntheta];
for(int itheta=0;itheta<ntheta;itheta++){
theta[itheta]=itheta*TMath::Pi()/ntheta/nn;
}
int maxper10 = findmaxper(V,ntheta,Vmean);
double maxper = (double)(maxper10+1)/10;
c1->cd(trkbin+1);
hFrame->Draw();
TGraph *gV2theta = new TGraph(ntheta,theta,V);
gV2theta->SetMarkerStyle(20);
gV2theta->SetMarkerSize(1.3);
gV2theta->SetMarkerColor(1);
gV2theta->SetLineColor(1);
gV2theta->Draw("Psame");
TLine *lup = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1+maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1+maxper));
TLine *ldown = new TLine(gV2theta->GetXaxis()->GetXmin(),Vmean*(1-maxper), gV2theta->GetXaxis()->GetXmax(),Vmean*(1-maxper));
TLine *l = new TLine(hFrame->GetXaxis()->GetXmin(),Vmean, hFrame->GetXaxis()->GetXmax(),Vmean);
l->SetLineStyle(2);
lup->SetLineStyle(2);
ldown->SetLineStyle(2);
l->SetLineWidth(1.2);
lup->SetLineWidth(1.2);
ldown->SetLineWidth(1.2);
TLatex *tl = new TLatex();
// tl->SetNDC();
tl->SetTextFont(42);
tl->SetTextSize(0.04);
// tl->SetBorderStyle(0);
tl->DrawLatex(0,Vmean*(1+maxper),Form("mean up %.f%%",maxper*100));
tl->DrawLatex(0,Vmean*(1-maxper),Form("mean down %.f%%",maxper*100));
tl->SetNDC();
tl->DrawLatex(0.7,0.85,Form("Multiplicity %d to %d",trkpointmin[trkbin],trkpointmax[trkbin]));
l->Draw("same");
lup->Draw("same");
ldown->Draw("same");
}
c1->cd(ntotbin+1);
TLatex *tlx0 = new TLatex(0.12,0.3,Form("track"));
TLatex *tlx1 = new TLatex(0.12,0.25,Form("%.1f<p_{T}<%.1f (GeV/c)",0.3,6.0));
tlx0->SetNDC();
tlx1->SetNDC();
tlx0->SetTextSize(0.045);
tlx1->SetTextSize(0.045);
hFrame->Draw();
tlx0->Draw("same");
tlx1->Draw("same");
if(isSum==0)c1->SaveAs("hV2theta_Prod.png");
else c1->SaveAs("hV2theta_Sum.png");
}