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


C++ TNtuple::GetArgs方法代码示例

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


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

示例1: read_ntuple_from_file

void read_ntuple_from_file(){

  int i,j,k,n;

  TFile *in = new TFile("ntupleoutputsample.root");
  TNtuple *data = (TNtuple*) in->GetObjectChecked("data","TNtuple");

  double pot,cur,temp,pres;
  float *row_content; //Must necessarily be float and not a double... WHY?

  TH1D *histo = new TH1D("histo","HISTO",100,0,10);

  cout << "Potential\tCurrent\tTemperature\tPressure" << endl;
  for(i=0;i<data->GetEntries();++i){
      data->GetEntry(i);
      row_content = data->GetArgs();
      pot = row_content[0];
      cur = row_content[1];
      temp = row_content[2];
      pres = row_content[3];
      cout << pot << "\t" << cur << "\t" << temp << "\t" << pres << endl;
      histo->Fill(pot);
  }

  histo->Draw();
}
开发者ID:sdporzio,项目名称:CodingExamples,代码行数:26,代码来源:read_ntuple_from_file.C

示例2: inputChain

Int_t mt102_readNtuplesFillHistosAndFit()
{

   // No nuisance for batch execution
   gROOT->SetBatch();

   // Perform the operation sequentially ---------------------------------------
   TChain inputChain("multiCore");
   inputChain.Add("mc101_multiCore_*.root");
   TH1F outHisto("outHisto", "Random Numbers", 128, -4, 4);
   {
      TimerRAII t("Sequential read and fit");
      inputChain.Draw("r >> outHisto");
      outHisto.Fit("gaus");
   }

   // We now go MT! ------------------------------------------------------------

   // The first, fundamental operation to be performed in order to make ROOT
   // thread-aware.
   ROOT::EnableMT();

   // We adapt our parallelisation to the number of input files
   const auto nFiles = inputChain.GetListOfFiles()->GetEntries();
   std::forward_list<UInt_t> workerIDs(nFiles);
   std::iota(std::begin(workerIDs), std::end(workerIDs), 0);


   // We define the histograms we'll fill
   std::vector<TH1F> histograms;
   histograms.reserve(nFiles);
   for (auto workerID : workerIDs){
      histograms.emplace_back(TH1F(Form("outHisto_%u", workerID), "Random Numbers", 128, -4, 4));
   }

   // We define our work item
   auto workItem = [&histograms](UInt_t workerID) {
      TFile f(Form("mc101_multiCore_%u.root", workerID));
      TNtuple *ntuple = nullptr;
      f.GetObject("multiCore", ntuple);
      auto &histo = histograms.at(workerID);
      for (UInt_t index = 0; index < ntuple->GetEntriesFast(); ++index) {
         ntuple->GetEntry(index);
         histo.Fill(ntuple->GetArgs()[0]);
      }
   };

   TH1F sumHistogram("SumHisto", "Random Numbers", 128, -4, 4);

   // Create the collection which will hold the threads, our "pool"
   std::vector<std::thread> workers;

   // We measure time here as well
   {
      TimerRAII t("Parallel execution");

      // Spawn workers
      // Fill the "pool" with workers
      for (auto workerID : workerIDs) {
         workers.emplace_back(workItem, workerID);
      }

      // Now join them
      for (auto&& worker : workers) worker.join();

      // And reduce
      std::for_each(std::begin(histograms), std::end(histograms),
                    [&sumHistogram](const TH1F & h) {
                       sumHistogram.Add(&h);
                    });

      sumHistogram.Fit("gaus",0);
   }

   return 0;

}
开发者ID:digideskio,项目名称:root,代码行数:77,代码来源:mt102_readNtuplesFillHistosAndFit.C


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