当前位置: 首页>>代码示例>>C++>>正文


C++ TLegend::DrawClone方法代码示例

本文整理汇总了C++中TLegend::DrawClone方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::DrawClone方法的具体用法?C++ TLegend::DrawClone怎么用?C++ TLegend::DrawClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TLegend的用法示例。


在下文中一共展示了TLegend::DrawClone方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fill_stack_eventcategories

void fill_stack_eventcategories(TString variable_name, TString data_name, std::vector<TString> signal_names, std::vector<TString> names){
    TString canvas_name=variable_name+"_stack_canvas";
    CreateCanvas(canvas_name,"",900,600);
    TString stack_name=variable_name+"_stack";
    CreateStack(stack_name,"");

    int Nbkg=names.size();
    
    vector<int> colors;
    colors.push_back(4);
    colors.push_back(9);
    colors.push_back(5);
    colors.push_back(419);
    
    colors.push_back(7);
    if(colors.size()<Nbkg) {
        cout << "please specify colors" << endl;
        return;
    }
    
    TLegend *L = new TLegend(0.6,0.57,0.89,0.89);
	L->SetFillColor(10);
	L->SetLineColor(10);
	L->SetLineWidth(0);
    
    for(int ibkg=0; ibkg<Nbkg; ibkg++){
        TString histName=variable_name+names.at(ibkg);
        hName[histName]->SetFillColor(colors.at(ibkg));
        stackName[stack_name]->Add(hName[histName]);
        L->AddEntry(hName[histName], names.at(ibkg));
    }
    
    
	TString eventspad_name="eventspad_"+variable_name;
	TString ratiopad_name="ratiopad_"+variable_name;
	
	TPad *events_pad = new TPad(eventspad_name,"Events",0.0,0.3,1,1);
	TPad *ratio_pad = new TPad(ratiopad_name,"Ratio",0,0.,1,0.3);
	
	events_pad->SetTopMargin(0.1);
	events_pad->SetBottomMargin(0.05);
	ratio_pad->SetTopMargin(0.05);
	ratio_pad->SetBottomMargin(0.3);
	
	CName[canvas_name]->cd();
	events_pad->Draw();
	ratio_pad->Draw();
	
	events_pad->cd();
    gPad->SetLogy();
    
    hName[variable_name+data_name]->GetYaxis()->SetTitleOffset(0.65);
    hName[variable_name+data_name]->GetYaxis()->SetTitleSize(0.08);
    hName[variable_name+data_name]->GetYaxis()->SetLabelSize(0.05);
    hName[variable_name+data_name]->GetXaxis()->SetLabelSize(0);
    hName[variable_name+data_name]->GetXaxis()->SetTitleSize(0);
    
    hName[variable_name+data_name]->SetMarkerSize(0.5);
    hName[variable_name+data_name]->SetMarkerStyle(20);
    hName[variable_name+data_name]->DrawCopy("E1");
    stackName[stack_name]->DrawClone("histo same");
    hName[variable_name+data_name]->DrawCopy("E1 same");// draw data on top of MC and MC on top of data, so that data will always be visible

    
    TLatex txt;
    txt.SetNDC(kTRUE);
    txt.DrawLatex(0.2,0.85,"S_{T} > 300 GeV");
    txt.DrawLatex(0.4,0.75,"S_{T} > 500 GeV");
    txt.DrawLatex(0.65,0.42,"S_{T} > 1000 GeV");

    
    for(int isig=0; isig<signal_names.size();isig++){
        TString sigName=variable_name+signal_names.at(isig);
        hName[sigName]->SetLineWidth(3);
        hName[sigName]->SetLineStyle(kDashed);
        hName[sigName]->SetLineColor(1+isig);
        L->AddEntry(hName[sigName], signal_names.at(isig));
        hName[sigName]->DrawCopy("hist same");
    }
    L->DrawClone("same");
    ratio_pad->cd();
    TString dataMC=variable_name+"_RatioDataMC";

    hName[dataMC]->GetYaxis()->SetTitleOffset(0.45);
	hName[dataMC]->GetYaxis()->SetTitleSize(0.15);
	hName[dataMC]->GetYaxis()->SetTitleOffset(0.45);
	hName[dataMC]->GetYaxis()->SetLabelSize(0.08);
	
	
	hName[dataMC]->GetXaxis()->SetTitleSize(0.15);
	hName[dataMC]->GetXaxis()->SetLabelSize(0.12);
	hName[dataMC]->GetXaxis()->SetTitleSize(0.15);
    
    hName[dataMC]->DrawCopy("E1");
    
}
开发者ID:btcarlso,项目名称:UserCode,代码行数:96,代码来源:stealth_plots.c

示例2: figure2_0_generator


//.........这里部分代码省略.........
 //   TCanvas* c1 = new TCanvas("c1","c1");
 //   TCanvas* c2 = new TCanvas("c2","c2");
	TCanvas* c3 = new TCanvas("c3","c3",1,1,1200,600);
	c3->Divide(2,1,0.01,0.01);

	gr_neg -> SetMarkerStyle(20);
	gr_neg -> SetMarkerColor(kBlue);
	gr_pos -> SetMarkerStyle(34);	
	gr_pos -> SetMarkerColor(kRed);




	TLatex* text_a = makeLatex("CMS PbPb #sqrt{s_{NN}}=5.02TeV",0.25,0.85) ;
	//TLatex* text_b = makeLatex("185 #leq N_{trk}^{offline} < 220",0.25,0.80) ;
	TLatex* text_b = makeLatex("30-40%",0.25,0.80) ;

	TLatex* text_c = makeLatex("0.8 < p_{T} < 0.85 GeV/c",0.25,0.75) ;
	TLatex* text_d = makeLatex("|#Delta#eta| > 2",0.25,0.70) ;

	text_a->SetTextFont(42);
	text_b->SetTextFont(42);
	text_c->SetTextFont(42);
	text_d->SetTextFont(42);



	TLegend* leg = new TLegend(0.76,0.80,0.94,.88);
	leg->SetLineColor(kWhite);
	leg->SetFillColor(0);
	leg->SetFillStyle(0);
	leg->AddEntry(gr_pos, "v_{2}^{#plus}{2}","p");
	leg->AddEntry(gr_neg , "v_{2}^{#minus}{2}","p");



	c3->cd(1);
	base->Draw("");
	gr_pos->Draw("PSame");
	gr_neg->Draw("PSame");
	text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	text_c->DrawClone("Same");
	text_d->DrawClone("Same");

	leg->DrawClone("Same");


    //Define a linear function
	TF1* fit1 = new TF1("f1", "[0]+x*[1]", -0.13, 0.13);

	fit1->SetLineColor(kRed);
	fit1->SetLineStyle(2);
	gr_diff->Fit(fit1,"RN0");
	fit1->Write();


	rebinned->Close();

	c3->cd(2);



	TLatex* text2 = makeLatex(Form("Intercept : %f #pm %f",fit1->GetParameter(0),fit1->GetParError(0)),0.45,0.30) ;
	TLatex* text1 = makeLatex(Form("slope : %.4f #pm %.4f",fit1->GetParameter(1),fit1->GetParError(1)),0.45,0.25) ;
	text1->SetTextFont(42);
	text2->SetTextFont(42);
	base2->Draw("");
	fit1->DrawClone("Same");
	gr_diff->SetMarkerStyle(20);
	gr_diff->Draw("PSame");

	text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	

	text1->DrawClone("Same");
	text2->DrawClone("Same");

	

	TF1 *fa1 = new TF1("fa1","0",-10,10); 
	fa1->SetLineColor(kBlack);
	fa1->SetLineWidth(0);
	fa1->DrawClone("Same");

	TLegend* leg2 = new TLegend(0.25,0.68,0.5,0.78);
	leg2->SetLineColor(kWhite);
	leg2->SetFillColor(0);
	leg2->SetFillStyle(0);
	leg2->AddEntry(fit1, "Linear fit","l");
	leg2->AddEntry(gr_diff , "data","p");
	leg2->DrawClone("Same");

	//SaveCanvas(c3,"pics",Form("30-40Narrowpt"));




}
开发者ID:SangeonPark,项目名称:Flow,代码行数:101,代码来源:figure2_0_generator.C

示例3: getAiZ


//.........这里部分代码省略.........
  }
  hPA0->SetLineWidth(3);
  hPA0->GetYaxis()->SetRangeUser(-1.,2.);
  hPA0->GetXaxis()->SetTitle("P_{T}(Z) [GeV]");
  hPA0->GetXaxis()->SetRangeUser(0,220);
  hPA0->GetYaxis()->SetTitle("A_{i}");
  hPA0->GetXaxis()->SetTitleSize(0.0625);
  hPA0->GetYaxis()->SetTitleSize(0.0625);
  hPA0->GetXaxis()->SetTitleOffset(1.00);
  hPA0->GetYaxis()->SetTitleOffset(1.20);
  hPA0->GetXaxis()->SetLabelSize(0.052);
  hPA0->GetYaxis()->SetLabelSize(0.052);
  hPA0->GetXaxis()->SetLabelOffset(0.01);
  hPA0->GetYaxis()->SetLabelOffset(0.01);
  hPA0->DrawCopy("hist");

  hPA1->Scale(5.0);
  hPA1->Divide(hPD);
  hPA1->SetLineColor(kRed);
  hPA1->SetLineWidth(3);
  //hPA1->DrawCopy("histsame");//we don't have sensitivity to A1 - sign of cos(theta_CS)

  hPA2->Scale(10.0);
  hPA2->Divide(hPD);
  hPA2->SetLineColor(kBlue);
  hPA2->SetLineWidth(3);
  hPA2->DrawCopy("histsame");

  hPA3->Scale(4.0);
  hPA3->Divide(hPD);
  hPA3->SetLineColor(kGreen);
  hPA3->SetLineWidth(3);
  hPA3->DrawCopy("histsame");

  hPA4->Scale(4.0);
  hPA4->Divide(hPD);
  hPA4->SetLineColor(kCyan);
  hPA4->SetLineWidth(3);
  //hPA4->DrawCopy("histsame");//we don't have sensitivity to A4 - sign of cos(theta_CS)

  TLatex *tplus = labelLatex(0.25,0.25,"Lepton Plus Charge");
  tplus->DrawClone("same");

  aLegend->DrawClone("same");  

  setPadMargins(aCanvas->cd(2));

  hMA0->Scale(20.0/3.0);
  hMA0->Divide(hMD);
  for(unsigned int i=0; i<hMA0->GetNbinsX(); i++) {
    hMA0->SetBinContent(i, (2.0/3.0) + hMA0->GetBinContent(i));
  }
  hMA0->SetLineWidth(3);
  hMA0->GetYaxis()->SetRangeUser(-1.,2.);
  hMA0->GetXaxis()->SetTitle("P_{T}(Z) [GeV]");
  hMA0->GetXaxis()->SetRangeUser(0,220);
  hMA0->GetYaxis()->SetTitle("A_{i}");
  hMA0->GetXaxis()->SetTitleSize(0.0625);
  hMA0->GetYaxis()->SetTitleSize(0.0625);
  hMA0->GetXaxis()->SetTitleOffset(1.00);
  hMA0->GetYaxis()->SetTitleOffset(1.20);
  hMA0->GetXaxis()->SetLabelSize(0.052);
  hMA0->GetYaxis()->SetLabelSize(0.052);
  hMA0->GetXaxis()->SetLabelOffset(0.01);
  hMA0->GetYaxis()->SetLabelOffset(0.01);
  hMA0->DrawCopy("hist");

  hMA1->Scale(5.0);
  hMA1->Divide(hMD);
  hMA1->SetLineColor(kRed);
  hMA1->SetLineWidth(3);
  //hMA1->DrawCopy("histsame");

  hMA2->Scale(10.0);
  hMA2->Divide(hMD);
  hMA2->SetLineColor(kBlue);
  hMA2->SetLineWidth(3);
  hMA2->DrawCopy("histsame");

  hMA3->Scale(4.0);
  hMA3->Divide(hMD);
  hMA3->SetLineColor(kGreen);
  hMA3->SetLineWidth(3);
  hMA3->DrawCopy("histsame");

  hMA4->Scale(4.0);
  hMA4->Divide(hMD);
  hMA4->SetLineColor(kCyan);
  hMA4->SetLineWidth(3);
  //hMA4->DrawCopy("histsame");

  TLatex *tminus = labelLatex(0.25,0.25,"Lepton Minus Charge");
  tminus->DrawClone("same");

  aLegend->DrawClone("same");  

  aCanvas->Print(".png");

  return;
}
开发者ID:bluejelibaby,项目名称:AnalysisV2,代码行数:101,代码来源:getAiZ.C

示例4: slopevscentrality


//.........这里部分代码省略.........
	double star_sysplus[] = { 3.152323796820371, 1.1348034014753392, 0.6881948851887814, 0.3091, 0.3775553601791398, 0.6362180836788593, 0.39244649316817704, 1.060086081410373, 4.931994052105091 };
	double xsysstar[] = {1,1,1,1,1,1,1,1,1};

	for(i=0;i<9;i++){
		star_sysminus[i]/=100;
		star_sysplus[i]/=100;
	}
	gStyle->SetLegendFont(42);

	TGraphErrors* slopevscent = new TGraphErrors(6,x_centrality,y_slope,NULL,statErr);
	TGraphErrors* ALICE = new TGraphErrors(8,x_alice,y_alice,NULL,alice_statErrors);
	TGraphErrors* STAR = new TGraphErrors(9,x_star,y_star,NULL,star_statErrors);
	TGraphAsymmErrors* ALICE_sys = new TGraphAsymmErrors(8, x_alice, y_alice, xsysalice, xsysalice, alice_sysminus, alice_sysplus);
	TGraphAsymmErrors* STAR_sys = new TGraphAsymmErrors(9, x_star, y_star, xsysstar, xsysstar, star_sysminus, star_sysplus);


	slopevscent -> SetMarkerStyle(20);
	slopevscent -> SetMarkerColor(kBlack);

	ALICE -> SetMarkerStyle(25);
	ALICE -> SetMarkerColor(kRed);
	ALICE -> SetLineColor(kRed);

	STAR -> SetMarkerStyle(kOpenStar);
	STAR -> SetMarkerColor(kBlue);
	STAR -> SetLineColor(kBlue);

	TH1D* base = new TH1D("base","base",1,0,100);
	base->GetYaxis()->SetRangeUser(0.00,0.06);
	base->GetXaxis()->SetTitle("Centrality(%)");
	base->GetYaxis()->SetTitle("Slope parameter(v_{2})");
	base->GetXaxis()->CenterTitle();
	base->GetYaxis()->CenterTitle();
	base->SetTitleSize  (0.040,"X");
	base->SetTitleOffset(1.4,"X");
	base->SetTitleFont  (42,"X");
	base->SetLabelOffset(0.006,"X");
	base->SetLabelSize  (0.040,"X");
	base->SetLabelFont  (42   ,"X");

	base->SetTitleSize  (0.040,"Y");
	base->SetTitleOffset(2.2,"Y");
	base->SetTitleFont  (42,"Y");
	base->SetLabelOffset(0.006,"Y");
	base->SetLabelSize  (0.040,"Y");
	base->SetLabelFont  (42   ,"Y");
	base->SetLineWidth(0);

	TCanvas* c3 = MakeCanvas("c3","c3");
	TLatex* text_a = makeLatex("CMS pPb #sqrt{s_{NN}}=5.02TeV",0.25,0.85) ;
	TLatex* text_b = makeLatex("185 #leq N_{trk}^{offline} < 260",0.25,0.80) ;
	TLatex* text_c = makeLatex("0.3 < p_{T} < 3 GeV/c",0.25,0.85) ;
	TLatex* text_d = makeLatex("|#Delta#eta| > 2",0.25,0.80) ;

	text_a->SetTextFont(42);
	text_b->SetTextFont(42);
	text_c->SetTextFont(42);
	text_d->SetTextFont(42);
	slopevscent->SetFillStyle(0);
	slopevscent->SetFillColor(0);
	slopevscent->SetFillStyle(0);
	slopevscent->SetFillColor(0);

	gStyle->SetOptTitle(0);


	TLegend* leg = new TLegend(.58,.70,.93,.90);
	leg->SetLineColor(kWhite);
	leg->SetFillColor(0);
	leg->SetFillStyle(0);
	leg->AddEntry(slopevscent, "CMS, Pb-Pb 5.02TeV","p");
	leg->AddEntry(ALICE, "ALICE, Pb-Pb 2.76TeV","p");
	leg->AddEntry(STAR, "STAR, Au-Au 200GeV","p");

	//leg->AddEntry(gr_neg, "neg","p");

	
	c3->cd();
	base->Draw("");
	ALICE->Draw("PSame");
	STAR->Draw("PSame");


	slopevscent->Draw("PSame");

//	STAR_sys->Draw("2Same");

	leg->DrawClone("PSame");
//	text_c->DrawClone("Same");
//	text_d->DrawClone("Same");

    //Define a linear function
	//SaveCanvas(c3,"pics","slopevscent_comparison");






}
开发者ID:SangeonPark,项目名称:Flow,代码行数:101,代码来源:slopevscentrality.C

示例5: makePlots


//.........这里部分代码省略.........
    ProbANu[k]->SetMarkerColor(42);
    ProbANu[k]->SetMarkerStyle(23);
    ProbANu[k]->SetMarkerSize(0.3);
    
    ProbANu[k]->SetFillColor(10);
    ProbANu[k]->SetMaximum(1.0);
    ProbANu[k]->SetMinimum(0.0);
    

  }
  
  leg->AddEntry( ProbNu[0], "#nu");
  leg->AddEntry( ProbANu[0], "#bar{#nu}");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.1);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(1001);


  c1->cd(1);
  gPad->SetGridx();
  gPad->SetGridy();
  gPad->SetLogx();

  if ( std::string(model).compare("EarthB") == 0 ) 
    ProbNu[0]->GetXaxis()->SetLimits(0.98e9, 1.0e10);

  ProbNu[0]->Draw("APL");
  ProbANu[0]->Draw("PL");
  topTitle(model);
  leg->DrawClone();
  
  c1->cd(2);
  gPad->SetGridx();
  gPad->SetGridy();
  gPad->SetLogx();
  
  if ( std::string(model).compare("EarthB") == 0 ) 
    ProbNu[1]->GetXaxis()->SetLimits(0.98e9, 1.0e10);
  
  ProbNu[1]->Draw("APL");
  ProbANu[1]->Draw("PL");
  leg->DrawClone();
    
  c1->cd(3);
  gPad->SetGridx();
  gPad->SetGridy();
  gPad->SetLogx();
  
  if ( std::string(model).compare("EarthB") == 0 ) 
    ProbNu[2]->GetXaxis()->SetLimits(0.98e9, 1.0e10);
  
  ProbNu[2]->Draw("APL");
  ProbANu[2]->Draw("PL");
  leg->DrawClone();

  c1->cd();

  std::stringstream saveAs;
    
  saveAs.str("");
  saveAs << path << model << "/pdf/" << "nueosc_probs_" << model << "_" << option << ".pdf";
  c1->SaveAs( saveAs.str().c_str() );
开发者ID:andres0sorio,项目名称:GRBsWork,代码行数:67,代码来源:make_plots_paper01_3xsingle_Psum.C

示例6: CumulantErrGraph_v2_allgraphs_cent


//.........这里部分代码省略.........

	gr_neg -> SetMarkerStyle(20);
	gr_neg -> SetMarkerColor(kBlue);
	gr_pos -> SetMarkerStyle(34);	
	gr_pos -> SetMarkerColor(kRed);




	TLatex* text_a = makeLatex("CMS PbPb #sqrt{s_{NN}}=5.02TeV",0.25,0.85) ;
	//TLatex* text_b = makeLatex("185 #leq N_{trk}^{offline} < 220",0.25,0.80) ;
	TLatex* text_b = makeLatex(Form("%d-%d centrality",mult_start[num],mult_end[num]),0.25,0.80) ;

	TLatex* text_c = makeLatex("0.3 < p_{T} < 3.0 GeV/c",0.25,0.75) ;
	TLatex* text_d = makeLatex("|#Delta#eta| > 1",0.25,0.70) ;

	text_a->SetTextFont(42);
	text_b->SetTextFont(42);
	text_c->SetTextFont(42);
	text_d->SetTextFont(42);



	TLegend* leg = new TLegend(0.76,0.80,0.94,.88);
	leg->SetLineColor(kWhite);
	leg->SetFillColor(0);
	leg->SetFillStyle(0);
	leg->AddEntry(gr_pos, "v_{2}^{#plus}{2}","p");
	leg->AddEntry(gr_neg , "v_{2}^{#minus}{2}","p");



	c3->cd(1);
	base->Draw("");
	gr_pos->Draw("PSame");
	gr_neg->Draw("PSame");
	text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	text_c->DrawClone("Same");
	text_d->DrawClone("Same");

	leg->DrawClone("Same");


    //Define a linear function
	TF1* fit1 = new TF1("f1", "[0]+x*[1]", -0.13, 0.13);

	fit1->SetLineColor(kRed);
	fit1->SetLineStyle(2);
	gr_diff->Fit(fit1,"RN0");
	fit1->Write();


	rebinned->Close();

	c3->cd(2);



	TLatex* text2 = makeLatex(Form("Intercept : %f #pm %f",fit1->GetParameter(0),fit1->GetParError(0)),0.45,0.30) ;
	TLatex* text1 = makeLatex(Form("slope : %.4f #pm %.4f",fit1->GetParameter(1),fit1->GetParError(1)),0.45,0.25) ;
	text1->SetTextFont(42);
	text2->SetTextFont(42);
	base2->Draw("");
	fit1->DrawClone("Same");
	gr_diff->SetMarkerStyle(20);
	gr_diff->Draw("PSame");

	text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	

	text1->DrawClone("Same");
	text2->DrawClone("Same");

	

	TF1 *fa1 = new TF1("fa1","0",-10,10); 
	fa1->SetLineColor(kBlack);
	fa1->SetLineWidth(0);
	fa1->DrawClone("Same");

	TLegend* leg2 = new TLegend(0.25,0.68,0.5,0.78);
	leg2->SetLineColor(kWhite);
	leg2->SetFillColor(0);
	leg2->SetFillStyle(0);
	leg2->AddEntry(fit1, "Linear fit","l");
	leg2->AddEntry(gr_diff , "data","p");
	leg2->DrawClone("Same");

	cout << mult_start[num] << endl;
	cout << mult_end[num] << endl;

	c3->Print(Form("~/Summer2016/pics/v2_cent_%d_%d.pdf",mult_start[num],mult_end[num]));
	c3->Print(Form("~/Summer2016/pics/v2_cent_%d_%d.gif",mult_start[num],mult_end[num]));




}
开发者ID:SangeonPark,项目名称:Flow,代码行数:101,代码来源:CumulantErrGraph_v2_allgraphs_cent.C

示例7: PlotWrite

void PlotWrite(TFile* input, TFile* output, TString output_folder, TString canvas, TString Hist_data, TString Hist_emu, TString XAxisLabel, TString YAxisLabel="Events", int rebin, int xAxisRange, TString Opt="")
{

  // Setup the canvas
  TCanvas *c1= new TCanvas(canvas,canvas,800,700);
  c1->SetLogy(1);

  // Get the histograms from the files
  if(Opt == "eta" || Opt == "phi")
  {
	if(Opt == "eta") {
	TH2F *Data2 = (TH2F*)input->Get(Hist_data);
	TH1D *Data = Data2->ProjectionX();
	if(rebin>0) Data->Rebin(rebin);
	if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange);

	TH2F *Emu2 = (TH2F*)input->Get(Hist_emu);
	TH1D *Emu = Emu2->ProjectionX();
	if(rebin>0) Emu->Rebin(rebin);
	if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange);
	}
	if(Opt == "phi") {
	TH2F *Data2 = (TH2F*)input->Get(Hist_data);	
	TH1D *Data = Data2->ProjectionY();
	if(rebin>0) Data->Rebin(rebin);
    if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange);

	TH2F *Emu2 = (TH2F*)input->Get(Hist_emu);
	TH1D *Emu = Emu2->ProjectionY();
	if(rebin>0) Emu->Rebin(rebin);
	if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange);
	}
  }
  else
  {
	TH1D *Data = (TH1D*)input->Get(Hist_data);
	if(rebin>0) Data->Rebin(rebin);
	if(xAxisRange>0) Data->GetXaxis()->SetRangeUser(0,xAxisRange);

	TH1D *Emu = (TH1D*)input->Get(Hist_emu);
	if(rebin>0) Emu->Rebin(rebin);
	if(xAxisRange>0) Emu->GetXaxis()->SetRangeUser(0,xAxisRange);
  }

  // Add the X axis label
  Emu->GetXaxis()->SetTitle(XAxisLabel);
  Emu->GetYaxis()->SetTitle(YAxisLabel);
  Emu->GetYaxis()->SetTitleSize(0.06);
  Emu->GetXaxis()->SetTitleSize(0.06);
  Emu->SetLineWidth(2);
  Emu->SetTitleOffset(1.10,"y");
  Emu->SetTitleOffset(0.80,"x");

  // Marker type for data
  Data->SetMarkerStyle(20);
  Data->SetMarkerColor(kRed);

  // plot them
  if (gPad->GetLogy()){
    Emu->SetMaximum(TMath::Max(Emu->GetMaximum(),Data->GetMaximum())*5);
  } else {
    Emu->SetMaximum(TMath::Max(Emu->GetMaximum(),Data->GetMaximum())*1.75);
  }
  Emu->DrawCopy("hist");
  Data->DrawCopy("psame");

  //make Legend
  TLegend * aLegend = new TLegend(0.646,0.768,0.746,0.868,NULL,"brNDC");
  aLegend->SetFillColor(0);
  aLegend->SetLineColor(0);
  aLegend->SetTextSize(0.05);
  aLegend->AddEntry(Emu,TString("Emulator"), "L");
  aLegend->AddEntry(Data,TString("Hardware"), "P");
  aLegend->DrawClone("same");
  gPad->RedrawAxis();

  //write canvas as png
  c1->Print(TString(output_folder+canvas+".png"));  

  //write canvas to output file
  output->cd();
  c1->Write();
  return;
}
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:84,代码来源:gctAnalyzerMergePlotter2.C

示例8: photon_JEC


//.........这里部分代码省略.........
            if( TMath::Abs(c->akPu3PF.jteta[jet2index]) > 1.3 )
                continue;
            Double_t dphi = TMath::ACos(TMath::Cos(c->photon.phi[leadingIndex] - c->akPu3PF.jtphi[jet2index]));
            if( dphi < 2.7 )
                continue;

            Double_t alpha = jet3pt/leadingPt;
            Double_t ratio = jet2pt/leadingPt;

            int ptbin = returnPtBin(leadingPt);
            if(ptbin != -1)
                Ratio[ii][ptbin]->Fill(alpha,ratio);

            alphas->Fill(alpha);
            hPhotonPt[ii]->Fill(leadingPt);
            hPhotonEta[ii]->Fill( c->photon.eta[leadingIndex] );
            hJet2Pt[ii]->Fill(jet2pt);
            hJet2Eta[ii]->Fill( c->akPu3PF.jteta[jet2index] );
            hJet3Pt[ii]->Fill(jet3pt);
            hJet3Eta[ii]->Fill( c->akPu3PF.jteta[jet3index] );
        }
    }

    TCanvas *canvas[nptbins];
    for(int i = 0; i < nptbins; i++)
    {
        TH1D *hRatiod = Ratio[0][i]->ProjectionX();
        TH1D *hRatiomc = Ratio[1][i]->ProjectionX();
        RdRmcalpha[i]->Divide(hRatiod,hRatiomc,1,1);

        canvas[i] = new TCanvas();
        RdRmcalpha[i]->Draw();
    }

    TCanvas *danvas = new TCanvas();
    alphas->Draw();
    danvas->SaveAs("alpha_counts.gif");


    hPhotonPt[0]->Scale( 1./hPhotonPt[0]->GetEntries() );
    hPhotonPt[1]->Scale( 1./hPhotonPt[1]->GetEntries() );
    TCanvas *d1 = new TCanvas();
    hPhotonPt[0]->Draw();
    hPhotonPt[1]->SetMarkerColor(kRed);
    hPhotonPt[1]->Draw("same");
    d1->SetLogy();
    TLegend *leg = new TLegend(0.75,0.75,0.9,0.9);
    leg->SetFillColor(0);
    leg->AddEntry(hPhotonPt[0], "Data","P");
    leg->AddEntry(hPhotonPt[1], "MC", "P");
    leg->DrawClone();
    d1->SaveAs("photon_pt.gif");

    hPhotonEta[0]->Scale( 1./hPhotonEta[0]->GetEntries() );
    hPhotonEta[1]->Scale( 1./hPhotonEta[1]->GetEntries() );
    TCanvas *d2 = new TCanvas();
    hPhotonEta[0]->Draw();
    hPhotonEta[1]->SetMarkerColor(kRed);
    hPhotonEta[1]->Draw("same");
    leg->DrawClone();
    d2->SaveAs("photon_eta.gif");

    hJet2Pt[0]->Scale( 1./hJet2Pt[0]->GetEntries() );
    hJet2Pt[1]->Scale( 1./hJet2Pt[1]->GetEntries() );
    TCanvas *d3 = new TCanvas();
    hJet2Pt[0]->Draw();
    hJet2Pt[1]->SetMarkerColor(kRed);
    hJet2Pt[1]->Draw("same");
    d3->SetLogy();
    leg->DrawClone();
    d3->SaveAs("jet2_pt.gif");

    hJet2Eta[0]->Scale( 1./hJet2Eta[0]->GetEntries() );
    hJet2Eta[1]->Scale( 1./hJet2Eta[1]->GetEntries() );
    TCanvas *d4 = new TCanvas();
    hJet2Eta[0]->Draw();
    hJet2Eta[1]->SetMarkerColor(kRed);
    hJet2Eta[1]->Draw("same");
    leg->DrawClone();
    d4->SaveAs("jet2_eta.gif");

    hJet3Pt[0]->Scale( 1./hJet3Pt[0]->GetEntries() );
    hJet3Pt[1]->Scale( 1./hJet3Pt[1]->GetEntries() );
    TCanvas *d5 = new TCanvas();
    hJet3Pt[0]->Draw();
    hJet3Pt[1]->SetMarkerColor(kRed);
    hJet3Pt[1]->Draw("same");
    d5->SetLogy();
    leg->DrawClone();
    d5->SaveAs("jet3_pt.gif");

    hJet3Eta[0]->Scale( 1./hJet3Eta[0]->GetEntries() );
    hJet3Eta[1]->Scale( 1./hJet3Eta[1]->GetEntries() );
    TCanvas *d6 = new TCanvas();
    hJet3Eta[0]->Draw();
    hJet3Eta[1]->SetMarkerColor(kRed);
    hJet3Eta[1]->Draw("same");
    leg->DrawClone();
    d6->SaveAs("jet3_eta.gif");
}
开发者ID:richard-cms,项目名称:UserCode,代码行数:101,代码来源:photon_JEC.C

示例9: figure2_0_generate


//.........这里部分代码省略.........
	

 //   TCanvas* c1 = new TCanvas("c1","c1");
 //   TCanvas* c2 = new TCanvas("c2","c2");
	TCanvas* c3 = new TCanvas("c3","c3",1,1,1200,600);
	c3->Divide(2,1,0.01,0.01);

	gr_neg -> SetMarkerStyle(20);
	gr_neg -> SetMarkerColor(kBlue);
	gr_pos -> SetMarkerStyle(34);	
	gr_pos -> SetMarkerColor(kRed);




	TLatex* text_a = makeLatex("CMS PbPb #sqrt{s_{NN}}=5.02TeV",0.25,0.85) ;
	//TLatex* text_b = makeLatex("185 #leq N_{trk}^{offline} < 220",0.25,0.80) ;
	TLatex* text_b = makeLatex("30-40%",0.25,0.80) ;

	TLatex* text_c = makeLatex("0.3 < p_{T} < 3.0 GeV/c",0.25,0.75) ;
	TLatex* text_d = makeLatex("|#Delta#eta| > 2",0.25,0.70) ;

	text_a->SetTextFont(42);
	text_b->SetTextFont(42);
	text_c->SetTextFont(42);
	text_d->SetTextFont(42);



	TLegend* leg = new TLegend(0.76,0.80,0.94,.88);
	leg->SetLineColor(kWhite);
	leg->SetFillColor(0);
	leg->SetFillStyle(0);
	leg->AddEntry(gr_pos, "v_{2}^{#plus}{2}","p");
	leg->AddEntry(gr_neg , "v_{2}^{#minus}{2}","p");



	c3->cd(1);
	base->Draw("");
	gr_pos->Draw("PSame");
	gr_neg->Draw("PSame");
	text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	text_c->DrawClone("Same");
	text_d->DrawClone("Same");

	leg->DrawClone("Same");


    //Define a linear function
	TF1* fit1 = new TF1("f1", "[0]+x*[1]", -0.13, 0.13);



	fit1->SetLineColor(kRed);
	fit1->SetLineStyle(2);
	gr_diff->Fit(fit1,"RN0");
fit1->Write();
rebinned->Close();

	c3->cd(2);



	TLatex* text2 = makeLatex(Form("Intercept : %f #pm %f",fit1->GetParameter(0),fit1->GetParError(0)),0.45,0.30) ;
	TLatex* text1 = makeLatex(Form("slope : %.4f #pm %.4f",fit1->GetParameter(1),fit1->GetParError(1)),0.45,0.25) ;
	text1->SetTextFont(42);
	text2->SetTextFont(42);
	base2->Draw("");
	fit1->DrawClone("Same");
	gr_diff->SetMarkerStyle(20);
	gr_diff->Draw("PSame");

	text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	

	text1->DrawClone("Same");
	text2->DrawClone("Same");

	

	TF1 *fa1 = new TF1("fa1","0",-10,10); 
	fa1->SetLineColor(kBlack);
	fa1->SetLineWidth(0);
	fa1->DrawClone("Same");

	TLegend* leg2 = new TLegend(0.25,0.68,0.5,0.78);
	leg2->SetLineColor(kWhite);
	leg2->SetFillColor(0);
	leg2->SetFillStyle(0);
	leg2->AddEntry(fit1, "Linear fit","l");
	leg2->AddEntry(gr_diff , "data","p");
	leg2->DrawClone("Same");

	//SaveCanvas(c3,"pics",Form("30-40SP"));


}
开发者ID:SangeonPark,项目名称:Flow,代码行数:101,代码来源:figure2_0_generate.C

示例10: compareWeights

void compareWeights(const char* fileName, const std::string plotTitle,
                    const std::string plotType, const std::string plot,
                    const std::string xlabel, const float xMin, const float xMax) {
    gStyle->SetOptStat(0);
    gROOT->ForceStyle();
 
    THStack* histStack = new THStack("histStack", plotTitle.c_str());
    TLegend* legend = new TLegend(.55 ,.55 ,.885 ,.875);
    legend->SetFillColor(kWhite);
     
    std::vector<std::string> weightNames = {"unit wgt = 0.000001"};
                                            //{"f_{T1} = 5e-12 ", "f_{T1} = 4e-12 ", 
                                            //"f_{T1} = 1.5e-12 ", "Standard Model"};
    std::vector<int> colors = {kRed-7, kAzure-3, kGreen-6, kBlack, kBlue-4};

    TFile signal_file(fileName);
    TCanvas* canvas = new TCanvas("canvas","Weight Comparison",150,10,990,660);
    canvas->cd();

    int numBins = 13;
    float rebinPoint = 0;
    double variableBins[numBins+1];
    for (int i = 0; i <= numBins; i++)
    {
        if (i < 10)
            rebinPoint += 75.;
        else if (i < 11)
            rebinPoint += 150.;
        else
            rebinPoint += 200;
        variableBins[i] = rebinPoint;
    }

    std::string bg_path = "/nfs_scratch/kdlong/wpz_zg_qcdbkgd/Events/run_01/";
    bg_path += fileName; 
    addBackground(histStack, bg_path, plotType, plot, legend, "WZ EWK + QCD",
                  variableBins, numBins);

    for (unsigned int i = 0; i < weightNames.size(); i++)
    {
        std::string path = weightNames[i] + "/" + plotType + "/" + plot;
        TH1F* hist = static_cast<TH1F*>(signal_file.GetObjectChecked(path.c_str(), 
                                                                     "TH1F"));
        //hist->SetFillColor(colors[i]);
        hist->SetLineColor(colors[i]);
        hist->SetLineWidth(2);
        TH1* histRebin = hist->Rebin(numBins, "histRebin", variableBins);
        histRebin->Sumw2();
        histStack->Add(histRebin, "hist E1");
        std::string legendName = "WZ EWK (" + weightNames[i] + ")";
        legend->AddEntry(hist, legendName.c_str(), "l");
    }
    
    histStack->Draw("nostack");
    histStack->GetXaxis()->SetTitle(xlabel.c_str());
    histStack->GetYaxis()->SetTitle("Events");
    //histStack->GetXaxis()->SetRangeUser(xMin, xMax); 
    //histStack->SetMaximum(125); 
    histStack->DrawClone("nostack");
    legend->DrawClone("same");
    canvas->Update();
    canvas->Print("WZTMassComp_zg_bg_cuts.pdf");
}
开发者ID:herndon,项目名称:VV_analysis,代码行数:63,代码来源:compareWeights.C

示例11: CumulantErrGraph_v2_normalized


//.........这里部分代码省略.........


 //   TCanvas* c1 = new TCanvas("c1","c1");
 //   TCanvas* c2 = new TCanvas("c2","c2");
	TCanvas* c3 = new TCanvas("c3","c3",1,1,1200,600);
	c3->Divide(2,1,0.01,0.01);

	gr_neg -> SetMarkerStyle(20);
	gr_neg -> SetMarkerColor(kBlue);
	gr_pos -> SetMarkerStyle(34);	
	gr_pos -> SetMarkerColor(kRed);




	TLatex* text_a = makeLatex("CMS PbPb #sqrt{s_{NN}}=5.02TeV",0.25,0.85) ;
	//TLatex* text_b = makeLatex("185 #leq N_{trk}^{offline} < 260",0.25,0.80) ;

	TLatex* text_c = makeLatex("0.3 < p_{T} < 3 GeV/c",0.25,0.75) ;
	TLatex* text_d = makeLatex("|#Delta#eta| > 2",0.25,0.70) ;

	text_a->SetTextFont(42);
	text_b->SetTextFont(42);
	text_c->SetTextFont(42);
	text_d->SetTextFont(42);



	TLegend* leg = new TLegend(0.76,0.80,0.94,.88);
	leg->SetLineColor(kWhite);
	leg->SetFillColor(0);
	leg->SetFillStyle(0);
	leg->AddEntry(gr_pos, "v_{3}^{#plus}{2}","p");
	leg->AddEntry(gr_neg , "v_{3}^{#minus}{2}","p");



	c3->cd(1);
	base->Draw("");
	gr_pos->Draw("PSame");
	gr_neg->Draw("PSame");
	//text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	//text_c->DrawClone("Same");
	//text_d->DrawClone("Same");

	leg->DrawClone("Same");


    //Define a linear function
	TF1* fit1 = new TF1("f1", "[0]+x*[1]", -0.2, 0.2);
	fit1->SetLineColor(kRed);
	fit1->SetLineStyle(2);
	gr_diff->Fit(fit1,"N0");
	fit1->Write();
	rebinned->Close();



	c3->cd(2);



	TLatex* text2 = makeLatex(Form("Intercept : %f #pm %f",fit1->GetParameter(0),fit1->GetParError(0)),0.45,0.30) ;
	TLatex* text1 = makeLatex(Form("slope : %.3f #pm %.3f",fit1->GetParameter(1),fit1->GetParError(1)),0.45,0.25) ;
	text1->SetTextFont(42);
	text2->SetTextFont(42);
	base2->Draw("");
	fit1->DrawClone("Same");
	gr_diff->SetMarkerStyle(20);
	gr_diff->Draw("PSame");

	//text_a->DrawClone("Same");
	text_b->DrawClone("Same");
	

	text1->DrawClone("Same");
	text2->DrawClone("Same");

	

	TF1 *fa1 = new TF1("fa1","0",-10,10); 
	fa1->SetLineColor(kBlack);
	fa1->SetLineWidth(0);
	fa1->DrawClone("Same");

	TLegend* leg2 = new TLegend(0.25,0.68,0.5,0.78);
	leg2->SetLineColor(kWhite);
	leg2->SetFillColor(0);
	leg2->SetFillStyle(0);
	leg2->AddEntry(fit1, "Linear fit","l");
	leg2->AddEntry(gr_diff , "data","p");
	leg2->DrawClone("Same");

	SaveCanvas(c3,"pics",Form("PbPb_crosscheck_v3_%d_%d",low,upp));




}
开发者ID:SangeonPark,项目名称:Flow,代码行数:101,代码来源:CumulantErrGraph_v2_normalized.C


注:本文中的TLegend::DrawClone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。