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


C++ TGraph2D::Clone方法代码示例

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


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

示例1: fillGraphsFromFilesDeltaNLL

void fillGraphsFromFilesDeltaNLL( const TString& par1name,
				  const TString& par2name,
				  const vector<TString>& fnames,
				  vector<string>&  keys,
				  map<string,TGraph2D *>& m_graphs)
{

  std::cout << "fillGraphsFromFilesDeltaNLL 1" << std::endl;

  keys.push_back("exp68");
  keys.push_back("exp95");
  keys.push_back("exp99");

  // uncommented below to plot observed!
  keys.push_back("obs95");

  TGraph2D *grobs = new TGraph2D();
  TGraph2D *grexp = new TGraph2D();

  m_graphs["obs95"] = grobs;
  m_graphs["exp95"] = grexp;

  grobs->SetName("graph2Dobs95");
  grexp->SetName("graph2Dexp95");

  Int_t nobs=0, nexp=0;

  for( size_t i=0; i<fnames.size(); i++) {
    
    TFile *f = new TFile(fnames[i]);
    TTree *t = (TTree *) f->Get("limit");

    if (!t) { 
      std::cerr<<"TFile "<<f->GetName()<<" does not contain the tree"<<std::endl;
      return;
    }
    cout << fnames[i] << " has limit tree with " << t->GetEntries() << " entries." << endl;

    Float_t deltaNLL, par1, par2;
    Int_t iToy;

    t->SetBranchAddress("iToy", &iToy);
    t->SetBranchAddress("deltaNLL", &deltaNLL);
    t->SetBranchAddress(par1name, &par1);
    t->SetBranchAddress(par2name, &par2);

    for (size_t j = 0, n = t->GetEntries(); j < n; ++j) {
      t->GetEntry(j);
      printf ("%d\r",j);
      if( !iToy){
	//	cout <<"!iToy" << endl;
	grobs->SetPoint(nobs++,par1,par2,2*deltaNLL);
	//	cout <<"grobs->SetPoint("<<nobs++<<","<<par1<<","<< par2<< ","<< 2*deltaNLL << endl;
      }
      else if (iToy == -1) {
	//	cout <<"iToy == -1" << endl;
	grexp->SetPoint(nexp++,par1,par2,2*deltaNLL);
      }
      else {
	cerr << "Unexpected value for iToy, = " << iToy << endl;
	exit(-1);
      }
    } // tree entry loop

    f->Close();
    delete f;

  } // file loop
  cout << endl;

  m_graphs["exp68"] = (TGraph2D*)grexp->Clone("graph2Dexp68");
  m_graphs["exp99"] = (TGraph2D*)grexp->Clone("graph2Dexp99");

#if 0
  TCanvas *canv = new TCanvas("tester","tester",500,500);
  cout << grexp->GetN()<<" points. " <<endl;
  grexp->Draw("TRI"); // cont 5z list");
#endif
}                                         // fillGraphsFromFilesDeltaNLL
开发者ID:senka,项目名称:CombinedEWKAnalysis_forMingshui,代码行数:79,代码来源:atgcplotLimit.C


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