本文整理汇总了C++中TF1::SetMarkerColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::SetMarkerColor方法的具体用法?C++ TF1::SetMarkerColor怎么用?C++ TF1::SetMarkerColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::SetMarkerColor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newBrezilianflagneventstGc
//.........这里部分代码省略.........
grafexp2sigma->SetPointError(0,0,0,sigma2down[0],sigma2up[0]);
grafexp2sigma->SetPoint(1,X[1],nE[1]);
grafexp2sigma->SetPointError(1,0,0,sigma2down[1],sigma2up[1]);
/*
grafexp2sigma->SetPoint(2,X[2],nE[2]);
grafexp2sigma->SetPointError(2,0,0,sigma2down[2],sigma2up[2]);
grafexp2sigma->SetPoint(3,X[3],nE[3]);
grafexp2sigma->SetPointError(3,0,0,sigma2down[3],sigma2up[3]);
grafexp2sigma->SetPoint(4,X[4],nE[4]);
grafexp2sigma->SetPointError(4,0,0,sigma2down[4],sigma2up[4]);
*/
grafexp2sigma->SetFillColor(kYellow);
grafexp2sigma->GetXaxis()->SetLabelFont(42);
// grafexp2sigma->SetLabel("");
grafexp2sigma->GetXaxis()->SetLabelOffset(0.007);
grafexp2sigma->GetXaxis()->SetLabelSize(0.034);
grafexp2sigma->GetXaxis()->SetTitleSize(0.045);
grafexp2sigma->GetXaxis()->SetTitleFont(22);
grafexp2sigma->GetXaxis()->SetTitleOffset(0.90);
grafexp2sigma->GetXaxis()->SetRangeUser(0, 0.2);
grafexp2sigma->GetYaxis()->SetRangeUser(0, 0.16);
grafexp2sigma->GetYaxis()->SetTitle("95% CL Limit on [#sigma_{tc#gamma} * Br(w #rightarrow l#nu)] (pb)");
grafexp2sigma->GetYaxis()->SetLabelFont(42);
grafexp2sigma->GetYaxis()->SetLabelOffset(0.007);
grafexp2sigma->GetYaxis()->SetLabelSize(0.034);
grafexp2sigma->GetYaxis()->SetTitleSize(0.045);
grafexp2sigma->GetYaxis()->SetTitleOffset(0.9);
grafexp2sigma->GetYaxis()->SetTitleFont(22);
grafexp2sigma->GetXaxis()->SetTitle("#kappa_{c}");
grafexp2sigma->SetTitle("");
// grafexp2sigma->SetMaximum(8);
TGraph *Expected= new TGraph(N,X,nE);
Expected->SetLineColor(4);
Expected->SetLineWidth(2);
Expected->SetMarkerColor(1);
Expected->SetMarkerStyle(20);
Expected->SetLineStyle(2);
Expected->GetYaxis()->SetTitle("Cross Section [pb]");
Expected->GetXaxis()->SetTitle("#Lambda_{T} [GeV]");
Expected->SetTitle("with ");
Expected->SetFillColor(10);
TGraph *Observed= new TGraph(N,X,nO);
Observed->SetLineColor(1);
Observed->SetLineWidth(2);
Observed->SetMarkerColor(1);
Observed->SetMarkerStyle(20);
// Observed->SetLineStyle(2);
Observed->GetYaxis()->SetTitle("Cross Section [pb]");
Observed->GetXaxis()->SetTitle("#Lambda_{T} [GeV]");
Observed->SetTitle("with ");
Observed->SetFillColor(10);
grafexp2sigma->Draw("AL3");
grafexp1sigma->Draw("L3same");
Expected->Draw("L");
Observed->Draw("L");
fa->SetLineColor(2);
fa->SetLineWidth(3);
fa->SetMarkerColor(1);
fa->Draw("same");
Observed->GetHistogram()->Draw("AXISSAMEY+");
Observed->GetHistogram()->Draw("AXISSAMEX+");
TLegend *leg1 = new TLegend(0.2, 0.6, 0.35, 0.8);
leg1->SetTextSize(0.03);
leg1->SetBorderSize(0);
leg1->SetLineColor(0);
leg1->SetLineWidth(0);
leg1->SetFillColor(kWhite);
leg1->AddEntry(fa, "Predicted", "L");
leg1->AddEntry(Observed, "95% CL Observed Limit", "L");
leg1->AddEntry(Expected, "95% CL Expected Limit", "L");
leg1->AddEntry(grafexp1sigma, "#pm1#sigma Exp.Limit", "F");
leg1->AddEntry(grafexp2sigma, "#pm2#sigma Exp.Limit", "F");
leg1->Draw();
TLine *line1 = new TLine(5, 1, 40, 1);
line1->SetLineColor(2);
line1->SetLineWidth(2);
// line1->Draw("same");
TPaveText *pt = new TPaveText(0.1,0.95,0.4,0.95, "NDC"); // NDC sets coords
pt->SetLineColor(10); // relative to pad dimensions
pt->SetFillColor(10); // text is black on white
pt->SetTextSize(0.045);
pt->SetTextAlign(12);
pt->AddText("CMS Preliminary, 19.1 fb^{-1}, #sqrt{s} = 8 TeV");
pt->SetShadowColor(10);
pt->Draw("same");
}
示例2: if
//---------------------------------------------------------------------------
//function to plot res vs. energy for pions (uses current dir, etc. settings)
//qty: 0 = response, 1 = resolution, 2 = sampling factor
TGraphErrors* g4_plot_res(int snum, int qty, bool do_pion, bool use_f_pion, bool do_fit, bool do_show, bool do_print=false){
Sample* sp = sample_map[snum];
if(!sp) { std::cout << "Sample " << snum << " is not loaded." << std::endl; return 0; }
//store values from get_res
Double_t* vals = new Double_t[maxHDe]; //sigma or mean
Double_t* xvals = new Double_t[maxHDe]; //sigma or mean
Double_t* y_errors = new Double_t[maxHDe]; //errors on pars
Double_t* logxvals = new Double_t[maxHDe]; //sigma or mean
//for storage of output info
energyRes* res_temp;
for (int i = 0; i < maxHDe; i++){
double energy = energies[i];
Double_t v, ve;
if(qty==2){
//get sampling factor for energy without setting value
std::pair<Double_t,Double_t> f_temp = g4_sample(snum,energy,do_pion,0);
v = f_temp.first;
ve = f_temp.second;
}
else {
res_temp = get_res(snum,energy,do_pion,use_f_pion,do_fit,0,0,1);
Double_t m, me, s, se;
if(do_fit){
TF1* fit = res_temp->getFit();
m = fit->GetParameter(1);
me = fit->GetParError(1);
s = fit->GetParameter(2);
se = fit->GetParError(2);
}
else{
m = res_temp->getStat(1);
me = res_temp->getStatErr(1);
s = res_temp->getStat(2);
se = res_temp->getStatErr(2);
}
if(qty==1){
v = s/m;
ve = v*sqrt(se*se/(s*s)+me*me/(m*m));
}
else if(qty==0){
v = m/energy;
ve = me/energy;
}
}
xvals[i] = energy;
logxvals[i] = log(energy);
vals[i] = v;
y_errors[i] = ve;
}
TCanvas* can;
TPaveText* pave;
TGraphErrors* val_graph;
TGraphErrors* fit_graph;
Int_t col, mrk;
col = kBlue; mrk = 21;
//graph values
std::string qtyaxes[] = {"Response (#mu/E_{true})","Resolution (#sigma/#mu)","sampling factor"};
if(do_pion) qtyaxes[0] = sp->name_rat + " #pi^{-} Response (R_{cal}/E_{gen})";
else qtyaxes[0] = sp->name_rat + " e^{-} Response (R_{cal}/E_{gen})";
fit_graph = new TGraphErrors(maxHDe,logxvals,vals,0,y_errors);
val_graph = new TGraphErrors(maxHDe,xvals,vals,0,y_errors);
val_graph->GetXaxis()->SetTitle("Energy [GeV]");
val_graph->GetYaxis()->SetTitle(qtyaxes[qty].c_str());
val_graph->SetTitle("");
val_graph->SetMarkerStyle(mrk);
val_graph->SetMarkerColor(col);
val_graph->SetMarkerSize(1.5);
val_graph->SetLineColor(col);
val_graph->SetFillColor(0);
//fit response for e/pi from pions
TF1* gfit = 0;
TF1* gline = 0;
double c, ce, k, ke;
std::stringstream epiname, ehname, kname;
if(qty==0 && do_pion){
gfit = new TF1("epi_fit","pol1",fit_graph->GetXaxis()->GetXmin(),fit_graph->GetXaxis()->GetXmax());
//gfit = new TF1("epi_fit","(1+([0]-1)*([1]*x))/[0]",val_graph->GetXaxis()->GetXmin(),val_graph->GetXaxis()->GetXmax());
//gfit = new TF1("epi","(1+([0]-1)*([1]*x^[2]))/[0]",val_graph->GetXaxis()->GetXmin(),val_graph->GetXaxis()->GetXmax());
gfit->SetParameter(0,0.9);
gfit->SetParameter(1,0.01);
//gfit->SetParameter(2,-2.8);
fit_graph->Fit(gfit,"NR");
//results
double a, ae, b, be;
//.........这里部分代码省略.........
示例3: computeDrellYanPtllWeight
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// root -l computeDrellYanPtllWeight.C+
// root -l -b -q computeDrellYanPtllWeight.C+
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void computeDrellYanPtllWeight(TString fname = "h_pt2l_mm")
{
gInterpreter->ExecuteMacro("PaperStyle.C");
TFile* file = TFile::Open("figures/Control/01_DY/" + fname + ".root");
TH1D* ratio = (TH1D*)file->Get("ratio");
// Draw the ratio
//----------------------------------------------------------------------------
TCanvas* c1 = new TCanvas("c1", "c1");
ratio->SetMinimum(0.85);
ratio->SetMaximum(1.20);
ratio->Draw("ep");
TString ytitle = Form("data / MC ratio / %.0f GeV", ratio->GetBinWidth(0));
SetAxis(ratio, ratio->GetXaxis()->GetTitle(), ytitle, 1.7, 1.8);
// Draw the old function
//----------------------------------------------------------------------------
TF1* fOld = new TF1("fOld", "[3]*(0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 90);
fOld->SetLineColor (kGreen+2);
fOld->SetMarkerColor(kGreen+2);
// https://github.com/latinos/PlotsConfigurations/blob/master/Configurations/ggH/nuisances_iteos.py#L969-L977
fOld->SetParameter(0, 0.1);
fOld->SetParameter(1, 14.0);
fOld->SetParameter(2, 8.8);
fOld->SetParameter(3, 1.08683);
fOld->Draw("same");
// Draw the old function error band
//------------------------------------------------------------------------------
if (errorband)
{
TF1* fOld_down = (TF1*)fOld->Clone("fOld_down");
TF1* fOld_up = (TF1*)fOld->Clone("fOld_up");
fOld_down->SetParameter(0, 13.6);
fOld_down->SetParameter(1, 8.6);
fOld_up->SetParameter(0, 14.4);
fOld_up->SetParameter(1, 9.0);
fOld_down->Draw("same");
fOld_up ->Draw("same");
}
// Update the fit parameters of the old function
//
// 1 p0 6.85257e-02 2.99341e-01 1.42129e-05 4.16760e-04
// 2 p1 1.24518e+01 4.76906e+01 3.55312e-03 6.41625e-07
// 3 p2 5.40627e+00 7.83907e+01 6.49546e-03 -1.96376e-06
// 4 p3 1.05396e+00 3.48880e-01 1.58779e-05 -3.97115e-05
//
//----------------------------------------------------------------------------
TF1* fNew = new TF1("fNew", "[3]*(0.95 - [0]*TMath::Erf((x-[1])/[2]))", 0, 90);
fNew->SetLineColor (kRed+1);
fNew->SetMarkerColor(kRed+1);
fNew->SetParameter(0, 0.1);
fNew->SetParameter(1, 10);
fNew->SetParameter(2, 1);
fNew->SetParameter(3, 1);
ratio->Fit(fNew, "mlr0");
fNew->Draw("same");
// Draw the updated error band
//------------------------------------------------------------------------------
if (errorband)
{
TF1* fNew_down = (TF1*)fNew->Clone("fNew_down");
TF1* fNew_up = (TF1*)fNew->Clone("fNew_up");
fNew_down->SetParameter(0, 0.97 * fNew->GetParameter(0));
fNew_down->SetParameter(1, 0.97 * fNew->GetParameter(1));
fNew_up->SetParameter(0, 1.03 * fNew->GetParameter(0));
fNew_up->SetParameter(1, 1.03 * fNew->GetParameter(1));
fNew_down->Draw("same");
//.........这里部分代码省略.........
示例4: get_res
//.........这里部分代码省略.........
stat_err[0] = 0;
stats[1] = m;
stat_err[1] = me;
stats[2] = s;
stat_err[2] = se;
//find peak
TSpectrum *spec = new TSpectrum(5);
if(nbins < 100) spec->Search(h_res,6,"nobackground nodraw goff"); //turn off background removal when nbins too small
else spec->Search(h_res,6,"nodraw goff");
Float_t* xpos = spec->GetPositionX();
Float_t* ypos = spec->GetPositionY();
Double_t p = xpos[0];
Double_t ph = ypos[0];
if(do_show) std::cout << "peak: " << p << std::endl;
//setup fitting function & do fit
if (do_fit){
gfit = new TF1("resp","gaus",0,h_res->GetXaxis()->GetXmax());
//if(do_jet){
// gfit->SetParameters(ph,p,s);
// if(m > p) gfit->SetRange(p-1.5*s,p+1.0*s); //high tail
// else gfit->SetRange(p-1.0*s,p+1.5*s); //low tail
//}
//else{
gfit->SetParameters((Double_t)N,m,s);
gfit->SetRange(m-2*s,m+1*s); //fit within 2 std devs
//if(m > p) gfit->SetRange(p-2*s,p+1*s); //high tail
//else gfit->SetRange(p-1*s,p+2*s); //low tail
//}
//formatting
gfit->SetLineColor(kRed);
gfit->SetMarkerColor(kRed);
gfit->SetLineWidth(2);
//fit
h_res->Fit(gfit,"LNQR");
}
//store parameters
theRes->setStats(stats,stat_err);
if(do_fit) theRes->setFit(gfit);
//store histo
h_res->SetDirectory(0);
theRes->setHist(h_res);
std::stringstream muname, signame, musigname, aLname, nLname, aRname, nRname, Nname, chiname;
muname.precision(2);
signame.precision(2);
musigname.precision(3);
aLname.precision(2);
nLname.precision(2);
aRname.precision(2);
nRname.precision(2);
chiname.precision(5);
if (do_fit) {
muname << fixed << "#mu = " << gfit->GetParameter(1) << " #pm " << gfit->GetParError(1);
signame << fixed << "#sigma = " << gfit->GetParameter(2) << " #pm " << gfit->GetParError(2);
musigname << fixed << "#sigma/#mu = " << gfit->GetParameter(2)/gfit->GetParameter(1) << " #pm " <<
gfit->GetParameter(2)/gfit->GetParameter(1) * sqrt( Power(gfit->GetParError(1),2)/Power(gfit->GetParameter(1),2) + Power(gfit->GetParError(2),2)/Power(gfit->GetParameter(2),2) );
//aLname << fixed << "a_{L} = " << gfit->GetParameter(3) << " #pm " << gfit->GetParError(3);
//nLname << fixed << "n_{L} = " << gfit->GetParameter(4) << " #pm " << gfit->GetParError(4);
//aRname << fixed << "a_{R} = " << gfit->GetParameter(5) << " #pm " << gfit->GetParError(5);
//nRname << fixed << "n_{R} = " << gfit->GetParameter(6) << " #pm " << gfit->GetParError(6);
chiname << fixed << "#chi^{2}/ndf = " << gfit->GetChisquare()/gfit->GetNDF();
}