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


C++ TF1::GetXmin方法代码示例

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


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

示例1: GetRandomTest

void GetRandomTest(){
	double k0=1.39;
	double k1 = 0.425;
	double theta0 = 3.41;
	double theta1 = 1.30;
	int iNpart=2;
	double k_=k0+k1*(iNpart-2);
        double theta_=theta0+theta1*TMath::Log(iNpart-1);
	TF1 *f = new TF1("f","TMath::GammaDist(x,[0],0,[1])",0,200);
	f->SetParameters(k1,theta_);
	cout<<"Value at 0 = "<<f->Eval(0)<<endl;
	cout<<"Value at 1e-11 = "<<f->Eval(1e-11)<<endl;
	cout<<"Integral 1= "<<f->Integral(f->GetXmin(),f->GetXmax())<<endl;
	f->SetRange(1e-12,200);
	cout<<"Integral 2= "<<f->Integral(f->GetXmin(),f->GetXmax())<<endl;
	cout<<"fXmin = "<<f->GetXmin()<<"\tfXmax = "<<f->GetXmax()<<"\tfNpx = "<<f->GetNpx()<<endl;
	f->SetNpx(1e5);
	TCanvas *c1 = new TCanvas();
	c1->SetLogy();
	cout<<"f mean = "<<f->Mean(0,200)<<endl;
	cout<<"math mean = "<<f->GetParameter(0)*f->GetParameter(1)<<endl;
	TH1D* h = new TH1D("h","h",1000,0,200);
	for(int i=0;i<1e6;i++){
		double para = f->GetRandom();
		h->Fill(para);
	}
	h->Scale(1.0/h->Integral()*1000/200);
	h->GetYaxis()->SetRangeUser(1e-10,1);
	h->SetMarkerStyle(24);
	h->SetMarkerColor(4);
	h->SetMarkerSize(1.1);
	TLegend *leg = new TLegend(0.6,0.7,0.8,0.9);
        leg->SetFillColor(0);
        leg->SetFillStyle(0);
        leg->SetBorderSize(0);
        leg->SetTextFont(42);
        leg->SetTextSize(0.03);
        leg->AddEntry(f,"function","lp");
        leg->AddEntry(h,"filled histogram","lp");
	h->Draw("P");
	f->Draw("same");
        leg->Draw("same");
	cout<<"h mean = "<<h->GetMean(1)<<endl;
	c1->Print("TestGetRandom.png");
	}
开发者ID:XuQiao,项目名称:HI,代码行数:45,代码来源:GetRandomTest.C

示例2: 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


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