本文整理汇总了C++中TGraphErrors::DrawClone方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::DrawClone方法的具体用法?C++ TGraphErrors::DrawClone怎么用?C++ TGraphErrors::DrawClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::DrawClone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TGraphErrors
/** @ingroup FMD_xsec_script
@param scale
@param filename
@param var
@param medName
@param thick
@param pdgName
*/
void
DrawXsection(Bool_t scale=kFALSE,
const char* filename="xsec.root",
const char* var="LOSS",
const char* medName="FMD_Si$",
Double_t thick=.03,
const char* pdgName="pi+")
{
TFile* file = TFile::Open(filename, "READ");
TTree* tree = static_cast<TTree*>(file->Get(Form("%s_%s",medName,
pdgName)));
TLeaf* tb = tree->GetLeaf("T");
TLeaf* vb = tree->GetLeaf(var);
if (!vb) {
std::cerr << "Leaf " << var << " not found" << std::endl;
return;
}
Float_t tkine, value;
tb->SetAddress(&tkine);
vb->SetAddress(&value);
Int_t n = tree->GetEntries();
Float_t xscale = 1;
Float_t yscale = 1;
if (scale) {
TDatabasePDG* pdgDb = TDatabasePDG::Instance();
TParticlePDG* pdgP = pdgDb->GetParticle(pdgName);
if (!pdgP) {
std::cerr << "Couldn't find particle " << pdgName << std::endl;
return;
}
Double_t m = pdgP->Mass();
Double_t q = pdgP->Charge() / 3;
if (m == 0 || q == 0) {
std::cerr << "Mass is 0" << std::endl;
return;
}
xscale = 1 / m;
yscale = 1 / (q * q);
}
TGraphErrors* graph = new TGraphErrors(n);
for (Int_t i = 0; i < n; i++) {
tree->GetEntry(i);
Double_t x = tkine*xscale;
Double_t y = value*yscale;
graph->SetPoint(i, x, y);
// 5 sigma
graph->SetPointError(i, 0, 5 * .1 * y);
}
TCanvas* c = new TCanvas("c","c");
c->SetLogx();
c->SetLogy();
graph->SetLineWidth(2);
graph->SetFillStyle(3001);
graph->SetFillColor(6);
graph->Draw("L");
graph->DrawClone("AL3");
c->Modified();
c->Update();
c->cd();
c->SaveAs("xsec.C");
}
示例2: softrad
//.........这里部分代码省略.........
if (!ga) {
ga = new TGraphErrors(0);
ga->SetMarkerStyle(g->GetMarkerStyle());
ga->SetMarkerColor(g->GetMarkerColor());
ga->SetLineColor(g->GetLineColor());
gamap[ct][cm][cs][ipt] = ga;
}
int n = ga->GetN();
ga->SetPoint(n, 0.01*a, g->GetY()[i]);
ga->SetPointError(n, 0, g->GetEY()[i]);
} // for i
} // for ialpha
} // for isample
} // for imethod
} // for itype
cout << "Drawing plots vs pT for each alpha" << endl << flush;
// 2x6 plots
for (int itype = 0; itype != ntypes; ++itype) {
for (int imethod = 0; imethod != nmethods; ++imethod) {
const char *ct = types[itype];
const char *cm = methods[imethod];
int ipad = ntypes*imethod + itype + 1; assert(ipad<=6);
c1->cd(ipad);
gPad->SetLogx();
h1->SetMaximum(itype<2 ? 1.15 : 1.08);
h1->SetMinimum(itype<2 ? 0.85 : 0.93);
h1->SetYTitle(Form("Response (%s)",ct));
h1->DrawClone("AXIS");
tex->DrawLatex(0.20,0.85,texlabel[cm]);
tex->DrawLatex(0.20,0.80,"|#eta| < 1.3, #alpha=0.1--0.3");
TLegend *leg = tdrLeg(0.60,0.75,0.90,0.90);
for (int isample = 0; isample != nsamples; ++isample) {
for (int ialpha = 0; ialpha != nalphas; ++ialpha) {
const char *cs = samples[isample];
const int a = alphas[ialpha];
TGraphErrors *g = gemap[ct][cm][cs][a]; assert(g);
// Clean out points with very large uncertainty for plot readability
for (int i = g->GetN()-1; i != -1; --i) {
if (g->GetEY()[i]>0.02) g->RemovePoint(i);
}
g->Draw("SAME Pz");
if (ialpha==0) leg->AddEntry(g,texlabel[cs],"P");
}
} // for isample
// Individual plots for JEC paper
if ( true ) { // paper
TH1D *h = new TH1D(Form("h_5%s_%s",ct,cm),
Form(";p_{T} (GeV);Response (%s)",ct),
1270,30,1300);
h->GetXaxis()->SetMoreLogLabels();
h->GetXaxis()->SetNoExponent();
h->SetMinimum(0.88);
h->SetMaximum(1.13);