本文整理汇总了C++中TGraphErrors::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::Clone方法的具体用法?C++ TGraphErrors::Clone怎么用?C++ TGraphErrors::Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::Clone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGraph
TGraphErrors* GetGraph(std::string fname)
{
TGraphErrors* gr = NULL;
std::string fGrName = "mygraph";
TFile *f = new TFile(fname.data());
if (!f->IsOpen())
{
std::cerr << "Failed to open " << fname << std::endl;
return gr;
}
TObject *obj = 0;
while (gr==0 || fGrName.empty())
{
std::cout << "\n"; gDirectory->ls();
std::cout << "\nEnter selection : ";
std::getline(std::cin, fGrName);
gDirectory->GetObject(fGrName.data(), obj);
if (dynamic_cast<TDirectory*>(obj))
{
(dynamic_cast<TDirectory*>(obj))->cd();
}
else
{
gr = dynamic_cast<TGraphErrors*>(obj);
}
std::cout << "fGrName=" << fGrName << std::endl;
std::cout << "gr=" << std::hex << gr << std::dec << std::endl;
}
if (gr!=NULL)
{
TGraphErrors* tgr = (TGraphErrors*) gr->Clone("mygraph_0");
gr=tgr;
// gr->SetDirectory(0);
}
return gr;
}
示例2: plotResoVsIC
int plotResoVsIC(){
SetTdrStyle();
const unsigned nIC = 10;
const unsigned ICval[nIC] = {0,1,2,3,4,5,10,15,20,50};
std::ostringstream label;
TFile *fcalib[nIC];
TGraphErrors *constant = new TGraphErrors();
constant->SetName("constant");
constant->SetTitle(";intercalib. smearing");
constant->SetMarkerStyle(20);
constant->SetMarkerColor(1);
constant->SetLineColor(1);
TGraphErrors *constantSR7 = new TGraphErrors();
constantSR7->SetName("constantSR7");
constantSR7->SetTitle(";intercalib. smearing");
constantSR7->SetMarkerStyle(23);
constantSR7->SetMarkerColor(2);
constantSR7->SetLineColor(2);
TGraphErrors *noise = (TGraphErrors *) constant->Clone("noise");
TGraphErrors *sampling = (TGraphErrors *) constant->Clone("sampling");
TGraphErrors *samplingSR7 = (TGraphErrors *) constantSR7->Clone("samplingSR7");
TCanvas *mycReso = new TCanvas("mycReso","mycReso",1500,1000);
mycReso->Divide(2,5);
TCanvas *mycR = new TCanvas("mycR","Sampling",1500,1000);
TCanvas *mycC = new TCanvas("mycC","Constant",1500,1000);
TCanvas *mycN = new TCanvas("mycN","Noise",1500,1000);
gStyle->SetOptFit(1111);
gStyle->SetOptStat(0);
gStyle->SetStatW(0.2);
gStyle->SetStatH(0.5);
TLatex lat;
char buf[500];
TGraphErrors *gr[nIC][2];
double x0,y0;
double x0_7,y0_7;
for (unsigned ic(0);ic<nIC;++ic){//loop on intercalib
label.str("");
label << "PLOTS/CalibReso";
label << "_vsE";
label << "_IC" << ICval[ic];
label << ".root";
fcalib[ic] = TFile::Open(label.str().c_str());
if (!fcalib[ic]) {
std::cout << " -- failed to open file: " << label.str() << std::endl;
continue;
}
else {
std::cout << " -- file " << label.str() << " successfully opened." << std::endl;
}
fcalib[ic]->cd("SR2");
gr[ic][0] = (TGraphErrors *)gDirectory->Get("resoRecoFit2eta21pu1");
fcalib[ic]->cd("SR7");
gr[ic][1] = (TGraphErrors *)gDirectory->Get("resoRecoFit7eta21pu1");
TF1 *fit = gr[ic][0]->GetFunction("reso");
TF1 *fit7 = gr[ic][1]->GetFunction("reso");
mycReso->cd(ic+1);
gr[ic][0]->Draw("APE");
fit->SetLineColor(6);
fit->Draw("same");
lat.SetTextSize(0.1);
sprintf(buf,"Single #gamma, #eta=2.1, 3#times3 cm^{2}");
lat.DrawLatexNDC(0.2,0.8,buf);
sprintf(buf,"ICsmear = %d %%",ICval[ic]);
lat.DrawLatexNDC(0.2,0.7,buf);
double cval = sqrt(pow(fit->GetParameter(1),2)-pow(y0,2));
constant->SetPoint(ic,ICval[ic]/100.,cval);
constant->SetPointError(ic,0,fit->GetParameter(1)*fit->GetParError(1)/cval);
noise->SetPoint(ic,ICval[ic]/100.,fit->GetParameter(2));
noise->SetPointError(ic,0,fit->GetParError(2));
sampling->SetPoint(ic,ICval[ic]/100.,fit->GetParameter(0));
sampling->SetPointError(ic,0,fit->GetParError(0));
cval = sqrt(pow(fit7->GetParameter(1),2)-pow(y0_7,2));
constantSR7->SetPoint(ic,ICval[ic]/100.,cval);
constantSR7->SetPointError(ic,0,fit7->GetParameter(1)*fit7->GetParError(1)/cval);
//constantSR7->SetPoint(ic,ICval[ic]/100.,fit7->GetParameter(1));
//constantSR7->SetPointError(ic,0,fit7->GetParError(1));
samplingSR7->SetPoint(ic,ICval[ic]/100.,fit7->GetParameter(0));
samplingSR7->SetPointError(ic,0,fit7->GetParError(0));
if (ic==0) {
constant->GetPoint(0,x0,y0);
constantSR7->GetPoint(0,x0_7,y0_7);
cval = sqrt(pow(fit->GetParameter(1),2)-pow(y0,2));
constant->SetPoint(ic,ICval[ic]/100.,cval);
//.........这里部分代码省略.........
示例3: Drawmethodcomp
//.........这里部分代码省略.........
t.SetTextSize(0.03);
t.SetTextAlign(33);
for (int i=0;i<N;i++) {
double x = hist->GetXaxis()->GetBinCenter(i+1);
t.DrawText(x,y,label[i]);
}
TLegend *leg0 = new TLegend(0.18,0.70,0.50,0.85);
leg0->SetFillColor(10);
leg0->SetBorderSize(0);
leg0->SetTextFont(42);
leg0->SetTextSize(0.047);
leg0->AddEntry(graph,"From Ancestor fitting","p");
leg0->AddEntry(graph1,"From One Comp fitting","p");
// leg0->AddEntry(Gri055_graph,"Gribov #Omega=0.55","p");
// leg0->AddEntry(Gri101_graph,"Gribov #Omega=1.01","p");
if(str=="Npart") leg0->AddEntry(graphNpartDil,"Npart from run I","p");
if(str=="Ncoll") leg0->AddEntry(graphNcollDil,"Ncoll from run I","p");
leg0->Draw();
c1->SaveAs(Form("%sGri.png",str.Data()));
c1->SaveAs(Form("%sGri.pdf",str.Data()));
TCanvas *c2 = new TCanvas("c2","c2",1,1,550,460);
c2->SetFillColor(10);
c2->SetFrameFillColor(0);
c2->SetFrameBorderSize(0);
c2->SetFrameBorderMode(0);
c2->SetLeftMargin(0.15);
c2->SetBottomMargin(0.15);
c2->SetTopMargin(0.02);
c2->SetRightMargin(0.02);
c2->SetTicks(-1);
c2->cd();
TGraphErrors* fdvf1 = (TGraphErrors*)graph->Clone("fdvf1");
TGraphErrors* f1dvDil = (TGraphErrors*)graph->Clone("f1dvDil");
TGraphErrors* fdvDil = (TGraphErrors*)graph->Clone("fdvDil");
TGraphErrors* Dilsys = (TGraphErrors*)graph->Clone("Dilsys");
TGraphErrors* Dilsys2 = (TGraphErrors*)graph->Clone("Dilsys2");
for(int ip = 0;ip<fdvf1->GetN();ip++){
double x = graph->GetX()[ip];
double ey = graph->GetEY()[ip];
double y = graph->GetY()[ip];
double ey1 = graph1->GetEY()[ip];
double y1 = graph1->GetY()[ip];
double eyNcoll = graphNcollDil->GetEY()[ip];
double yNcoll = graphNcollDil->GetY()[ip];
double eyNpart = graphNpartDil->GetEY()[ip];
double yNpart = graphNpartDil->GetY()[ip];
if(y1!=0 && y!=0){
fdvf1->SetPoint(ip,x,y/y1);
fdvf1->SetPointError(ip,0,y/y1*sqrt((ey/y)**2+(ey1/y1)**2));
if(str=="Ncoll"){
fdvDil->SetPoint(ip,x,y/yNcoll);
double yerr = y/yNcoll*sqrt((ey/y)**2+(eyNcoll/yNcoll)**2);
fdvDil->SetPointError(ip,0,0);
f1dvDil->SetPoint(ip,x,y1/yNcoll);
double y1err = y1/yNcoll*sqrt((ey1/y1)**2+(eyNcoll/yNcoll)**2);
f1dvDil->SetPointError(ip,0,0);
Dilsys->SetPoint(ip,x,1.);
Dilsys->SetPointError(ip,0,TMath::Max(fabs(y1/yNcoll-1),fabs(y/yNcoll-1)));
Dilsys2->SetPoint(ip,x,1.);
Dilsys2->SetPointError(ip,0,TMath::Max(yerr,y1err));
}
else if(str=="Npart"){
fdvDil->SetPoint(ip,x,y/yNpart);
double yerr = y/yNpart*sqrt((ey/y)**2+(eyNcoll/yNpart)**2);
示例4: apt_all
void apt_all(){
//=========Macro generated from canvas: MyCanvas/My Canvas
//========= (Thu Dec 3 18:47:52 2009) by ROOT version5.25/04
gROOT->Reset();
gROOT->ProcessLine(".x rootlogon.C");
gStyle->SetTitleYOffset(1.5);
TCanvas *MyCanvas = new TCanvas("MyCanvas", "My Canvas",0,0,550,600);
MyCanvas->SetLogx();
double msize = 2;
TH1D *hDist = new TH1D("hDist","hDist",20,9,10000);
hDist->GetXaxis()->SetRange(1,20);
hDist->SetMinimum(0.3);
//hDist->SetMaximum(0.7);
hDist->SetMaximum(0.6);
hDist->SetLineStyle(0);
hDist->GetXaxis()->SetTitle("#sqrt{s} [GeV]");
hDist->GetYaxis()->SetTitle("#LTp_{T}#GT [GeV/c]");
hDist->GetXaxis()->CenterTitle();
hDist->GetYaxis()->CenterTitle();
hDist->GetYaxis()->SetNdivisions(510);
hDist->Draw("");
// Fit function
//TF1 *func = new TF1("func","0.426-0.0198*log(x^2)+0.00156*log(x^2)^2",18,100000);
//TF1 *func = new TF1("func","0.430-0.0207*log(x^2)+0.00161*log(x^2)^2",18,100000);
TF1 *func = new TF1("func","0.425-0.0197*log(x^2)+0.00156*log(x^2)^2",18,100000);
func->SetLineColor(1);
func->SetLineWidth(2.0);
func->Draw("same");
// ============================= ISR
// OK, from http://www.slac.stanford.edu/spires/find/hep/www?j=NUPHA,B84,269
TGraphErrors *gre = new TGraphErrors(4);
gre->SetName("Graph");
gre->SetTitle("Graph");
gre->SetMarkerStyle(28);
gre->SetMarkerSize(msize);
gre->SetPoint(0,23.32,0.362);// plab = 289
gre->SetPointError(0,0,0.004); // errors are not verified!
gre->SetPoint(1,30.59,0.364);// plab = 498
gre->SetPointError(1,0,0.00497238);
gre->SetPoint(2,44.61,0.366); // plab = 1060
gre->SetPointError(2,0,0.00478821);
gre->SetPoint(3,53.06,0.368); // plab = 1500
gre->SetPointError(3,0,0.00497238);
TH1F *Graph1 = new TH1F("Graph1","Graph",100,19.03788,56.0634);
Graph1->SetMinimum(0.3551011);
Graph1->SetMaximum(0.374549);
gre->SetHistogram(Graph1);
gre->Draw("pz");
TGraph* gre01 = gre->Clone("gre01");
gre01->SetMarkerStyle(0);
// gre01->Draw("pzsame");
// ============================= UA1
// OK, from http://dx.doi.org/10.1016/0550-3213(90)90493-W
gre = new TGraphErrors(7);
gre->SetName("Graph");
gre->SetTitle("Graph");
gre->SetMarkerStyle(3);
gre->SetMarkerSize(msize);
gre->SetPoint(0,200,0.392);
gre->SetPointError(0,0,0.003);
gre->SetPoint(1,260,0.404);
gre->SetPointError(1,0,0.004);
gre->SetPoint(2,380,0.408);
gre->SetPointError(2,0,0.004);
gre->SetPoint(3,500,0.419);
gre->SetPointError(3,0,0.004);
gre->SetPoint(4,620,0.426);
gre->SetPointError(4,0,0.004);
gre->SetPoint(5,790,0.435);
gre->SetPointError(5,0,0.004);
gre->SetPoint(6,900,0.447);
gre->SetPointError(6,0,0.003);
TH1F *Graph2 = new TH1F("Graph2","Graph",100,131.4964,972.7974);
Graph2->SetMinimum(0.3826521);
Graph2->SetMaximum(0.4560221);
gre->SetHistogram(Graph2);
gre->Draw("pz");
TGraph* gre02 = gre->Clone("gre02");
gre02->SetMarkerStyle(0);
//.........这里部分代码省略.........
示例5: fsr
void fsr(int ins = -1, double pt = 200., std::string sample = "dijet") {
setTDRStyle();
TDirectory *curdir = gDirectory;
const char *cs = sample.c_str();
map<string, const char *> title;
title["dijet"] = "Dijet";
title["gamjet"] = "#gamma+jet";
TFile *fp8 = new TFile("alphafracs_p8.root","READ");
assert(fp8 && !fp8->IsZombie());
TFile *fp6 = new TFile("alphafracs_p6.root","READ");
assert(fp6 && !fp6->IsZombie());
TFile *fhw = new TFile("alphafracs_hwpp.root","READ");
assert(fhw && !fhw->IsZombie());
curdir->cd();
TProfile *p8_10 = (TProfile*)fp8->Get("prof10"); assert(p8_10);
TProfile *p8_15 = (TProfile*)fp8->Get("prof15"); assert(p8_15);
TProfile *p8_20 = (TProfile*)fp8->Get("prof20"); assert(p8_20);
TProfile *p8_30 = (TProfile*)fp8->Get("prof30"); assert(p8_30);
TH1D *h8_0 = p8_10->ProjectionX("h8_10");
TProfile *p6_10 = (TProfile*)fp6->Get("prof10"); assert(p6_10);
TProfile *p6_15 = (TProfile*)fp6->Get("prof15"); assert(p6_15);
TProfile *p6_20 = (TProfile*)fp6->Get("prof20"); assert(p6_20);
TProfile *p6_30 = (TProfile*)fp6->Get("prof30"); assert(p6_30);
TH1D *h6_0 = p6_10->ProjectionX("h6_10");
TProfile *hw_10 = (TProfile*)fhw->Get("prof10"); assert(hw_10);
TProfile *hw_15 = (TProfile*)fhw->Get("prof15"); assert(hw_15);
TProfile *hw_20 = (TProfile*)fhw->Get("prof20"); assert(hw_20);
TProfile *hw_30 = (TProfile*)fhw->Get("prof30"); assert(hw_30);
TH1D *hw_0 = hw_10->ProjectionX("hw_10");
TH1D *dt_0 = (TH1D*)hw_0->Clone("dt_0");
TH1D *dt_10 = hw_10->ProjectionX("dt_10");
TH1D *dt_15 = hw_15->ProjectionX("dt_15");
TH1D *dt_20 = hw_20->ProjectionX("dt_20");
TH1D *dt_30 = hw_30->ProjectionX("dt_30");
const int ns = 3;//4;
const int np = 5;
TH1D* ps[ns][np] = {{h8_0, p8_10, p8_15, p8_20, p8_30},
{h6_0, p6_10, p6_15, p6_20, p6_30},
{hw_0, hw_10, hw_15, hw_20, hw_30}};//,
//{dt_0, dt_10, dt_15, dt_20, dt_30}};
double alpha[np] = {0, 0.10, 0.15, 0.20, 0.30};
int markers[ns][2] = {{kFullSquare, kFullCircle},
{kOpenSquare, kOpenCircle},
{kOpenDiamond, kOpenStar}};//,
//{kDot, kDot}};
int colors[np] = {kBlack, kRed, kOrange+2, kGreen+2, kBlue};
assert(ins>=-1 && ins<ns);
// Approximate data as 1:1 mixture of P6 and Herwig++
/*
double whw = 0.5;
for (int j = 0; j != np; ++j) {
for (int k = 1; k != hw_0->GetNbinsX()+1; ++k) {
ps[ns-1][j]->SetBinContent(k, (1-whw)*ps[1][j]->GetBinContent(k) +
whw*ps[2][j]->GetBinContent(k));
ps[ns-1][j]->SetBinError(k, (1-whw)*ps[1][j]->GetBinError(k) +
whw*ps[2][j]->GetBinError(k));
}
}
*/
TGraphErrors *gas[ns];
TGraphErrors *ga = new TGraphErrors(4);
TF1 *f1 = new TF1("f1","[0]+[1]*x",0,0.35);
for (int i = 0; i != ns; ++i) {
for (int k = 1; k != p8_10->GetNbinsX()+1; ++k) {
for (int j = 1; j != np; ++j) {
ga->SetPoint(j, alpha[j], ps[i][j]->GetBinContent(k));
ga->SetPointError(j, 0., ps[i][j]->GetBinError(k));
}
ga->Fit(f1, "QRN");
ps[i][0]->SetBinContent(k, f1->GetParameter(0));
ps[i][0]->SetBinError(k, f1->GetParError(0));
if (p8_10->FindBin(pt)==k) {
gas[i] = (TGraphErrors*)ga->Clone(Form("ga_%d",i));
}
}
}
TH1D *h = new TH1D("h",";p_{T,parton} (GeV);"
"#LTp_{T,gen} / p_{T,parton}#GT", 100, 0, 900);
h->SetMaximum(1.06);//1.03);
h->SetMinimum(0.91);//0.96);
TLatex *tex = new TLatex();
//.........这里部分代码省略.........
示例6: drawAvsB
//.........这里部分代码省略.........
TGraphErrors *gg2 = (TGraphErrors*)fg2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
assert(gg2);
gg = addGraph(gg,gg2);
}
TGraphErrors *gf = (TGraphErrors*)ff->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
assert(gf);
if (ff2) {
TGraphErrors *gf2 = (TGraphErrors*)ff2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs));
assert(gf2);
gf = addGraph(gf,gf2);
}
if (!(gf->GetN()==gg->GetN())) {
// Remove highest pT point is that is the offender (BCD vs GH)
if (gg->GetN()>gf->GetN() &&
fabs(gg->GetX()[gg->GetN()-1]/gf->GetX()[gf->GetN()-1]-1)>0.1 &&
fabs(gg->GetX()[gg->GetN()-2]/gf->GetX()[gf->GetN()-1]-1)<0.1) {
cout << "Remove point B(N-1)" << endl;
gg->RemovePoint(gg->GetN()-1);
}
else {
cout << "sample " << samples[is] << " method " << methods[im]
<< " gf->N: " << gf->GetN() << " gg->N: " << gg->GetN() << endl;
cout << " x_gf(N-1)=" << gf->GetX()[gf->GetN()-1]
<< " x_gg(N-1)=" << gg->GetX()[gg->GetN()-1]
<< " x_gg(N-2)=" << gg->GetX()[gg->GetN()-2] << endl;
}
assert(gf->GetN()==gg->GetN());
}
TGraphErrors *g = (TGraphErrors*)gg->Clone(Form("ge_%s_%s",cm,cs));
for (int i = 0; i != g->GetN(); ++i) {
double yg = gg->GetY()[i];
double yf = gf->GetY()[i];
g->SetPoint(i, gg->GetX()[i], yf / yg);
double ex = gg->GetEX()[i];
double eg = gg->GetEY()[i];
double ef = gf->GetEY()[i];
g->SetPointError(i, ex, yf/yg*sqrt(pow(eg/yg,2)+pow(ef/yf,2)));
}
//g->Draw(is==0 ? "AP" : "SAMEP");
g->SetLineWidth(1+is);
g->Draw("SAMEPZ");
if (samples[is]=="gamjet" && methods[im]=="mpfchs1" && nogjmpf) {
tex->SetTextColor(kBlue);
tex->DrawLatex(0.20,0.63,"#gamma+jet MPF excl. from fit");
tex->SetTextColor(kBlack);
}
else if (samples[is]=="gamjet" && methods[im]=="ptchs" && nogjptb) {
tex->SetTextColor(kBlue);
tex->DrawLatex(0.20,0.63,"#gamma+jet p_{T}^{bal} excl. from fit");
tex->SetTextColor(kBlack);
}
else if ((samples[is]=="zmmjet" || samples[is]=="zeejet") &&
methods[im]=="ptchs" && nozjptb) {
tex->SetTextColor(kRed);
tex->DrawLatex(0.20,0.63,"Z+jet p_{T}^{bal} excl. from fit");
tex->SetTextColor(kBlack);
}
else if (samples[is]=="multijet") {
g->SetMarkerColor(kGray+1);
g->SetLineColor(kGray+1);