本文整理汇总了C++中TGraphErrors::GetHistogram方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::GetHistogram方法的具体用法?C++ TGraphErrors::GetHistogram怎么用?C++ TGraphErrors::GetHistogram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::GetHistogram方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlotERes
void PlotERes(string FilterSet){
stringstream name;
name<<FilterSet<<"_vsEnergy";
TH2F* thePlot = (TH2F*)gDirectory->Get(name.str().c_str());
if (thePlot==NULL){
cout<<"No plot"<<endl;
return;
}
int numYBins = thePlot->GetNbinsY();
TF1 * myFunc = new TF1("myFunc","gaus",-0.3,0.3);
double * x = (double*)malloc(numYBins*sizeof(double));
double * y = (double*)malloc(numYBins*sizeof(double));
double * ey = (double*)malloc(numYBins*sizeof(double));
for (int i=0;i<numYBins;i++){
TH1D* proj=thePlot->ProjectionX("_px",i,numYBins-1);
if (proj->GetEntries()>40){
TFitResultPtr result = proj->Fit("myFunc","RQS");
Int_t status = result;
if (status==0){
cout<<result->Value(2)*2.35*4<<endl;
x[i]=i;
y[i]=result->Value(2)*2.35*4;
ey[i]=result->UpperError(2)*2.35*4;
}
}
}
TGraphErrors * graph = new TGraphErrors(numYBins,x,y,0,ey);
graph->GetHistogram()->SetMarkerStyle(5);
graph->Draw("AP");
}
示例2: main
//.........这里部分代码省略.........
}
gROOT->Reset();
gROOT->SetStyle("Plain");
gStyle->SetPadTickX(1);
gStyle->SetPadTickY(1);
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
gStyle->SetFitFormat("6.3g");
gStyle->SetPalette(1);
gStyle->SetTextFont(42);
gStyle->SetTextSize(0.05);
gStyle->SetTitleFont(42, "xyz");
gStyle->SetTitleSize(0.05);
gStyle->SetLabelFont(42, "xyz");
gStyle->SetLabelSize(0.05);
gStyle->SetTitleXOffset(0.8);
gStyle->SetTitleYOffset(1.1);
gROOT->ForceStyle();
TFile *th = new TFile("output/Occupancy.root", "RECREATE");
th->cd();
// Final plots
TCanvas *cEB = new TCanvas ("EB occupancy", "EB occupancy");
cEB->cd();
cEB->SetGridx();
cEB->SetGridy();
h_OccupancyEB->Write();
th->Close();
// Final plots
TCanvas *cEEp = new TCanvas ("EE+ occupancy", "EE+ occupancy");
cEEp->cd();
cEEp->SetGridx();
cEEp->SetGridy();
OccupancyEEP_vs_Eta->SetMarkerStyle(20);
OccupancyEEP_vs_Eta->SetMarkerColor(kGreen + 2);
OccupancyEEP_vs_Eta->GetHistogram()->GetXaxis()-> SetRangeUser(1.5, 2.5);
OccupancyEEP_vs_Eta->GetHistogram()->GetYaxis()-> SetTitle("Single xtal Event / fb^{-1}");
OccupancyEEP_vs_Eta->GetHistogram()->GetXaxis()-> SetTitle("#eta");
OccupancyEEP_vs_Eta->Draw("ap");
// Final plots
TCanvas *cEEm = new TCanvas ("EE- occupancy", "EE- occupancy");
cEEm->cd();
cEEm->SetGridx();
cEEm->SetGridy();
OccupancyEEM_vs_Eta->SetMarkerStyle(20);
OccupancyEEM_vs_Eta->SetMarkerColor(kGreen + 2);
OccupancyEEM_vs_Eta->GetHistogram()->GetXaxis()-> SetRangeUser(-2.5, -1.5);
OccupancyEEM_vs_Eta->GetHistogram()->GetYaxis()-> SetTitle("Single xtal Event / fb^{-1}");
OccupancyEEM_vs_Eta->GetHistogram()->GetXaxis()-> SetTitle("#eta");
OccupancyEEM_vs_Eta->Draw("ap");
TCanvas* cAll = new TCanvas("cAll", "history plot vs date", 1);
cAll ->cd();
cAll ->SetGridx();
cAll ->SetGridy();
OccupancyAll->SetMarkerStyle(20);
OccupancyAll->SetMarkerColor(kRed + 2);
OccupancyAll->GetHistogram()->GetXaxis()-> SetRangeUser(-2.55, 2.55);
OccupancyAll->GetHistogram()->GetYaxis()-> SetTitle("Number of Electrons / Crystal / fb^{-1}");
OccupancyAll->GetHistogram()->GetXaxis()-> SetTitle("#eta_{seed}");
OccupancyAll->Draw("ap");
OccupancyAll2->SetMarkerStyle(20);
OccupancyAll2->SetMarkerColor(kGreen + 2);
OccupancyAll2->Draw("psame");
TLegend * leg = new TLegend(0.5, 0.7, 0.6, 0.87);
leg->SetFillColor(0);
leg->AddEntry(OccupancyAll, "Preselected Events", "LP");
leg->AddEntry(OccupancyAll2, "Events Used For Calibration", "LP");
leg->Draw("same");
char latexBuffer[250];
sprintf(latexBuffer, "CMS 2012 Preliminary");
TLatex* latex = new TLatex(0.18, 0.92, latexBuffer);
latex -> SetNDC();
latex -> SetTextFont(62);
latex -> SetTextSize(0.035);
latex -> Draw("same");
sprintf(latexBuffer, "#sqrt{s} = 8 TeV L = 11.35 fb^{-1}");
TLatex* latex2 = new TLatex(0.6, 0.92, latexBuffer);
latex2 -> SetNDC();
latex2 -> SetTextFont(42);
latex2 -> SetTextSize(0.035);
latex2 -> Draw("same");
cAll -> Print(("EleOccupancy_W_" + category + ".C").c_str(), "cxx");
return 0;
}
示例3: Calibration
//.........这里部分代码省略.........
for (int i=0; i<numberoffiles; i++){
gROOT->Reset();
for (int k=0; k<numberofchambers; k++){
histo[i][k]= (TH1F*) files[i]->Get(energy[k]);
if (!histo[i][k]){std::cerr << "Could not get histogram " << energy[k] << "in file "
<< files[i]->GetName() << std::endl;}
std::cout << "=========================================================================" << std::endl;
std::cout << files[i]->GetName() << std::endl;
canname = filename[i] + histo[i][k]->GetName();
can[i][k] = new TCanvas(canname, canname,800,600);
can[i][k]->cd();
histo[i][k]->Draw();
TF1 *fit = 0;
double mpc = 0;
double minfit = 0.;
double maxfit = 0.05;
histo[i][k]->Fit("landau","R+","same",minfit,maxfit);
fit = (TF1*) histo[i][k]->GetFunction("landau");
mpc = fit->GetParameter(1) - mpshift * fit->GetParameter(2);
mpv.push_back(mpc);
mpvr.push_back(fit->GetParError(1));
chamr.push_back(0.);
thesigma.push_back(fit->GetParameter(2));
thesigmaerr.push_back(fit->GetParError(2));
// if(i==0) {mpvname = "grMPV_50GeV"; sigmaname = "grSigma_50GeV";}
// if(i==1) {mpvname = "grMPV_100GeV";sigmaname = "grSigma_100GeV";}
// if(i==2) {mpvname = "grMPV_150GeV";sigmaname = "grSigma_150GeV";}
// if(i==3) {mpvname = "grMPV_200GeV";sigmaname = "grSigma_200GeV";}
mpvname[i] = "grMPV_" + filename[i];
sigmaname[i] = "grSigma" + filename[i];
// std::cout << "Chamber " << k << " MPV "<< mpc << std::endl;
can[i][k]->Print(canname + ".root",".root");
can[i][k]->Close();
}// end of loop over histos
TGraphErrors *gr = new TGraphErrors(mpv.size(),&chamb[0],&mpv[0],&mpvr[0],&chamr[0]);
gr->SetMarkerStyle(20);
gr->SetMarkerSize(1.0);
// gr->GetYaxis()->SetRangeUser(0.,100.);
//gr->GetXaxis()->SetRangeUser(0.,300.);
gr->SetTitle(mpvname[i]);
gr->GetHistogram()->SetXTitle(" Chamber ");
gr->GetHistogram()->SetYTitle(" Landau MPV (MIPs) ");
gr->GetYaxis()->SetTitleOffset(1.6);
TCanvas *c1 = new TCanvas("c1","mpv",200,10,700,500);
gr->Draw("APL");
c1->Update();
c1->Print(mpvname[i]+".png",".png");
c1->Close();
mpv.clear();
mpvr.clear();
TGraphErrors *grs = new TGraphErrors(thesigma.size(),&chamb[0],&thesigma[0],&thesigmaerr[0],&chamr[0]);
grs->SetMarkerStyle(20);
grs->SetMarkerSize(1.0);
// grs->GetYaxis()->SetRangeUser(0.,100.);
//grs->GetXaxis()->SetRangeUser(0.,300.);
grs->SetTitle(sigmaname[i]);
grs->GetHistogram()->SetXTitle(" Chamber ");
grs->GetHistogram()->SetYTitle(" Sigma ");
grs->GetYaxis()->SetTitleOffset(1.6);
TCanvas *c2 = new TCanvas("c2","sigma",200,10,700,500);
grs->Draw("APL");
c2->Update();
c2->Print(sigmaname[i]+".png",".png");
c2->Close();
thesigma.clear();
thesigmaerr.clear();
chamr.clear();
gr->Delete();
c1->Close();
c1->Close();
}// end of loop over files
}
示例4: t1pfmetPhiwithCorr
//.........这里部分代码省略.........
/*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l");
leg->AddEntry(h2,"m_{#chi} = 10 GeV","l");
leg->AddEntry(h3,"m_{#chi} = 100 GeV","l");
leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/
// leg->AddEntry(h1,"m_{Z'} = 600 GeV","l");
leg->AddEntry(hbkg1,"#gamma #gamma","f");
// leg->AddEntry(h2,"m_{Z'} = 800 GeV","l");
leg->AddEntry(hbkg2,"Drell Yann","f");
// leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l");
leg->AddEntry(hbkg3,"#gamma + Jets","f");
// leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l");
leg->AddEntry(hbkg5,"QCD","f");
// leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples
leg->AddEntry(hbkg4,"ggH","f");
//leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples
leg->AddEntry(hbkg6,"VH","f");
// leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples
leg->AddEntry(hbkg7,"ttH","f");
leg->AddEntry(hbkg8,"VBF H","f");
leg->AddEntry(hbkg9,"t + #gamma + Jets","f");
leg->AddEntry(hbkg10,"tt + #gamma +Jets","f");
leg->AddEntry(hbkg11,"#gamma+W","f");
leg->AddEntry(hbkg12,"#gamma+Z","f");
leg->AddEntry(hsum,"Bkg uncertainty","f");
leg->Draw("same");
gStyle->SetOptStat(0);
canvas->cd();
smallPad->Draw();
smallPad->cd();
TGraphErrors *gr = new TGraphErrors(0);
double integralData=hdata->Integral();
double integralBKG=hsum->Integral();
double error, ratio;
for(int w=1; w<20; w++){
if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){
gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w)));
ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w));
error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w));
std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl;
gr->SetPointError(w, hdata->GetBinWidth(w)/2,error);
}else{
gr->SetPoint(w, hdata->GetBinCenter(w),10);
}
}
gStyle->SetPadTickY(1);
gStyle->SetPadTickX(1);
gr->GetHistogram()->SetMaximum(2);
gr->GetHistogram()->SetMinimum(0.1);
gStyle->SetTextSize(14);
gROOT->ForceStyle();
gr->GetXaxis()->SetLabelFont(43);
gr->GetXaxis()->SetLabelSize(15);
gr->GetYaxis()->SetLabelFont(43);
gr->GetYaxis()->SetLabelSize(15);
gr->GetXaxis()->SetLimits(-4,4);
gPad->SetGrid();
gStyle->SetStripDecimals(kTRUE);
gr->SetMarkerStyle(20);
gr->SetMarkerSize(0.7);
gr->Draw("AZP");
gr->GetXaxis()->SetTitle("#phi_{MET}^{corr}");
gr->GetXaxis()->SetTitleSize(0.1);
gr->GetYaxis()->SetTitleSize(0.1);
gr->GetYaxis()->SetNdivisions(505);
gr->GetXaxis()->SetTitleOffset(1);
gr->GetYaxis()->SetTitle("Data/MC");
gr->GetYaxis()->SetTitleOffset(0.4);
gr->SetTitle("");
smallPad->Update();
TF1* line = new TF1("line","1",-4,4);
line->SetLineColor(kRed);
line->SetLineWidth(2);
line->Draw("L same");
gr->Draw("ZP SAME");
canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/metphicorr_MET%.0lf.pdf",METmin));
canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/metphicorr_MET%.0lf.png",METmin));
}
示例5: HwwNoteFigs
//.........这里部分代码省略.........
histo1->SetXTitle(XTitle);
histo2->SetXTitle(XTitle);
histo3->SetXTitle(XTitle);
histo4->SetXTitle(XTitle);
histo1->SetTitleSize(0.05, "X");
histo1->GetXaxis()->SetTitleFont(62);
histo1->GetXaxis()->SetLabelFont(61);
histo1->GetYaxis()->SetLabelFont(61);
histo1->GetYaxis()->SetTitleOffset(1.3);
histo1->SetLabelSize(0.04, "Y");
histo1->SetLabelSize(0.04, "X");
int min = histoBg->FindBin(-1.5);
int max = histoBg->FindBin(1.5);
histoBg->GetXaxis()->SetRange(min,max);
histoBg->SetMarkerStyle(20);
histoBg->SetMarkerSize(1.0);
histoBg->GetYaxis()->SetTitleOffset(1.40);
histo0->SetMarkerStyle(21);
histo0->SetMarkerSize(1.0);
histoBg->Rebin(ReBin);
histo0->Rebin(ReBin);
histoBg->SetLineColor(4);
histo0->SetLineColor(1);
scaleHist(histoBg);
scaleHist(histo0);
cout << "bg events: " << histoBg->GetSumOfWeights() << endl;
cout << "si events: " << histo0->GetSumOfWeights() << endl;
histoBg->SetYTitle("Events");
histo1->SetMinimum(0.01);
if(ysel == 0) {
histo1->Draw("hist");
}
else {
histo0->Draw("E");
histo1->Draw("hist,same");
}
histo2->Draw("hist,same");
histo3->Draw("hist,same");
histo4->Draw("hist,same");
histo0->Draw("E, same");
//histoBg->DrawCopy("hist");
//histo0->DrawCopy("hist,same");
TLegend* leg = new TLegend(0.63, 0.75, 0.92, 0.92);
leg->SetFillColor(0);
char theSLine[100];
if(mass != 999) sprintf(theSLine,"Signal, m_{H}=%d GeV",mass);
else sprintf(theSLine,"WW");
cout << theSLine << endl;
leg ->AddEntry(histo0,theSLine);
leg ->AddEntry(histo4,"W+Jets, W#gamma","F");
leg ->AddEntry(histo3,"di-boson","F");
leg ->AddEntry(histo2,"t#bar{t}, tW","F");
leg ->AddEntry(histo1,"Drell-Yan","F");
leg->Draw("same");
TString fileOutput1(filename.Data());
TString theLine = "_";
theLine = theLine + "plot.eps";
fileOutput1.ReplaceAll(".root",theLine.Data());
fileOutput1.ReplaceAll("../","");
fileOutput1.ReplaceAll("rootfiles_fastsim/","");
fileOutput1.ReplaceAll("rootfiles_fullsim/","");
c1->SaveAs(fileOutput1.Data());
//return;
//--------------------------------
TCanvas* c3 = new TCanvas("c3","c3",550,-200,500,500);
c3->SetLogx();
c3->SetLogy();
gPad->SetGrid(1,1);
TGraphErrors* gBDTD = makeGraphFromHists(histo0, histoBg);
gBDTD->Draw("APXl");
TH1* zBDTD = gBDTD->GetHistogram();
zBDTD->SetXTitle("Signal Events");
zBDTD->SetYTitle("Signal/Background");
//zBDTD->SetYTitle("Background Events");
//zBDTD->DrawCopy();
TLegend* leg3 = new TLegend(0.7, 0.7, 0.9, 0.9);
leg3->SetFillColor(0);
leg3->AddEntry(gBDTD,theSLine,"lp");
leg3->Draw("same");
TString fileOutput2(filename.Data());
theLine = "_";
theLine = theLine + "counts.eps";
fileOutput2.ReplaceAll(".root",theLine.Data());
fileOutput2.ReplaceAll("../","");
fileOutput2.ReplaceAll("rootfiles_fastsim/","");
fileOutput2.ReplaceAll("rootfiles_fullsim/","");
c3->SaveAs(fileOutput2.Data());
}
示例6: phi2
//.........这里部分代码省略.........
leg->AddEntry(hbkg3,"#gamma + Jets","f");
leg->AddEntry(h2,"m_{Z'} = 800 GeV","l");
leg->AddEntry(hbkg5,"QCD","f");
leg->AddEntry(hbkg4,"ggH","f");
leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l");
leg->AddEntry(hbkg6,"VH","f");
leg->AddEntry(hbkg7,"ttH","f");
leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l");
leg->AddEntry(hbkg8,"VBF H","f");
leg->AddEntry(hbkg9,"t + #gamma + Jets","f");
leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l");
leg->AddEntry(hbkg10,"tt + #gamma +Jets","f");
leg->AddEntry(hbkg11,"#gamma+W","f");
leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l");
leg->AddEntry(hbkg12,"#gamma+Z","f");
leg->AddEntry(hsum,"Bkg uncertainty","f");
leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l");
leg->Draw("same");
c1->cd();
smallPad->Draw();
smallPad->cd();
TGraphErrors *gr = new TGraphErrors(0);
double integralData=hdata->Integral();
double integralBKG=hsum->Integral();
double error, ratio;
for(int w=1; w<20; w++){
if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){
gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w)));
ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w));
error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w));
std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl;
gr->SetPointError(w, hdata->GetBinWidth(w)/2,error);
}else{
gr->SetPoint(w, hdata->GetBinCenter(w),10);
}
}
gStyle->SetPadTickY(1);
gStyle->SetPadTickX(1);
gr->GetHistogram()->SetMaximum(2);
gr->GetHistogram()->SetMinimum(0.1);
gStyle->SetTextSize(14);
gROOT->ForceStyle();
gr->GetXaxis()->SetLabelFont(43);
gr->GetXaxis()->SetLabelSize(15);
gr->GetYaxis()->SetLabelFont(43);
gr->GetYaxis()->SetLabelSize(15);
gr->GetXaxis()->SetLimits(-4,4);
gPad->SetGrid();
gStyle->SetStripDecimals(kTRUE);
gr->SetMarkerStyle(20);
gr->SetMarkerSize(0.7);
gr->Draw("AZP");
gr->GetXaxis()->SetTitle("#phi_{2}");
gr->GetXaxis()->SetTitleSize(0.1);
gr->GetYaxis()->SetTitleSize(0.1);
gr->GetYaxis()->SetNdivisions(505);
gr->GetXaxis()->SetTitleOffset(1);
gr->GetYaxis()->SetTitle("Data/MC");
gr->GetYaxis()->SetTitleOffset(0.4);
gr->SetTitle("");
smallPad->Update();
TF1* line = new TF1("line","1",-4,4);
line->SetLineColor(kRed);
line->SetLineWidth(2);
line->Draw("L same");
gr->Draw("ZP SAME");
if(pt1min==0 && pt2min == 0 && METmin == 0){
c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/phi2.png");
c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/phi2.pdf");
}
if(pt1min==0.65 && pt2min == 0.25){
c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/phi2_optcuts_MET%.0lf.png",METmin));
c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/phi2_optcuts_MET%.0lf.pdf",METmin));
}
}
示例7: DeltaPhi
//.........这里部分代码省略.........
leg->AddEntry(hbkg12,"#gamma+Z","f");
leg->AddEntry(hsum,"Bkg uncertainty","f");
leg->Draw("same");
cout<<"check5"<<endl;
gStyle->SetOptStat(0);
c1->cd();
smallPad->Draw();
smallPad->cd();
TGraphErrors *gr = new TGraphErrors(0);
double integralData=hdata->Integral();
double integralBKG=hsum->Integral();
double error, ratio;
for(int w=1; w<15; w++){
if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){
gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w)));
ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w));
error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w));
std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl;
gr->SetPointError(w, hdata->GetBinWidth(w)/2,error);
}else{
gr->SetPoint(w, hdata->GetBinCenter(w),10);
}
}
gStyle->SetPadTickY(1);
gStyle->SetPadTickX(1);
gr->GetHistogram()->SetMaximum(2);
gr->GetHistogram()->SetMinimum(0.1);
gStyle->SetTextSize(14);
gROOT->ForceStyle();
gr->GetXaxis()->SetLabelFont(43);
gr->GetXaxis()->SetLabelSize(15);
gr->GetYaxis()->SetLabelFont(43);
gr->GetYaxis()->SetLabelSize(15);
gr->GetXaxis()->SetLimits(0,3.5);
gPad->SetGrid();
gStyle->SetStripDecimals(kTRUE);
gr->SetMarkerStyle(20);
gr->SetMarkerSize(0.7);
gr->Draw("AZP");
gr->GetXaxis()->SetTitle("|#Delta#phi(#gamma#gamma,E^{miss}_{T})|");
gr->GetXaxis()->SetTitleSize(0.1);
gr->GetYaxis()->SetTitleSize(0.1);
gr->GetYaxis()->SetNdivisions(505);
gr->GetXaxis()->SetTitleOffset(1);
gr->GetYaxis()->SetTitle("Data/MC");
gr->GetYaxis()->SetTitleOffset(0.4);
gr->SetTitle("");
smallPad->Update();
TF1* line = new TF1("line","1",0,3.5);
line->SetLineColor(kRed);
line->SetLineWidth(2);
line->Draw("L same");
示例8: fitwitherr2
void fitwitherr2() {
fetchpc3dphidz();
float pt[50];
float errx[50];
for (int ipt=0; ipt<50; ipt++) {
pt[ipt] = ipt*0.1 + 0.05;
errx[ipt] = 0.0;
}
gStyle->SetOptStat(kFALSE);
//gStyle->SetOptFit(1101);
ofstream fout("run16dAupc3matchingsmooth.h");
ofstream fout2("run16dAupc3matchingsmooth2.h");
for (int iarm=0; iarm<2; iarm++) {
for (int ich=0; ich<2; ich++) {
for(int ivz=0; ivz<10; ivz++){
string arm;
string ch;
if (iarm == 0) arm = "east";
else if (iarm == 1) arm = "west";
else arm = "err";
if (ich == 0) ch = "pos";
else if (ich == 1) ch = "neg";
else ch = "err";
string bbcz;
if (ivz==0) bbcz = "-10 to -8";
else if (ivz==1) bbcz = "-8 to -6";
else if (ivz==2) bbcz = "-6 to -4";
else if (ivz==3) bbcz = "-4 to -2";
else if (ivz==4) bbcz = "-2 to 0";
else if (ivz==5) bbcz = "0 to 2";
else if (ivz==6) bbcz = "2 to 4";
else if (ivz==7) bbcz = "4 to 6";
else if (ivz==8) bbcz = "6 to 8";
else if (ivz==9) bbcz = "8 to 10";
else bbcz = "err";
TCanvas *c1 = new TCanvas("c1","c1",500,500);
c1->SetGridx();
TGraphErrors* dphisigma = new TGraphErrors(50,pt,pc3dphisigma[iarm][ich][ivz],errx,pc3dphisigmaerr[iarm][ich][ivz]);
dphisigma->SetTitle(Form("dphisigma_%s_%s_%s",arm,ch,bbcz));
dphisigma->SetLineColor(1);
dphisigma->SetMarkerStyle(20);
dphisigma->SetMarkerSize(0.8);
dphisigma->GetXaxis()->SetRangeUser(0.2,5.0);
dphisigma->GetHistogram()->SetMaximum(0.01);
dphisigma->GetHistogram()->SetMinimum(-0.01);
dphisigma->GetXaxis()->SetTitle("p_{T}");
dphisigma->GetYaxis()->SetTitle("dphi sigma");
dphisigma->Draw("AP");
TPaveText *p1 = new TPaveText(0.2,0.8,0.9,0.9,"NDC");
p1->AddText("Fit function: a+bx+cx^{2}+dx^{3}+ex^{4}+fx^{5}+#frac{g}{#sqrt{x}}+#frac{h}{x^{2}}");
p1->Draw("same");
TF1 *fdphisigma = new TF1("fdphisigma","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.3,5.0);
//TF1 *fdphisigma2 = new TF1("fdphisigma2","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.2,5.0);
dphisigma->Fit("fdphisigma","Q0","",0.4,4.0);
//double sigma_par[8];
//fdphisigma->GetParameters(sigma_par);
//fdphisigma->SetParameters(sigma_par);
//dphisigma->Fit("fdphisigma2","Q0","",0.3,5.0);
fdphisigma->Draw("same");
fout << "fdphisigma->SetParameters(" << fdphisigma->GetParameter(0) << "," << fdphisigma->GetParameter(1) << "," << fdphisigma->GetParameter(2) << "," << fdphisigma->GetParameter(3) << "," << fdphisigma->GetParameter(4) << "," << fdphisigma->GetParameter(5) << "," << fdphisigma->GetParameter(6) << "," << fdphisigma->GetParameter(7) << ");" << endl;
for(int ipar=0;ipar<8;ipar++){
fout2 << "PC3_dphisigma[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdphisigma->GetParameter(ipar) << ";" << endl;
}
c1->Print(Form("smooth/dphisigma_%d_%d_%d.png",iarm,ich,ivz));
delete c1;
TCanvas *c3 = new TCanvas("c3","c3",500,500);
c3->SetGridx();
TGraphErrors* dphimean = new TGraphErrors(50,pt,pc3dphimean[iarm][ich][ivz],errx,pc3dphimeanerr[iarm][ich][ivz]);
dphimean->SetTitle(Form("dphimean_%s_%s_%s",arm,ch,bbcz));
dphimean->SetLineColor(1);
dphimean->SetMarkerStyle(20);
dphimean->SetMarkerSize(0.8);
dphimean->GetXaxis()->SetRangeUser(0.2,5.0);
dphimean->GetHistogram()->SetMaximum(0.01);
dphimean->GetHistogram()->SetMinimum(-0.01);
dphimean->GetXaxis()->SetTitle("p_{T}");
dphimean->GetYaxis()->SetTitle("dphi mean");
dphimean->Draw("AP");
TPaveText *p3 = new TPaveText(0.2,0.8,0.9,0.9,"NDC");
p3->AddText("Fit function: a+bx+#frac{c}{x}+#frac{d}{#sqrt{x}}+#frac{e}{x^{2}}+#frac{f}{x^{3}}+#frac{g}{x^{4}}");
p3->Draw("same");
TF1 *fdphimean = new TF1("fdphimean","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.3,5.0);
//TF1 *fdphimean2 = new TF1("fdphimean2","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.2,5.0);
dphimean->Fit("fdphimean","Q0","",0.4,4.0);
double mean_par[7];
//fdphimean->GetParameters(mean_par);
//.........这里部分代码省略.........
示例9: AbsorberStudy_RooFit
//.........这里部分代码省略.........
// RooFitResult* filters = gauss.fitTo(dh, NumCPU(4), Save(true), SumW2Error(kTRUE), PrintLevel(-1));
//RooFitResult* filters = landau.fitTo(dh, NumCPU(4), Range("fitRegion1"), Save(true), SumW2Error(kTRUE), PrintLevel(-1));
gauss.plotOn(frame,LineColor(4));//this will show fit overlay on canvas
gauss.paramOn(frame); //this will display the fit parameters on canvas
filters->Print();
// // Access list of final fit parameter values
// std::cout << "final value of floating parameters" << std::endl ;
// filters->floatParsFinal().Print("s") ;
//mpc = fit->GetParameter(1) - mpshift * fit->GetParameter(2);
mpc = mean.getVal();
maxv.push_back(mpc);
maxvr.push_back( (mean.getError()) );
eneerr.push_back(0.);
thesigma.push_back( (sigma.getVal()) );
thesigmaerr.push_back( (sigma.getError()) );
// std::cout << "File " << filename[i] << " Eneer " << k << " MAXV "<< mpc << std::endl;
// can[i][k]->Print(canname + ".root",".root");
// can[i][k]->Close();
// // Draw all frames on a canvas
// can[k] = new TCanvas(filename[i], filename[i],800,600);
// can[k]->cd();
// gPad->SetLeftMargin(0.15);
// frame->GetXaxis()->SetTitle("E (GeV)");
// frame->GetXaxis()->SetTitleOffset(1.2);
// frame->GetXaxis()->SetRangeUser(0.,0.05);
// // float binsize = histo[i][k]->GetBinWidth(1);
// // char Bsize[50];
// //sprintf(Bsize,"Events per %2.2f",binsize);
// frame->GetYaxis()->SetTitle("Events");
//frame->GetYaxis()->SetTitleOffset(1.2);
frame->Draw() ;
// can[k]->Print(filename[i]+".pdf",".pdf");
// can[k]->Print(histogramname[k]+".png",".png");
// can[k]->Close();
can[i][k]->Print(canname + ".root",".root");
//can[i][k]->Close();
} // end of loop over histos
//For the multi plot
} // end of loop over files
TFile f("maxvandsigma.root","recreate");
TGraphErrors *grMAXV = new TGraphErrors(maxv.size(),&ene[0],&maxv[0],&maxvr[0],&eneerr[0]);
TGraphErrors *grSigma = new TGraphErrors(thesigma.size(),&ene[0],&thesigma[0],&thesigmaerr[0],&eneerr[0]);
//======================================================================================
//For the maxv plot
TCanvas *c1 = new TCanvas("c1","maxv",200,10,1200,968);
grMAXV->SetMarkerStyle(20);
grMAXV->SetMarkerSize(1.2);
grMAXV->Draw("APL");
c1->Update();
grMAXV->SetTitle( " Maximum energy loss for different e^{-} energies in Fe absorber " );
grMAXV->GetHistogram()->SetXTitle(" Energy (GeV) ");
grMAXV->GetHistogram()->SetYTitle(" Maximum energy loss location (mm) ");
grMAXV->GetYaxis()->SetRangeUser(50.,150.);
c1->Update();
//c1->Print("maxv.png",".png");
c1->Write();
c1->Close();
//======================================================================================
//For the sigma plot
TCanvas *c2 = new TCanvas("c2","sigma",200,10,1200,968);
grSigma->SetMarkerStyle(20);
grSigma->SetMarkerSize(1.2);
grSigma->Draw("APL");
c2->Update();
grSigma->SetTitle( " Sigma Value for different e^{-} energies " );
grSigma->GetHistogram()->SetXTitle(" Energy (GeV) ");
grSigma->GetHistogram()->SetYTitle(" Sigma (mm) ");
//grSigma->GetYaxis()->SetRangeUser(0.20,0.40);
c2->Update();
//c2->Print("sigma.png",".png");
c2->Write();
c2->Close();
f.Close();
}
示例10: plot_rcp_for_energy
void plot_rcp_for_energy( string energy = "15", bool pannel = false ){
RooPlotLib rpl;
TH1 * master = new TH1D( "frame", "frame", 100, 0, 10 );
master->Draw();
if ( !pannel ){
gPad->SetLeftMargin( 0.15 );
gPad->SetBottomMargin( 0.15 );
gPad->SetRightMargin( 0.01 );
gPad->SetTopMargin( 0.01 );
}
gStyle->SetTitleFontSize(0.1);
vector<string> plcs = { "Ks0", "Lambda", "Xi" };
if ( "19" == energy || "27" == energy || "39" == energy )
plcs.push_back( "Omega" );
TLegend * leg = new TLegend( 0.2, 0.5, 0.65, 0.85 );
leg-> SetNColumns(2);
leg->SetTextFont( 52 );
leg->SetTextSize( 0.07 );
int index = 0;
for ( string plc : plcs){
TGraphErrors * g = plot_single_rcp( energy, plc );
rpl.style( g )
.set( "color", colors[ index ] )
.set( "markerstyle", markers[ index ] )
.set( "markersize", 2 );
rpl.style( g->GetHistogram() )
.set( "titlesize", 0.25 );
leg->AddEntry( g, legend_label(plc).c_str(), "pe" );
index ++;
}
rpl.style( master )
//.set( "title", energy + " GeV; p_{T} [GeV/c]; R_{CP} (0-5%) / (40-60%)" )
.set( "title", energy_label( energy ) + " GeV; p_{T} [GeV/c]" )
.set( "optstat", 0 )
.set( "yr", 0.2, 4.2 )
.set( "xr", 0.2, 5.2 )
.set( "xls", 0.08 )
.set( "yls", 0.08 )
.set( "yts", 0.08 )
.set( "xts", 0.08 );
TLine * lUnity = new TLine( 0.2, 1, 5.2, 1 );
rpl.style( lUnity )
.set( "color", kBlack )
.set( "linewidth", 4 )
.set( "linestyle", kDashed )
.set( "draw", "same" )
.draw();
if ( "39" == energy )
leg->Draw("same");
}
示例11: main
//.........这里部分代码省略.........
scale_vs_ieta->SetMarkerStyle(20);
scale_vs_ieta->SetMarkerSize(1);
scale_vs_ieta->SetMarkerColor(kBlue + 2);
/// Gaussian Fit of spread coefficient dstribution
TF1 *fgaus = new TF1("fgaus", "gaus", -1, 1);
int np = 0;
for (int i = 1; i < hcmap1-> GetNbinsY() + 1; i++) {
float etaring = hcmap1-> GetYaxis()->GetBinCenter(i);
if (etaring == 0.5) continue;
if ( hspread[i - 1]->GetEntries() == 0) {
sigma_vs_ieta-> SetPoint(np, etaring, -100);
np++;
continue;
}
hspread[i - 1]->Fit("fgaus", "Q");
sigma_vs_ieta-> SetPoint(np, etaring, fgaus->GetParameter(2));
sigma_vs_ieta-> SetPointError(np, 0, fgaus->GetParError(2));
rms_vs_ieta -> SetPoint(np, etaring, hspread[i - 1]->GetRMS());
rms_vs_ieta -> SetPointError(np, 0, hspread[i - 1]->GetRMSError() );
scale_vs_ieta-> SetPoint(np, etaring, fgaus->GetParameter(1));
scale_vs_ieta-> SetPointError(np, 0, fgaus->GetParError(1));
if( fabs(etaring) < 20 ) {
hringdiff->Fill( fgaus->GetParameter(1) );
}
np++;
}
/// Final Plot
TGraphErrors* gr_stat_prec = (TGraphErrors*) f4->Get("gr_stat_prec");
TCanvas *csigma = new TCanvas("csigma", "csigma");
csigma->SetGridx();
csigma->SetGridy();
sigma_vs_ieta->GetHistogram()->GetYaxis()-> SetRangeUser(0.00, 0.2);
sigma_vs_ieta->GetHistogram()->GetXaxis()-> SetRangeUser(-85, 85);
sigma_vs_ieta->GetHistogram()->GetYaxis()-> SetTitle("#sigma");
sigma_vs_ieta->GetHistogram()->GetXaxis()-> SetTitle("ieta");
sigma_vs_ieta->Draw("ap");
rms_vs_ieta->Draw("psame");
gr_stat_prec->Draw("psame");
/// Residual Plot (spread - statistical precision)
TGraphErrors* residual = new TGraphErrors();
for(int pp = 0; pp < gr_stat_prec->GetN(); pp++) {
double eta1, eta2, tot, stat;
gr_stat_prec->GetPoint(pp, eta1, stat);
sigma_vs_ieta->GetPoint(pp, eta2, tot);
if(eta1 != eta2) {
cout << "error different ring " << eta1 << " " << eta2 << endl;
}
double res = tot * tot - stat * stat;
if (res > 0) res = sqrt(res);
else res = -sqrt(fabs(res));
double errres = sqrt( pow(tot * sigma_vs_ieta->GetErrorY(pp), 2) + pow(stat * gr_stat_prec->GetErrorY(pp), 2)) / fabs(res);
residual->SetPoint(pp, eta1, res);
residual->SetPointError(pp, 0, errres);
}
/// Residual spread plot
TCanvas *cres = new TCanvas("cres", "cresidual");
cres->SetGridx();
cres->SetGridy();
residual->GetHistogram()->GetYaxis()-> SetRangeUser(-0.1, 0.1);
residual->GetHistogram()->GetXaxis()-> SetRangeUser(-85, 85);