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


C++ TGraphErrors::SetFillColorAlpha方法代码示例

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


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

示例1: raaExpOpen_pt

void raaExpOpen_pt(const char* inputDir = "../macro_raa/outRoot", // the place where the input root files, with the histograms are
                   bool bSavePlots      = true,
                   bool bDrawCh         = true,
                   double xMax          = 30 // x-axis range limit (ALICE D has x-range maximum value at 36, CMS has it at 30)
                  )
{
  // set the style
  gSystem->mkdir(Form("./figs/png"), kTRUE);
  gSystem->mkdir(Form("./figs/pdf"), kTRUE);
  setTDRStyle();
  
  // read CMS graphs
  TFile *pgRaaCms_pt   = new TFile(Form("%s/makeRaa_pt.root",inputDir));
  // ##################### HIGH PT ############################
  TGraphErrors *pgCms     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi");
  TGraphErrors *pgCmsP    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP");
  TGraphErrors *pgCmsSyst = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst");
  pgCmsSyst->SetFillColorAlpha(kOrange-9,0.5);
  pgCms->SetName("gNonPrJpsi");

  TBox *lumi = (TBox*)pgRaaCms_pt->Get("lumi");
  lumi->SetFillColor(kOrange-9);
  lumi->SetFillStyle(1001);
  lumi->SetX1(xMax-0.75); lumi->SetX2(xMax);
  TBox *lumi_lowpt = (TBox*)lumi->Clone("lumi_lowpt");
  lumi_lowpt->SetFillColor(kViolet-9);
  lumi_lowpt->SetFillStyle(1001);
  lumi_lowpt->SetX1(xMax-1.5); lumi_lowpt->SetX2(xMax-0.75);

  // ##################### LOW PT ############################
  TGraphErrors *pgCms_lowpt     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi_pt365y1624");
  TGraphErrors *pgCmsP_lowpt    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP_pt365y1624");
  TGraphErrors *pgCmsSyst_lowpt = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst_pt365y1624");
  pgCmsSyst_lowpt->SetFillColorAlpha(kViolet-9,0.5);
  pgCms_lowpt->SetName("gNonPrJpsi_pt365y1624");

  //-------------------------------------------------------------------- 
  // *********** CMS Charged particle RAA
  TGraphAsymmErrors *p8165_d5x1y1 = new TGraphAsymmErrors(p8165_d5x1y1_numpoints, p8165_d5x1y1_xval, p8165_d5x1y1_yval, p8165_d5x1y1_xerrminus, p8165_d5x1y1_xerrplus, p8165_d5x1y1_ystatminus, p8165_d5x1y1_ystatplus);
  TGraphAsymmErrors *p8165_d5x1y1_syst = new TGraphAsymmErrors(p8165_d5x1y1_numpoints, p8165_d5x1y1_xval, p8165_d5x1y1_yval, p8165_d5x1y1_xerrminus, p8165_d5x1y1_xerrplus, p8165_d5x1y1_yerrminus, p8165_d5x1y1_yerrplus);
  p8165_d5x1y1->SetName("cms_ch_raa");
  // X-axis errors will be discarded
  for (int i=0; i<p8165_d5x1y1_numpoints; i++) {
    p8165_d5x1y1->SetPointEXlow(i,0);
    p8165_d5x1y1->SetPointEXhigh(i,0);
    p8165_d5x1y1_syst->SetPointEXlow(i,0.5);
    p8165_d5x1y1_syst->SetPointEXhigh(i,0.5);
  }
   
  // *********** ALICE D RAA vs. pT
  TGraphAsymmErrors *p9059_d15x1y1 = new TGraphAsymmErrors(p9059_d15x1y1_numpoints, p9059_d15x1y1_xval, p9059_d15x1y1_yval, p9059_d15x1y1_xerrminus, p9059_d15x1y1_xerrplus, p9059_d15x1y1_yerrminus, p9059_d15x1y1_yerrplus);
  TGraphAsymmErrors *p9059_d15x1y1_syst = new TGraphAsymmErrors(p9059_d15x1y1_numpoints, p9059_d15x1y1_xval, p9059_d15x1y1_yval, p9059_d15x1y1_xerrminus, p9059_d15x1y1_xerrplus, p9059_d15x1y1_yerrminus, p9059_d15x1y1_yerrplus);
  p9059_d15x1y1->SetName("alice_d_raa");
  // X-axis errors will be discarded
  for (int i=0; i<p9059_d15x1y1_numpoints; i++) {
    p9059_d15x1y1->SetPointEXlow(i,0);
    p9059_d15x1y1->SetPointEXhigh(i,0);
    p9059_d15x1y1_syst->SetPointEXlow(i,0.5);
    p9059_d15x1y1_syst->SetPointEXhigh(i,0.5);
    if (xMax<=30 && (i+1)==p9059_d15x1y1_numpoints) {
      double x,y;
      p9059_d15x1y1->GetPoint(i,x,y);
      p9059_d15x1y1->SetPoint(i,x+5,y);
      p9059_d15x1y1_syst->GetPoint(i,x,y);
      p9059_d15x1y1_syst->SetPoint(i,x+5,y);
    }
  }

  // Style for graphs
  p9059_d15x1y1->SetMarkerStyle(kOpenSquare);
  p9059_d15x1y1->SetMarkerSize(1.3);
  p9059_d15x1y1->SetMarkerColor(kBlack);
  p9059_d15x1y1->SetLineColor(kBlack);
  p9059_d15x1y1_syst->SetFillColorAlpha(kGray+1,0.5);

  p8165_d5x1y1->SetMarkerStyle(20);
  p8165_d5x1y1->SetMarkerSize(1.3);
  p8165_d5x1y1->SetMarkerColor(kTeal+3);
  p8165_d5x1y1->SetLineColor(kTeal+4);
  p8165_d5x1y1_syst->SetFillColorAlpha(kTeal-1,0.5);



  //---------------------------------------------------------
  TLine *line = new TLine(0.,1,xMax,1);
  line->SetLineStyle(1);
  line->SetLineWidth(1);

  TCanvas *pc = new TCanvas("pc","pc");

  TF1 *f4 = new TF1("f4","1",0,xMax);
  f4->SetLineWidth(1);
  f4->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f4->GetYaxis()->SetTitle("R_{AA}");
  f4->GetXaxis()->SetRangeUser(0.0,xMax);
  f4->GetYaxis()->SetRangeUser(0.0,1.5);
  f4->GetXaxis()->CenterTitle(kTRUE);
 
  f4->Draw();
  lumi->Draw();
//.........这里部分代码省略.........
开发者ID:CMS-HIN-dilepton,项目名称:DimuonCADIs,代码行数:101,代码来源:raaExpOpen_pt.C

示例2: raaTheoryOpen_pt

void raaTheoryOpen_pt(const char* inputDir = "../macro_raa/outRoot", // the place where the input root files, with the histograms are
                     bool bSavePlots      = true,
                     bool bDoBRaa  = true
                     )
{
   // set the style
  gSystem->mkdir(Form("./figs/png"), kTRUE);
  gSystem->mkdir(Form("./figs/pdf"), kTRUE);
  setTDRStyle();
  
  // read CMS graphs
  TFile *pgRaaCms_pt   = new TFile(Form("%s/makeRaa_pt.root",inputDir));
  // ##################### HIGH PT ############################
  TGraphErrors *pgCms     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi");
  TGraphErrors *pgCmsP    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP");
  TGraphErrors *pgCmsSyst = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst");
  pgCmsSyst->SetFillColorAlpha(kOrange-9,0.5);
  pgCms->SetName("gNonPrJpsi");

  TBox *lumi = (TBox*)pgRaaCms_pt->Get("lumi");
  lumi->SetFillColor(kGray+1);
  lumi->SetFillStyle(1001);
  lumi->SetX1(28.5); lumi->SetX2(30);

  // ##################### LOW PT ############################
  TGraphErrors *pgCms_lowpt     = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsi_pt365y1624");
  TGraphErrors *pgCmsP_lowpt    = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiP_pt365y1624");
  TGraphErrors *pgCmsSyst_lowpt = (TGraphErrors *)pgRaaCms_pt->Get("gNonPrJpsiSyst_pt365y1624");
  pgCmsSyst_lowpt->SetFillColorAlpha(kViolet-9,0.5);
  pgCms_lowpt->SetName("gNonPrJpsi_pt365y1624");

   
  //-------------------------------------------------------------------- 
  // *********** Theory curves with filled area
  TGraph *pgRaaB_rapp       = new TGraph(2*raaB_rapp_vspt_numpoints);
  pgRaaB_rapp->SetName("pgRaaB_rapp");
  for (int i=0; i<raaB_rapp_vspt_numpoints; i++) {
    pgRaaB_rapp->SetPoint(i,raaB_rapp_pt[i],raaB_rapp_vspt_yhigh[i]);
    pgRaaB_rapp->SetPoint(raaB_rapp_vspt_numpoints+i,
        raaB_rapp_pt[raaB_rapp_vspt_numpoints-i-1],raaB_rapp_vspt_ylow[raaB_rapp_vspt_numpoints-i-1]);
  }

  TGraph *pgRaaB_whdg       = new TGraph(2*raaB_whdg_vspt_numpoints);
  pgRaaB_whdg->SetName("pgRaaB_whdg");
  for (int i=0; i<raaB_whdg_vspt_numpoints; i++) {
    pgRaaB_whdg->SetPoint(i,raaB_whdg_pt[i],raaB_whdg_vspt_yhigh[i]);
    pgRaaB_whdg->SetPoint(raaB_whdg_vspt_numpoints+i,
        raaB_whdg_pt[raaB_whdg_vspt_numpoints-i-1],raaB_whdg_vspt_ylow[raaB_whdg_vspt_numpoints-i-1]);
  }

  TGraph *pgRaaNPJpsi_vitev       = new TGraph(2*raaNPJpsi_vitev_vspt_numpoints);
  pgRaaNPJpsi_vitev->SetName("pgRaaNPJpsi_vitev");
  for (int i=0; i<raaNPJpsi_vitev_vspt_numpoints; i++) {
    pgRaaNPJpsi_vitev->SetPoint(i,raaNPJpsi_vitev_pt[i],raaNPJpsi_vitev_vspt_yhigh[i]);
    pgRaaNPJpsi_vitev->SetPoint(raaNPJpsi_vitev_vspt_numpoints+i,
        raaNPJpsi_vitev_pt[raaNPJpsi_vitev_vspt_numpoints-i-1],raaNPJpsi_vitev_vspt_ylow[raaNPJpsi_vitev_vspt_numpoints-i-1]);
  }

  TGraph *pgRaaNPJpsi_vitev_noDissoc = new TGraph(2*raaNPJpsi_vitev_vspt_noDissoc_numpoints);
  pgRaaNPJpsi_vitev_noDissoc->SetName("pgRaaNPJpsi_vitev_noDissoc");
  for (int i=0; i<raaNPJpsi_vitev_vspt_noDissoc_numpoints; i++) {
    pgRaaNPJpsi_vitev_noDissoc->SetPoint(i,raaNPJpsi_vitev_noDissoc_pt[i],raaNPJpsi_vitev_vspt_noDissoc_yhigh[i]);
    pgRaaNPJpsi_vitev_noDissoc->SetPoint(raaNPJpsi_vitev_vspt_noDissoc_numpoints+i,
        raaNPJpsi_vitev_noDissoc_pt[raaNPJpsi_vitev_vspt_noDissoc_numpoints-i-1],raaNPJpsi_vitev_vspt_noDissoc_ylow[raaNPJpsi_vitev_vspt_noDissoc_numpoints-i-1]);
  }

  // *********** Theory curves with line
  TGraph *pgRaaNPJpsi_mcatshq     = new TGraph(raaNPJpsi_mcatshq_vspt_numpoints,raaNPJpsi_mcatshq_pt,raaNPJpsi_mcatshq_vspt);
  pgRaaNPJpsi_mcatshq->SetName("pgRaaNPJpsi_mcatshq");
  TGraph *pgRaaNPJpsi_mcatshq_rad = new TGraph(raaNPJpsi_mcatshq_rad_vspt_numpoints,raaNPJpsi_mcatshq_rad_pt,raaNPJpsi_mcatshq_rad_vspt);
  pgRaaNPJpsi_mcatshq_rad->SetName("pgRaaNPJpsi_mcatshq_rad");
  TGraph *pgRaaNPJpsi_bamps       = new TGraph(raaNPJpsi_bamps_vspt_numpoints,raaNPJpsi_bamps_pt,raaNPJpsi_bamps_vspt_yval);
  pgRaaNPJpsi_bamps->SetName("pgRaaNPJpsi_bamps");

  // Style for filled graphs
  pgRaaB_rapp->SetFillColor(kRed-7);
  pgRaaB_rapp->SetFillStyle(1001);
  pgRaaB_whdg->SetFillColor(kOrange);
  pgRaaB_whdg->SetFillStyle(1001);

  pgRaaNPJpsi_vitev->SetFillColor(kAzure+1);
  pgRaaNPJpsi_vitev->SetFillStyle(1001);
  pgRaaNPJpsi_vitev_noDissoc->SetFillColor(kAzure-9);
  pgRaaNPJpsi_vitev_noDissoc->SetFillStyle(1001);

  // Style for line graphs
  pgRaaNPJpsi_mcatshq->SetLineColor(kTeal+4);
  pgRaaNPJpsi_mcatshq_rad->SetLineColor(kTeal+3);
  pgRaaNPJpsi_bamps->SetLineColor(kRed+1);
  
//  pgRaaNPJpsi_mcatshq->SetLineStyle(3);
//  pgRaaNPJpsi_mcatshq_rad->SetLineStyle(3);
//  pgRaaNPJpsi_bamps->SetLineStyle(3);
  
  pgRaaNPJpsi_mcatshq->SetLineWidth(4);
  pgRaaNPJpsi_mcatshq_rad->SetLineWidth(4);
  pgRaaNPJpsi_bamps->SetLineWidth(3);


  //---------------------------------------------------------
//.........这里部分代码省略.........
开发者ID:CMS-HIN-dilepton,项目名称:DimuonCADIs,代码行数:101,代码来源:raaTheoryOpen_pt.C

示例3: fitParamSet

void fitParamSet( string plc = "Pi", string charge = "n", int iPar = 0 ){

	gStyle->SetOptStat( 0 );
	gStyle->SetOptFit( 111 );

	XmlConfig cfg( "TpcEff.xml" );
	Logger::setGlobalLogLevel( "info" );
	vector<int> centralityBins = { 0, 1, 2, 3, 4, 5, 6 };
	vector<double> centrality = { 266.9, 218.8, 167.2, 114.3, 75.06, 36.99, 11.8 };
	vector<XmlFunction> fns;

	vector<double> x, y, ey;

	for ( int i : centralityBins ){
		INFO( "", fmt::format("{0}_{1}.TpcEffParams[{2}]", plc, charge, i) );
		XmlFunction fn( &cfg, fmt::format("{0}_{1}.TpcEffParams[{2}]", plc, charge, i) );
		fns.push_back( fn );
	}




	// Parameter A
	y.clear();
	x.clear();
	for ( int i : centralityBins ){
		y.push_back( fns[i].getTF1()->GetParameter( iPar ) );
		ey.push_back( fns[i].getTF1()->GetParError( iPar ) );
		x.push_back( centrality[ i ] );
	}
	TH1I* frame = new TH1I( "frame", (plc_label( plc, charge ) + " efficiency fit parameter " + ts( iPar ) ).c_str(), 100, 0, 300 );
	TGraphErrors * gA = new TGraphErrors( x.size(), x.data(), y.data(), 0, ey.data() );
	TF1 * fpol = new TF1( "fpol1", "pol1" );
	gA->Fit( fpol, "SE" );
	TFitResultPtr fitResult = gA->Fit( fpol, "SE" );

	double x1 = 0;
	double x2 = 300;

	TGraphErrors * band = FitConfidence::choleskyBands( fitResult, fpol, 500, 100, nullptr, x1, x2 );

	frame->Draw();
	vector<double> rangeMod = { 0.05, 0.05, 2 };
	frame->GetYaxis()->SetRangeUser( *std::min_element(y.begin(),y.end()) - rangeMod[ iPar ], *std::max_element(y.begin(),y.end()) + rangeMod[ iPar ] );
	
	gA->Draw( "same pe" );
	band->SetFillColorAlpha( kRed, 0.7 );
	band->Draw( "same e3" );
	gA->SetMarkerStyle( 8 );
	gA->SetMarkerSize( 2 );

	// gA->GetXaxis()->SetRangeUser( 0, 10 );
	// XmlFunction fn( &cfg, "Pi_n.TpcEffParams[0]" );

	
	// INFO( "", fn.getTF1()->GetParameter( 0 ) );
	

	// translate name to even format
	map<string, string> chargeMap = { { "p" , "c1" }, { "n" , "c0" } } ;
	map<string, string> plcMap = { { "Pi" , "p0" }, { "K" , "p1" }, { "P" , "p2" } };
	map<int, string> parMap = { { 0 , "a" }, { 1 , "b" }, { 2 , "c" } };


	gPad->Print( fmt::format( "efficiency_{0}_{1}_{2}.png", chargeMap[ charge ], plcMap[ plc ], parMap[ iPar ] ).c_str() );

}
开发者ID:jdbrice,项目名称:rcpMaker,代码行数:67,代码来源:fitParamSet.C


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