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


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

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


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

示例1: multidimSampling

void multidimSampling() {

#ifdef __CINT__
   std::cout << "DO NOT RUN WITH CINT:" << std::endl;
   std::cout << "we are using a custom function which requires" << std::endl;
   std::cout << "that this tutorial must be compiled with ACLIC" << std::endl;
  return;
#endif

   const int N = 100000;
   //const int NBin = 1000;
   const int DIM = 4;

   double xmin[] = {-10,-10,-10, -10};
   double xmax[] = { 10, 10, 10,  10};
   double par0[] = { 1., -1., 2, 0, // the gaussian mu
                     1, 2, 1, 3, // the sigma
                     0.5,0.,0.,0.,0.,0.8 };  // the correlation

   const int NPAR = DIM + DIM*(DIM+1)/2; // 14 in the 4d case
   // generate the sample
   GausND gaus4d(4);
   TF1 * f = new TF1("functionND",gaus4d,0,1,14);
   f->SetParameters(par0);

   double x0[] = {0,0,0,0};
   // for debugging
   if (debug) f->EvalPar(x0,0);
   debug = false;

   TString name;
   for (int i = 0; i < NPAR; ++i )  {
      if (i < DIM) f->SetParName(i, name.Format("mu_%d",i+1) );
      else if (i < 2*DIM) f->SetParName(i, name.Format("sig_%d",i-DIM+1) );
      else if (i < 2*DIM) f->SetParName(i, name.Format("sig_%d",i-2*DIM+1) );
   }

   //ROOT::Math::DistSamplerOptions::SetDefaultSampler("Foam");
   DistSampler * sampler = Factory::CreateDistSampler();
   if (sampler == 0) {
      Info("multidimSampling","Default sampler %s is not available try with Foam ",
           ROOT::Math::DistSamplerOptions::DefaultSampler().c_str() );
      ROOT::Math::DistSamplerOptions::SetDefaultSampler("Foam");
   }
   sampler = Factory::CreateDistSampler();
   if (sampler == 0) {
      Error("multidimSampling","Foam sampler is not available - exit ");
      return;
   }

   sampler->SetFunction(*f,DIM);
   sampler->SetRange(xmin,xmax);
   bool ret = sampler->Init();

   std::vector<double> data1(DIM*N);
   double v[DIM];
   TStopwatch w;

   if (!ret) {
      Error("Sampler::Init","Error initializing unuran sampler");
      return;
   }

   // generate the data
   w.Start();
   for (int i = 0; i < N; ++i) {
      sampler->Sample(v);
      for (int j = 0; j < DIM; ++j)
         data1[N*j + i]     = v[j];
   }
   w.Stop();
   w.Print();

   // fill tree with data
   TFile * file = new TFile("multiDimSampling.root","RECREATE");
   double x[DIM];
   TTree * t1 = new TTree("t1","Tree from Unuran");
   t1->Branch("x",x,"x[4]/D");
   for (int i = 0; i < N; ++i) {
      for (int j = 0; j < DIM; ++j) {
         x[j] = data1[i+N*j];
      }
      t1->Fill();
   }

   // plot the data
   t1->Draw("x[0]:x[1]:x[2]:x[3]","","candle");
   TCanvas * c2 = new TCanvas();
   c2->Divide(3,2);
   int ic=1;
   c2->cd(ic++);
   t1->Draw("x[0]:x[1]");
   c2->cd(ic++);
   t1->Draw("x[0]:x[2]");
   c2->cd(ic++);
   t1->Draw("x[0]:x[3]");
   c2->cd(ic++);
   t1->Draw("x[1]:x[2]");
   c2->cd(ic++);
   t1->Draw("x[1]:x[3]");
//.........这里部分代码省略.........
开发者ID:MycrofD,项目名称:root,代码行数:101,代码来源:multidimSampling.C


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