本文整理汇总了C++中TH2D::GetBinError方法的典型用法代码示例。如果您正苦于以下问题:C++ TH2D::GetBinError方法的具体用法?C++ TH2D::GetBinError怎么用?C++ TH2D::GetBinError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH2D
的用法示例。
在下文中一共展示了TH2D::GetBinError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mytestreweight
void mytestreweight(){
TFile*finput=new TFile("fworking.root");
TH1D*hBPtFONLL=(TH1D*)finput->Get("hBPt");
TH1D*hDPtFONLL=(TH1D*)finput->Get("hDPt");
TH2D*hD=(TH2D*)finput->Get("hD");
hD->SetXTitle("B p_{T} (GeV/c)");
hD->SetYTitle("D^{0} p_{T} (GeV/c)");
hBPtFONLL->SetXTitle("B p_{T} (GeV/c)");
hDPtFONLL->SetXTitle("D p_{T} (GeV/c)");
TH2D *hDreweight = (TH2D*)hD->Clone("hDreweight");
TH1D *hBPtPythia = hD->ProjectionX("hBPtPythia");
TH1D *hDPtPythia = hD->ProjectionY("hDPtPythia");
for (int x=1;x<=hDreweight->GetNbinsX()+1;x++){ //loop over the B pt bins
if (hBPtPythia->GetBinContent(x)==0) continue;
double ratio = hBPtFONLL->GetBinContent(x)/hBPtPythia->GetBinContent(x); // in each pt bin we calculate the ratio of pythiaB/FONLLB
for (int y=1;y<=hDreweight->GetNbinsY()+1;y++){ //loop over the D pt bins
double ratio2 = ratio; //copy the ratio for each B bin
double val = hDreweight->GetBinContent(x,y)*ratio2;
double valError = hDreweight->GetBinError(x,y)*ratio2;
hDreweight->SetBinContent(x,y,val);
hDreweight->SetBinError(x,y,valError);
}
}
TH1D *hBPtPythiaReweight = hDreweight->ProjectionX("hBPtPythiaReweight");
TH1D *hDPtPythiaReweight = hDreweight->ProjectionY("hDPtPythiaReweight");
hBPtPythiaReweight->Divide(hBPtFONLL);
TCanvas*canvas=new TCanvas("canvas","canvas",1000,500);
canvas->SetLogy();
canvas->Divide(3,1);
canvas->cd(1);
hBPtFONLL->Draw();
canvas->cd(2);
hBPtPythia->Draw();
canvas->cd(3);
hBPtPythiaReweight->Draw();
}
示例2: DrawTH2DZ
void DrawTH2DZ(TFile* File, char* Histos_Name, char* legend, char* Title, char* Xlegend, char* Ylegend, double xmin, double xmax, double ymin, double ymax, bool save, char* save_path, bool Normalization)
{
TH2D* Histos = File->Get(Histos_Name);
Histos->SetTitle();
Histos->SetStats(kFALSE);
Histos->GetXaxis()->SetTitle(Xlegend);
Histos->GetYaxis()->SetTitle(Ylegend);
Histos->GetYaxis()->SetTitleOffset(1.20);
// Histos->GetYaxis()->SetTitleOffset(1.0);
if(xmin!=xmax)Histos->SetAxisRange(xmin,xmax,"X");
if(ymin!=ymax)Histos->SetAxisRange(ymin,ymax,"Y");
if(Normalization){
for(int x=0;x<Histos->GetXaxis()->GetNbins();x++){
TH1D* tmp = Histos->ProjectionY("",x,x);
double Integral = tmp->Integral();
if(Integral==0)continue;
double Factor = 1/Integral;
for(int y=0;y<Histos->GetYaxis()->GetNbins();y++){
Histos->SetBinContent(x,y, Histos->GetBinContent(x,y)*Factor );
Histos->SetBinError (x,y, Histos->GetBinError (x,y)*Factor );
}
}
}
Histos->Draw("COLZ");
gPad->SetLogz(1);
/* c1->Update();
TPaletteAxis* palette = (TPaletteAxis*)Histos->GetListOfFunctions()->FindObject("palette");
palette->SetLabelOffset(0.1);
palette->SetTitleOffset(0.1);
c1->Modified();
*/
if(save==1){
// char path[255]; sprintf(path,"Pictures/PNG/%s.png",save_path); c1->SaveAs(path);
// char path[255]; sprintf(path,"Pictures/EPS/%s.eps",save_path); c1->SaveAs(path);
// char path[255]; sprintf(path,"Pictures/C/%s.C" ,save_path); c1->SaveAs(path);
c1->SaveAs(save_path);
}
}
示例3: swap
std::pair<Matrix, Matrix> roothist_to_matrix(const TH2D & hist, bool transpose){
int ngen = hist.GetNbinsY();
int nreco = hist.GetNbinsX();
if(transpose){
swap(ngen, nreco);
}
Matrix m = Matrix(nreco, ngen);
Matrix m_e = Matrix(nreco, ngen);
for(int i=0; i<nreco; ++i){
for(int j=0; j<ngen; ++j){
int nx = i+1;
int ny = j+1;
if(transpose) swap(nx, ny);
m(i,j) = hist.GetBinContent(nx, ny);
m_e(i,j) = hist.GetBinError(nx, ny);
}
}
return pair<Matrix, Matrix>(move(m), move(m_e));
}
示例4: ExtractOutputHistos
//.........这里部分代码省略.........
hAllFound->Draw("same"); // MC pt distribution
}
/*
.L ~/ITSupgrade/BuildDetector/DetectorK.cxx+
// All NEW
DetectorK its("ALICE","ITS");
its.MakeAliceAllNew(0);
its.SetMaxRadiusOfSlowDetectors(0.01);
its.SolveViaBilloir(0);
TGraph *c = its.GetGraphRecoEfficiency(0,3,2);
c->Draw("C");
// Current
DetectorK its("ALICE","ITS");
its.MakeAliceCurrent(0,0);
its.SetMaxRadiusOfSlowDetectors(0.01);
its.SolveViaBilloir(0);
TGraph *c = its.GetGraphRecoEfficiency(0,4,2);
c->Draw("C");
*/
TCanvas *c3 = new TCanvas("c3","impact");//,200,10,900,900);
c3->Divide(2,1); c3->cd(1);
// Impact parameter
// Impact parameter resolution ---------------
h2Ddca->Draw("colz");
h2Ddca->FitSlicesY() ;
TH2D *dcaM = (TH2D*)gDirectory->Get("dca2D_1"); dcaM->Draw("same");
TH2D *dcaRMS = (TH2D*)gDirectory->Get("dca2D_2"); //dcaRMS->Draw();
TGraphErrors *d0 = new TGraphErrors();
for (Int_t ibin =1; ibin<=dcaRMS->GetXaxis()->GetNbins(); ibin++) {
d0->SetPoint( ibin-1,dcaRMS->GetBinCenter(ibin),dcaRMS->GetBinContent(ibin)*1e4); // microns
d0->SetPointError(ibin-1,0,dcaRMS->GetBinError(ibin)*1e4); // microns
}
d0->SetMarkerStyle(21);
d0->SetMaximum(200); d0->SetMinimum(0);
d0->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
d0->GetYaxis()->SetTitle("R-#phi Pointing Resolution (#mum)");
d0->SetName("dca"); d0->SetTitle("DCAvsPt");
c3->cd(1); h2Ddca->Draw("surf2");
c3->cd(2); d0->Draw("APE");
// PT RESOLUTION ------------
TCanvas *c4 = new TCanvas("c4","pt resolution");//,200,10,900,900);
c4->Divide(2,1); c4->cd(1);
// Impact parameter
h2Dpt->Draw("colz");
h2Dpt->FitSlicesY() ;
TH2D *dPtM = (TH2D*)gDirectory->Get("dPt2D_1"); dPtM->Draw("same");
TH2D *dPtRMS = (TH2D*)gDirectory->Get("dPt2D_2"); // dPtRMS->Draw("");
TGraphErrors *gPt = new TGraphErrors();
for (Int_t ibin =1; ibin<=dPtRMS->GetXaxis()->GetNbins(); ibin++) {
gPt->SetPoint( ibin-1,dPtRMS->GetBinCenter(ibin),dPtRMS->GetBinContent(ibin));
gPt->SetPointError(ibin-1,0,dPtRMS->GetBinError(ibin));
}
gPt->SetMarkerStyle(21);
gPt->SetMaximum(20); gPt->SetMinimum(0);
gPt->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
gPt->GetYaxis()->SetTitle("relative momentum resolution (%)");
gPt->SetName("dPt"); gPt->SetTitle("DPTvsPt");
c4->cd(1); h2Dpt->Draw("surf2");
c4->cd(2); gPt->Draw("APE");
// EXPORT --------
TFile f("histos.root","RECREATE");
hMultCount->Write();
hAllMC->Write();
hAllFound->Write();
hImperfect->Write();
hPerfect->Write();
hNoMCTrack->Write();
hPurity->Write();
hEff->Write();
hFake->Write();
hAnna->Write();
h2Ddca->Write();
d0->Write();
h2Dpt->Write();
gPt->Write();
f.Close();
return;
}
示例5: plotMerged
void plotMerged(Bool_t onlyPlot=0) {
gStyle->SetPalette(1);
TFile f("histoSum.root","UPDATE");
TH1F* hAllMC = f.Get("allMC");
TH1F* hAllFound= f.Get("allFound");
TH1F* hImperfect= f.Get("imperfect");
TH1F* hPerfect= f.Get("perfect");
TH1F* hNoMCTrack= f.Get("noMCtrack");
// have to be recalculated
TH1F* hPurity = f.Get("purity");
TH1F* hEff= f.Get("efficiency");
TH1F* hFake= f.Get("fake");
TH1F* hAnna= f.Get("annaEff");
TH2D* h2Ddca= f.Get("dca2D");
TGraphErrors *d0= f.Get("dca");
TH2D* h2Dpt= f.Get("dPt2D");
TGraphErrors *gPt= f.Get("dPt");
if (!onlyPlot) {
/* // Get Errors right
hAllMC->Sumw2();
hAllFound->Sumw2();
hPerfect->Sumw2();
hImperfect->Sumw2();
h2Dpt->Sumw2();
h2Ddca->Sumw2();
*/
// Efficiencies - and normalize to 100%
TF1 f1("f1","100+x*0",0.,1.e3);
hPurity->Divide(hPerfect,hAllFound,1,1,"b");
hPurity->Multiply(&f1);
hPurity->SetMarkerColor(kGreen);
hPurity->SetMarkerStyle(21);
hPurity->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
hPurity->SetStats(0);
hPurity->GetYaxis()->SetRangeUser(0,100);
hPurity->SetTitle("Efficiency & Purity");
hEff->Divide(hPerfect,hAllMC,1,1,"b");
hEff->Multiply(&f1);
hEff->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
hEff->SetMarkerColor(kBlue);
hEff->SetMarkerStyle(21);
hEff->SetStats(0);
hFake->Divide(hImperfect,hAllMC,1,1,"b");
hFake->Multiply(&f1);
hFake->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
hFake->SetMarkerColor(kRed);
hFake->SetMarkerStyle(21);
hFake->SetStats(0);
hAnna->Divide(hAllFound,hAllMC,1,1,"b");
hAnna->Multiply(&f1);
hAnna->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
hAnna->SetMarkerColor(kBlack);
hAnna->SetMarkerStyle(21);
hAnna->SetStats(0);
// Impact parameter resolution ---------------
TCanvas *c3 = new TCanvas("c3","impact");//,200,10,900,900);
c3->Divide(2,1); c3->cd(1);
h2Ddca->DrawCopy("colz");
h2Ddca->FitSlicesY() ;
TH2D *dcaM = (TH2D*)gDirectory->Get("dca2D_1"); dcaM->Draw("same");
TH2D *dcaRMS = (TH2D*)gDirectory->Get("dca2D_2"); //dcaRMS->Draw();
TGraphErrors *d0 = new TGraphErrors();
for (Int_t ibin =1; ibin<=dcaRMS->GetXaxis()->GetNbins(); ibin++) {
d0->SetPoint( ibin-1,dcaRMS->GetBinCenter(ibin),dcaRMS->GetBinContent(ibin)*1e4); // microns
d0->SetPointError(ibin-1,0,dcaRMS->GetBinError(ibin)*1e4); // microns
}
d0->SetMarkerStyle(21);
d0->SetMaximum(200); d0->SetMinimum(0);
d0->GetXaxis()->SetTitle("transverse momentum p_{t} (GeV)");
d0->GetYaxis()->SetTitle("R-#phi Pointing Resolution (#mum)");
d0->SetName("dca"); d0->SetTitle("DCAvsPt");
// c3->cd(1); h2Ddca->Draw("surf2");
c3->cd(2); d0->Draw("APE");
// PT RESOLUTION ------------
TCanvas *c4 = new TCanvas("c4","pt resolution");//,200,10,900,900);
c4->Divide(2,1); c4->cd(1);
h2Dpt->DrawCopy("colz");
h2Dpt->FitSlicesY() ;
TH2D *dPtM = (TH2D*)gDirectory->Get("dPt2D_1"); dPtM->Draw("same");
TH2D *dPtRMS = (TH2D*)gDirectory->Get("dPt2D_2"); // dPtRMS->Draw("");
TGraphErrors *gPt = new TGraphErrors();
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
mapspad[j]->SetLeftMargin( 0.05);
mapspad[j]->SetRightMargin( 0.15);
mapspad[j]->SetTopMargin( 0.05);
mapspad[j]->SetBottomMargin(0.05);
mapspad[j]->Draw();
mapspad[j]->cd();
map = (TH2D*)file->Get(("DarkMap"+HV+"V"+itoa(j)).c_str());
map->SetTitle("");
map->SetMaximum(maxrate);
map->SetMinimum(0);
map->Draw("COLZ");
// 1D histogram
histcan->cd();
histpad[j] = new TPad("", "", xlo, ylo, xhi, yhi);
histpad[j]->SetLeftMargin( 0.05);
histpad[j]->SetRightMargin( 0.15);
histpad[j]->SetTopMargin( 0.05);
histpad[j]->SetBottomMargin(0.05);
histpad[j]->Draw();
histpad[j]->SetLogy();
histpad[j]->cd();
hist = new TH1D(("hist"+itoa(i)+itoa(j)).c_str(), title[j].c_str(), 100, 0, maxrate);
tree->Draw(("rate"+itoa(j)+">>"+hist->GetName()).c_str(), "", "", 1, i);
// Graph
x[j][i] = HVs[i];
xe[j][i] = 0;
y[j][i] = 0;
ye[j][i] = 0;
double yval = 0, yerr = 0;
double npix = 0;
for(int k = 0; k < 64; k++)
{
yval = map->GetBinContent((k/8)+1, (k%8)+1);
yerr = map->GetBinError((k/8)+1, (k%8)+1);
if(yval<0) continue;
y[j][i] += yval;
ye[j][i] += yerr*yerr;
npix++;
}
y[j][i] /= npix;
ye[j][i] = sqrt(ye[j][i])/npix;
cout << npix << "\t" << y[j][i] << "±" << ye[j][i] << endl;
}
gStyle->SetOptStat("m");
histcan->SaveAs(("./figs/"+(string)histcan->GetName()+".pdf").c_str());
histcan->SaveAs(("./figs/"+(string)histcan->GetName()+".png").c_str());
mapscan->SaveAs(("./figs/"+(string)mapscan->GetName()+".pdf").c_str());
mapscan->SaveAs(("./figs/"+(string)mapscan->GetName()+".png").c_str());
}
mg = new TMultiGraph();
lg = new TLegend(0.17,0.6,0.45,0.82);
lg->SetFillStyle(0);
lg->SetLineWidth(0);
int linecolour[4] = {kBlue,kRed+1,kGreen+1,kViolet};
int linestyle[4] = {2,9,3,5};
int index[4] = {1, 0, 2, 3}; // More sensible order
for(int k = 0; k < 4; k++)
{
int j = index[k];
graph[j] = new TGraphErrors(n, x[j], y[j], xe[j], ye[j]);
graph[j]->SetTitle(title[j].c_str());
graph[j]->SetLineWidth(2);
indivgraphcan[j] = new TCanvas((title[j]+"graph").c_str(),"",1000,900);
indivgraphcan[j]->Draw();
graph[j]->GetXaxis()->SetTitle("High Voltage [V]");
graph[j]->GetYaxis()->SetTitle("Dark count rate [Hz]");