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


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

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


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

示例1: drawBeamSpotGraph

void drawBeamSpotGraph (TDirectory* directory, TH1* refHisto, const char* name,
			const char* fname, float* runSummary = 0)
{
  TGraphErrors* graph = directory->Get(name);
  if ( graph==0 )  return;

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

  char newName[64];
  newName[0] = 'c';
  strcpy(&newName[1],name);
  std::string fullName(name);
  if ( fname )  fullName += fname;
  else  fullName += directory->GetName();
  TCanvas* c = new TCanvas(fullName.c_str(),fullName.c_str());
  newName[0] = 'h';
  TH1* h = refHisto->Clone(newName);
  h->Reset();
  h->SetTitle(name);
  std::string xTitle("Luminosity block / ");
  xTitle += directory->GetName();
  h->GetXaxis()->SetTitle(xTitle->c_str());
//   int nb = h->GetNbinsX();
//   if ( nb>50 ) {
//     int iscale = nb/50+1;
//     TAxis* xaxis = h->GetXaxis();
//     for ( int i=1; i<=h->GetNbinsX(); ++i ) {
//       if ( (i-1)%iscale )  xaxis->SetBinLabel(i,"");
//     }
//   }
  TAxis* yaxis = h->GetYaxis();
  float scale(1);
  if ( strcmp(name,"x")==0 ) {
    yaxis->SetTitle("PV x position [mm]");
    scale = 10.;
  }
  else if ( strcmp(name,"y")==0 ) {
    yaxis->SetTitle("PV y position [mm]");
    scale = 10.;
  }
  else if ( strcmp(name,"z")==0 ) {
    yaxis->SetTitle("PV z position [cm]");
  }
  else if ( strcmp(name,"ex")==0 ) {
    yaxis->SetTitle("PV x width [#mum]");
    scale = 10000.;
  }
  else if ( strcmp(name,"ey")==0 ) {
    yaxis->SetTitle("PV y width [#mum]");
    scale = 10000.;
  }
  else if ( strcmp(name,"ez")==0 ) {
    yaxis->SetTitle("PV z width [cm]");
  }
  else if ( strcmp(name,"corrxy")==0 ) {
    yaxis->SetTitle("PV x-y correlation");
  }
  else if ( strcmp(name,"dxdz")==0 ) {
    yaxis->SetTitle("PV slope dx/dz [10^{-3}]");
    scale = 1000.;
  }
  else if ( strcmp(name,"dydz")==0 ) {
    yaxis->SetTitle("PV slope dy/dz [10^{-3}]");
    scale = 1000.;
  }
  scaleGraph(graph,scale);

  double xmin,xmax,ymin,ymax;
  graph->ComputeRange(xmin,ymin,xmax,ymax);
  h->SetMinimum((ymax+ymin)/2.-2.*(ymax-ymin)/2.);
  h->SetMaximum((ymax+ymin)/2.+2.*(ymax-ymin)/2.);
  h->Draw();
  graph->SetMarkerStyle(20);
//   graph->SetMarkerColor(2);
//   graph->SetLineColor(2);
  graph->Draw("P");
  graph->Fit("pol1","same");
  graph->GetFunction("pol1")->SetLineStyle(2);
  graph->GetFunction("pol1")->SetLineWidth(2);

  TF1* fit = graph->GetFunction("pol1");
  cout << "Pol1 fit chi2 = " << fit->GetChisquare() 
       << " " << fit->GetNDF() << endl;

//   string epsName = fullName + ".eps";
//   c->SaveAs(epsName.c_str());
//   string pngName = fullName + ".png";
//   c->SaveAs(pngName.c_str());

  if ( runSummary ) {
    TF1* fit = graph->GetFunction("pol1");
    runSummary[0] = fit->GetChisquare();
    runSummary[1] = fit->GetNDF();
    runSummary[2] = fit->GetParameter(0);
    runSummary[3] = fit->GetParError(0);
    runSummary[4] = fit->GetParameter(1);
    runSummary[5] = fit->GetParError(1);
  }
}
开发者ID:wa01,项目名称:usercode,代码行数:100,代码来源:drawBeamSpotGraphs.C


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