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


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

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


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

示例1: TPTiming

void TPTiming ()
{
    TAxis * ax = TPMatchEmul2D->GetZaxis() ;
    ax->SetRangeUser(-1,6) ;

    TCanvas* canv = new TCanvas("canv", "canv") ;
    canv->SetLogz(0) ;
    gStyle->SetOptStat(10) ;
    int color[10]= {1,10,3,4,5,6,7,8,9,2} ;
    gStyle->SetPalette(7, color) ;
    TPMatchEmul2D->GetXaxis()->SetTitle("Phi index");
    TPMatchEmul2D->GetYaxis()->SetTitle("Eta index");
    TPMatchEmul2D->Draw("colz") ;

    TH2I * label = new TH2I("label", "",72, 1, 73, 38, -19, 19) ;
    label->SetMarkerSize(0.6);
    label->SetBit(kCanDelete);
    for (int x=3 ; x<73 ; x+=4) {
        for (int y=21; y<=37; y++) {
            int towernb = 4*(y-21)+1 ;
            label->SetBinContent(x-1, y, towernb) ; //EB+
            label->SetBinContent(x, 40-y, towernb) ; //EB-
        }
    }
    label->Draw("same text") ;

    TLatex txt;
    txt.SetTextSize(0.02);
    TLine line;
    line.SetLineColor(1) ;
    line.SetLineStyle(1) ;
    line.SetLineWidth(1) ;
    TAxis* xAxis = TPMatchEmul2D->GetXaxis();
    TAxis* yAxis = TPMatchEmul2D->GetYaxis();

    // draw SM borders and numbers
    float sm ;
    for (int i=0; i<36 ; i++ ) {
        if (i<18) {
            sm = 4*i+3 ;
            line.DrawLine(sm, 1, sm, 18) ;
            txt.SetTextAlign(32);
            txt.DrawText(sm-1+0.3, -17.7, Form("-%d",i+1));
        }
        else {
            sm = 4*(i-18)+3 ;
            line.DrawLine(sm, 0, sm, -17) ;
            txt.SetTextAlign(12);
            txt.DrawText(sm-2+0.3, 18.5, Form("+%d",i-17));
        }
    }
    line.DrawLine(1, 0, 73, 0) ;
    line.DrawLine(1, -17, 73, -17) ;
    line.DrawLine(1, 1, 73, 1) ;
    line.DrawLine(1, 18, 73, 18) ;

}
开发者ID:cms-ecal-L1TriggerTeam,项目名称:CMS-ECAL_TPGAnalysis,代码行数:57,代码来源:TPTiming.C

示例2: ZoomSelected

//________________________________________________________________
void KVCanvas::ZoomSelected(TH2* TheHisto)
{
   if (!TheHisto) return;
   TAxis* ax = TheHisto->GetXaxis();

   Double_t ratio1 = (xmin - GetUxmin()) / (GetUxmax() - GetUxmin());
   Double_t ratio2 = (xmax - GetUxmin()) / (GetUxmax() - GetUxmin());
   if ((ratio2 - ratio1 > 0.05)) ax->SetRangeUser(xmin, xmax);

   ax = TheHisto->GetYaxis();

   ratio1 = (ymin - GetUymin()) / (GetUymax() - GetUymin());
   ratio2 = (ymax - GetUymin()) / (GetUymax() - GetUymin());
   if ((ratio2 - ratio1 > 0.05)) ax->SetRangeUser(ymin, ymax);

   xmax = xmin = ymax = ymin = 0.;
   return;
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:19,代码来源:KVCanvas.cpp

示例3: plotImportance

void plotImportance(const char* canvas, const char* title,
		    const unsigned nVars,
		    const char vars[][200], 
		    const double* importance, const double* error,
		    bool automaticRange=false)
{
  TCanvas *c 
    = new TCanvas(canvas,"SPR Variable Importance",200,10,600,400);
  gStyle->SetPalette(1);
  TH1D* h1 = new TH1D("importance",title,nVars,0,nVars);
  double ymin(0), ymax(0);
  for( int i=0;i<nVars;i++ ) {
    h1->Fill(vars[i],importance[i]);
    if( automaticRange ) {
      ymin = ( ymin>importance[i] ? importance[i] : ymin );
      ymax = ( ymax<importance[i] ? importance[i] : ymax );
    }
  }
  if( automaticRange ) {
    ymin = ( ymin<0 ? ymin*1.2 : ymin*0.8 );
    ymax *= 1.2;
  }
  else {
    ymin = 0.;
    ymax = 1.;
  }
  if( error == 0 ) {
    for( int i=0;i<nVars;i++ )
      h1->SetBinError(i+1,0.);
  }
  else {
    for( int i=0;i<nVars;i++ )
      h1->SetBinError(i+1,error[i]);
  }
  h1->LabelsDeflate("X");
  h1->LabelsOption("v");
  h1->SetLabelSize(0.06,"X");
  h1->SetLineColor(4);
  h1->SetMarkerStyle(21);
  h1->SetMarkerColor(4);
  h1->SetLineWidth(2);
  TAxis* yaxis = h1->GetYaxis();
  yaxis->SetRangeUser(ymin,ymax);
  if( error == 0 ) {
    h1->SetLineColor(4);
    h1->SetFillColor(4);
    h1->SetBarWidth(0.8);
    h1->SetBarOffset(0.1);
    h1->Draw("B");
  }
  else
    h1->Draw("E0P");
  l = new TLine(0,0,nVars,0); l->Draw();
}
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:54,代码来源:spr_plot.C

示例4: showHistograms

void showHistograms(double canvasSizeX, double canvasSizeY,
		    TH1* histogram, 
		    double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset,
		    bool useLogScale, 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.15);
  canvas->SetBottomMargin(0.15);
  canvas->SetLogy(useLogScale);

  histogram->SetTitle("");
  histogram->SetStats(true);
  histogram->SetMinimum(yMin);
  histogram->SetMaximum(yMax);
  histogram->SetLineColor(1);
  histogram->SetLineWidth(2);
  histogram->SetMarkerColor(1);
  histogram->SetMarkerStyle(20);
  histogram->SetMarkerSize(1.5);
  histogram->Draw("hist");

  TAxis* xAxis = histogram->GetXaxis();
  xAxis->SetRangeUser(xMin, xMax);
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleSize(0.060);
  xAxis->SetTitleOffset(xAxisOffset);
  xAxis->SetLabelSize(0.050);
  xAxis->SetNdivisions(505);

  TAxis* yAxis = histogram->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleSize(0.060);
  yAxis->SetTitleOffset(yAxisOffset);
  yAxis->SetLabelSize(0.050);
  yAxis->SetNdivisions(505);

  canvas->Update();
  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName, 0, idx);
  if ( useLogScale ) outputFileName_plot.append("_log");
  else outputFileName_plot.append("_linear");
  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 canvas;  
}
开发者ID:veelken,项目名称:SVfitMEM,代码行数:51,代码来源:makeTFNormalizationPlots.C

示例5: TCanvas

// ===  FUNCTION  ============================================================
//         Name:  TPlot::Compare1D
//  Description:  
// ===========================================================================
bool TPlot::Compare1D(std::string histname)
{
  std::vector<PlotID> vth1;

  for(unsigned int i=0; i < plist.size(); ++i)
  {
    PlotID temp;
    temp.name = histname;
    temp.det = plist.at(i).first;
    temp.algo = plist.at(i).second;
    temp.marker = detMark[temp.det];
    temp.color = algColor[temp.algo];
    temp.hist = GetHist1D(histname, temp.det, temp.algo);
    vth1.push_back(temp);
  }

  TCanvas *c1 = new TCanvas("Canvas", "Yes, another Canvas", 10, 10, 800, 600);
  TLegend *leg = new TLegend(0.660804,0.5776614,0.959799,0.9319372,NULL,"brNDC");

  
  TAxis* xaxis = NULL;
  TAxis* yaxis = NULL;
  double Ymax = 0;
  double ingl = 0;
  for(unsigned int i=0; i < vth1.size(); ++i)
  {
    PlotID  plot1D = vth1.at(i);
    
    // Set Marker and Color
    plot1D.hist->SetMarkerStyle(plot1D.marker);
    plot1D.hist->SetMarkerColor(plot1D.color);
    plot1D.hist->SetLineColor(plot1D.color);
    plot1D.hist->SetLineWidth(1);
    plot1D.hist->SetMarkerSize(1);

    /*if (histname.find("TauEta")  != std::string::npos)*/
    /*{*/
      /*plot1D.hist->Rebin(10);*/
    /*}*/


    //if (histname.find("Response")  == std::string::npos &&
        //histname.find("Resolution")  == std::string::npos) {
      ////plot1D.hist->Rebin(2);
      //}
    // Draw
    if (i == 0)
    {
      plot1D.hist->Draw("PE");
      xaxis = plot1D.hist->GetXaxis();
      yaxis = plot1D.hist->GetYaxis();
      ingl =  plot1D.hist->Integral();
    }
    else
    {
      if (histname.find("Response")  == std::string::npos &&
          histname.find("Resolution")  == std::string::npos) {
        /*plot1D.hist->Scale(ingl / plot1D.hist->Integral());*/
      }
      plot1D.hist->Draw("samepe");
    }

    // Add Legend
    std::stringstream ss;
    ss << plot1D.det << " " << plot1D.algo;
    leg->AddEntry(plot1D.hist, ss.str().c_str(), "lp" );

    // Get Yaxis maximun
    Ymax = plot1D.hist->GetMaximum() > Ymax ? plot1D.hist->GetMaximum() : Ymax;
    yaxis->SetRangeUser(0.0, 1.2*Ymax);
  }

  SetPlotStyle(histname, c1, leg, xaxis, yaxis);
  leg->Draw();

  for(std::set<std::string>::const_iterator it=vformat.begin();
    it!=vformat.end(); ++it)
  {
    std::stringstream ss;
    ss << histname <<"." << *it;
    c1->Update();
    c1->SaveAs(ss.str().c_str());
  }

  delete c1;
  delete leg;

  return true;
}       // -----  end of function TPlot::Compare1D  -----
开发者ID:zhenbinwu,项目名称:PFAnalyzer,代码行数:93,代码来源:TPlot.C

示例6: FitSignal


//.........这里部分代码省略.........
			for(int i=0; i<nPar; i++) {
			printf("old,new = %10.5f %10.5f\n",parMin[i],par2[i]);
			fits[ind]->SetParameter(i,par2[i]);
			}
			*/

		// restore original fit
		fval = 0.0;
		gMinuit->Eval(nPar,0,fval,parMin,0);
		for(int i=0; i<nPar; i++) fits[ind]->SetParameter(i,parMin[i]);



		//extract fit error matrix
		gMinuit->mnemat(matrix.GetMatrixArray(),nPar);
		matrix.Print();

		for(int i=0; i<nPar; i++) {
			for(int j=0; j<nPar; j++) {
				printf("%10.5f",matrix(i,j)/sqrt(matrix(i,i)*matrix(j,j)));
			}
			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");
开发者ID:hkaushalya,项目名称:CDFPhoJets,代码行数:67,代码来源:TPeaksHiggs.C

示例7: showHistograms

void showHistograms(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,
		    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,
		    bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
		    const std::string& outputFileName)
{
  const unsigned numBinsMin_rebinned = 20;
  TH1* histogram1_rebinned = rebinHistogram(histogram1, numBinsMin_rebinned, xMin, xMax);
  TH1* histogram2_rebinned = rebinHistogram(histogram2, numBinsMin_rebinned, xMin, xMax);
  TH1* histogram3_rebinned = rebinHistogram(histogram3, numBinsMin_rebinned, xMin, xMax);
  TH1* histogram4_rebinned = rebinHistogram(histogram4, numBinsMin_rebinned, xMin, xMax);

  TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2);
  
  canvas->SetLeftMargin(0.14);
  canvas->SetBottomMargin(0.12);

  canvas->SetLogy(useLogScale);

  histogram1_rebinned->SetTitle("");
  histogram1_rebinned->SetStats(false);
  histogram1_rebinned->SetMinimum(yMin);
  histogram1_rebinned->SetMaximum(yMax);

  TAxis* xAxis = histogram1_rebinned->GetXaxis();
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleSize(0.045);
  xAxis->SetTitleOffset(xAxisOffset);  
  if ( xMax > xMin ) {
    std::cout << "limiting x-axis range to " << xMin << ".." << xMax << std::endl;
    xAxis->SetRangeUser(xMin, xMax);
  }

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

  int colors[4] = { 1, 2, 3, 4 };
  int lineStyles[4] = { 1, 7, 4, 3 };

  histogram1_rebinned->SetLineColor(colors[0]);
  histogram1_rebinned->SetLineWidth(2);
  histogram1_rebinned->SetLineStyle(lineStyles[0]);
  histogram1_rebinned->Draw("hist");

  if ( histogram2_rebinned ) {
    histogram2_rebinned->SetLineColor(colors[1]);
    histogram2_rebinned->SetLineWidth(2);
    histogram2_rebinned->SetLineStyle(lineStyles[1]);
    histogram2_rebinned->Draw("histsame");
  }

  if ( histogram3_rebinned ) {
    histogram3_rebinned->SetLineColor(colors[2]);
    histogram3_rebinned->SetLineWidth(2);
    histogram3_rebinned->SetLineStyle(lineStyles[2]);
    histogram3_rebinned->Draw("histsame");
  }

  if ( histogram4_rebinned ) {
    histogram4_rebinned->SetLineColor(colors[3]);
    histogram4_rebinned->SetLineWidth(2);
    histogram4_rebinned->SetLineStyle(lineStyles[3]);
    histogram4_rebinned->Draw("histsame");
  }

  TLegend* legend = new TLegend(legendPosX, legendPosY, legendPosX + legendSizeX, legendPosY + legendSizeY, "", "brNDC"); 
  legend->SetBorderSize(0);
  legend->SetFillColor(0);
  legend->SetTextSize(legendTextSize);
  legend->AddEntry(histogram1_rebinned, legendEntry1.data(), "l");
  if ( histogram2_rebinned ) legend->AddEntry(histogram2_rebinned, legendEntry2.data(), "l");
  if ( histogram3_rebinned ) legend->AddEntry(histogram3_rebinned, legendEntry3.data(), "l");
  if ( histogram4_rebinned ) legend->AddEntry(histogram4_rebinned, legendEntry4.data(), "l");
  legend->Draw();

  TPaveText* label = 0;
  if ( labelTextLines.size() > 0 ) {
    label = new TPaveText(labelPosX, labelPosY, labelPosX + labelSizeX, labelPosY + labelSizeY, "brNDC");
    for ( std::vector<std::string>::const_iterator labelTextLine = labelTextLines.begin();
	  labelTextLine != labelTextLines.end(); ++labelTextLine ) {
      label->AddText(labelTextLine->data());
    }
    label->SetFillColor(10);
    label->SetBorderSize(0);
    label->SetTextColor(1);
    label->SetTextAlign(12);
    label->SetTextSize(labelTextSize);
    label->Draw();
  }

//.........这里部分代码省略.........
开发者ID:JehadMousa,项目名称:TauAnalysis-CandidateTools,代码行数:101,代码来源:makeSVfitPerformancePlots_WH.C

示例8: Subtraction

//------------------------------------------------------------------------------
//Subtraction 
//------------------------------------------------------------------------------
void Subtraction(TString  hname,
		   TString  xtitle,
		   Int_t    ngroup       = -1,
		   Int_t    precision    = 1,
		   TString  units        = "NULL",
		   Double_t xmin         = -999,
		   Double_t xmax         =  999,
		   Bool_t   moveOverflow = true)
{
  TCanvas* canvas = new TCanvas(hname, hname, 800, 800);

  TPad* pad1 = new TPad("pad1", "pad1", 0, 0.0, 1, 1.0);

  pad1->SetTopMargin   (0.08);
  //pad1->SetBottomMargin(0.02);
  pad1->Draw();
      

  //----------------------------------------------------------------------------
  // pad1
  //----------------------------------------------------------------------------
  pad1->cd();

  pad1->SetLogy(_setLogy);

  TH1F* hist[nProcesses];

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

    hist[ip] = (TH1F*)input[ip]->Get(hname);
    hist[ip]->SetName(hname + process[ip]);

    if (moveOverflow) MoveOverflowBins  (hist[ip], xmin, xmax);
    else              ZeroOutOfRangeBins(hist[ip], xmin, xmax);

	if (ngroup > 0) hist[ip]->Rebin(ngroup);

	if (_dataDriven && ip == iWW)    hist[ip]->Scale(WWScale[_njet]);
	if (_dataDriven && ip == iDY)    hist[ip]->Scale(ZjScale[_njet]);
	if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]);

  }

  // Data subtraction for Top background estimation
  //----------------------------------------------------------------------------
  TH1F* subData = (TH1F*)hist[iData]->Clone("subData");
  for (UInt_t ip=0; ip<nProcesses; ip++) {
	  if (ip == itt) continue;
	  if (ip == itW) continue;
	  if (ip == iData ) continue;
	  subData->Add(hist[ip],-1);
  }
  subData->SetLineColor(kRed+1);
  Double_t subData_Yield = subData->Integral();
  //subData->SetLineColor();

  // Top background
  //----------------------------------------------------------------------------
  TH1F* Top = (TH1F*)hist[itt]->Clone("Top");
  Top->Add(hist[itW]);
  Top->SetLineColor(kBlue+1);
  Double_t Top_Yield = Top->Integral();

  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = subData->GetXaxis();
  TAxis* yaxis = subData->GetYaxis();

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

  xaxis->SetTitle(xtitle);
  yaxis->SetTitle(Form(ytitle.Data(), subData->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);

  subData->Draw("hist");
  Top->Draw("hist same");

  // Adjust scale
  //----------------------------------------------------------------------------
  subData->SetMinimum(0.0);
  
  Float_t theMax   = GetMaximumIncludingErrors(subData, xmin, xmax);
  Float_t theMaxMC = GetMaximumIncludingErrors(Top,       xmin, xmax);

  if (theMaxMC > theMax) theMax = theMaxMC;

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

示例9: DrawHistogram


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

      //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;

  hist[iData]->SetMaximum(theMax);


  // Legend
  //----------------------------------------------------------------------
  Double_t x0      = 0.720; 
  Double_t y0      = 0.834; 
  Double_t yoffset = 0.048;
  Double_t delta   = yoffset + 0.001;
  Double_t ndelta  = 0;
开发者ID:d4space,项目名称:HWWSE,代码行数:66,代码来源:drawDistributions.C

示例10: plotVariable


//.........这里部分代码省略.........
      if (category == "wGwoGSF") CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf<0.5";
      if (category == "wGwGSFwoPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput<-0.1";
      if (category == "wGwGSFwPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput>-0.1";
    }

    if(discriminator == "-AntiEMed"){
      if (category == "NoEleMatch") CategorySelection = "Tau_GsfEleMatch<0.5"; 
      if (category == "woG") CategorySelection = "Tau_NumGammaCands<0.5"; 
      if (category == "wGwoGSF") CategorySelection = "Tau_NumGammaCands>0.5 && (Tau_HasGsf<0.5 || (Tau_HasGsf>0.5 && Elec_PFMvaOutput>-0.1))";
      if (category == "wGwGSFwoPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput<-0.1";
    }

  TCut ElecSelection = CategorySelection && PUSelection && ElecPtSelection && ElecAbsEtaSelection && ElecMatchSelection ;
  TCut TauSelection = CategorySelection && PUSelection && TauPtSelection && TauAbsEtaSelection && TauMatchSelection ;
  TCut Selection;
  if (variable.find("Elec")!=std::string::npos)Selection = ElecSelection;
  if (variable.find("Tau")!=std::string::npos)Selection = TauSelection;
  

  TH1F* hVariable   = new TH1F( "hVariable" ,"" , nBins ,xMin, xMax);
  hVariable->SetXTitle(Form("%s",variable.data()));

  if (matching->find("EleMatch")!=std::string::npos){
//     hVariable->SetFillColor(kRed);
//     hVariable->SetFillStyle(3345);
    hVariable->SetLineColor(kRed);
    hVariable->SetLineWidth(2);
  }
  if (matching->find("HadMatch")!=std::string::npos){
//     hVariable->SetFillColor(kBlue);
//     hVariable->SetFillStyle(3354);
    hVariable->SetLineColor(kBlue);
    hVariable->SetLineWidth(2);
  }  
  inputTree->Draw(Form("%s>>hVariable",variable.data()));

  cout<<"Variable plotted : "<<variable<<endl;
  cout<<"Matching applied : "<<matching->data()<<endl;
  cout<<"  Total number of Candidates : "<<hVariable->GetEntries()<<endl;
  inputTree->Draw(Form("%s>>hVariable",variable.data()),Selection);
  cout<<"  Number of Cantidates after selection: "<<hVariable->GetEntries()<<endl;
  hVariable->Scale(1./hVariable->Integral());
  leg->AddEntry(hVariable,Form("%s",matching->data()));

  histograms.push_back(hVariable);
  c1->Clear();
  }
//   double yMin = +1.e+6;
//   double yMax = -1.e+6;
  TH1* refHistogram = histograms.front();
  refHistogram->SetStats(false);
  refHistogram->SetTitle("");
//   refHistogram->SetMinimum(yMin);
//   refHistogram->SetMaximum(yMax);


  if (xAxisTitle == "HoHplusE" ) {
    refHistogram->SetMaximum(1.0);
    refHistogram->SetMinimum(0.01);
    c1->SetLogy();
  }

  if(xAxisTitle == "E_{#gamma}/(P_{in}-P_{out})" ){
    refHistogram->SetMaximum(0.03);
    refHistogram->SetMinimum(0.0);
  }

  if(xAxisTitle == "HadrMva(#tau)" ){
    refHistogram->SetMaximum(0.25);
    refHistogram->SetMinimum(0.0);
  }

  TAxis* xAxis = refHistogram->GetXaxis();
  xAxis->SetTitle(xAxisTitle.Data());
  xAxis->SetTitleOffset(1.15);
  //if(variable.find("AbsEta")!=std::string::npos)xAxis->SetLimits(AbsEtaMin, AbsEtaMax);
  TAxis* yAxis = refHistogram->GetYaxis();
  yAxis->SetTitle(yAxisTitle.Data());
  yAxis->SetTitleOffset(1.30);

  int numHistograms = histograms.size();
  float YMax = 0;
  for ( int iHistogram = 0; iHistogram < numHistograms; ++iHistogram ) {
    TH1* histogram = histograms[iHistogram];
    if(histogram->GetMaximum()>YMax) YMax = histogram->GetMaximum();
  }
  for ( int iHistogram = 0; iHistogram < numHistograms; ++iHistogram ) {
    TH1* histogram = histograms[iHistogram];
    yAxis->SetRangeUser(0.,YMax+0.10*YMax);
    std::string drawOption = "hist";
    if ( iHistogram > 0 ) drawOption.append("same");
    histogram->Draw(drawOption.data());
    leg->Draw();

  }//loop matchings
  string outputName = Form("plots/plotVariablesAntiEMVA/%s/plotVariablesAntiEMVA_v4_%s_%s_%s",category.Data(),category.Data(),variable.data(),Region.Data());
  c1->Print(std::string(outputName).append(".png").data());
  c1->Print(std::string(outputName).append(".pdf").data());

}
开发者ID:inaranjo,项目名称:ElectronsStudies,代码行数:101,代码来源:plotVariablesAntiEMVACVS.C

示例11: DrawHistogram


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

      //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;

  hist[iData]->SetMaximum(theMax);


  // Legend
  //----------------------------------------------------------------------------
  Double_t x0      = 0.720; 
  Double_t y0      = 0.834; 
  Double_t yoffset = 0.048;
  Double_t delta   = yoffset + 0.001;
  Double_t ndelta  = 0;
开发者ID:d4space,项目名称:HWW,代码行数:67,代码来源:drawDistributions_SS.C

示例12: makePlot


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

  int lineColors[4] = { 1, 2, 6, 4 };
  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");
开发者ID:veelken,项目名称:SVfitPerformanceStudies,代码行数:67,代码来源:makeSVfitMEM_massPlots_from13.C

示例13: main


//.........这里部分代码省略.........
      ymin = ymin < reco->GetMinimum() ? ymin : reco->GetMinimum();
      ymax = ymax > reco->GetMaximum() ? ymax : reco->GetMaximum();
      if (i == 0)
      {
        yaxis = reco->GetYaxis();
        xaxis = reco->GetXaxis();
        reco->Draw();
      }
      else
      {
        reco->Draw("same");
      }

      reco->GetYaxis()->SetTitle("Efficiency");

      if (vDec.at(i).find("PU") != std::string::npos)
      {

        std::cout << " vDec.at(i)" << vDec.at(i) << std::endl;
        std::cout<<"Run to \033[0;31m"<<__func__<<"\033[0m at \033[1;36m"<< __FILE__<<"\033[0m, line \033[0;34m"<< __LINE__<<"\033[0m"<< std::endl; 
        if (vDec.at(i) == "PhaseI_0PU")    
        {
          lg->AddEntry(reco, "Phase I, <PU>=0",   "fl");
          reco->SetLineColor(1);
        }
        if (vDec.at(i) == "PhaseI_140PU")  
        { 
          lg->AddEntry(reco, "Phase I, <PU>=140", "fl");
          reco->SetLineColor(4);
        }
        if (vDec.at(i) == "PhaseII3_140PU") 
        {
          lg->AddEntry(reco, "Phase II Conf3, <PU>=140", "fl");
          //lg->AddEntry(reco, "PhaseII3 <PU>=140", "fl");
          reco->SetLineColor(kGreen+2);
        }
        if (vDec.at(i) == "PhaseII4_140PU") 
        {
          lg->AddEntry(reco, "Phase II Conf4, <PU>=140", "fl");
          reco->SetLineColor(2);
        }


        //TString leg = vDec.at(i);
        //lg->AddEntry(reco, leg.ReplaceAll("_", " "), "l");
      }
      TString xlabel = reco->GetXaxis()->GetTitle();
      std::cout << xlabel << std::endl;
      if (xlabel =="#Pt_{Matched m} [GeV]") 
        std::cout<<"Run to \033[0;31m"<<__func__<<"\033[0m at \033[1;36m"<< __FILE__<<"\033[0m, line \033[0;34m"<< __LINE__<<"\033[0m"<< std::endl; 
      if (xlabel =="#eta_{Matched e}" ) xlabel = "#eta_{e}";
      if (xlabel =="#eta_{Matched m}" ) xlabel = "#eta_{#mu}";
      if (xlabel =="#eta_{Matched t}" ) xlabel = "#eta_{t}";
      if (xlabel =="#Pt_{Matched e} [GeV] " ) xlabel = "#P_{T}^{e} [GeV]";
      if (xlabel =="#Pt_{Matched m} [GeV] " ) xlabel = "#P_{T}^{#mu} [GeV]";
      if (xlabel =="#Pt_{Matched t} [GeV] " ) xlabel = "#P_{T}^{t} [GeV]";
      reco->GetXaxis()->SetTitle(xlabel);



      reco->GetYaxis()->SetTitleOffset(1.0);
      reco->GetXaxis()->SetTitleOffset(0.9);
      reco->GetYaxis()->SetTitleSize(0.06);
      reco->GetXaxis()->SetTitleSize(0.06);
      reco->GetYaxis()->SetLabelSize(0.05);
      reco->GetXaxis()->SetLabelSize(0.05);
      //reco->GetYaxis()->SetRangeUser(0.1*ymin, 5*ymax);
      //c1->Print("Pt.png");
      //c1->Print("MuonEta_0.png");
      //c1->Print("EleEta_0.png");
      //TH1F* jet = (TH1F*)HT->GetTH1("JetPTScale", cut);
      //jet->Draw();
      //c1->Print("Jet.png");

      delete HT;

    }

    yaxis->SetRangeUser(0.8*ymin, 1.2*ymax);
    xaxis->SetRangeUser(-4.5, 4.5);
    lg->Draw();
    DrawTitle();
    c1->RedrawAxis();

    std::stringstream ss;
    ss << "Efficiency_"<<vLep.at(j)<< "_"<< cut<< ".png";
    c1->Print(ss.str().c_str());
    ss.str("");
    ss << "Efficiency_"<<vLep.at(j)<< "_"<< cut<< ".pdf";
    c1->Print(ss.str().c_str());
    ss.str("");
    ss << "Efficiency_"<<vLep.at(j)<< "_"<< cut<< ".C";
    c1->Print(ss.str().c_str());
    ss.str("");
    ss << "Efficiency_"<<vLep.at(j)<< "_"<< cut<< ".root";
    c1->Print(ss.str().c_str());
  }

  return EXIT_SUCCESS;
}				// ----------  end of function main  ----------
开发者ID:aratkata,项目名称:CMSUpgrade,代码行数:101,代码来源:PlotEff.C

示例14: 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,代码来源:

示例15: main


//.........这里部分代码省略.........
  VColor.push_back(4);
  VColor.push_back(kOrange+9);
  VColor.push_back(kGreen+2);
  VColor.push_back(6);
  VColor.push_back(60);

  if (filename.find("Discovery") != std::string::npos)
    style = "Discovery";
  if (filename.find("CLimit") != std::string::npos)
    style = "CLimit";

//----------------------------------------------------------------------------
//  Default input cross section
//----------------------------------------------------------------------------
  std::map<int, double> SigXs;
  SigXs[112] = 46;
  SigXs[200] = 11.47;
  SigXs[500] = 0.45;

  double x[3], y[3];

  x[0] = 112;
  x[1] = 200;
  x[2] = 500;

  y[0] = SigXs[x[0]] * 1;
  y[1] = SigXs[x[1]] * 1;
  y[2] = SigXs[x[2]] * 1;


//----------------------------------------------------------------------------
//  A Test pave
//----------------------------------------------------------------------------
//// Add to the plot the S/B ratio
  TPaveText *pt = 0;
  pt = new TPaveText(0.5587248,0.7669492,0.9446309,0.9110169,"brNDC");
  pt->SetFillColor(0);
  pt->SetBorderSize(0);
  pt->SetTextSize(0.04);
  pt->SetTextColor(4);
  std::stringstream lumi;

  lumi << "3000 fb^{-1}, 14 TeV";
  pt->AddText(lumi.str().c_str());
  lumi.str("");

  if (style == "CLimit")
  lumi << "95\% C.L. Limit";
  if (style == "Discovery")
  lumi << "Discovery sensitivity";
  pt->AddText(lumi.str().c_str());
  lumi.str("");

  char scenario = ' ';
  if (plateu == 10) scenario = 'A';
  if (plateu == 5) scenario = 'B';
  if (plateu == 1) scenario = 'C';
  if (scenario != ' ')
  {
    lumi << "Scenario " << scenario;
    pt->AddText(lumi.str().c_str());
  }

//----------------------------------------------------------------------------
//  Cross Section
//----------------------------------------------------------------------------
  TGraph* xs = new TGraph(3, x, y);

  xs->SetMarkerStyle(10);
  xs->SetTitle("");
  xs->SetLineColor(VColor[0]);

  Xaxis = xs->GetXaxis();
  Yaxis = xs->GetYaxis();
  leg->AddEntry(xs, "Wino", "l");
  xs->Draw("ALP");

  PlotLines(c1, leg);

////----------------------------------------------------------------------------
//// End
////----------------------------------------------------------------------------
  Yaxis->SetRangeUser(0.1, 300);
  ////Yaxis->SetRangeUser(0, 70);
  Yaxis->SetTitle("#sigma (fb)");
  Xaxis->SetTitle("m(#tilde{#chi}^{0}_{1}) [GeV]");

  //fit->Draw("same");
  pt->Draw();
  TString outname = filename;
  outname.ReplaceAll(".log", "");
  std::stringstream ss;
  ss<< outname.Data()<< "_" << plateu << "p.pdf";
  c1->SaveAs(ss.str().c_str());
  ss.str("");
  ss<< outname.Data()<< "_" << plateu << "p.png";
  c1->SaveAs(ss.str().c_str());

  return EXIT_SUCCESS;
}				// ----------  end of function main  ----------
开发者ID:aratkata,项目名称:CMSUpgrade,代码行数:101,代码来源:PlotLimit.C


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