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


C++ TAxis::SetTitleOffset方法代码示例

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


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

示例1: showHistogram2d

void showHistogram2d(TH2* histogram, 
		     const std::string& xAxisTitle, const std::string& yAxisTitle,
		     int zAxisNormOption, double zMin, double zMax, 
		     Float_t* genX, Float_t* genY, 
		     const std::string& outputFileName)
{
  TCanvas* canvas = new TCanvas("canvas", "canvas", 900, 800);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);

  canvas->SetTopMargin(0.10);
  canvas->SetLeftMargin(0.12);
  canvas->SetRightMargin(0.14);
  canvas->SetBottomMargin(0.12);

  histogram->SetTitle("");
  histogram->SetStats(false);
  int numBinsX = histogram->GetNbinsX();
  int numBinsY = histogram->GetNbinsY();
  if ( zAxisNormOption == kNormByQuantiles ) {
    std::vector<double> binContents;
    for ( int iBinX = 1; iBinX <= numBinsX; ++iBinX ) {
      for ( int iBinY = 1; iBinY <= numBinsY; ++iBinY ) {
	binContents.push_back(histogram->GetBinContent(iBinX, iBinY));
      }
    }
    std::sort(binContents.begin(), binContents.end());
    histogram->SetMinimum(binContents[TMath::Nint(0.05*binContents.size())]);
    histogram->SetMaximum(binContents[TMath::Nint(0.95*binContents.size())]);
  } else if ( zAxisNormOption == kNormByNegLogMax ) {
    double maxBinContent = 0.;
    for ( int iBinX = 1; iBinX <= numBinsX; ++iBinX ) {
      for ( int iBinY = 1; iBinY <= numBinsY; ++iBinY ) {
	double binContent = histogram->GetBinContent(iBinX, iBinY);
	if ( binContent > maxBinContent ) {
	  std::cout << "binX = " << iBinX << " (x = " << histogram->GetXaxis()->GetBinCenter(iBinX) << ")," 
		    << " binY = " << iBinY << " (y = " << histogram->GetYaxis()->GetBinCenter(iBinY) << "): maxBinContent = " << maxBinContent << std::endl;
	  maxBinContent = binContent;
	}
      }
    }
    double logMaxBinContent = TMath::Log(maxBinContent);
    for ( int iBinX = 1; iBinX <= numBinsX; ++iBinX ) {
      for ( int iBinY = 1; iBinY <= numBinsY; ++iBinY ) {
	double binContent = histogram->GetBinContent(iBinX, iBinY);
	if ( binContent > 0. ) {
	  histogram->SetBinContent(iBinX, iBinY, -TMath::Log(binContent) + logMaxBinContent);
	} else {
	  histogram->SetBinContent(iBinX, iBinY, -1.);
	}
      }
    }
    histogram->SetMinimum(0.);
    histogram->SetMaximum(zMax);
  } else if ( zAxisNormOption == kNormByValue ) {
    histogram->SetMinimum(zMin);
    histogram->SetMaximum(zMax);
  } else assert(0);

  TAxis* xAxis = histogram->GetXaxis();
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleOffset(1.15);

  TAxis* yAxis = histogram->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleOffset(1.30);

  gStyle->SetPalette(1,0);
  histogram->Draw("COLZ");

  TMarker* genMarker = 0;
  if ( genX && genY ) {
    genMarker = new TMarker(*genX, *genY, 34);
    genMarker->SetMarkerColor(1);
    genMarker->SetMarkerSize(2);
    genMarker->Draw();
  }

  canvas->Update();
  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName, 0, idx);
  if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
  canvas->Print(std::string(outputFileName_plot).append(".png").data());
  canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
  canvas->Print(std::string(outputFileName_plot).append(".root").data());

  delete genMarker;
  delete canvas;  
}
开发者ID:veelken,项目名称:SVfitDevelopment,代码行数:89,代码来源:plotMarkovChainMonitorTree.C

示例2: FitSignal


//.........这里部分代码省略.........
			printf("\n");
		}
		//matrix.Draw("text");

		float hm = h->GetMaximum();
		if(mode==0) {
			//TAxis* ax = h->GetXaxis();
			//ax->SetRangeUser(24.1,199.9);
			h->SetMaximum(1.2*hm);
			//h->SetMinimum(0.0);
		} else if(mode==1) {
			TAxis* ax = h->GetXaxis();
			ax->SetRangeUser(20.0,500.0);
			h->SetMaximum(1.15*hm);
			h->SetMinimum(0.0);
		}


		h->Draw();
		fits[ind]->SetLineColor(1);
		fits[ind]->SetLineWidth(2.0);
		fits[ind]->Draw("SAME");
		// find chi2's and KS's
		//AnaChiKs(h,fits[ind]);



		TAxis* ax,*ay;
		ax = h->GetXaxis(); 
		ay = h->GetYaxis();
		ax->SetTitle("m(#gamma#gamma) (GeV/c^{2})"); 
		ay->SetTitle("Entries/2 GeV/c^{2}");
		ax->CenterTitle(); ay->CenterTitle();
		ax->SetTitleOffset(0.9);
		ay->SetTitleOffset(1.0);
		ax->SetTitleSize(0.08);
		ay->SetTitleSize(0.07);
		ax->SetLabelSize(0.07);
		ay->SetLabelSize(0.07);

		gPad->SetLeftMargin(0.16);
		gPad->SetBottomMargin(0.16);

		TText* text;
		text = new TLatex(0.5,0.8,"Diphoton Data");
		text->SetNDC(true);
		text->SetTextSize(0.06);
		text->Draw();
		if(ind==0)      text = new TLatex(0.5,0.72,"Central-Central");
		else if(ind==1) text = new TLatex(0.5,0.72,"Central-Plug");
		text->SetNDC(true);
		text->SetTextSize(0.06);
		text->Draw();
		if(ind==0) {
			text = new TLatex(0.15,0.92,"W/Z H#rightarrow X(#gamma#gamma)");
			text->SetNDC(true);
			text->SetTextSize(0.08);
			text->Draw();

			text = new TLatex(0.5,0.92,"CDF Run II Preliminary, 2.0 fb^{-1}");
			text->SetNDC(true);
			text->SetTextSize(0.06);
			text->Draw();
		}    

		/*
开发者ID:hkaushalya,项目名称:CDFPhoJets,代码行数:67,代码来源:TPeaksHiggs.C

示例3: showFunctions1d

void showFunctions1d(std::vector<TF1*>& functions, const std::vector<std::string>& legendEntries,
		     const TString& xAxisTitle, double yMin, double yMax, const TString& yAxisTitle, 
		     const std::string& outputFileName)
{
  assert(functions.size() == legendEntries.size());

  TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  
  canvas->SetLeftMargin(0.12);
  canvas->SetBottomMargin(0.12);

  assert(functions.size() > 0);
  TF1* refFunction = functions[0];

  TH1* dummyHistogram = new TH1F("dummyHistogram", "dummyHistogram", 10, refFunction->GetXmin(), refFunction->GetXmax());
  dummyHistogram->SetStats(false);
  dummyHistogram->SetTitle("");
  dummyHistogram->SetMinimum(-TMath::Log(yMax));
  dummyHistogram->SetMaximum(-TMath::Log(yMax) + 5.);
  
  TAxis* xAxis = dummyHistogram->GetXaxis();
  xAxis->SetTitle(xAxisTitle.Data());
  xAxis->SetTitleOffset(1.15);

  TAxis* yAxis = dummyHistogram->GetYaxis();
  yAxis->SetTitle(Form("-log(%s)", yAxisTitle.Data()));
  yAxis->SetTitleOffset(1.30);

  dummyHistogram->Draw("axis");

  int colors[] = { 1, 2, 3, 4, 5, 6, 7, 15 };
  int numFunctions = functions.size();
  if ( numFunctions > 8 ) {
    std::cerr << "<showFunctions1d>:" << std::endl;
    std::cerr << "Number of functions must not exceed 8 !!" << std::endl;
    assert(0);
  }
  
  for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) {
    TF1* function = functions[iFunction];
    function->SetLineColor(colors[iFunction]);
    function->SetLineWidth(2);
    function->Draw("same");
  }

  TLegend* legend = new TLegend(0.68, 0.89 - (0.03 + 0.040*numFunctions), 0.89, 0.89, "", "brNDC"); 
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  legend->SetTextSize(0.035);
  for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) {
    TF1* function = functions[iFunction];
    const std::string& legendEntry = legendEntries[iFunction];
    legend->AddEntry(function, legendEntry.data(), "l");
  }
  legend->Draw();

  canvas->Update();
  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName, 0, idx);
  if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
  canvas->Print(std::string(outputFileName_plot).append(".png").data());
  canvas->Print(std::string(outputFileName_plot).append(".pdf").data());

  delete dummyHistogram;
  delete legend;
  delete canvas;
}
开发者ID:JehadMousa,项目名称:TauAnalysis-CandidateTools,代码行数:69,代码来源:toyMClikelihoods.C

示例4: ratio

/*
 * Main Function
 */
void ratio() {

  gStyle->SetFrameLineWidth(1); 
                                
  //Number of Measurements
  const int NUM = 2;
  
  //Measurements and uncertainties
  // mean, -stat, +stat, -syst, +syst  
  double m[NUM][5] = {
    0.98, 0.10, 0.10, 0.14, 0.14,
    //1.33, 0.32, 0.32, 0.22, 0.22
    1.26, 0.37, 0.37, 0.46, 0.46
  };
  
  //Theory and uncertainties
  // mean, -uncert, +uncert
  double t[NUM][3] = {
    1.0, 0.114, 0.114,
    1.0, 0.111, 0.111
  };

  // label text, sub-label text
  // Note: TString does not work, b/c one cannot pass an array of TStrings
  // as an argument to a function
  char label[NUM][2][100] = {
    "Z#gamma#gamma", "",
    //"W#gamma#gamma", ""
    "W#gamma#gamma (#mu)", ""
  };

  // format: 
  // # color, bgColor, fontSytle, linewidth, markerStyle 
  int aux[NUM][5] = {
    1,  10, 42, 2, 20,
    1,  10, 42, 2, 20
  };

  // determning the x size of the plot
  double lowX = LOW_X;
  double uppX = UPP_X;

  
  TH2F* lft = new TH2F("lft", "", 50, lowX, uppX, 1, 0.0, 1.0);

  // height = NUM*unitHeight + 2*spacers + 1*bottomMargin + 0.5*topMargin
  const double unitHeight = 50.0; // even number
  const double height = (double(NUM)+2.0)*unitHeight+100.0+30.0;
  // how much to step each time to cover the vertical range of the histo in
  // exactly NUM+2 steps
  const double vstep  = unitHeight/(height-100.0-30.0);
  const double width = 800.0;

  printf("Canvas: width=%d, height=%d\n",
	 TMath::Nint(width), TMath::Nint(height));
  printf("Y-step = %6.4f\n", vstep);

  
  // Set canvas and margins
  TCanvas* canvas = new TCanvas("canvas", "canvas", 200, 0,
				TMath::Nint(width), TMath::Nint(height));
  
  canvas->SetFillColor(10);
  canvas->SetRightMargin(20.0/width);
  canvas->SetLeftMargin(20.0/width);
  canvas->SetBottomMargin(56.0/height);
  canvas->SetTopMargin(30.0/height);
  canvas->Draw();
  canvas->cd();

  //printf("TopMargin   : %6.4f\n", canvas->GetTopMargin());
  //printf("BottomMargin: %6.4f\n", canvas->GetBottomMargin());

  TAxis* xaxis = lft->GetXaxis();
  TAxis* yaxis = lft->GetYaxis();
  xaxis->CenterTitle(kTRUE);  
  xaxis->SetTitleSize(0.07);  
  xaxis->SetTitleFont(62);    
  xaxis->SetTitleOffset(1.1); 
  xaxis->SetNdivisions(6,5,0);
    
  xaxis->SetLabelOffset(0.01);
  xaxis->SetLabelSize(0.05);
  xaxis->SetLabelFont(42);
  yaxis->SetLabelSize(0.0);
  yaxis->SetNdivisions(-1);

  lft->SetXTitle("Cross Section Ratio  #sigma_{Exp} / #sigma_{Theory}");
  lft->SetYTitle("");
  lft->SetStats(kFALSE);
  lft->SetTitle("");
  lft->Draw();

    
  // Draw Theory Bands
  for (int i=0; i!=NUM; ++i) {
    drawTheory(i, t[i][0], t[i][1], t[i][2], vstep);
//.........这里部分代码省略.........
开发者ID:cranelli,项目名称:WGamGam,代码行数:101,代码来源:ratio.C

示例5: drawFigure7

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// drawFigure7
//
//    parameter = "dg0"
//    parameter = "lam0"
//    parameter = "dk0"
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void drawFigure7(TString parameter = "dk0")
{
  gInterpreter->ExecuteMacro("WZPaperStyle.C");

  gSystem->mkdir("pdf", kTRUE);
  gSystem->mkdir("png", kTRUE);


  // Individual settings
  //----------------------------------------------------------------------------
  if (parameter.Contains("dg0"))
    {
      xtitle = "#Delta#kappa^{Z}";
      ytitle = "#lambda";
      xmin   = -0.5;
      xmax   =  0.5;
      ymin   = -0.039;
      ymax   =  0.053;
    }
  else if (parameter.Contains("lam0"))
    {
      xtitle = "#Delta#kappa^{Z}";
      ytitle = "#Deltag^{Z}_{1}";
      xmin   = -0.53;
      xmax   =  0.53;
      ymin   = -0.05;
      ymax   =  0.09;
    }
  else if (parameter.Contains("dk0"))
    {
      xtitle = "#Deltag^{Z}_{1}";
      ytitle = "#lambda";
      xmin   = -0.059;
      xmax   =  0.059;
      ymin   = -0.037;
      ymax   =  0.052;
    }


  // Read the input file
  //----------------------------------------------------------------------------
  TFile* file = new TFile("rootfiles/contours_" + parameter + "_2Dpol2.root", "read");

  TGraph* cont_exp_68 = (TGraph*)file->Get("cont_exp_68");
  TGraph* cont_exp_95 = (TGraph*)file->Get("cont_exp_95");
  TGraph* cont_exp_99 = (TGraph*)file->Get("cont_exp_99");
  TGraph* cont_obs_95 = (TGraph*)file->Get("cont_obs_95");
  TGraph* bestFit     = (TGraph*)file->Get("bestFit");

  bestFit->SetMarkerSize(1.5);
  bestFit->SetMarkerStyle(34);

  TGraph* g_large = new TGraph(2);

  g_large->SetPoint(0, -1.0, 1.0);
  g_large->SetPoint(1,  1.0, 1.0);


  // Draw
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas("canvas", "canvas");

  TMultiGraph* mg = new TMultiGraph();

  mg->Add(cont_exp_68);
  mg->Add(cont_exp_95);
  mg->Add(cont_exp_99);
  mg->Add(cont_obs_95);
  mg->Add(bestFit, "p");
  mg->Add(g_large);

  mg->Draw("ac");

  mg->SetMinimum(ymin);
  mg->SetMaximum(ymax);


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = mg->GetXaxis();
  TAxis* yaxis = mg->GetYaxis();
  
  xaxis->SetLabelFont  (    42);
  xaxis->SetLabelOffset(  0.01);
  xaxis->SetLabelSize  (  0.05);
  xaxis->SetNdivisions (   505);
  xaxis->SetTitle      (xtitle);
  xaxis->SetTitleFont  (    42);
  xaxis->SetTitleOffset(   1.2);
  xaxis->SetTitleSize  (  0.05);

//.........这里部分代码省略.........
开发者ID:piedraj,项目名称:usercode,代码行数:101,代码来源:drawFigure7.C

示例6: showGraphs

void showGraphs(double canvasSizeX, double canvasSizeY,
		TGraph* graph1, const std::string& legendEntry1,
		TGraph* graph2, const std::string& legendEntry2,
		TGraph* graph3, const std::string& legendEntry3,
		TGraph* graph4, const std::string& legendEntry4,
		TGraph* graph5, const std::string& legendEntry5,
		TGraph* graph6, const std::string& legendEntry6,
		int colors[], int markerStyles[], 
		double legendTextSize, double legendPosX, double legendPosY, double legendSizeX, double legendSizeY, 
		std::vector<std::string>& labelTextLines, double labelTextSize,
		double labelPosX, double labelPosY, double labelSizeX, double labelSizeY,
		double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset,
		double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
		const std::string& outputFileName)
{
  TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  
  canvas->SetLeftMargin(0.14);
  canvas->SetBottomMargin(0.12);

  TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 100, xMin, xMax);
  dummyHistogram->SetTitle("");
  dummyHistogram->SetStats(false);
  dummyHistogram->SetMinimum(yMin);
  dummyHistogram->SetMaximum(yMax);

  TAxis* xAxis = dummyHistogram->GetXaxis();
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleSize(0.045);
  xAxis->SetTitleOffset(xAxisOffset);

  TAxis* yAxis = dummyHistogram->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleSize(0.045);
  yAxis->SetTitleOffset(yAxisOffset);

  dummyHistogram->Draw("axis");

  graph1->SetLineColor(colors[0]);
  graph1->SetLineWidth(2);
  graph1->SetMarkerColor(colors[0]);
  graph1->SetMarkerStyle(markerStyles[0]);
  graph1->SetMarkerSize(2);
  graph1->Draw("p");

  if ( graph2 ) {
    graph2->SetLineColor(colors[1]);
    graph2->SetLineWidth(2);
    graph2->SetMarkerColor(colors[1]);
    graph2->SetMarkerStyle(markerStyles[1]);
    graph2->SetMarkerSize(2);
    graph2->Draw("p");
  }
  
  if ( graph3 ) {
    graph3->SetLineColor(colors[2]);
    graph3->SetLineWidth(2);
    graph3->SetMarkerColor(colors[2]);
    graph3->SetMarkerStyle(markerStyles[2]);
    graph3->SetMarkerSize(2);
    graph3->Draw("p");
  }

  if ( graph4 ) {
    graph4->SetLineColor(colors[3]);
    graph4->SetLineWidth(2);
    graph4->SetMarkerColor(colors[3]);
    graph4->SetMarkerStyle(markerStyles[3]);
    graph4->SetMarkerSize(2);
    graph4->Draw("p");
  }

  if ( graph5 ) {
    graph5->SetLineColor(colors[4]);
    graph5->SetLineWidth(2);
    graph5->SetMarkerColor(colors[4]);
    graph5->SetMarkerStyle(markerStyles[4]);
    graph5->SetMarkerSize(2);
    graph5->Draw("p");
  }

  if ( graph6 ) {
    graph6->SetLineColor(colors[5]);
    graph6->SetLineWidth(2);
    graph6->SetMarkerColor(colors[5]);
    graph6->SetMarkerStyle(markerStyles[5]);
    graph6->SetMarkerSize(2);
    graph6->Draw("p");
  }
  
  TLegend* legend = new TLegend(legendPosX, legendPosY, legendPosX + legendSizeX, legendPosY + legendSizeY, "", "brNDC"); 
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  legend->SetTextSize(legendTextSize);
  legend->AddEntry(graph1, legendEntry1.data(), "p");
  if ( graph2 ) legend->AddEntry(graph2, legendEntry2.data(), "p");
  if ( graph3 ) legend->AddEntry(graph3, legendEntry3.data(), "p");
  if ( graph4 ) legend->AddEntry(graph4, legendEntry4.data(), "p");
//.........这里部分代码省略.........
开发者ID:JehadMousa,项目名称:TauAnalysis-CandidateTools,代码行数:101,代码来源:makeSVfitPerformancePlots_WH.C

示例7: showDistribution

//-------------------------------------------------------------------------------
void showDistribution(const TString& title, double canvasSizeX, double canvasSizeY,
		      TH1* histogram1, const std::string& legendEntry1,
		      TH1* histogram2, const std::string& legendEntry2,
		      TH1* histogram3, const std::string& legendEntry3,
		      TH1* histogram4, const std::string& legendEntry4,
		      const std::string& xAxisTitle, double xAxisOffset,
		      bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
		      double legendX0, double legendY0, 
		      const std::string& outputFileName)
{
  TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  canvas->SetLeftMargin(0.12);
  canvas->SetBottomMargin(0.12);
  canvas->SetLogy(useLogScale);

  int colors[6] = { 1, 2, 3, 4, 6, 7 };
  int markerStyles[6] = { 22, 32, 20, 24, 21, 25 };

  int numHistograms = 1;
  if ( histogram2 ) ++numHistograms;
  if ( histogram3 ) ++numHistograms;
  if ( histogram4 ) ++numHistograms;

  TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.05*numHistograms, "", "brNDC"); 
  legend->SetBorderSize(0);
  legend->SetFillColor(0);

  histogram1->SetTitle("");
  histogram1->SetStats(false);
  histogram1->SetMinimum(yMin);
  histogram1->SetMaximum(yMax);
  histogram1->SetLineColor(colors[0]);
  histogram1->SetLineWidth(2);
  histogram1->SetMarkerColor(colors[0]);
  histogram1->SetMarkerStyle(markerStyles[0]);
  histogram1->Draw("e1p");
  legend->AddEntry(histogram1, legendEntry1.data(), "p");

  TAxis* xAxis = histogram1->GetXaxis();
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleOffset(xAxisOffset);

  TAxis* yAxis = histogram1->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleOffset(yAxisOffset);

  if ( histogram2 ) {
    histogram2->SetLineColor(colors[1]);
    histogram2->SetLineWidth(2);
    histogram2->SetMarkerColor(colors[1]);
    histogram2->SetMarkerStyle(markerStyles[1]);
    histogram2->Draw("e1psame");
    legend->AddEntry(histogram2, legendEntry2.data(), "p");
  }

  if ( histogram3 ) {
    histogram3->SetLineColor(colors[2]);
    histogram3->SetLineWidth(2);
    histogram3->SetMarkerColor(colors[2]);
    histogram3->SetMarkerStyle(markerStyles[2]);
    histogram3->Draw("e1psame");
    legend->AddEntry(histogram3, legendEntry3.data(), "p");
  }

  if ( histogram4 ) {
    histogram4->SetLineColor(colors[3]);
    histogram4->SetLineWidth(2);
    histogram4->SetMarkerColor(colors[3]);
    histogram4->SetMarkerStyle(markerStyles[3]);
    histogram4->Draw("e1psame");
    legend->AddEntry(histogram4, legendEntry4.data(), "p");
  }

  legend->Draw();

  TPaveText* label = 0;
  if ( title.Length() > 0 ) {
    label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC");
    label->AddText(title.Data());
    label->SetTextAlign(13);
    label->SetTextSize(0.045);
    label->SetFillStyle(0);
    label->SetBorderSize(0);
    label->Draw();
  }
  
  canvas->Update();
  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName, 0, idx);
  if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
  canvas->Print(std::string(outputFileName_plot).append(".png").data());
  canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
  
  delete legend;
  delete label;
  delete canvas;  
}
开发者ID:jpavel,项目名称:HighPtTau_539,代码行数:100,代码来源:plotTauIdMVAEfficiency_and_FakeRate.C

示例8: makeNeuralMtautauPerformancePlots

void makeNeuralMtautauPerformancePlots()
{
    std::string inputFileName = "../test/testNeuralMtautau.root";
    TFile* inputFile = TFile::Open(inputFileName.data());

    std::string histogramName = "histogramRecVsGenMass";
    TH2* histogram2d = dynamic_cast<TH2*>(getHistogram(inputFile, "", histogramName.data()));

    const int numGenMassBins = 17;
    double genMassBins[] = { 0., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 160., 200., 250., 300., 350., 400., 500. };
    int genMassBin_index = 0;

    TH1* histogram1dTruncatedSum = 0;

    TGraphErrors* graph_mean = new TGraphErrors(numGenMassBins);
    TGraphErrors* graph_rms  = new TGraphErrors(numGenMassBins);

    int numBins2dX = histogram2d->GetNbinsX();
    for ( int iBin2dX = 1; iBin2dX <= numBins2dX; ++iBin2dX ) {
        std::string histogram1dName = std::string(histogram2d->GetName()).append(Form("BinX%i", iBin2dX));
        TH1* histogram1d = histogram2d->ProjectionX(histogram1dName.data(), iBin2dX, iBin2dX);

        std::string histogram1dTruncatedName = std::string(histogram2d->GetName()).append(Form("BinX%i_truncated", iBin2dX));
        TH1* histogram1dTruncated = new TH1D(histogram1dTruncatedName.data(), histogram1dTruncatedName.data(), 200, 0., 2.);

        double mTauTau_gen = histogram2d->GetXaxis()->GetBinCenter(iBin2dX);
        //if ( mTauTau_gen > 100. ) continue;
        //std::cout << "iBin2dX = " << iBin2dX << ": mTauTau(gen) = " << mTauTau_gen << std::endl;
        //std::cout << "histogram1d: mean = " << histogram1d->GetMean() << ","
        //	        << " rms = " << histogram1d->GetRMS() << std::endl;

        int numBins1d = histogram1d->GetNbinsX();
        for ( int iBin1d = 1; iBin1d <= numBins1d; ++iBin1d ) {
            double mTauTau_rec = histogram1d->GetBinCenter(iBin1d);
            //std::cout << "iBin1d = " << iBin1d << ": mTauTau(rec) = " << mTauTau_rec << std::endl;
            double ratio = mTauTau_rec/mTauTau_gen;
            //std::cout << "ratio = " << ratio << std::endl;
            double binContent = histogram1d->GetBinContent(iBin1d);
            if ( binContent > 1.e-2 ) histogram1dTruncated->Fill(ratio, binContent);
        }
        //std::cout << "histogram1dTruncated: mean = " << histogram1dTruncated->GetMean() << ","
        //	        << " rms = " << histogram1dTruncated->GetRMS() << std::endl;

        delete histogram1d;

        if ( mTauTau_gen > genMassBins[genMassBin_index + 1] && mTauTau_gen < genMassBins[numGenMassBins - 1] ) {
            double x = 0.5*(genMassBins[genMassBin_index] + genMassBins[genMassBin_index + 1]);
            double xErr = 0.5*(genMassBins[genMassBin_index + 1] - genMassBins[genMassBin_index]);
            double y_mean = histogram1dTruncatedSum->GetMean();
            double yErr_mean = histogram1dTruncatedSum->GetMeanError();
            double y_rms = histogram1dTruncatedSum->GetRMS();
            double yErr_rms = histogram1dTruncatedSum->GetRMSError();
            //std::cout << "mTauTau(gen) = " << x << ": mean = " << y_mean << " +/- " << yErr_mean << ","
            //	  << " rms = " << y_rms << " +/- " << yErr_rms << std::endl;
            graph_mean->SetPoint(genMassBin_index, x, y_mean);
            graph_mean->SetPointError(genMassBin_index, xErr, yErr_mean);
            graph_rms->SetPoint(genMassBin_index, x, y_rms);
            graph_rms->SetPointError(genMassBin_index, xErr, yErr_rms);
            delete histogram1dTruncatedSum;
            histogram1dTruncatedSum = 0;
            ++genMassBin_index;
        }

        if ( !histogram1dTruncatedSum ) {
            histogram1dTruncatedSum = histogram1dTruncated;
        } else {
            histogram1dTruncatedSum->Add(histogram1dTruncated);
            delete histogram1dTruncated;
        }
    }

    delete histogram1dTruncatedSum;

    TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600);
    canvas->SetFillColor(10);
    canvas->SetBorderSize(2);
    canvas->SetLeftMargin(0.12);
    canvas->SetBottomMargin(0.12);
    canvas->SetLogy();

    TH1* dummyHistogram = new TH1F("dummyHistogram", "dummyHistogram", 50, 0., 500.);
    dummyHistogram->SetStats(false);
    dummyHistogram->SetTitle("");
    dummyHistogram->SetMinimum(1.e-2);
    dummyHistogram->SetMaximum(1.e+1);

    TAxis* xAxis = dummyHistogram->GetXaxis();
    xAxis->SetTitle("M_{#tau#tau}^{gen} / GeV");
    xAxis->SetTitleOffset(1.15);

    TAxis* yAxis = dummyHistogram->GetYaxis();
    yAxis->SetTitle("M_{#tau#tau}^{rec} / GeV");
    yAxis->SetTitleOffset(1.30);

    dummyHistogram->Draw("axis");

    graph_mean->SetMarkerStyle(20);
    graph_mean->SetMarkerColor(1);
    graph_mean->Draw("P");

//.........这里部分代码省略.........
开发者ID:nsahoo,项目名称:cmssw-1,代码行数:101,代码来源:makeNeuralMtautauPerformancePlots.C

示例9: makePlot


//.........这里部分代码省略.........
  int lineStyles[4] = { 1, 1, 1, 1 };
  int lineWidths[4] = { 2, 2, 2, 2 };
  int fillColors[4] = { 10, 2, 6, 4 };
  int fillStyles[4] = { 0, 3002, 3004, 3005 };

  histogramDYJets->SetFillColor(fillColors[0]);
  histogramDYJets->SetFillStyle(fillStyles[0]);
  histogramDYJets->SetLineColor(lineColors[0]);
  histogramDYJets->SetLineStyle(lineStyles[0]);
  histogramDYJets->SetLineWidth(lineWidths[0]);

  histogramHiggs125->SetFillColor(fillColors[1]);
  histogramHiggs125->SetFillStyle(fillStyles[1]);
  histogramHiggs125->SetLineColor(lineColors[1]);
  histogramHiggs125->SetLineStyle(lineStyles[1]);
  histogramHiggs125->SetLineWidth(lineWidths[1]);

  histogramHiggs200->SetFillColor(fillColors[2]);
  histogramHiggs200->SetFillStyle(fillStyles[2]);
  histogramHiggs200->SetLineColor(lineColors[2]);
  histogramHiggs200->SetLineStyle(lineStyles[2]);
  histogramHiggs200->SetLineWidth(lineWidths[2]);

  histogramHiggs300->SetFillColor(fillColors[3]);
  histogramHiggs300->SetFillStyle(fillStyles[3]);
  histogramHiggs300->SetLineColor(lineColors[3]);
  histogramHiggs300->SetLineStyle(lineStyles[3]);
  histogramHiggs300->SetLineWidth(lineWidths[3]);

  TAxis* xAxis = histogramHiggs300->GetXaxis();
  if ( histogram == "mVis"    ) xAxis->SetRangeUser(0,350);
  else xAxis->SetRangeUser(0,450);
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleOffset(1.00);
  xAxis->SetTitleSize(0.070);
  xAxis->SetTitleFont(42);
  xAxis->SetLabelOffset(0.010);
  xAxis->SetLabelSize(0.050);
  xAxis->SetLabelFont(42);
  xAxis->SetTickLength(0.040);
  xAxis->SetNdivisions(505);

  //double xMin = 20.;
  //double xMax = xAxis->GetXmax();
  //xAxis->SetRangeUser(xMin, xMax);

  TAxis* yAxis = histogramHiggs300->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleOffset(1.20);
  yAxis->SetTitleSize(0.070);
  yAxis->SetTitleFont(42);
  yAxis->SetLabelOffset(0.010);
  yAxis->SetLabelSize(0.055);
  yAxis->SetLabelFont(42);
  yAxis->SetTickLength(0.040);  
  yAxis->SetNdivisions(505);

  histogramHiggs300->SetTitle("");
  histogramHiggs300->SetStats(false);
  histogramHiggs300->SetMaximum(1.2*histogramDYJets->GetMaximum());
  histogramHiggs300->SetMinimum(0.);
  histogramHiggs300->Draw("hist");
  histogramHiggs200->Draw("histsame");
  histogramHiggs125->Draw("histsame");
  histogramDYJets->Draw("histsame");
  histogramHiggs300->Draw("axissame");
开发者ID:veelken,项目名称:SVfitPerformanceStudies,代码行数:67,代码来源:makeSVfitMEM_massPlots_from13.C

示例10: plotFit


//.........这里部分代码省略.........
               if (fittph < tphMin) tphMin = fittph;

               if (fittph > tphMax) tphMax = fittph;

               fitxArray[tphStep] = fitx;

               if (fitx < fitxMin) fitxMin = fitx;

               if (fitx > fitxMax) fitxMax = fitx;

               tphStep++;


              TMarker *m = new TMarker(fitxArray[tphStep],tphArray[tphStep],20);
              m->SetMarkerSize(2);
              m->SetMarkerColor(31+tphStep);
              m->Draw();



            }
         }

         if (s2bStep == 0) {

            TH1F* frame = MyC->DrawFrame(0.0,0.0,1.1*fitxMax,1.1);
//          TH1F* frame = MyC->DrawFrame(0.7*fitxMin,0.7*tphMin,1.1*fitxMax,1.1*tphMax);

            TAxis *xaxis = frame->GetXaxis();
            TAxis *yaxis = frame->GetYaxis();
   
            xaxis->SetTitle("x = u^{2}/v^{2}");
            xaxis->CenterTitle();
            xaxis->SetTitleOffset(1.);
            xaxis->SetDecimals();
            xaxis->SetLabelSize(0.03);
            xaxis->SetLabelOffset(0.01);
        
            yaxis->SetTitle("tan^{2}(#phi)");
            yaxis->CenterTitle();
            yaxis->SetTitleOffset(1.);
            yaxis->SetDecimals();
            yaxis->SetLabelSize(0.03);
            yaxis->SetLabelOffset(0.01);

            frame->SetTitle(plottitle.c_str());

         }

         tphplots[s2bStep] = new TGraph(tphSteps,fitxArray,tphArray);

         tphplots[s2bStep]->SetMarkerStyle(20);

         tphplots[s2bStep]->SetMarkerSize(0.4);
   
         tphplots[s2bStep]->Draw("CP");

      }
   }

   else if (strpltmd.compare("s2b") == 0) {

      s2bMax = -1.0;

      TGraph *s2bplots[tphSteps-100];
开发者ID:jxi24,项目名称:GAPP,代码行数:66,代码来源:plotFit.C

示例11: DrawZPeak


//.........这里部分代码省略.........
  allmc->SetFillStyle  (3345);
  allmc->SetLineColor  (kWhite);
  allmc->SetLineWidth  (0);
  allmc->SetMarkerColor(kOrange-2);
  allmc->SetMarkerSize (0);

  THStack* hs = new THStack();

  if (energy.Contains("8TeV"))
    {
      WV->SetFillColor(kRed+1);  // kAzure
      WV->SetLineColor(kRed+1);  // kAzure

      VVV->SetFillColor(kRed+1);  // kBlack
      VVV->SetLineColor(kRed+1);  // kBlack

      hs->Add(VVV);
      hs->Add(WV);
    }

  hs->Add(Zgamma);
  hs->Add(ZZ);
  hs->Add(fakes);
  hs->Add(WZ);


  // Draw
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas(energy, energy);

  data->Draw("ep");


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = data->GetXaxis();
  TAxis* yaxis = data->GetYaxis();
  
  xaxis->SetLabelFont  (  42);
  xaxis->SetLabelOffset(0.01);
  xaxis->SetLabelSize  (0.05);
  xaxis->SetNdivisions ( 505);
  xaxis->SetTitleFont  (  42);
  xaxis->SetTitleOffset( 1.3);
  xaxis->SetTitleSize  (0.05);

  yaxis->SetLabelFont  (  42);
  yaxis->SetLabelOffset(0.01);
  yaxis->SetLabelSize  (0.05);
  yaxis->SetNdivisions ( 505);
  yaxis->SetTitleFont  (  42);
  yaxis->SetTitleOffset( 1.6);
  yaxis->SetTitleSize  (0.05);

  xaxis->SetRangeUser(68, 112);
  xaxis->SetTitle("m_{#font[12]{ll}} (GeV)");
  yaxis->SetTitle(Form("Events /  %.0f GeV", data->GetBinWidth(0)));


  // Adjust scale
  //----------------------------------------------------------------------------
  Float_t theMax   = GetMaximumIncludingErrors(data);
  Float_t theMaxMC = GetMaximumIncludingErrors(allmc);

  if (theMaxMC > theMax) theMax = theMaxMC;

  data->SetMaximum(1.15 * theMax);


  // Legend
  //----------------------------------------------------------------------------
  Double_t x0 = 0.635;
  Double_t y0 = 0.770;

  DrawTLegend(x0, y0 + 2.*(_yoffset+0.001), data,  " Data",               "ep");
  DrawTLegend(x0, y0 + 1.*(_yoffset+0.001), WZ,    " WZ",                 "f");
  DrawTLegend(x0, y0,                       fakes, " Non-prompt leptons", "f");
  DrawTLegend(x0, y0 - 1.*(_yoffset+0.001), ZZ,    " MC background",      "f");
  DrawTLegend(x0, y0 - 2.*(_yoffset+0.001), allmc, " stat. #oplus syst.", "f");


  // Finish it
  //----------------------------------------------------------------------------
  data->SetTitle("");

  DrawTLatex(_cmsTextFont,   0.215, 0.880, 0.055, 13, "CMS");
  //  DrawTLatex(_extraTextFont, 0.215, 0.826, 0.030, 13, "Preliminary");
  DrawTLatex(_lumiTextFont,  0.940, 0.940, 0.040, 31, _lumiText);

  hs   ->Draw("hist,same");
  allmc->Draw("e2,same");
  data ->Draw("ep,same");

  canvas->GetFrame()->DrawClone();
  canvas->RedrawAxis();
  canvas->Update();
  
  canvas->SaveAs("pdf/" + name + energy + ".pdf");
  canvas->SaveAs("png/" + name + energy + ".png");
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例12: DrawHistogram


//.........这里部分代码省略.........
    Double_t binValue = 0;
    Double_t binError = 0;

    for (UInt_t ip=0; ip<nProcesses; ip++) {

      if (ip == iData) continue;

      Double_t binContent = hist[ip]->GetBinContent(ibin);
      
      binValue += binContent;
      binError += (hist[ip]->GetBinError(ibin) * hist[ip]->GetBinError(ibin));

      //We need to calculate systematic uncertainty for ggH case
//      if (_dataDriven)
//	binError += (systError[ip]*binContent * systError[ip]*binContent);
    }
    
    binError = sqrt(binError);

    allmc->SetBinContent(ibin, binValue);
    allmc->SetBinError  (ibin, binError);
  }


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = hist[iData]->GetXaxis();
  TAxis* yaxis = hist[iData]->GetYaxis();

  TString ytitle = Form("entries / %s.%df", "%", precision);

  xaxis->SetTitle(xtitle);
  yaxis->SetTitle(Form(ytitle.Data(), hist[iData]->GetBinWidth(0)));
  yaxis->SetTitleOffset(1.6);

  if (!units.Contains("NULL")) {
    
    xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data()));
    yaxis->SetTitle(Form("%s %s",   yaxis->GetTitle(), units.Data()));
  }


  // Draw
  //----------------------------------------------------------------------------
  xaxis->SetRangeUser(xmin, xmax);

  hist[iData]->Draw("ep");
  hstack     ->Draw("hist,same");
  allmc      ->Draw("e2,same");
  hist[iData]->Draw("ep,same");


  // Adjust scale
  //----------------------------------------------------------------------------
  Float_t theMax   = GetMaximumIncludingErrors(hist[iData], xmin, xmax);
  Float_t theMaxMC = GetMaximumIncludingErrors(allmc,       xmin, xmax);

  if (theMaxMC > theMax) theMax = theMaxMC;

  if (pad1->GetLogy()) {

    theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7);

    hist[iData]->SetMinimum(0.05);
  }
  else theMax *= 1.55;
开发者ID:d4space,项目名称:HWW,代码行数:67,代码来源:drawDistributions_SS.C

示例13: drawFigure6

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// drawFigure6
//
//    logy = 0
//    logy = 1
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void drawFigure6(Int_t logy = 0)
{
  gInterpreter->ExecuteMacro("WZPaperStyle.C");

  gSystem->mkdir("pdf", kTRUE);
  gSystem->mkdir("png", kTRUE);


  // Read the input file
  //----------------------------------------------------------------------------
  TString name = "WZ_PtZ_plot_allCh_largeATGC";

  TFile* file = new TFile("rootfiles/" + name + ".root", "read");

  TCanvas* c1 = (TCanvas*)file->Get("c1_allCh");

  TH1F* data     = (TH1F*)c1->FindObject("histo_data_3e");
  TH1F* aTGC_dk  = (TH1F*)c1->FindObject("histo_aTGC_dk_3e");
  TH1F* aTGC_lam = (TH1F*)c1->FindObject("histo_aTGC_lam_3e");
  TH1F* aTGC_dg  = (TH1F*)c1->FindObject("histo_aTGC_dg_3e");
  TH1F* WZ       = (TH1F*)c1->FindObject("histo_SM_3e");
  TH1F* fakes    = (TH1F*)c1->FindObject("fake_0");
  TH1F* ZZ       = (TH1F*)c1->FindObject("total_bkg_rebined_ZZ_0");
  TH1F* Zgamma   = (TH1F*)c1->FindObject("total_bkg_rebined_Zgamma_0");
  TH1F* WV       = (TH1F*)c1->FindObject("total_bkg_rebined_WV_0");
  TH1F* VVV      = (TH1F*)c1->FindObject("total_bkg_rebined_VVV_0");

  WZ->SetFillColor(kOrange-2);
  WZ->SetLineColor(kOrange-2);

  Zgamma->SetFillColor(kRed+1);
  Zgamma->SetLineColor(kRed+1);

  ZZ->SetFillColor(kRed+1);
  ZZ->SetLineColor(kRed+1);

  fakes->SetFillColor(kGray+1);
  fakes->SetLineColor(kGray+1);

  WV->SetFillColor(kRed+1);
  WV->SetLineColor(kRed+1);

  VVV->SetFillColor(kRed+1);
  VVV->SetLineColor(kRed+1);


  // Draw
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas("canvas", "canvas");

  canvas->SetLogy(logy);

  data->Draw("ep");


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = data->GetXaxis();
  TAxis* yaxis = data->GetYaxis();
  
  xaxis->SetLabelFont  (  42);
  xaxis->SetLabelOffset(0.01);
  xaxis->SetLabelSize  (0.05);
  xaxis->SetNdivisions ( 505);
  xaxis->SetTitleFont  (  42);
  xaxis->SetTitleOffset( 1.2);
  xaxis->SetTitleSize  (0.05);

  yaxis->SetLabelFont  (  42);
  yaxis->SetLabelOffset(0.01);
  yaxis->SetLabelSize  (0.05);
  yaxis->SetNdivisions ( 505);
  yaxis->SetTitleFont  (  42);
  yaxis->SetTitleOffset( 1.6);
  yaxis->SetTitleSize  (0.05);

  xaxis->SetTitle("p_{T}^{Z} (GeV)");
  yaxis->SetTitle(Form("Events /  %.0f GeV", data->GetBinWidth(0)));


  // Adjust scale
  //----------------------------------------------------------------------------
  Float_t theMax   = GetMaximumIncludingErrors(data);
  Float_t theMaxMC = GetMaximumIncludingErrors(aTGC_dk);

  if (theMaxMC > theMax) theMax = theMaxMC;

  if (canvas->GetLogy()) {
    data->SetMaximum(15 * theMax);
    data->SetMinimum(1);
  } else {
    data->SetMaximum(1.2 * theMax);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: showGraphs

void showGraphs(double canvasSizeX, double canvasSizeY,
		const std::vector<std::string>& entriesToPlot,
		std::map<std::string, TGraph*>& graphs,
		std::map<std::string, std::string>& legendEntries,
		int colors[], int lineWidths[], int lineStyles[],
		double legendTextSize, double legendPosX, double legendPosY, double legendSizeX, double legendSizeY, 
		double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset,
		double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
		const std::string& outputFileName)
{
  TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  
  canvas->SetLeftMargin(0.14);
  canvas->SetBottomMargin(0.12);

  TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 100, xMin, xMax);
  dummyHistogram->SetTitle("");
  dummyHistogram->SetStats(false);
  dummyHistogram->SetMinimum(yMin);
  dummyHistogram->SetMaximum(yMax);

  TAxis* xAxis = dummyHistogram->GetXaxis();
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleSize(0.045);
  xAxis->SetTitleOffset(xAxisOffset);

  TAxis* yAxis = dummyHistogram->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleSize(0.045);
  yAxis->SetTitleOffset(yAxisOffset);

  dummyHistogram->Draw("axis");

  TLegend* legend = new TLegend(legendPosX, legendPosY, legendPosX + legendSizeX, legendPosY + legendSizeY, "", "brNDC"); 
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  legend->SetTextSize(legendTextSize);

  size_t numEntriesToPlot = entriesToPlot.size();
  for ( size_t iEntryToPlot = 0; iEntryToPlot < numEntriesToPlot; ++iEntryToPlot ) {
    const std::string& entryToPlot = entriesToPlot[iEntryToPlot];
    TGraph* graph = graphs[entryToPlot];
    assert(graph);
    graph->SetLineColor(colors[iEntryToPlot]);
    graph->SetLineWidth(lineWidths[iEntryToPlot]);
    graph->SetLineStyle(lineStyles[iEntryToPlot]);
    graph->SetMarkerColor(colors[iEntryToPlot]);
    graph->Draw("L");

    legend->AddEntry(graph, legendEntries[entryToPlot].data(), "l");
  }

  legend->Draw();

  canvas->Update();
  std::string outputFileName_plot = "plots/";
  size_t idx = outputFileName.find_last_of('.');
  outputFileName_plot.append(std::string(outputFileName, 0, idx));
  if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
  canvas->Print(std::string(outputFileName_plot).append(".png").data());
  canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
  
  delete dummyHistogram;
  delete legend;
  delete canvas;  
}
开发者ID:veelken,项目名称:SVfitDevelopment,代码行数:68,代码来源:makeSVfitLikelihoodSeparationPlots.C

示例15: plot_ZJetBalance

void plot_ZJetBalance(int JetAlgo) {

  Float_t pt[NGenPtBins];
  TString ptBin[NGenPtBins];

  
  for(int i=0; i<NGenPtBins; i++) {
    pt[i] = 0.5*( GenPt[i] + GenPt[i+1] );
    ptBin[i] = Form("%d_%d", (int) GenPt[i], (int) GenPt[i+1] );
  }


  Float_t errpt[NGenPtBins];
  Float_t genMean[NGenPtBins];
  Float_t genSigma[NGenPtBins]; 
  Float_t recoMean[NGenPtBins]; 
  Float_t recoSigma[NGenPtBins];
 

  TString algoSt;
  if(JetAlgo==0) algoSt = "_ic5";
  if(JetAlgo==1) algoSt = "_ic7";
  if(JetAlgo==2) algoSt = "_mp5";
  if(JetAlgo==3) algoSt = "_mp7";
  if(JetAlgo==4) algoSt = "_kt6";

  TString textFilename = "ZjetPtBalance" + algoSt + TString(".txt");
  TString JetResponseFilename 
    = "Histograms_ZjetResponse" + algoSt + TString(".root");

  FILE *file = fopen(textFilename,"w+");
  fprintf( file ,"%s    %s   %s   %s   %s \n", "pT bin", 
	   "genMean", "genSigma", "recoMean", "recoSigma");

  TH1F* responseHistGen;
  TH1F* responseHistReco;
  TH1F* genJetpt;
  TH1F* caloJetpt;
  TH1F* Zpt;

  if(storeResponsHistogramsInRootFile == true) {
    TFile respHistFile(JetResponseFilename,"RECREATE");
  }


  for(int i=0; i<NGenPtBins; i++) {

    responseHistGen = new TH1F("responseHistGen_"+ptBin[i],"", 40, 0.0, 2.0);
    responseHistGen->Sumw2();
    TAxis* responseHistGenx = responseHistGen->GetXaxis();
    TAxis* responseHistGeny = responseHistGen->GetYaxis();
    responseHistGenx->SetTitle("p_{T,Jet} / p_{T,Z}   ");
    responseHistGeny->SetTitle("Events / 0.05         ");
    responseHistGeny->SetTitleOffset(1.2);
    
    responseHistReco = new TH1F("responseHistReco_"+ptBin[i],"", 40, 0.0, 2.0);
    responseHistReco->Sumw2();
    responseHistReco->SetLineColor(2);
    responseHistReco->SetMarkerColor(2);
    

    genJetpt = new TH1F("genJetpt_"+ptBin[i],"", NGenPtBins-1, GenPt);
    genJetpt->Sumw2();

    caloJetpt = new TH1F("caloJetpt_"+ptBin[i],"", NGenPtBins-1, GenPt);
    caloJetpt->Sumw2();

    recoZpt = new TH1F("recoZpt_"+ptBin[i],"", NGenPtBins-1, GenPt);
    recoZpt->Sumw2();

    errpt[i]     = 0.0;
    genMean[i]   = 0.0;
    genSigma[i]  = 0.0; 
    recoMean[i]  = 0.0; 
    recoSigma[i] = 0.0;


    plot_ZJetBalance(  JetAlgo, i, *responseHistGen, *responseHistReco, 
		      *genJetpt, *caloJetpt, *recoZpt);

    genMean[i]   = (Float_t) responseHistGen->GetMean(1);
    genSigma[i]  = (Float_t) responseHistGen->GetMean(11);
    recoMean[i]  = (Float_t) responseHistReco->GetMean(1); 
    recoSigma[i] = (Float_t) responseHistReco->GetMean(11);


    if(storeResponseInTextFile == true) {
      fprintf( file ,"%5.1f   %5.4f   %5.4f   %5.4f   %5.4f \n", pt[i],
	       genMean[i], genSigma[i], recoMean[i], recoSigma[i] );
    }

    if(storeResponsHistogramsInRootFile == true) {
      respHistFile.cd();
      responseHistGen->Write();
      responseHistReco->Write();
      genJetpt->Write();
      caloJetpt->Write();
      recoZpt->Write();
    }
    
//.........这里部分代码省略.........
开发者ID:kalanand,项目名称:UserCode,代码行数:101,代码来源:plot_ZJetBalance.C


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